Skip to content

Commit 4bc5579

Browse files
committed
Ensure Resolver::register_macros_for_all_crates only executes once
1 parent 1ebbbf1 commit 4bc5579

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
213213
/// Add every proc macro accessible from the current crate to the `macro_map` so diagnostics can
214214
/// find them for suggestions.
215215
pub(crate) fn register_macros_for_all_crates(&mut self) {
216+
if self.all_crate_macros_already_registered {
217+
return;
218+
}
219+
self.all_crate_macros_already_registered = true;
216220
let def_ids = self.cstore().all_proc_macro_def_ids();
217221
for def_id in def_ids {
218222
self.get_macro_by_def_id(def_id);

compiler/rustc_resolve/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,10 @@ pub struct Resolver<'ra, 'tcx> {
12491249

12501250
mods_with_parse_errors: FxHashSet<DefId>,
12511251

1252+
/// Whether `Resolver::register_macros_for_all_crates` has been called once already, as we
1253+
/// don't need to run it more than once.
1254+
all_crate_macros_already_registered: bool,
1255+
12521256
// Stores pre-expansion and pre-placeholder-fragment-insertion names for `impl Trait` types
12531257
// that were encountered during resolution. These names are used to generate item names
12541258
// for APITs, so we don't want to leak details of resolution into these names.
@@ -1644,6 +1648,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16441648
all_macro_rules: Default::default(),
16451649
delegation_fn_sigs: Default::default(),
16461650
glob_delegation_invoc_ids: Default::default(),
1651+
all_crate_macros_already_registered: false,
16471652
impl_unexpanded_invocations: Default::default(),
16481653
impl_binding_keys: Default::default(),
16491654
current_crate_outer_attr_insert_span,

0 commit comments

Comments
 (0)