Skip to content

Commit 92dea43

Browse files
committed
resolve: Change &mut Resolver to &Resolver when possible
1 parent 27bb8f1 commit 92dea43

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

compiler/rustc_expand/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ pub trait ResolverExpand {
10421042
fn next_node_id(&mut self) -> NodeId;
10431043
fn invocation_parent(&self, id: LocalExpnId) -> LocalDefId;
10441044

1045-
fn resolve_dollar_crates(&mut self);
1045+
fn resolve_dollar_crates(&self);
10461046
fn visit_ast_fragment_with_placeholders(
10471047
&mut self,
10481048
expn_id: LocalExpnId,

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
8484
/// Reachable macros with block module parents exist due to `#[macro_export] macro_rules!`,
8585
/// but they cannot use def-site hygiene, so the assumption holds
8686
/// (<https://github.com/rust-lang/rust/pull/77984#issuecomment-712445508>).
87-
pub(crate) fn get_nearest_non_block_module(&mut self, mut def_id: DefId) -> Module<'ra> {
87+
pub(crate) fn get_nearest_non_block_module(&self, mut def_id: DefId) -> Module<'ra> {
8888
loop {
8989
match self.get_module(def_id) {
9090
Some(module) => return module,
@@ -93,14 +93,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
9393
}
9494
}
9595

96-
pub(crate) fn expect_module(&mut self, def_id: DefId) -> Module<'ra> {
96+
pub(crate) fn expect_module(&self, def_id: DefId) -> Module<'ra> {
9797
self.get_module(def_id).expect("argument `DefId` is not a module")
9898
}
9999

100100
/// If `def_id` refers to a module (in resolver's sense, i.e. a module item, crate root, enum,
101101
/// or trait), then this function returns that module's resolver representation, otherwise it
102102
/// returns `None`.
103-
pub(crate) fn get_module(&mut self, def_id: DefId) -> Option<Module<'ra>> {
103+
pub(crate) fn get_module(&self, def_id: DefId) -> Option<Module<'ra>> {
104104
match def_id.as_local() {
105105
Some(local_def_id) => self.local_module_map.get(&local_def_id).copied(),
106106
None => {
@@ -133,7 +133,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
133133
}
134134
}
135135

136-
pub(crate) fn expn_def_scope(&mut self, expn_id: ExpnId) -> Module<'ra> {
136+
pub(crate) fn expn_def_scope(&self, expn_id: ExpnId) -> Module<'ra> {
137137
match expn_id.expn_data().macro_def_id {
138138
Some(def_id) => self.macro_def_scope(def_id),
139139
None => expn_id
@@ -143,7 +143,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
143143
}
144144
}
145145

146-
pub(crate) fn macro_def_scope(&mut self, def_id: DefId) -> Module<'ra> {
146+
pub(crate) fn macro_def_scope(&self, def_id: DefId) -> Module<'ra> {
147147
if let Some(id) = def_id.as_local() {
148148
self.local_macro_def_scopes[&id]
149149
} else {

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,12 +2776,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
27762776
}
27772777

27782778
/// Finds a cfg-ed out item inside `module` with the matching name.
2779-
pub(crate) fn find_cfg_stripped(
2780-
&mut self,
2781-
err: &mut Diag<'_>,
2782-
segment: &Symbol,
2783-
module: DefId,
2784-
) {
2779+
pub(crate) fn find_cfg_stripped(&self, err: &mut Diag<'_>, segment: &Symbol, module: DefId) {
27852780
let local_items;
27862781
let symbols = if module.is_local() {
27872782
local_items = self
@@ -2807,7 +2802,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
28072802
}
28082803

28092804
fn comes_from_same_module_for_glob(
2810-
r: &mut Resolver<'_, '_>,
2805+
r: &Resolver<'_, '_>,
28112806
parent_module: DefId,
28122807
module: DefId,
28132808
visited: &mut FxHashMap<DefId, bool>,

compiler/rustc_resolve/src/effective_visibilities.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ pub(crate) struct EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
3838
}
3939

4040
impl Resolver<'_, '_> {
41-
fn nearest_normal_mod(&mut self, def_id: LocalDefId) -> LocalDefId {
41+
fn nearest_normal_mod(&self, def_id: LocalDefId) -> LocalDefId {
4242
self.get_nearest_non_block_module(def_id.to_def_id()).nearest_parent_mod().expect_local()
4343
}
4444

45-
fn private_vis_import(&mut self, binding: NameBinding<'_>) -> Visibility {
45+
fn private_vis_import(&self, binding: NameBinding<'_>) -> Visibility {
4646
let NameBindingKind::Import { import, .. } = binding.kind else { unreachable!() };
4747
Visibility::Restricted(
4848
import
@@ -52,7 +52,7 @@ impl Resolver<'_, '_> {
5252
)
5353
}
5454

55-
fn private_vis_def(&mut self, def_id: LocalDefId) -> Visibility {
55+
fn private_vis_def(&self, def_id: LocalDefId) -> Visibility {
5656
// For mod items `nearest_normal_mod` returns its argument, but we actually need its parent.
5757
let normal_mod_id = self.nearest_normal_mod(def_id);
5858
if normal_mod_id == def_id {

compiler/rustc_resolve/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
16051605
}
16061606

16071607
fn new_extern_module(
1608-
&mut self,
1608+
&self,
16091609
parent: Option<Module<'ra>>,
16101610
kind: ModuleKind,
16111611
expn_id: ExpnId,
@@ -1996,7 +1996,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19961996
}
19971997
}
19981998

1999-
fn resolve_crate_root(&mut self, ident: Ident) -> Module<'ra> {
1999+
fn resolve_crate_root(&self, ident: Ident) -> Module<'ra> {
20002000
debug!("resolve_crate_root({:?})", ident);
20012001
let mut ctxt = ident.span.ctxt();
20022002
let mark = if ident.name == kw::DollarCrate {
@@ -2069,7 +2069,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
20692069
module
20702070
}
20712071

2072-
fn resolve_self(&mut self, ctxt: &mut SyntaxContext, module: Module<'ra>) -> Module<'ra> {
2072+
fn resolve_self(&self, ctxt: &mut SyntaxContext, module: Module<'ra>) -> Module<'ra> {
20732073
let mut module = self.expect_module(module.nearest_parent_mod());
20742074
while module.span.ctxt().normalize_to_macros_2_0() != *ctxt {
20752075
let parent = module.parent.unwrap_or_else(|| self.expn_def_scope(ctxt.remove_mark()));

compiler/rustc_resolve/src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
172172
self.invocation_parents[&id].parent_def
173173
}
174174

175-
fn resolve_dollar_crates(&mut self) {
175+
fn resolve_dollar_crates(&self) {
176176
hygiene::update_dollar_crate_names(|ctxt| {
177177
let ident = Ident::new(kw::DollarCrate, DUMMY_SP.with_ctxt(ctxt));
178178
match self.resolve_crate_root(ident).kind {
@@ -1147,7 +1147,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11471147
///
11481148
/// Possibly replace its expander to a pre-defined one for built-in macros.
11491149
pub(crate) fn compile_macro(
1150-
&mut self,
1150+
&self,
11511151
macro_def: &ast::MacroDef,
11521152
ident: Ident,
11531153
attrs: &[rustc_hir::Attribute],

0 commit comments

Comments
 (0)