From 54cd8248190506054057d6bf12f1e957f09b13d6 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 17 Dec 2021 19:16:16 +0800 Subject: [PATCH] Remove effect of `#[no_link]` attribute on name resolution Previously it hid all non-macro names from other crates. This has no relation to linking and can change name resolution behavior in some cases (e.g. glob conflicts), in addition to just producing the "unresolved name" errors --- compiler/rustc_metadata/src/rmeta/decoder.rs | 10 +--------- src/test/ui/no-link.rs | 3 ++- src/test/ui/no-link.stderr | 9 --------- 3 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 src/test/ui/no-link.stderr diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index b2c7818a542..153899b3526 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1099,10 +1099,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { }; // Iterate over all children. - let macros_only = self.dep_kind.lock().macros_only(); - if !macros_only { - let children = self.root.tables.children.get(self, id).unwrap_or_else(Lazy::empty); - + if let Some(children) = self.root.tables.children.get(self, id) { for child_index in children.decode((self, sess)) { // Get the item. let child_kind = match self.maybe_kind(child_index) { @@ -1200,11 +1197,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { if let EntryKind::Mod(exports) = kind { for exp in exports.decode((self, sess)) { - match exp.res { - Res::Def(DefKind::Macro(..), _) => {} - _ if macros_only => continue, - _ => {} - } callback(exp); } } diff --git a/src/test/ui/no-link.rs b/src/test/ui/no-link.rs index 939271832e3..c80e61b4511 100644 --- a/src/test/ui/no-link.rs +++ b/src/test/ui/no-link.rs @@ -1,8 +1,9 @@ +// check-pass // aux-build:empty-struct.rs #[no_link] extern crate empty_struct; fn main() { - empty_struct::XEmpty1; //~ ERROR cannot find value `XEmpty1` in crate `empty_struct` + empty_struct::XEmpty1 {}; } diff --git a/src/test/ui/no-link.stderr b/src/test/ui/no-link.stderr deleted file mode 100644 index 66a74ff6560..00000000000 --- a/src/test/ui/no-link.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0425]: cannot find value `XEmpty1` in crate `empty_struct` - --> $DIR/no-link.rs:7:19 - | -LL | empty_struct::XEmpty1; - | ^^^^^^^ not found in `empty_struct` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0425`.