@@ -22,8 +22,8 @@ pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Diagno
22
22
}
23
23
let edit = edit_builder. finish ( ) ;
24
24
Some ( vec ! [ fix(
25
- "remove_mut " ,
26
- "Remove unnecessary `mut` " ,
25
+ "add_mut " ,
26
+ "Change it to be mutable " ,
27
27
SourceChange :: from_text_edit( file_id, edit) ,
28
28
use_range,
29
29
) ] )
@@ -66,7 +66,7 @@ pub(crate) fn unused_mut(ctx: &DiagnosticsContext<'_>, d: &hir::UnusedMut) -> Di
66
66
let ast = d. local . primary_source ( ctx. sema . db ) . syntax_ptr ( ) ;
67
67
Diagnostic :: new (
68
68
"unused-mut" ,
69
- "remove this `mut` " ,
69
+ "variable does not need to be mutable " ,
70
70
ctx. sema . diagnostics_display_range ( ast) . range ,
71
71
)
72
72
. severity ( Severity :: WeakWarning )
@@ -89,7 +89,7 @@ mod tests {
89
89
fn f(_: i32) {}
90
90
fn main() {
91
91
let mut x = 2;
92
- //^^^^^ 💡 weak: remove this `mut`
92
+ //^^^^^ 💡 weak: variable does not need to be mutable
93
93
f(x);
94
94
}
95
95
"# ,
@@ -264,7 +264,7 @@ fn main() {
264
264
fn f(_: i32) {}
265
265
fn main() {
266
266
let mut x = (2, 7);
267
- //^^^^^ 💡 weak: remove this `mut`
267
+ //^^^^^ 💡 weak: variable does not need to be mutable
268
268
f(x.1);
269
269
}
270
270
"# ,
@@ -298,7 +298,7 @@ fn main() {
298
298
r#"
299
299
fn main() {
300
300
let mut x = &mut 2;
301
- //^^^^^ 💡 weak: remove this `mut`
301
+ //^^^^^ 💡 weak: variable does not need to be mutable
302
302
*x = 5;
303
303
}
304
304
"# ,
@@ -343,7 +343,7 @@ fn main() {
343
343
fn main() {
344
344
match (2, 3) {
345
345
(x, mut y) => {
346
- //^^^^^ 💡 weak: remove this `mut`
346
+ //^^^^^ 💡 weak: variable does not need to be mutable
347
347
x = 7;
348
348
//^^^^^ 💡 error: cannot mutate immutable variable `x`
349
349
}
@@ -364,7 +364,7 @@ fn main() {
364
364
fn main() {
365
365
return;
366
366
let mut x = 2;
367
- //^^^^^ 💡 weak: remove this `mut`
367
+ //^^^^^ 💡 weak: variable does not need to be mutable
368
368
&mut x;
369
369
}
370
370
"# ,
@@ -374,7 +374,7 @@ fn main() {
374
374
fn main() {
375
375
loop {}
376
376
let mut x = 2;
377
- //^^^^^ 💡 weak: remove this `mut`
377
+ //^^^^^ 💡 weak: variable does not need to be mutable
378
378
&mut x;
379
379
}
380
380
"# ,
@@ -395,7 +395,7 @@ fn main(b: bool) {
395
395
g();
396
396
}
397
397
let mut x = 2;
398
- //^^^^^ 💡 weak: remove this `mut`
398
+ //^^^^^ 💡 weak: variable does not need to be mutable
399
399
&mut x;
400
400
}
401
401
"# ,
@@ -409,7 +409,7 @@ fn main(b: bool) {
409
409
return;
410
410
}
411
411
let mut x = 2;
412
- //^^^^^ 💡 weak: remove this `mut`
412
+ //^^^^^ 💡 weak: variable does not need to be mutable
413
413
&mut x;
414
414
}
415
415
"# ,
@@ -423,7 +423,7 @@ fn main(b: bool) {
423
423
fn f(_: i32) {}
424
424
fn main() {
425
425
let mut x;
426
- //^^^^^ 💡 weak: remove this `mut`
426
+ //^^^^^ 💡 weak: variable does not need to be mutable
427
427
x = 5;
428
428
f(x);
429
429
}
@@ -434,7 +434,7 @@ fn main() {
434
434
fn f(_: i32) {}
435
435
fn main(b: bool) {
436
436
let mut x;
437
- //^^^^^ 💡 weak: remove this `mut`
437
+ //^^^^^ 💡 weak: variable does not need to be mutable
438
438
if b {
439
439
x = 1;
440
440
} else {
@@ -477,15 +477,15 @@ fn f(_: i32) {}
477
477
fn main() {
478
478
loop {
479
479
let mut x = 1;
480
- //^^^^^ 💡 weak: remove this `mut`
480
+ //^^^^^ 💡 weak: variable does not need to be mutable
481
481
f(x);
482
482
if let mut y = 2 {
483
- //^^^^^ 💡 weak: remove this `mut`
483
+ //^^^^^ 💡 weak: variable does not need to be mutable
484
484
f(y);
485
485
}
486
486
match 3 {
487
487
mut z => f(z),
488
- //^^^^^ 💡 weak: remove this `mut`
488
+ //^^^^^ 💡 weak: variable does not need to be mutable
489
489
}
490
490
}
491
491
}
@@ -498,7 +498,7 @@ fn main() {
498
498
check_diagnostics (
499
499
r#"
500
500
fn f(mut x: i32) {
501
- //^^^^^ 💡 weak: remove this `mut`
501
+ //^^^^^ 💡 weak: variable does not need to be mutable
502
502
}
503
503
"# ,
504
504
) ;
@@ -519,7 +519,7 @@ fn f(x: i32) {
519
519
//- minicore: iterators
520
520
fn f(x: [(i32, u8); 10]) {
521
521
for (a, mut b) in x {
522
- //^^^^^ 💡 weak: remove this `mut`
522
+ //^^^^^ 💡 weak: variable does not need to be mutable
523
523
a = 2;
524
524
//^^^^^ 💡 error: cannot mutate immutable variable `a`
525
525
}
@@ -567,7 +567,7 @@ fn f() {
567
567
fn f(_: i32) {}
568
568
fn main() {
569
569
let ((Some(mut x), None) | (_, Some(mut x))) = (None, Some(7));
570
- //^^^^^ 💡 weak: remove this `mut`
570
+ //^^^^^ 💡 weak: variable does not need to be mutable
571
571
f(x);
572
572
}
573
573
"# ,
@@ -583,7 +583,7 @@ fn f(_: i32) {}
583
583
fn main() {
584
584
#[allow(unused_mut)]
585
585
let mut x = 2;
586
- //^^^^^ 💡 weak: remove this `mut`
586
+ //^^^^^ 💡 weak: variable does not need to be mutable
587
587
f(x);
588
588
}
589
589
"# ,
0 commit comments