Skip to content

Commit 774d96a

Browse files
committed
resolve: early_resolve_ident_in_lexical_scope -> resolve_ident_in_scope_set
1 parent f5703d5 commit 774d96a

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15571557
});
15581558
}
15591559
for ns in [Namespace::MacroNS, Namespace::TypeNS, Namespace::ValueNS] {
1560-
let Ok(binding) = self.cm().early_resolve_ident_in_lexical_scope(
1560+
let Ok(binding) = self.cm().resolve_ident_in_scope_set(
15611561
ident,
15621562
ScopeSet::All(ns),
15631563
parent_scope,
@@ -2371,7 +2371,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23712371
}
23722372
} else {
23732373
self.cm()
2374-
.early_resolve_ident_in_lexical_scope(
2374+
.resolve_ident_in_scope_set(
23752375
ident,
23762376
ScopeSet::All(ns_to_try),
23772377
parent_scope,
@@ -2474,7 +2474,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24742474
},
24752475
)
24762476
});
2477-
if let Ok(binding) = self.cm().early_resolve_ident_in_lexical_scope(
2477+
if let Ok(binding) = self.cm().resolve_ident_in_scope_set(
24782478
ident,
24792479
ScopeSet::All(ValueNS),
24802480
parent_scope,

compiler/rustc_resolve/src/ident.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
351351
// Encountered a module item, abandon ribs and look into that module and preludes.
352352
return self
353353
.cm()
354-
.early_resolve_ident_in_lexical_scope(
354+
.resolve_ident_in_scope_set(
355355
orig_ident,
356356
ScopeSet::Late(ns, module, finalize.map(|finalize| finalize.node_id)),
357357
parent_scope,
@@ -376,13 +376,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
376376
unreachable!()
377377
}
378378

379-
/// Resolve an identifier in lexical scope.
380-
/// This is a variation of `fn resolve_ident_in_lexical_scope` that can be run during
381-
/// expansion and import resolution (perhaps they can be merged in the future).
382-
/// The function is used for resolving initial segments of macro paths (e.g., `foo` in
383-
/// `foo::bar!();` or `foo!();`) and also for import paths on 2018 edition.
379+
/// Resolve an identifier in the specified set of scopes.
384380
#[instrument(level = "debug", skip(self))]
385-
pub(crate) fn early_resolve_ident_in_lexical_scope<'r>(
381+
pub(crate) fn resolve_ident_in_scope_set<'r>(
386382
self: CmResolver<'r, 'ra, 'tcx>,
387383
orig_ident: Ident,
388384
scope_set: ScopeSet<'ra>,
@@ -811,7 +807,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
811807
ModuleOrUniformRoot::Module(module) => module,
812808
ModuleOrUniformRoot::ModuleAndExternPrelude(module) => {
813809
assert_eq!(shadowing, Shadowing::Unrestricted);
814-
let binding = self.early_resolve_ident_in_lexical_scope(
810+
let binding = self.resolve_ident_in_scope_set(
815811
ident,
816812
ScopeSet::ModuleAndExternPrelude(ns, module),
817813
parent_scope,
@@ -827,7 +823,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
827823
return if ns != TypeNS {
828824
Err((Determined, Weak::No))
829825
} else {
830-
let binding = self.early_resolve_ident_in_lexical_scope(
826+
let binding = self.resolve_ident_in_scope_set(
831827
ident,
832828
ScopeSet::ExternPrelude,
833829
parent_scope,
@@ -852,7 +848,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
852848
}
853849
}
854850

855-
let binding = self.early_resolve_ident_in_lexical_scope(
851+
let binding = self.resolve_ident_in_scope_set(
856852
ident,
857853
ScopeSet::All(ns),
858854
parent_scope,
@@ -945,7 +941,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
945941
// Now we are in situation when new item/import can appear only from a glob or a macro
946942
// expansion. With restricted shadowing names from globs and macro expansions cannot
947943
// shadow names from outer scopes, so we can freely fallback from module search to search
948-
// in outer scopes. For `early_resolve_ident_in_lexical_scope` to continue search in outer
944+
// in outer scopes. For `resolve_ident_in_scope_set` to continue search in outer
949945
// scopes we return `Undetermined` with `Weak::Yes`.
950946

951947
// Check if one of unexpanded macros can still define the name,
@@ -1635,7 +1631,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16351631
_ => Err(Determinacy::determined(finalize.is_some())),
16361632
}
16371633
} else {
1638-
self.reborrow().early_resolve_ident_in_lexical_scope(
1634+
self.reborrow().resolve_ident_in_scope_set(
16391635
ident,
16401636
ScopeSet::All(ns),
16411637
parent_scope,

compiler/rustc_resolve/src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14461446
return;
14471447
}
14481448

1449-
match this.cm().early_resolve_ident_in_lexical_scope(
1449+
match this.cm().resolve_ident_in_scope_set(
14501450
target,
14511451
ScopeSet::All(ns),
14521452
&import.parent_scope,

compiler/rustc_resolve/src/macros.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
789789
self.prohibit_imported_non_macro_attrs(None, res.ok(), path_span);
790790
res
791791
} else {
792-
let binding = self.reborrow().early_resolve_ident_in_lexical_scope(
792+
let binding = self.reborrow().resolve_ident_in_scope_set(
793793
path[0].ident,
794794
ScopeSet::Macro(kind),
795795
parent_scope,
@@ -951,7 +951,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
951951
// FIXME: Should be an output of Speculative Resolution.
952952
let macro_resolutions = self.single_segment_macro_resolutions.take();
953953
for (ident, kind, parent_scope, initial_binding, sugg_span) in macro_resolutions {
954-
match self.cm().early_resolve_ident_in_lexical_scope(
954+
match self.cm().resolve_ident_in_scope_set(
955955
ident,
956956
ScopeSet::Macro(kind),
957957
&parent_scope,
@@ -1006,7 +1006,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10061006

10071007
let builtin_attrs = mem::take(&mut self.builtin_attrs);
10081008
for (ident, parent_scope) in builtin_attrs {
1009-
let _ = self.cm().early_resolve_ident_in_lexical_scope(
1009+
let _ = self.cm().resolve_ident_in_scope_set(
10101010
ident,
10111011
ScopeSet::Macro(MacroKind::Attr),
10121012
&parent_scope,
@@ -1112,7 +1112,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11121112
// If such resolution is successful and gives the same result
11131113
// (e.g. if the macro is re-imported), then silence the lint.
11141114
let no_macro_rules = self.arenas.alloc_macro_rules_scope(MacroRulesScope::Empty);
1115-
let fallback_binding = self.reborrow().early_resolve_ident_in_lexical_scope(
1115+
let fallback_binding = self.reborrow().resolve_ident_in_scope_set(
11161116
path.segments[0].ident,
11171117
ScopeSet::Macro(MacroKind::Bang),
11181118
&ParentScope { macro_rules: no_macro_rules, ..*parent_scope },

0 commit comments

Comments
 (0)