]> git.lizzy.rs Git - rust.git/commitdiff
Print correct crate name
authorManish Goregaokar <manishsmail@gmail.com>
Tue, 8 Sep 2015 19:52:03 +0000 (01:22 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Tue, 8 Sep 2015 19:52:03 +0000 (01:22 +0530)
src/librustc/middle/infer/error_reporting.rs
src/test/compile-fail/type-mismatch-same-crate-name.rs

index 363af87b70ba0f13c9344aa64bd9bd066c5ab337..7ec39ac851574dda434a6cbc1163d0d73777e95f 100644 (file)
@@ -511,9 +511,11 @@ fn check_and_note_conflicting_crates(&self, terr: &ty::TypeError<'tcx>, sp: Span
                 // We compare strings because PathMod and PathName can be different
                 // for imported and non-imported crates
                 if exp_path == found_path {
+                    let crate_name = self.tcx.sess.cstore
+                                         .get_crate_data(did1.krate).name();
                     self.tcx.sess.span_note(sp, &format!("Perhaps two different versions \
                                                           of crate `{}` are being used?",
-                                                          exp_path[0]));
+                                                          crate_name));
                 }
             }
         };
index 69ef31e90e47caebfbd455baeeda0e2a56d58ac6..014fa35c309e6cb79ce9f542733fe7d971e829cd 100644 (file)
@@ -25,9 +25,9 @@ fn main() {
         extern crate crate_a1 as a;
         a::try_foo(foo2); //~ ERROR mismatched types
                           //~^ HELP run
-                          //~^^ NOTE Perhaps two different versions of crate `main`
+                          //~^^ NOTE Perhaps two different versions of crate `crate_a1`
         a::try_bar(bar2); //~ ERROR mismatched types
                           //~^ HELP run
-                          //~^^ NOTE Perhaps two different versions of crate `main`
+                          //~^^ NOTE Perhaps two different versions of crate `crate_a1`
     }
 }