@@ -22,8 +22,8 @@ pub(crate) fn need_mut(ctx: &DiagnosticsContext<'_>, d: &hir::NeedMut) -> Diagno
2222 }
2323 let edit = edit_builder. finish ( ) ;
2424 Some ( vec ! [ fix(
25- "remove_mut " ,
26- "Remove unnecessary `mut` " ,
25+ "add_mut " ,
26+ "Change it to be mutable " ,
2727 SourceChange :: from_text_edit( file_id, edit) ,
2828 use_range,
2929 ) ] )
@@ -66,7 +66,7 @@ pub(crate) fn unused_mut(ctx: &DiagnosticsContext<'_>, d: &hir::UnusedMut) -> Di
6666 let ast = d. local . primary_source ( ctx. sema . db ) . syntax_ptr ( ) ;
6767 Diagnostic :: new (
6868 "unused-mut" ,
69- "remove this `mut` " ,
69+ "variable does not need to be mutable " ,
7070 ctx. sema . diagnostics_display_range ( ast) . range ,
7171 )
7272 . severity ( Severity :: WeakWarning )
@@ -89,7 +89,7 @@ mod tests {
8989fn f(_: i32) {}
9090fn main() {
9191 let mut x = 2;
92- //^^^^^ 💡 weak: remove this `mut`
92+ //^^^^^ 💡 weak: variable does not need to be mutable
9393 f(x);
9494}
9595"# ,
@@ -264,7 +264,7 @@ fn main() {
264264fn f(_: i32) {}
265265fn main() {
266266 let mut x = (2, 7);
267- //^^^^^ 💡 weak: remove this `mut`
267+ //^^^^^ 💡 weak: variable does not need to be mutable
268268 f(x.1);
269269}
270270"# ,
@@ -298,7 +298,7 @@ fn main() {
298298 r#"
299299fn main() {
300300 let mut x = &mut 2;
301- //^^^^^ 💡 weak: remove this `mut`
301+ //^^^^^ 💡 weak: variable does not need to be mutable
302302 *x = 5;
303303}
304304"# ,
@@ -343,7 +343,7 @@ fn main() {
343343fn main() {
344344 match (2, 3) {
345345 (x, mut y) => {
346- //^^^^^ 💡 weak: remove this `mut`
346+ //^^^^^ 💡 weak: variable does not need to be mutable
347347 x = 7;
348348 //^^^^^ 💡 error: cannot mutate immutable variable `x`
349349 }
@@ -364,7 +364,7 @@ fn main() {
364364fn main() {
365365 return;
366366 let mut x = 2;
367- //^^^^^ 💡 weak: remove this `mut`
367+ //^^^^^ 💡 weak: variable does not need to be mutable
368368 &mut x;
369369}
370370"# ,
@@ -374,7 +374,7 @@ fn main() {
374374fn main() {
375375 loop {}
376376 let mut x = 2;
377- //^^^^^ 💡 weak: remove this `mut`
377+ //^^^^^ 💡 weak: variable does not need to be mutable
378378 &mut x;
379379}
380380"# ,
@@ -395,7 +395,7 @@ fn main(b: bool) {
395395 g();
396396 }
397397 let mut x = 2;
398- //^^^^^ 💡 weak: remove this `mut`
398+ //^^^^^ 💡 weak: variable does not need to be mutable
399399 &mut x;
400400}
401401"# ,
@@ -409,7 +409,7 @@ fn main(b: bool) {
409409 return;
410410 }
411411 let mut x = 2;
412- //^^^^^ 💡 weak: remove this `mut`
412+ //^^^^^ 💡 weak: variable does not need to be mutable
413413 &mut x;
414414}
415415"# ,
@@ -423,7 +423,7 @@ fn main(b: bool) {
423423fn f(_: i32) {}
424424fn main() {
425425 let mut x;
426- //^^^^^ 💡 weak: remove this `mut`
426+ //^^^^^ 💡 weak: variable does not need to be mutable
427427 x = 5;
428428 f(x);
429429}
@@ -434,7 +434,7 @@ fn main() {
434434fn f(_: i32) {}
435435fn main(b: bool) {
436436 let mut x;
437- //^^^^^ 💡 weak: remove this `mut`
437+ //^^^^^ 💡 weak: variable does not need to be mutable
438438 if b {
439439 x = 1;
440440 } else {
@@ -477,15 +477,15 @@ fn f(_: i32) {}
477477fn main() {
478478 loop {
479479 let mut x = 1;
480- //^^^^^ 💡 weak: remove this `mut`
480+ //^^^^^ 💡 weak: variable does not need to be mutable
481481 f(x);
482482 if let mut y = 2 {
483- //^^^^^ 💡 weak: remove this `mut`
483+ //^^^^^ 💡 weak: variable does not need to be mutable
484484 f(y);
485485 }
486486 match 3 {
487487 mut z => f(z),
488- //^^^^^ 💡 weak: remove this `mut`
488+ //^^^^^ 💡 weak: variable does not need to be mutable
489489 }
490490 }
491491}
@@ -498,7 +498,7 @@ fn main() {
498498 check_diagnostics (
499499 r#"
500500fn f(mut x: i32) {
501- //^^^^^ 💡 weak: remove this `mut`
501+ //^^^^^ 💡 weak: variable does not need to be mutable
502502}
503503"# ,
504504 ) ;
@@ -519,7 +519,7 @@ fn f(x: i32) {
519519//- minicore: iterators
520520fn f(x: [(i32, u8); 10]) {
521521 for (a, mut b) in x {
522- //^^^^^ 💡 weak: remove this `mut`
522+ //^^^^^ 💡 weak: variable does not need to be mutable
523523 a = 2;
524524 //^^^^^ 💡 error: cannot mutate immutable variable `a`
525525 }
@@ -567,7 +567,7 @@ fn f() {
567567fn f(_: i32) {}
568568fn main() {
569569 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
571571 f(x);
572572}
573573"# ,
@@ -583,7 +583,7 @@ fn f(_: i32) {}
583583fn main() {
584584 #[allow(unused_mut)]
585585 let mut x = 2;
586- //^^^^^ 💡 weak: remove this `mut`
586+ //^^^^^ 💡 weak: variable does not need to be mutable
587587 f(x);
588588}
589589"# ,
0 commit comments