Skip to content

Commit 0991559

Browse files
committed
Cut some needless muts in compiler
1 parent 8365fcb commit 0991559

File tree

103 files changed

+259
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+259
-286
lines changed

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
114114
self.arena.alloc(hir::LetStmt { hir_id, super_, ty, pat, init, els, span, source })
115115
}
116116

117-
fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {
117+
fn lower_block_check_mode(&self, b: &BlockCheckMode) -> hir::BlockCheckMode {
118118
match *b {
119119
BlockCheckMode::Default => hir::BlockCheckMode::DefaultBlock,
120120
BlockCheckMode::Unsafe(u) => {

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
122122
})
123123
}
124124

125-
fn lower_delegation_generics(&mut self, span: Span) -> &'hir hir::Generics<'hir> {
125+
fn lower_delegation_generics(&self, span: Span) -> &'hir hir::Generics<'hir> {
126126
self.arena.alloc(hir::Generics {
127127
params: &[],
128128
predicates: &[],
@@ -179,7 +179,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
179179
}
180180

181181
fn lower_delegation_sig(
182-
&mut self,
182+
&self,
183183
sig_id: DefId,
184184
decl: &'hir hir::FnDecl<'hir>,
185185
span: Span,

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
424424
})
425425
}
426426

427-
pub(crate) fn lower_lit(&mut self, token_lit: &token::Lit, span: Span) -> hir::Lit {
427+
pub(crate) fn lower_lit(&self, token_lit: &token::Lit, span: Span) -> hir::Lit {
428428
let lit_kind = match LitKind::from_token_lit(*token_lit) {
429429
Ok(lit_kind) => lit_kind,
430430
Err(err) => {
@@ -435,19 +435,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
435435
respan(self.lower_span(span), lit_kind)
436436
}
437437

438-
fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
438+
fn lower_unop(&self, u: UnOp) -> hir::UnOp {
439439
match u {
440440
UnOp::Deref => hir::UnOp::Deref,
441441
UnOp::Not => hir::UnOp::Not,
442442
UnOp::Neg => hir::UnOp::Neg,
443443
}
444444
}
445445

446-
fn lower_binop(&mut self, b: BinOp) -> BinOp {
446+
fn lower_binop(&self, b: BinOp) -> BinOp {
447447
Spanned { node: b.node, span: self.lower_span(b.span) }
448448
}
449449

450-
fn lower_assign_op(&mut self, a: AssignOp) -> AssignOp {
450+
fn lower_assign_op(&self, a: AssignOp) -> AssignOp {
451451
Spanned { node: a.node, span: self.lower_span(a.span) }
452452
}
453453

@@ -681,7 +681,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
681681
hir::Arm { hir_id, pat, guard, body, span }
682682
}
683683

684-
fn lower_capture_clause(&mut self, capture_clause: CaptureBy) -> CaptureBy {
684+
fn lower_capture_clause(&self, capture_clause: CaptureBy) -> CaptureBy {
685685
match capture_clause {
686686
CaptureBy::Ref => CaptureBy::Ref,
687687
CaptureBy::Use { use_kw } => CaptureBy::Use { use_kw: self.lower_span(use_kw) },
@@ -1103,7 +1103,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11031103
}
11041104

11051105
fn closure_movability_for_fn(
1106-
&mut self,
1106+
&self,
11071107
decl: &FnDecl,
11081108
fn_decl_span: Span,
11091109
coroutine_kind: Option<hir::CoroutineKind>,
@@ -1133,7 +1133,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11331133
}
11341134

11351135
fn lower_closure_binder<'c>(
1136-
&mut self,
1136+
&self,
11371137
binder: &'c ClosureBinder,
11381138
) -> (hir::ClosureBinder, &'c [GenericParam]) {
11391139
let (binder, params) = match binder {
@@ -1283,7 +1283,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12831283
/// if they are not tuple structs.
12841284
/// Type checking will take care of the full validation later.
12851285
fn extract_tuple_struct_path<'a>(
1286-
&mut self,
1286+
&self,
12871287
expr: &'a Expr,
12881288
) -> Option<(&'a Option<Box<QSelf>>, &'a Path)> {
12891289
if let ExprKind::Path(qself, path) = &expr.kind {
@@ -1305,7 +1305,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13051305
/// if they are not unit structs.
13061306
/// Type checking will take care of the full validation later.
13071307
fn extract_unit_struct_path<'a>(
1308-
&mut self,
1308+
&self,
13091309
expr: &'a Expr,
13101310
) -> Option<(&'a Option<Box<QSelf>>, &'a Path)> {
13111311
if let ExprKind::Path(qself, path) = &expr.kind {
@@ -1589,7 +1589,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15891589
Some(Label { ident: self.lower_ident(label.ident) })
15901590
}
15911591

1592-
fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {
1592+
fn lower_loop_destination(&self, destination: Option<(NodeId, Label)>) -> hir::Destination {
15931593
let target_id = match destination {
15941594
Some((id, _)) => {
15951595
if let Some(loop_id) = self.resolver.get_label_res(id) {
@@ -1610,7 +1610,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16101610
hir::Destination { label, target_id }
16111611
}
16121612

1613-
fn lower_jump_destination(&mut self, id: NodeId, opt_label: Option<Label>) -> hir::Destination {
1613+
fn lower_jump_destination(&self, id: NodeId, opt_label: Option<Label>) -> hir::Destination {
16141614
if self.is_in_loop_condition && opt_label.is_none() {
16151615
hir::Destination {
16161616
label: None,

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
685685
self.arena.alloc(item)
686686
}
687687

688-
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemId {
688+
fn lower_foreign_item_ref(&self, i: &ForeignItem) -> hir::ForeignItemId {
689689
hir::ForeignItemId { owner_id: self.owner_id(i.id) }
690690
}
691691

@@ -951,7 +951,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
951951
self.arena.alloc(item)
952952
}
953953

954-
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemId {
954+
fn lower_trait_item_ref(&self, i: &AssocItem) -> hir::TraitItemId {
955955
hir::TraitItemId { owner_id: self.owner_id(i.id) }
956956
}
957957

@@ -1135,7 +1135,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11351135
self.arena.alloc(item)
11361136
}
11371137

1138-
fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemId {
1138+
fn lower_impl_item_ref(&self, i: &AssocItem) -> hir::ImplItemId {
11391139
hir::ImplItemId { owner_id: self.owner_id(i.id) }
11401140
}
11411141

@@ -1582,7 +1582,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15821582
}
15831583

15841584
pub(super) fn lower_fn_header(
1585-
&mut self,
1585+
&self,
15861586
h: FnHeader,
15871587
default_safety: hir::Safety,
15881588
attrs: &[hir::Attribute],
@@ -1613,7 +1613,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16131613
}
16141614
}
16151615

1616-
pub(super) fn lower_abi(&mut self, abi_str: StrLit) -> ExternAbi {
1616+
pub(super) fn lower_abi(&self, abi_str: StrLit) -> ExternAbi {
16171617
let ast::StrLit { symbol_unescaped, span, .. } = abi_str;
16181618
let extern_abi = symbol_unescaped.as_str().parse().unwrap_or_else(|_| {
16191619
self.error_on_invalid_abi(abi_str);
@@ -1645,7 +1645,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16451645
extern_abi
16461646
}
16471647

1648-
pub(super) fn lower_extern(&mut self, ext: Extern) -> ExternAbi {
1648+
pub(super) fn lower_extern(&self, ext: Extern) -> ExternAbi {
16491649
match ext {
16501650
Extern::None => ExternAbi::Rust,
16511651
Extern::Implicit(_) => ExternAbi::FALLBACK,
@@ -1670,7 +1670,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16701670
});
16711671
}
16721672

1673-
pub(super) fn lower_constness(&mut self, c: Const) -> hir::Constness {
1673+
pub(super) fn lower_constness(&self, c: Const) -> hir::Constness {
16741674
match c {
16751675
Const::Yes(_) => hir::Constness::Const,
16761676
Const::No => hir::Constness::NotConst,

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
732732
}
733733

734734
#[instrument(level = "trace", skip(self))]
735-
fn lower_res(&mut self, res: Res<NodeId>) -> Res {
735+
fn lower_res(&self, res: Res<NodeId>) -> Res {
736736
let res: Result<Res, ()> = res.apply_id(|id| {
737737
let owner = self.current_hir_id_owner;
738738
let local_id = self.ident_and_label_to_local_id.get(&id).copied().ok_or(())?;
@@ -748,11 +748,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
748748
res.unwrap_or(Res::Err)
749749
}
750750

751-
fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
751+
fn expect_full_res(&self, id: NodeId) -> Res<NodeId> {
752752
self.resolver.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
753753
}
754754

755-
fn lower_import_res(&mut self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
755+
fn lower_import_res(&self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
756756
let per_ns = self.resolver.get_import_res(id);
757757
let per_ns = per_ns.map(|res| res.map(|res| self.lower_res(res)));
758758
if per_ns.is_empty() {
@@ -1595,7 +1595,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
15951595
}))
15961596
}
15971597

1598-
fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
1598+
fn lower_fn_params_to_idents(&self, decl: &FnDecl) -> &'hir [Option<Ident>] {
15991599
self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
16001600
PatKind::Missing => None,
16011601
PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
@@ -2365,15 +2365,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23652365
}))
23662366
}
23672367

2368-
fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
2368+
fn lower_unsafe_source(&self, u: UnsafeSource) -> hir::UnsafeSource {
23692369
match u {
23702370
CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
23712371
UserProvided => hir::UnsafeSource::UserProvided,
23722372
}
23732373
}
23742374

23752375
fn lower_trait_bound_modifiers(
2376-
&mut self,
2376+
&self,
23772377
modifiers: TraitBoundModifiers,
23782378
) -> hir::TraitBoundModifiers {
23792379
let constness = match modifiers.constness {

compiler/rustc_ast_lowering/src/pat.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
331331
}
332332
}
333333

334-
fn pat_wild_with_node_id_of(&mut self, p: &Pat, hir_id: hir::HirId) -> &'hir hir::Pat<'hir> {
334+
fn pat_wild_with_node_id_of(&self, p: &Pat, hir_id: hir::HirId) -> &'hir hir::Pat<'hir> {
335335
self.arena.alloc(self.pat_with_node_id_of(p, hir::PatKind::Wild, hir_id))
336336
}
337337

338338
/// Construct a `Pat` with the `HirId` of `p.id` already lowered.
339339
fn pat_with_node_id_of(
340-
&mut self,
340+
&self,
341341
p: &Pat,
342342
kind: hir::PatKind<'hir>,
343343
hir_id: hir::HirId,
@@ -360,7 +360,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
360360
hir::PatKind::Wild
361361
}
362362

363-
fn lower_range_end(&mut self, e: &RangeEnd, has_end: bool) -> hir::RangeEnd {
363+
fn lower_range_end(&self, e: &RangeEnd, has_end: bool) -> hir::RangeEnd {
364364
match *e {
365365
RangeEnd::Excluded if has_end => hir::RangeEnd::Excluded,
366366
// No end; so `X..` behaves like `RangeFrom`.

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'a> AstValidator<'a> {
142142
}
143143

144144
fn check_type_alias_where_clause_location(
145-
&mut self,
145+
&self,
146146
ty_alias: &TyAlias,
147147
) -> Result<(), errors::WhereClauseBeforeTypeAlias> {
148148
if ty_alias.ty.is_none() || !ty_alias.where_clauses.before.has_where_token {

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn parse_cfg_entry<S: Stage>(
9090
}
9191

9292
fn parse_cfg_entry_version<S: Stage>(
93-
cx: &mut AcceptContext<'_, '_, S>,
93+
cx: &AcceptContext<'_, '_, S>,
9494
list: &MetaItemListParser<'_>,
9595
meta_span: Span,
9696
) -> Option<CfgEntry> {
@@ -119,7 +119,7 @@ fn parse_cfg_entry_version<S: Stage>(
119119
}
120120

121121
fn parse_cfg_entry_target<S: Stage>(
122-
cx: &mut AcceptContext<'_, '_, S>,
122+
cx: &AcceptContext<'_, '_, S>,
123123
list: &MetaItemListParser<'_>,
124124
meta_span: Span,
125125
) -> Option<CfgEntry> {
@@ -169,7 +169,7 @@ fn parse_name_value<S: Stage>(
169169
name_span: Span,
170170
value: Option<&NameValueParser>,
171171
span: Span,
172-
cx: &mut AcceptContext<'_, '_, S>,
172+
cx: &AcceptContext<'_, '_, S>,
173173
) -> Option<CfgEntry> {
174174
try_gate_cfg(name, span, cx.sess(), cx.features_option());
175175

compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<S: Stage> SingleAttributeParser<S> for RustcBuiltinMacroParser {
6666
}
6767

6868
fn parse_derive_like<S: Stage>(
69-
cx: &mut AcceptContext<'_, '_, S>,
69+
cx: &AcceptContext<'_, '_, S>,
7070
args: &ArgParser<'_>,
7171
trait_name_mandatory: bool,
7272
) -> Option<(Option<Symbol>, ThinVec<Symbol>)> {

compiler/rustc_attr_parsing/src/attributes/prototype.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<S: Stage> SingleAttributeParser<S> for CustomMirParser {
6767
}
6868

6969
fn extract_value<S: Stage>(
70-
cx: &mut AcceptContext<'_, '_, S>,
70+
cx: &AcceptContext<'_, '_, S>,
7171
key: Symbol,
7272
arg: &ArgParser<'_>,
7373
span: Span,
@@ -96,7 +96,7 @@ fn extract_value<S: Stage>(
9696
}
9797

9898
fn parse_dialect<S: Stage>(
99-
cx: &mut AcceptContext<'_, '_, S>,
99+
cx: &AcceptContext<'_, '_, S>,
100100
dialect: Option<(Symbol, Span)>,
101101
failed: &mut bool,
102102
) -> Option<(MirDialect, Span)> {
@@ -118,7 +118,7 @@ fn parse_dialect<S: Stage>(
118118
}
119119

120120
fn parse_phase<S: Stage>(
121-
cx: &mut AcceptContext<'_, '_, S>,
121+
cx: &AcceptContext<'_, '_, S>,
122122
phase: Option<(Symbol, Span)>,
123123
failed: &mut bool,
124124
) -> Option<(MirPhase, Span)> {

0 commit comments

Comments
 (0)