Skip to content

Commit

Permalink
remove unused muts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Apr 28, 2023
1 parent 69c71da commit fc63926
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast_pretty/src/pp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ impl Printer {

fn check_stack(&mut self, mut depth: usize) {
while let Some(&index) = self.scan_stack.back() {
let mut entry = &mut self.buf[index];
let entry = &mut self.buf[index];
match entry.token {
Token::Begin(_) => {
if depth == 0 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/member_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn append_list(
) {
let mut p = target_list;
loop {
let mut r = &mut constraints[p];
let r = &mut constraints[p];
match r.next_constraint {
Some(q) => p = q,
None => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
let target_scopes = visitor.fixup_scopes.drain(start_point..);

for scope in target_scopes {
let mut yield_data =
let yield_data =
visitor.scope_tree.yield_in_scope.get_mut(&scope).unwrap().last_mut().unwrap();
let count = yield_data.expr_and_pat_count;
let span = yield_data.span;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ mod parse {
}
}

let mut options = slot.get_or_insert_default();
let options = slot.get_or_insert_default();
let mut seen_always = false;
let mut seen_never = false;
let mut seen_ignore_loops = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
let mut map = HashMap::new();
map.insert("a", Test { v: 0 });

for (_k, mut v) in map.iter_mut() {
for (_k, v) in map.iter_mut() {
//~^ HELP use mutable method
//~| NOTE this iterator yields `&` references
v.v += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {
let mut map = HashMap::new();
map.insert("a", Test { v: 0 });

for (_k, mut v) in map.iter() {
for (_k, v) in map.iter() {
//~^ HELP use mutable method
//~| NOTE this iterator yields `&` references
v.v += 1;
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/suggestions/suggest-mut-method-for-loop-hashmap.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0594]: cannot assign to `v.v`, which is behind a `&` reference
--> $DIR/suggest-mut-method-for-loop-hashmap.rs:17:9
|
LL | for (_k, mut v) in map.iter() {
| ----------
| | |
| | help: use mutable method: `iter_mut()`
| this iterator yields `&` references
LL | for (_k, v) in map.iter() {
| ----------
| | |
| | help: use mutable method: `iter_mut()`
| this iterator yields `&` references
...
LL | v.v += 1;
| ^^^^^^^^ `v` is a `&` reference, so the data it refers to cannot be written
Expand Down

0 comments on commit fc63926

Please sign in to comment.