2021-06-27 01:22:46 -05:00
|
|
|
// edition:2021
|
2020-12-12 23:11:15 -06:00
|
|
|
|
|
|
|
// Ensure that diagnostics for mutability error (because the root variable
|
|
|
|
// isn't mutable) work with `capture_disjoint_fields` enabled.
|
|
|
|
|
|
|
|
fn mut_error_struct() {
|
|
|
|
let x = (10, 10);
|
|
|
|
let y = (x, 10);
|
|
|
|
let z = (y, 10);
|
|
|
|
|
|
|
|
let mut c = || {
|
|
|
|
z.0.0.0 = 20;
|
2021-03-17 01:51:27 -05:00
|
|
|
//~^ ERROR: cannot assign to `z.0.0.0`, as it is not declared as mutable
|
2020-12-12 23:11:15 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
c();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mut_error_box() {
|
|
|
|
let x = (10, 10);
|
|
|
|
let bx = Box::new(x);
|
|
|
|
|
|
|
|
let mut c = || {
|
|
|
|
bx.0 = 20;
|
2021-03-17 01:51:27 -05:00
|
|
|
//~^ ERROR: cannot assign to `*bx.0`, as it is not declared as mutable
|
2020-12-12 23:11:15 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
c();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
mut_error_struct();
|
|
|
|
mut_error_box();
|
|
|
|
}
|