Skip to content

Clean up in each_child_of_item #80646

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

Merged
merged 3 commits into from
Jan 3, 2021
Merged
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
29 changes: 12 additions & 17 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,19 +1055,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {

// Iterate over all children.
let macros_only = self.dep_kind.lock().macros_only();
let children = self.root.tables.children.get(self, id).unwrap_or_else(Lazy::empty);
for child_index in children.decode((self, sess)) {
if macros_only {
continue;
}

// Get the item.
if let Some(child_kind) = self.maybe_kind(child_index) {
match child_kind {
EntryKind::MacroDef(..) => {}
_ if macros_only => continue,
_ => {}
}
if !macros_only {
let children = self.root.tables.children.get(self, id).unwrap_or_else(Lazy::empty);

for child_index in children.decode((self, sess)) {
// Get the item.
let child_kind = match self.maybe_kind(child_index) {
Some(child_kind) => child_kind,
None => continue,
};

// Hand off the item to the callback.
match child_kind {
Expand Down Expand Up @@ -1102,8 +1098,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
}

let def_key = self.def_key(child_index);
let span = self.get_span(child_index, sess);
if def_key.disambiguated_data.data.get_opt_name().is_some() {
let span = self.get_span(child_index, sess);
let kind = self.def_kind(child_index);
let ident = self.item_ident(child_index, sess);
let vis = self.get_visibility(child_index);
Expand Down Expand Up @@ -1137,9 +1133,8 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
// within the crate. We only need this for fictive constructors,
// for other constructors correct visibilities
// were already encoded in metadata.
let attrs: Vec<_> =
self.get_item_attrs(def_id.index, sess).collect();
if sess.contains_name(&attrs, sym::non_exhaustive) {
let mut attrs = self.get_item_attrs(def_id.index, sess);
if attrs.any(|item| item.has_name(sym::non_exhaustive)) {
let crate_def_id = self.local_def_id(CRATE_DEF_INDEX);
vis = ty::Visibility::Restricted(crate_def_id);
}
Expand Down