Skip to content
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

Remove effect of #[no_link] attribute on name resolution #92034

Merged
merged 1 commit into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
};

// Iterate over all children.
let macros_only = self.dep_kind.lock().macros_only();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macros_only flag is only set for proc macro crates (processed above), and for #[no_link] crates.
Maybe it should be renamed, but I don't want to do it in a single PR with observable language changes.

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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/ui/no-link.rs
Original file line number Diff line number Diff line change
@@ -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 {};
}
9 changes: 0 additions & 9 deletions src/test/ui/no-link.stderr

This file was deleted.