Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'expected struct cargo_metadata::Package, found a different struct cargo_metadata::Package' should note that one is a module and one is a crate #80255

Open
jyn514 opened this issue Dec 21, 2020 · 7 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Dec 21, 2020

error[E0308]: mismatched types
  --> src/utils/cargo_metadata.rs:50:9
   |
50 |         &self.root
   |         ^^^^^^^^^^ expected struct `cargo_metadata::Package`, found a different struct `cargo_metadata::Package`
   |
   = note: expected reference `&cargo_metadata::Package` (struct `cargo_metadata::Package`)
              found reference `&cargo_metadata::Package` (struct `cargo_metadata::Package`)

It's impossible to tell here whether it found the version from the current module, crate::utils::cargo_metadata, or the one from the crate, ::cargo_metadata. It would be nice to at least say why they might be different, the same way the compiler warns about two versions of a crate.

(I feel like I reported this bug already, but I can't seem to find it.)

@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. labels Dec 21, 2020
@jyn514 jyn514 changed the title expected struct cargo_metadata::Package, found a different struct cargo_metadata::Package should note that one is a module and one is a crate 'expected struct cargo_metadata::Package, found a different struct cargo_metadata::Package' should note that one is a module and one is a crate Dec 21, 2020
@camelid
Copy link
Member

camelid commented Dec 22, 2020

Looks the error is produced here:

fn report_maybe_different(
f: &mut fmt::Formatter<'_>,
expected: &str,
found: &str,
) -> fmt::Result {
// A naive approach to making sure that we're not reporting silly errors such as:
// (expected closure, found closure).
if expected == found {
write!(f, "expected {}, found a different {}", expected, found)
} else {
write!(f, "expected {}, found {}", expected, found)
}
}

@camelid camelid added the E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. label Dec 22, 2020
@pierwill
Copy link
Member

@rustbot claim

@camelid
Copy link
Member

camelid commented Dec 23, 2020

@pierwill Note that this issue will likely be tricky to fix!

@pierwill
Copy link
Member

Flew too close to sun again.

@pierwill pierwill removed their assignment Dec 24, 2020
@camelid
Copy link
Member

camelid commented Dec 24, 2020

Flew too close to sun again.

That's okay! I've been working on rustc for months now and I don't think I know how to fix this issue :)

@JohnTitor JohnTitor added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Dec 30, 2020
@estebank
Copy link
Contributor

estebank commented Dec 3, 2024

I believe this is already handled (and fully fixed by #133767).

@jyn514
Copy link
Member Author

jyn514 commented Dec 4, 2024

that doesn’t look related at all. it’s about two versions of the same crate. this is about having one be a crate and the other be a local module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-confusing Diagnostics: Confusing error or lint that should be reworked. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants