mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 05:51:58 +00:00
Fix &mut
removal suggestion
This commit is contained in:
parent
f63d2bc657
commit
9344779f71
@ -449,8 +449,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
|
||||
.is_ok_and(|snippet| snippet.starts_with("&mut ")) =>
|
||||
{
|
||||
err.span_label(span, format!("cannot {act}"));
|
||||
err.span_suggestion(
|
||||
span,
|
||||
err.span_suggestion_verbose(
|
||||
span.with_hi(span.lo() + BytePos(5)),
|
||||
"try removing `&mut` here",
|
||||
"",
|
||||
Applicability::MaybeIncorrect,
|
||||
|
@ -2,10 +2,13 @@ error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-33819.rs:4:34
|
||||
|
|
||||
LL | Some(ref v) => { let a = &mut v; },
|
||||
| ^^^^^^
|
||||
| |
|
||||
| cannot borrow as mutable
|
||||
| help: try removing `&mut` here
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
help: try removing `&mut` here
|
||||
|
|
||||
LL - Some(ref v) => { let a = &mut v; },
|
||||
LL + Some(ref v) => { let a = v; },
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -2,10 +2,13 @@ error[E0596]: cannot borrow `key` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-34337.rs:6:9
|
||||
|
|
||||
LL | get(&mut key);
|
||||
| ^^^^^^^^
|
||||
| |
|
||||
| cannot borrow as mutable
|
||||
| help: try removing `&mut` here
|
||||
| ^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
help: try removing `&mut` here
|
||||
|
|
||||
LL - get(&mut key);
|
||||
LL + get(key);
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
@ -2,10 +2,13 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
|
||||
--> $DIR/issue-37139.rs:12:18
|
||||
|
|
||||
LL | test(&mut x);
|
||||
| ^^^^^^
|
||||
| |
|
||||
| cannot borrow as mutable
|
||||
| help: try removing `&mut` here
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
help: try removing `&mut` here
|
||||
|
|
||||
LL - test(&mut x);
|
||||
LL + test(x);
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user