Skip to content

Commit c762773

Browse files
committed
resolve: ParentScope::default -> ParentScope::module
1 parent 136db22 commit c762773

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

src/librustc_resolve/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a> Resolver<'a> {
166166
let def_id = module.def_id().unwrap();
167167
for child in self.cstore.item_children_untracked(def_id, self.session) {
168168
let child = child.map_id(|_| panic!("unexpected id"));
169-
BuildReducedGraphVisitor { parent_scope: ParentScope::default(module), r: self }
169+
BuildReducedGraphVisitor { parent_scope: ParentScope::module(module), r: self }
170170
.build_reduced_graph_for_external_crate_res(child);
171171
}
172172
module.populated.set(true)

src/librustc_resolve/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
509509
// During late resolution we only track the module component of the parent scope,
510510
// although it may be useful to track other components as well for diagnostics.
511511
let graph_root = resolver.graph_root;
512-
let parent_scope = ParentScope::default(graph_root);
512+
let parent_scope = ParentScope::module(graph_root);
513513
LateResolutionVisitor {
514514
r: resolver,
515515
parent_scope,

src/librustc_resolve/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ pub struct ParentScope<'a> {
140140
}
141141

142142
impl<'a> ParentScope<'a> {
143-
pub fn default(module: Module<'a>) -> ParentScope<'a> {
143+
/// Creates a parent scope with the passed argument used as the module scope component,
144+
/// and other scope components set to default empty values.
145+
pub fn module(module: Module<'a>) -> ParentScope<'a> {
144146
ParentScope {
145147
module,
146148
expansion: ExpnId::root(),
@@ -1017,7 +1019,7 @@ impl<'a> hir::lowering::Resolver for Resolver<'a> {
10171019
segments,
10181020
};
10191021

1020-
let parent_scope = &ParentScope::default(self.graph_root);
1022+
let parent_scope = &ParentScope::module(self.graph_root);
10211023
let res = match self.resolve_ast_path(&path, ns, parent_scope) {
10221024
Ok(res) => res,
10231025
Err((span, error)) => {
@@ -1090,7 +1092,7 @@ impl<'a> Resolver<'a> {
10901092
}
10911093

10921094
let mut invocation_parent_scopes = FxHashMap::default();
1093-
invocation_parent_scopes.insert(ExpnId::root(), ParentScope::default(graph_root));
1095+
invocation_parent_scopes.insert(ExpnId::root(), ParentScope::module(graph_root));
10941096

10951097
let mut macro_defs = FxHashMap::default();
10961098
macro_defs.insert(ExpnId::root(), root_def_id);
@@ -2671,7 +2673,7 @@ impl<'a> Resolver<'a> {
26712673
let def_id = self.definitions.local_def_id(module_id);
26722674
self.module_map.get(&def_id).copied().unwrap_or(self.graph_root)
26732675
});
2674-
let parent_scope = &ParentScope::default(module);
2676+
let parent_scope = &ParentScope::module(module);
26752677
let res = self.resolve_ast_path(&path, ns, parent_scope).map_err(|_| ())?;
26762678
Ok((path, res))
26772679
}

src/librustc_resolve/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a> base::Resolver for Resolver<'a> {
101101
ExpnKind::Macro(MacroKind::Attr, sym::test_case), DUMMY_SP, self.session.edition()
102102
)));
103103
let module = self.module_map[&self.definitions.local_def_id(id)];
104-
self.invocation_parent_scopes.insert(expn_id, ParentScope::default(module));
104+
self.invocation_parent_scopes.insert(expn_id, ParentScope::module(module));
105105
self.definitions.set_invocation_parent(expn_id, module.def_id().unwrap().index);
106106
expn_id
107107
}

src/librustdoc/passes/collect_intra_doc_links.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ fn macro_resolve(cx: &DocContext<'_>, path_str: &str) -> Option<Res> {
432432
let path = ast::Path::from_ident(Ident::from_str(path_str));
433433
cx.enter_resolver(|resolver| {
434434
if let Ok((Some(ext), res)) = resolver.resolve_macro_path(
435-
&path, None, &ParentScope::default(resolver.graph_root), false, false
435+
&path, None, &ParentScope::module(resolver.graph_root), false, false
436436
) {
437437
if let SyntaxExtensionKind::LegacyBang { .. } = ext.kind {
438438
return Some(res.map_id(|_| panic!("unexpected id")));

0 commit comments

Comments
 (0)