Skip to content

Commit b7f6c95

Browse files
committed
resolve: Move resolve_ident_in_module_unadjusted for real modules to a separate method
1 parent 621d870 commit b7f6c95

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
348348
)));
349349
} else if let RibKind::Block(Some(module)) = rib.kind
350350
&& let Ok(binding) = self.cm().resolve_ident_in_module_unadjusted(
351-
ModuleOrUniformRoot::Module(module),
351+
module,
352352
ident,
353353
ns,
354354
parent_scope,
@@ -590,7 +590,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
590590
)
591591
};
592592
let binding = self.reborrow().resolve_ident_in_module_unadjusted(
593-
ModuleOrUniformRoot::Module(module),
593+
module,
594594
ident,
595595
ns,
596596
adjusted_parent_scope,
@@ -667,7 +667,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
667667
let mut result = Err(Determinacy::Determined);
668668
if let Some(prelude) = self.prelude
669669
&& let Ok(binding) = self.reborrow().resolve_ident_in_module_unadjusted(
670-
ModuleOrUniformRoot::Module(prelude),
670+
prelude,
671671
ident,
672672
ns,
673673
parent_scope,
@@ -846,7 +846,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
846846
// No adjustments
847847
}
848848
}
849-
self.resolve_ident_in_module_unadjusted(
849+
self.resolve_ident_in_virt_module_unadjusted(
850850
module,
851851
ident,
852852
ns,
@@ -857,11 +857,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
857857
ignore_import,
858858
)
859859
}
860+
860861
/// Attempts to resolve `ident` in namespaces `ns` of `module`.
861862
/// Invariant: if `finalize` is `Some`, expansion and import resolution must be complete.
862863
#[instrument(level = "debug", skip(self))]
863-
fn resolve_ident_in_module_unadjusted<'r>(
864-
mut self: CmResolver<'r, 'ra, 'tcx>,
864+
fn resolve_ident_in_virt_module_unadjusted<'r>(
865+
self: CmResolver<'r, 'ra, 'tcx>,
865866
module: ModuleOrUniformRoot<'ra>,
866867
ident: Ident,
867868
ns: Namespace,
@@ -873,8 +874,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
873874
ignore_binding: Option<NameBinding<'ra>>,
874875
ignore_import: Option<Import<'ra>>,
875876
) -> Result<NameBinding<'ra>, (Determinacy, Weak)> {
876-
let module = match module {
877-
ModuleOrUniformRoot::Module(module) => module,
877+
match module {
878+
ModuleOrUniformRoot::Module(module) => self.resolve_ident_in_module_unadjusted(
879+
module,
880+
ident,
881+
ns,
882+
parent_scope,
883+
shadowing,
884+
finalize,
885+
ignore_binding,
886+
ignore_import,
887+
),
878888
ModuleOrUniformRoot::ModuleAndExternPrelude(module) => {
879889
assert_eq!(shadowing, Shadowing::Unrestricted);
880890
let binding = self.resolve_ident_in_scope_set(
@@ -929,8 +939,20 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
929939
);
930940
return binding.map_err(|determinacy| (determinacy, Weak::No));
931941
}
932-
};
942+
}
943+
}
933944

945+
fn resolve_ident_in_module_unadjusted<'r>(
946+
mut self: CmResolver<'r, 'ra, 'tcx>,
947+
module: Module<'ra>,
948+
ident: Ident,
949+
ns: Namespace,
950+
parent_scope: &ParentScope<'ra>,
951+
shadowing: Shadowing,
952+
finalize: Option<Finalize>,
953+
ignore_binding: Option<NameBinding<'ra>>,
954+
ignore_import: Option<Import<'ra>>,
955+
) -> Result<NameBinding<'ra>, (Determinacy, Weak)> {
934956
let key = BindingKey::new(ident, ns);
935957
// `try_borrow_mut` is required to ensure exclusive access, even if the resulting binding
936958
// doesn't need to be mutable. It will fail when there is a cycle of imports, and without
@@ -1048,7 +1070,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10481070
None => continue,
10491071
};
10501072
let result = self.reborrow().resolve_ident_in_module_unadjusted(
1051-
ModuleOrUniformRoot::Module(module),
1073+
module,
10521074
ident,
10531075
ns,
10541076
adjusted_parent_scope,

0 commit comments

Comments
 (0)