forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#83251 - estebank:issue-83241, r=oli-obk
Suggestion for call on immutable binding of mutable type When calling a method requiring a mutable self borrow on an inmutable to a mutable borrow of the type, suggest making the binding mutable. Fix rust-lang#83241.
- Loading branch information
Showing
6 changed files
with
210 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,65 @@ | ||
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable | ||
--> $DIR/mut-borrow-of-mut-ref.rs:5:7 | ||
--> $DIR/mut-borrow-of-mut-ref.rs:7:7 | ||
| | ||
LL | g(&mut b); | ||
| ^^^^^^ | ||
| | | ||
| cannot borrow as mutable | ||
| help: try removing `&mut` here | ||
LL | h(&mut b); | ||
| ^^^^^^ cannot borrow as mutable | ||
| | ||
note: the binding is already a mutable borrow | ||
--> $DIR/mut-borrow-of-mut-ref.rs:4:13 | ||
| | ||
LL | pub fn f(b: &mut i32) { | ||
| ^^^^^^^^ | ||
help: try removing `&mut` here | ||
| | ||
LL - h(&mut b); | ||
LL + h(b); | ||
| | ||
|
||
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable | ||
--> $DIR/mut-borrow-of-mut-ref.rs:8:12 | ||
--> $DIR/mut-borrow-of-mut-ref.rs:11:12 | ||
| | ||
LL | g(&mut &mut b); | ||
| ^^^^^^ | ||
| | | ||
| cannot borrow as mutable | ||
| help: try removing `&mut` here | ||
| ^^^^^^ cannot borrow as mutable | ||
| | ||
note: the binding is already a mutable borrow | ||
--> $DIR/mut-borrow-of-mut-ref.rs:4:13 | ||
| | ||
LL | pub fn f(b: &mut i32) { | ||
| ^^^^^^^^ | ||
help: try removing `&mut` here | ||
| | ||
LL - g(&mut &mut b); | ||
LL + g(&mut b); | ||
| | ||
|
||
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable | ||
--> $DIR/mut-borrow-of-mut-ref.rs:18:12 | ||
| | ||
LL | h(&mut &mut b); | ||
| ^^^^^^ cannot borrow as mutable | ||
| | ||
note: the binding is already a mutable borrow | ||
--> $DIR/mut-borrow-of-mut-ref.rs:17:13 | ||
| | ||
LL | pub fn g(b: &mut i32) { | ||
| ^^^^^^^^ | ||
help: try removing `&mut` here | ||
| | ||
LL - h(&mut &mut b); | ||
LL + h(&mut b); | ||
| | ||
|
||
error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable | ||
--> $DIR/mut-borrow-of-mut-ref.rs:35:5 | ||
| | ||
LL | f.bar(); | ||
| ^ cannot borrow as mutable | ||
| | ||
help: consider making the binding mutable | ||
| | ||
LL | pub fn baz(mut f: &mut String) { | ||
| +++ | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0596`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters