mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
resolve: ParentScope::default
-> ParentScope::module
This commit is contained in:
parent
136db2235a
commit
c76277340e
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ fn macro_resolve(cx: &DocContext<'_>, path_str: &str) -> Option<Res> {
|
||||
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")));
|
||||
|
Loading…
Reference in New Issue
Block a user