-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add note for possible crate mismatches in type errors #28300
Conversation
…m two different crate of the same name (rust-lang#22750)
self.tcx.sess.note("errrr0"); | ||
report_path_match(exp_found.expected, exp_found.found); | ||
}, | ||
_ => () // FIXME(Manishearth) handle traits and stuff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC all FIXMEs should have an associated issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, it's the same bug (since this is only a partial fix)
So excited for this patch to land! The messages look good to me. |
let report_path_match = |did1: DefId, did2: DefId| { | ||
// Only external crates, if either is from a local | ||
// module we could have false positives | ||
if !(did1.is_local() || did2.is_local()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should check that the crates are different - for example:
fn main() {
let _ = [{struct Foo; Foo}, {struct Foo; Foo}];
}
The error in the above code will see the path "main::Foo" for both of the two different types.
//~^^ NOTE Perhaps two different versions of crate `main` | ||
a::try_bar(bar2); //~ ERROR mismatched types | ||
//~^ HELP run | ||
//~^^ NOTE Perhaps two different versions of crate `main` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to look up the crate names from the crate numbers in the DefId
s (and/or find the subset of the path which refers to the extern crate
item).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@bors r+ |
📌 Commit c65d338 has been approved by |
Partially fixes #22750 I'll write a test for this when I figure out how to. r? @eddyb cc @steveklabnik
Partially fixes #22750
I'll write a test for this when I figure out how to.
r? @eddyb
cc @steveklabnik