don't try to blame tuple fields for immutability
Tuple fields don't have an `&T` in their declaration that can be changed to `&mut T` - skip them.. Fixes #41104.
This commit is contained in:
parent
5309a3e31d
commit
95bd41e339
3 changed files with 24 additions and 8 deletions
|
|
@ -51,3 +51,9 @@ pub fn with_arg(z: Z, w: &Z) {
|
|||
let _ = &mut z.x;
|
||||
let _ = &mut w.x;
|
||||
}
|
||||
|
||||
pub fn with_tuple() {
|
||||
let mut y = 0;
|
||||
let x = (&y,);
|
||||
*x.0 = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,5 +90,11 @@ error: cannot borrow immutable field `w.x` as mutable
|
|||
52 | let _ = &mut w.x;
|
||||
| ^^^ cannot mutably borrow immutable field
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: cannot assign to immutable borrowed content `*x.0`
|
||||
--> $DIR/issue-39544.rs:58:5
|
||||
|
|
||||
58 | *x.0 = 1;
|
||||
| ^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue