about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_metadata/rmeta/decoder/cstore_impl.rs2
-rw-r--r--src/librustc_middle/query/mod.rs4
-rw-r--r--src/librustc_middle/ty/query/mod.rs1
-rw-r--r--src/librustc_passes/lang_items.rs22
-rw-r--r--src/test/ui/duplicate_entry_error.rs1
-rw-r--r--src/test/ui/duplicate_entry_error.stderr4
-rw-r--r--src/test/ui/error-codes/E0152.rs1
-rw-r--r--src/test/ui/error-codes/E0152.stderr4
-rw-r--r--src/test/ui/panic-handler/panic-handler-std.rs1
-rw-r--r--src/test/ui/panic-handler/panic-handler-std.stderr6
10 files changed, 42 insertions, 4 deletions
diff --git a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs
index 1b168bf0117..abbe45fe02e 100644
--- a/src/librustc_metadata/rmeta/decoder/cstore_impl.rs
+++ b/src/librustc_metadata/rmeta/decoder/cstore_impl.rs
@@ -239,6 +239,8 @@ provide! { <'tcx> tcx, def_id, other, cdata,
 
         syms
     }
+
+    crate_extern_paths => { cdata.source().paths().cloned().collect() }
 }
 
 pub fn provide(providers: &mut Providers<'_>) {
diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs
index ba5a8c3ec20..e7f9ad9d1cf 100644
--- a/src/librustc_middle/query/mod.rs
+++ b/src/librustc_middle/query/mod.rs
@@ -1042,6 +1042,10 @@ rustc_queries! {
             eval_always
             desc { "looking up the extra filename for a crate" }
         }
+        query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
+            eval_always
+            desc { "looking up the paths for extern crates" }
+        }
     }
 
     TypeChecking {
diff --git a/src/librustc_middle/ty/query/mod.rs b/src/librustc_middle/ty/query/mod.rs
index 35d19b7603f..2ad49b1acce 100644
--- a/src/librustc_middle/ty/query/mod.rs
+++ b/src/librustc_middle/ty/query/mod.rs
@@ -57,6 +57,7 @@ use rustc_span::{Span, DUMMY_SP};
 use std::borrow::Cow;
 use std::collections::BTreeMap;
 use std::ops::Deref;
+use std::path::PathBuf;
 use std::sync::Arc;
 
 #[macro_use]
diff --git a/src/librustc_passes/lang_items.rs b/src/librustc_passes/lang_items.rs
index 0be37cb0960..0326591a931 100644
--- a/src/librustc_passes/lang_items.rs
+++ b/src/librustc_passes/lang_items.rs
@@ -146,6 +146,28 @@ impl LanguageItemCollector<'tcx> {
                             ));
                         }
                     }
+                    let mut note_def = |which, def_id: DefId| {
+                        let crate_name = self.tcx.crate_name(def_id.krate);
+                        let note = if def_id.is_local() {
+                            format!("{} definition in the local crate (`{}`)", which, crate_name)
+                        } else {
+                            let paths: Vec<_> = self
+                                .tcx
+                                .crate_extern_paths(def_id.krate)
+                                .iter()
+                                .map(|p| p.display().to_string())
+                                .collect();
+                            format!(
+                                "{} definition in `{}` loaded from {}",
+                                which,
+                                crate_name,
+                                paths.join(", ")
+                            )
+                        };
+                        err.note(&note);
+                    };
+                    note_def("first", original_def_id);
+                    note_def("second", item_def_id);
                 }
                 err.emit();
             }
diff --git a/src/test/ui/duplicate_entry_error.rs b/src/test/ui/duplicate_entry_error.rs
index b8d98a8999b..776ecedea7e 100644
--- a/src/test/ui/duplicate_entry_error.rs
+++ b/src/test/ui/duplicate_entry_error.rs
@@ -1,3 +1,4 @@
+// normalize-stderr-test "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
 // note-pattern: first defined in crate `std`.
 
 // Test for issue #31788 and E0152
diff --git a/src/test/ui/duplicate_entry_error.stderr b/src/test/ui/duplicate_entry_error.stderr
index 2d52ea3f6c2..61cccf40ed8 100644
--- a/src/test/ui/duplicate_entry_error.stderr
+++ b/src/test/ui/duplicate_entry_error.stderr
@@ -1,5 +1,5 @@
 error[E0152]: found duplicate lang item `panic_impl`
-  --> $DIR/duplicate_entry_error.rs:10:1
+  --> $DIR/duplicate_entry_error.rs:11:1
    |
 LL | / fn panic_impl(info: &PanicInfo) -> ! {
 LL | |
@@ -8,6 +8,8 @@ LL | | }
    | |_^
    |
    = note: the lang item is first defined in crate `std` (which `duplicate_entry_error` depends on)
+   = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
+   = note: second definition in the local crate (`duplicate_entry_error`)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/error-codes/E0152.rs b/src/test/ui/error-codes/E0152.rs
index 94467b9bdde..d716ca1a14f 100644
--- a/src/test/ui/error-codes/E0152.rs
+++ b/src/test/ui/error-codes/E0152.rs
@@ -1,3 +1,4 @@
+// normalize-stderr-test "loaded from .*liballoc-.*.rlib" -> "loaded from SYSROOT/liballoc-*.rlib"
 #![feature(lang_items)]
 
 #[lang = "owned_box"]
diff --git a/src/test/ui/error-codes/E0152.stderr b/src/test/ui/error-codes/E0152.stderr
index fbaa276ce10..7445c2880af 100644
--- a/src/test/ui/error-codes/E0152.stderr
+++ b/src/test/ui/error-codes/E0152.stderr
@@ -1,10 +1,12 @@
 error[E0152]: found duplicate lang item `owned_box`
-  --> $DIR/E0152.rs:4:1
+  --> $DIR/E0152.rs:5:1
    |
 LL | struct Foo;
    | ^^^^^^^^^^^
    |
    = note: the lang item is first defined in crate `alloc` (which `std` depends on)
+   = note: first definition in `alloc` loaded from SYSROOT/liballoc-*.rlib
+   = note: second definition in the local crate (`E0152`)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/panic-handler/panic-handler-std.rs b/src/test/ui/panic-handler/panic-handler-std.rs
index 0acc2722cb2..6183c886cfa 100644
--- a/src/test/ui/panic-handler/panic-handler-std.rs
+++ b/src/test/ui/panic-handler/panic-handler-std.rs
@@ -1,3 +1,4 @@
+// normalize-stderr-test "loaded from .*libstd-.*.rlib" -> "loaded from SYSROOT/libstd-*.rlib"
 // error-pattern: found duplicate lang item `panic_impl`
 
 
diff --git a/src/test/ui/panic-handler/panic-handler-std.stderr b/src/test/ui/panic-handler/panic-handler-std.stderr
index f71c28e5aa6..bb656089bca 100644
--- a/src/test/ui/panic-handler/panic-handler-std.stderr
+++ b/src/test/ui/panic-handler/panic-handler-std.stderr
@@ -1,5 +1,5 @@
 error[E0152]: found duplicate lang item `panic_impl`
-  --> $DIR/panic-handler-std.rs:7:1
+  --> $DIR/panic-handler-std.rs:8:1
    |
 LL | / fn panic(info: PanicInfo) -> ! {
 LL | |     loop {}
@@ -7,9 +7,11 @@ LL | | }
    | |_^
    |
    = note: the lang item is first defined in crate `std` (which `panic_handler_std` depends on)
+   = note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
+   = note: second definition in the local crate (`panic_handler_std`)
 
 error: argument should be `&PanicInfo`
-  --> $DIR/panic-handler-std.rs:7:16
+  --> $DIR/panic-handler-std.rs:8:16
    |
 LL | fn panic(info: PanicInfo) -> ! {
    |                ^^^^^^^^^