Skip to content

Commit c65d338

Browse files
committed
Print correct crate name
1 parent 00e7005 commit c65d338

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/librustc/middle/infer/error_reporting.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
511511
// We compare strings because PathMod and PathName can be different
512512
// for imported and non-imported crates
513513
if exp_path == found_path {
514+
let crate_name = self.tcx.sess.cstore
515+
.get_crate_data(did1.krate).name();
514516
self.tcx.sess.span_note(sp, &format!("Perhaps two different versions \
515517
of crate `{}` are being used?",
516-
exp_path[0]));
518+
crate_name));
517519
}
518520
}
519521
};

src/test/compile-fail/type-mismatch-same-crate-name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ fn main() {
2525
extern crate crate_a1 as a;
2626
a::try_foo(foo2); //~ ERROR mismatched types
2727
//~^ HELP run
28-
//~^^ NOTE Perhaps two different versions of crate `main`
28+
//~^^ NOTE Perhaps two different versions of crate `crate_a1`
2929
a::try_bar(bar2); //~ ERROR mismatched types
3030
//~^ HELP run
31-
//~^^ NOTE Perhaps two different versions of crate `main`
31+
//~^^ NOTE Perhaps two different versions of crate `crate_a1`
3232
}
3333
}

0 commit comments

Comments
 (0)