Rollup merge of #148187 - LorrensP-2158466:cm-res-variance, r=petrochenkov

Remove uses of `&mut CmResolver`

Before rust-lang/rust#148329, using CmResolver in closures was not possible when trying to reborrow. This pr changes uses of `&mut CmResolver` into a bare `CmResolver`, to keep the code clean (and to not have `&mut &mut Resolver`)

r? @petrochenkov
This commit is contained in:
Jonathan Brouwer 2026-01-26 18:19:13 +01:00 committed by GitHub
commit bd85bab5a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 9 deletions

View file

@ -58,7 +58,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
orig_ctxt: Span,
derive_fallback_lint_id: Option<NodeId>,
mut visitor: impl FnMut(
&mut CmResolver<'r, 'ra, 'tcx>,
CmResolver<'_, 'ra, 'tcx>,
Scope<'ra>,
UsePrelude,
Span,
@ -165,7 +165,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
if visit {
let use_prelude = if use_prelude { UsePrelude::Yes } else { UsePrelude::No };
if let ControlFlow::Break(break_result) =
visitor(&mut self, scope, use_prelude, ctxt)
visitor(self.reborrow(), scope, use_prelude, ctxt)
{
return Some(break_result);
}
@ -438,7 +438,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
parent_scope,
orig_ident.span,
derive_fallback_lint_id,
|this, scope, use_prelude, ctxt| {
|mut this, scope, use_prelude, ctxt| {
let ident = Ident::new(orig_ident.name, ctxt);
// The passed `ctxt` is already normalized, so avoid expensive double normalization.
let ident = Macros20NormalizedIdent(ident);

View file

@ -893,7 +893,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
};
let mut indeterminate_count = 0;
self.per_ns_cm(|this, ns| {
self.per_ns_cm(|mut this, ns| {
if !type_ns_only || ns == TypeNS {
if bindings[ns].get() != PendingDecl::Pending {
return;

View file

@ -1831,13 +1831,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
f(self, MacroNS);
}
fn per_ns_cm<'r, F: FnMut(&mut CmResolver<'r, 'ra, 'tcx>, Namespace)>(
fn per_ns_cm<'r, F: FnMut(CmResolver<'_, 'ra, 'tcx>, Namespace)>(
mut self: CmResolver<'r, 'ra, 'tcx>,
mut f: F,
) {
f(&mut self, TypeNS);
f(&mut self, ValueNS);
f(&mut self, MacroNS);
f(self.reborrow(), TypeNS);
f(self.reborrow(), ValueNS);
f(self, MacroNS);
}
fn is_builtin_macro(&self, res: Res) -> bool {
@ -1902,7 +1902,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
let scope_set = ScopeSet::All(TypeNS);
self.cm().visit_scopes(scope_set, parent_scope, ctxt, None, |this, scope, _, _| {
self.cm().visit_scopes(scope_set, parent_scope, ctxt, None, |mut this, scope, _, _| {
match scope {
Scope::ModuleNonGlobs(module, _) => {
this.get_mut().traits_in_module(module, assoc_item, &mut found_traits);