Skip to content

Commit 3289351

Browse files
Adress review.
1 parent c7f94d9 commit 3289351

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

compiler/rustc_resolve/src/imports.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
973973
///
974974
/// Meanwhile, if resolution is successful, the side effect of the resolution is returned.
975975
fn resolve_import<'r>(
976-
self: &mut CmResolver<'r, 'ra, 'tcx>,
976+
mut self: CmResolver<'r, 'ra, 'tcx>,
977977
import: Import<'ra>,
978978
) -> (Option<SideEffect<'ra>>, usize) {
979979
debug!(
@@ -1018,12 +1018,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10181018

10191019
let mut import_bindings = PerNS::default();
10201020
let mut indeterminate_count = 0;
1021-
self.reborrow().per_ns_cm(|this, ns| {
1021+
1022+
// HACK: Use array of namespaces in the same order as `per_ns_mut`.
1023+
// We can't use `per_ns_cm` because of the invariance on CmResolver (RefOrMut).
1024+
for ns in [TypeNS, ValueNS, MacroNS] {
10221025
if !type_ns_only || ns == TypeNS {
10231026
if bindings[ns].get() != PendingBinding::Pending {
1024-
return;
1027+
continue;
10251028
};
1026-
let binding_result = this.reborrow().maybe_resolve_ident_in_module(
1029+
let binding_result = self.reborrow().maybe_resolve_ident_in_module(
10271030
module,
10281031
source,
10291032
ns,
@@ -1033,7 +1036,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10331036
let pending_binding = match binding_result {
10341037
Ok(binding) => {
10351038
// We need the `target`, `source` can be extracted.
1036-
let imported_binding = this.import(binding, import);
1039+
let imported_binding = self.import(binding, import);
10371040
Some(Some(imported_binding))
10381041
}
10391042
Err(Determinacy::Determined) => Some(None),
@@ -1044,8 +1047,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10441047
};
10451048
import_bindings[ns] = pending_binding;
10461049
}
1047-
});
1048-
1050+
}
10491051
(
10501052
Some(SideEffect {
10511053
imported_module: module,

compiler/rustc_resolve/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,15 +1823,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18231823
f(self, MacroNS);
18241824
}
18251825

1826-
fn per_ns_cm<'r, F: FnMut(&mut CmResolver<'r, 'ra, 'tcx>, Namespace)>(
1827-
mut self: CmResolver<'r, 'ra, 'tcx>,
1828-
mut f: F,
1829-
) {
1830-
f(&mut self, TypeNS);
1831-
f(&mut self, ValueNS);
1832-
f(&mut self, MacroNS);
1833-
}
1834-
18351826
fn is_builtin_macro(&self, res: Res) -> bool {
18361827
self.get_macro(res).is_some_and(|macro_data| macro_data.ext.builtin_name.is_some())
18371828
}

0 commit comments

Comments
 (0)