diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index c42a933a954a9..539e4a301e012 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -166,7 +166,7 @@ impl<'a> Resolver<'a> { let def_id = module.def_id().unwrap(); for child in self.cstore.item_children_untracked(def_id, self.session) { let child = child.map_id(|_| panic!("unexpected id")); - BuildReducedGraphVisitor { parent_scope: ParentScope::default(module), r: self } + BuildReducedGraphVisitor { parent_scope: ParentScope::module(module), r: self } .build_reduced_graph_for_external_crate_res(child); } module.populated.set(true) diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index d97ee61d839a2..ffdfd85002bca 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -509,7 +509,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> { // During late resolution we only track the module component of the parent scope, // although it may be useful to track other components as well for diagnostics. let graph_root = resolver.graph_root; - let parent_scope = ParentScope::default(graph_root); + let parent_scope = ParentScope::module(graph_root); LateResolutionVisitor { r: resolver, parent_scope, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 2b55f9dc79d08..9b5eb51eb582d 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -140,7 +140,9 @@ pub struct ParentScope<'a> { } impl<'a> ParentScope<'a> { - pub fn default(module: Module<'a>) -> ParentScope<'a> { + /// Creates a parent scope with the passed argument used as the module scope component, + /// and other scope components set to default empty values. + pub fn module(module: Module<'a>) -> ParentScope<'a> { ParentScope { module, expansion: ExpnId::root(), @@ -1017,7 +1019,7 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> { segments, }; - let parent_scope = &ParentScope::default(self.graph_root); + let parent_scope = &ParentScope::module(self.graph_root); let res = match self.resolve_ast_path(&path, ns, parent_scope) { Ok(res) => res, Err((span, error)) => { @@ -1090,7 +1092,7 @@ impl<'a> Resolver<'a> { } let mut invocation_parent_scopes = FxHashMap::default(); - invocation_parent_scopes.insert(ExpnId::root(), ParentScope::default(graph_root)); + invocation_parent_scopes.insert(ExpnId::root(), ParentScope::module(graph_root)); let mut macro_defs = FxHashMap::default(); macro_defs.insert(ExpnId::root(), root_def_id); @@ -2671,7 +2673,7 @@ impl<'a> Resolver<'a> { let def_id = self.definitions.local_def_id(module_id); self.module_map.get(&def_id).copied().unwrap_or(self.graph_root) }); - let parent_scope = &ParentScope::default(module); + let parent_scope = &ParentScope::module(module); let res = self.resolve_ast_path(&path, ns, parent_scope).map_err(|_| ())?; Ok((path, res)) } diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 2ca8771cda6a1..079145e816cd5 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -101,7 +101,7 @@ impl<'a> base::Resolver for Resolver<'a> { ExpnKind::Macro(MacroKind::Attr, sym::test_case), DUMMY_SP, self.session.edition() ))); let module = self.module_map[&self.definitions.local_def_id(id)]; - self.invocation_parent_scopes.insert(expn_id, ParentScope::default(module)); + self.invocation_parent_scopes.insert(expn_id, ParentScope::module(module)); self.definitions.set_invocation_parent(expn_id, module.def_id().unwrap().index); expn_id } diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 5767b5b3b46a5..c73c46472d804 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -432,7 +432,7 @@ fn macro_resolve(cx: &DocContext<'_>, path_str: &str) -> Option { let path = ast::Path::from_ident(Ident::from_str(path_str)); cx.enter_resolver(|resolver| { if let Ok((Some(ext), res)) = resolver.resolve_macro_path( - &path, None, &ParentScope::default(resolver.graph_root), false, false + &path, None, &ParentScope::module(resolver.graph_root), false, false ) { if let SyntaxExtensionKind::LegacyBang { .. } = ext.kind { return Some(res.map_id(|_| panic!("unexpected id")));