Skip to content

rustc_metadata: Switch module children decoding to an iterator #104730

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
Nov 26, 2022
Merged
Changes from 1 commit
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
Next Next commit
rustc_metadata: Do not encode empty reexport lists
This is more a cleanup than optimization
  • Loading branch information
petrochenkov committed Nov 22, 2022
commit f3b5791a47eea13cb1d3fec644fc0c6ea9c37c96
12 changes: 5 additions & 7 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,13 +1267,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
// the crate root for consistency with other crates (some of the resolver
// code uses it). However, we skip encoding anything relating to child
// items - we encode information about proc-macros later on.
let reexports = if !self.is_proc_macro {
tcx.module_reexports(local_def_id).unwrap_or(&[])
} else {
&[]
};

record_array!(self.tables.module_reexports[def_id] <- reexports);
if self.is_proc_macro {
// Encode this here because we don't do it in encode_def_ids.
record!(self.tables.expn_that_defined[def_id] <- tcx.expn_that_defined(local_def_id));
Expand Down Expand Up @@ -1305,6 +1298,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
}
}
}));

if let Some(reexports) = tcx.module_reexports(local_def_id) {
assert!(!reexports.is_empty());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert!(!reexports.is_empty());
debug_assert!(!reexports.is_empty());

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This assert is very cheap (both in absolute value, and relatively to everything else happening here), so I think we can always enable it.

record_array!(self.tables.module_reexports[def_id] <- reexports);
}
}
}

Expand Down