diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2019-04-22 08:40:08 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2019-04-22 08:40:08 +0100 |
| commit | 8eef102270647af94f38274efb9a2fd5ef8a92ec (patch) | |
| tree | 95d7674ad687c45b730906915e79a0993138306b /src/test/ui/borrowck | |
| parent | aa6fb6caf9d8456c70144ccba1e969c85926e229 (diff) | |
| download | rust-8eef102270647af94f38274efb9a2fd5ef8a92ec.tar.gz rust-8eef102270647af94f38274efb9a2fd5ef8a92ec.zip | |
update tests for migrate mode by default
Diffstat (limited to 'src/test/ui/borrowck')
465 files changed, 2149 insertions, 9781 deletions
diff --git a/src/test/ui/borrowck/assign_mutable_fields.nll.stderr b/src/test/ui/borrowck/assign_mutable_fields.nll.stderr deleted file mode 100644 index 35101df4e0a..00000000000 --- a/src/test/ui/borrowck/assign_mutable_fields.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/assign_mutable_fields.rs:9:5 - | -LL | x.0 = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/assign_mutable_fields.rs:17:5 - | -LL | x.0 = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/assign_mutable_fields.rs b/src/test/ui/borrowck/assign_mutable_fields.rs index 85d6f3b74c0..b60726d0c8b 100644 --- a/src/test/ui/borrowck/assign_mutable_fields.rs +++ b/src/test/ui/borrowck/assign_mutable_fields.rs @@ -1,22 +1,22 @@ -// Currently, we permit you to assign to individual fields of a mut -// var, but we do not permit you to use the complete var afterwards. +// Currently, we do permit you to assign to individual fields of an +// uninitialized var. // We hope to fix this at some point. // // FIXME(#54987) fn assign_both_fields_and_use() { let mut x: (u32, u32); - x.0 = 1; + x.0 = 1; //~ ERROR x.1 = 22; - drop(x.0); //~ ERROR - drop(x.1); //~ ERROR + drop(x.0); + drop(x.1); } fn assign_both_fields_the_use_var() { let mut x: (u32, u32); - x.0 = 1; + x.0 = 1; //~ ERROR x.1 = 22; - drop(x); //~ ERROR + drop(x); } fn main() { } diff --git a/src/test/ui/borrowck/assign_mutable_fields.stderr b/src/test/ui/borrowck/assign_mutable_fields.stderr index 904d2ed97de..35101df4e0a 100644 --- a/src/test/ui/borrowck/assign_mutable_fields.stderr +++ b/src/test/ui/borrowck/assign_mutable_fields.stderr @@ -1,21 +1,15 @@ -error[E0381]: use of possibly uninitialized variable: `x.0` - --> $DIR/assign_mutable_fields.rs:11:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/assign_mutable_fields.rs:9:5 | -LL | drop(x.0); - | ^^^ use of possibly uninitialized `x.0` +LL | x.0 = 1; + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x.1` - --> $DIR/assign_mutable_fields.rs:12:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/assign_mutable_fields.rs:17:5 | -LL | drop(x.1); - | ^^^ use of possibly uninitialized `x.1` +LL | x.0 = 1; + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/assign_mutable_fields.rs:19:10 - | -LL | drop(x); - | ^ use of possibly uninitialized `x` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.nll.stderr b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.nll.stderr deleted file mode 100644 index 17969137a98..00000000000 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.nll.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:15:27 - | -LL | let _f = to_fn(|| x = 42); - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:15:24 - | -LL | let _f = to_fn(|| x = 42); - | ^^^^^^^^^ - -error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:18:31 - | -LL | let _g = to_fn(|| set(&mut y)); - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:18:24 - | -LL | let _g = to_fn(|| set(&mut y)); - | ^^^^^^^^^^^^^^ - -error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:21:55 - | -LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:21:52 - | -LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); - | ^^^^^^^^^ - -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:27:32 - | -LL | let _f = to_fn(move || x = 42); - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:27:24 - | -LL | let _f = to_fn(move || x = 42); - | ^^^^^^^^^^^^^^ - -error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:30:36 - | -LL | let _g = to_fn(move || set(&mut y)); - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:30:24 - | -LL | let _g = to_fn(move || set(&mut y)); - | ^^^^^^^^^^^^^^^^^^^ - -error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:33:65 - | -LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/borrow-immutable-upvar-mutation.rs:33:57 - | -LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); - | ^^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr index f979f385c94..17969137a98 100644 --- a/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr +++ b/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr @@ -1,72 +1,70 @@ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:15:27 | LL | let _f = to_fn(|| x = 42); - | ^^^^^^ + | ^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:15:24 | LL | let _f = to_fn(|| x = 42); | ^^^^^^^^^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/borrow-immutable-upvar-mutation.rs:18:36 +error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:18:31 | LL | let _g = to_fn(|| set(&mut y)); - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:18:24 | LL | let _g = to_fn(|| set(&mut y)); | ^^^^^^^^^^^^^^ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:21:55 | LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); - | ^^^^^^ + | ^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:21:52 | LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); | ^^^^^^^^^ -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:27:32 | LL | let _f = to_fn(move || x = 42); - | ^^^^^^ + | ^^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:27:24 | LL | let _f = to_fn(move || x = 42); | ^^^^^^^^^^^^^^ -error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable - --> $DIR/borrow-immutable-upvar-mutation.rs:30:41 +error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/borrow-immutable-upvar-mutation.rs:30:36 | LL | let _g = to_fn(move || set(&mut y)); - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:30:24 | LL | let _g = to_fn(move || set(&mut y)); | ^^^^^^^^^^^^^^^^^^^ -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure --> $DIR/borrow-immutable-upvar-mutation.rs:33:65 | LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); - | ^^^^^^ + | ^^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/borrow-immutable-upvar-mutation.rs:33:57 | LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); @@ -74,5 +72,4 @@ LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }) error: aborting due to 6 previous errors -Some errors have detailed explanations: E0387, E0596. -For more information about an error, try `rustc --explain E0387`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr b/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr deleted file mode 100644 index 503ea49d74e..00000000000 --- a/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr +++ /dev/null @@ -1,65 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:12:13 - | -LL | let r = &x.0; - | ---- borrow of `x.0` occurs here -LL | let y = x; - | ^ move out of `x` occurs here -LL | -LL | r.use_ref(); - | - borrow later used here - -error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:18:13 - | -LL | let a = &x.0; - | ---- immutable borrow occurs here -LL | let b = &mut x.0; - | ^^^^^^^^ mutable borrow occurs here -LL | a.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:23:13 - | -LL | let a = &mut x.0; - | -------- first mutable borrow occurs here -LL | let b = &mut x.0; - | ^^^^^^^^ second mutable borrow occurs here -LL | a.use_ref(); - | - first borrow later used here - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:28:13 - | -LL | let r = &x.0; - | ---- borrow of `x.0` occurs here -LL | let y = x; - | ^ move out of `x` occurs here -LL | r.use_ref(); - | - borrow later used here - -error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:33:13 - | -LL | let a = &x.0; - | ---- immutable borrow occurs here -LL | let b = &mut x.0; - | ^^^^^^^^ mutable borrow occurs here -LL | a.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:38:13 - | -LL | let a = &mut x.0; - | -------- first mutable borrow occurs here -LL | let b = &mut x.0; - | ^^^^^^^^ second mutable borrow occurs here -LL | a.use_mut(); - | - first borrow later used here - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0499, E0502, E0505. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrow-tuple-fields.stderr b/src/test/ui/borrowck/borrow-tuple-fields.stderr index 83017564c24..503ea49d74e 100644 --- a/src/test/ui/borrowck/borrow-tuple-fields.stderr +++ b/src/test/ui/borrowck/borrow-tuple-fields.stderr @@ -1,62 +1,63 @@ error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:12:9 + --> $DIR/borrow-tuple-fields.rs:12:13 | LL | let r = &x.0; - | --- borrow of `x.0` occurs here + | ---- borrow of `x.0` occurs here LL | let y = x; - | ^ move out of `x` occurs here + | ^ move out of `x` occurs here +LL | +LL | r.use_ref(); + | - borrow later used here error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:18:18 + --> $DIR/borrow-tuple-fields.rs:18:13 | LL | let a = &x.0; - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let b = &mut x.0; - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^^ mutable borrow occurs here +LL | a.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:23:18 + --> $DIR/borrow-tuple-fields.rs:23:13 | LL | let a = &mut x.0; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let b = &mut x.0; - | ^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^ second mutable borrow occurs here +LL | a.use_ref(); + | - first borrow later used here error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrow-tuple-fields.rs:28:9 + --> $DIR/borrow-tuple-fields.rs:28:13 | LL | let r = &x.0; - | --- borrow of `x.0` occurs here + | ---- borrow of `x.0` occurs here LL | let y = x; - | ^ move out of `x` occurs here + | ^ move out of `x` occurs here +LL | r.use_ref(); + | - borrow later used here error[E0502]: cannot borrow `x.0` as mutable because it is also borrowed as immutable - --> $DIR/borrow-tuple-fields.rs:33:18 + --> $DIR/borrow-tuple-fields.rs:33:13 | LL | let a = &x.0; - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let b = &mut x.0; - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^^ mutable borrow occurs here +LL | a.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time - --> $DIR/borrow-tuple-fields.rs:38:18 + --> $DIR/borrow-tuple-fields.rs:38:13 | LL | let a = &mut x.0; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let b = &mut x.0; - | ^^^ second mutable borrow occurs here + | ^^^^^^^^ second mutable borrow occurs here LL | a.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error: aborting due to 6 previous errors diff --git a/src/test/ui/borrowck/borrowck-access-permissions.ast.nll.stderr b/src/test/ui/borrowck/borrowck-access-permissions.ast.nll.stderr deleted file mode 100644 index 12f9ad8276f..00000000000 --- a/src/test/ui/borrowck/borrowck-access-permissions.ast.nll.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:12:19 - | -LL | let x = 1; - | - help: consider changing this to be mutable: `mut x` -... -LL | let _y1 = &mut x; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable static item `static_x` as mutable - --> $DIR/borrowck-access-permissions.rs:18:19 - | -LL | let _y1 = &mut static_x; - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:27:19 - | -LL | let box_x = Box::new(1); - | ----- help: consider changing this to be mutable: `mut box_x` -... -LL | let _y1 = &mut *box_x; - | ^^^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:36:19 - | -LL | let ref_x = &x; - | -- help: consider changing this to be a mutable reference: `&mut x` -... -LL | let _y1 = &mut *ref_x; - | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer - --> $DIR/borrowck-access-permissions.rs:46:23 - | -LL | let ptr_x : *const _ = &x; - | -- help: consider changing this to be a mutable pointer: `&mut x` -... -LL | let _y1 = &mut *ptr_x; - | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:56:18 - | -LL | let foo_ref = &foo; - | ---- help: consider changing this to be a mutable reference: `&mut foo` -LL | let _y = &mut *foo_ref.f; - | ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-access-permissions.ast.stderr b/src/test/ui/borrowck/borrowck-access-permissions.ast.stderr deleted file mode 100644 index 10f8d5f857e..00000000000 --- a/src/test/ui/borrowck/borrowck-access-permissions.ast.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/borrowck-access-permissions.rs:12:24 - | -LL | let x = 1; - | - help: make this binding mutable: `mut x` -... -LL | let _y1 = &mut x; - | ^ cannot borrow mutably - -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/borrowck-access-permissions.rs:18:24 - | -LL | let _y1 = &mut static_x; - | ^^^^^^^^ - -error[E0596]: cannot borrow immutable `Box` content `*box_x` as mutable - --> $DIR/borrowck-access-permissions.rs:27:24 - | -LL | let box_x = Box::new(1); - | ----- help: make this binding mutable: `mut box_x` -... -LL | let _y1 = &mut *box_x; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable borrowed content `*ref_x` as mutable - --> $DIR/borrowck-access-permissions.rs:36:24 - | -LL | let _y1 = &mut *ref_x; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable dereference of raw pointer `*ptr_x` as mutable - --> $DIR/borrowck-access-permissions.rs:46:28 - | -LL | let _y1 = &mut *ptr_x; - | ^^^^^^ cannot borrow as mutable - -error[E0389]: cannot borrow data mutably in a `&` reference - --> $DIR/borrowck-access-permissions.rs:56:23 - | -LL | let _y = &mut *foo_ref.f; - | ^^^^^^^^^^ assignment into an immutable reference - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0389, E0596. -For more information about an error, try `rustc --explain E0389`. diff --git a/src/test/ui/borrowck/borrowck-access-permissions.rs b/src/test/ui/borrowck/borrowck-access-permissions.rs index 993742f427e..469ad508b0e 100644 --- a/src/test/ui/borrowck/borrowck-access-permissions.rs +++ b/src/test/ui/borrowck/borrowck-access-permissions.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static static_x : i32 = 1; static mut static_x_mut : i32 = 1; @@ -9,14 +6,12 @@ fn main() { let mut x_mut = 1; { // borrow of local - let _y1 = &mut x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut x; //~ ERROR [E0596] let _y2 = &mut x_mut; // No error } { // borrow of static - let _y1 = &mut static_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut static_x; //~ ERROR [E0596] unsafe { let _y2 = &mut static_x_mut; } // No error } @@ -24,8 +19,7 @@ fn main() { let box_x = Box::new(1); let mut box_x_mut = Box::new(1); - let _y1 = &mut *box_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut *box_x; //~ ERROR [E0596] let _y2 = &mut *box_x_mut; // No error } @@ -33,8 +27,7 @@ fn main() { let ref_x = &x; let ref_x_mut = &mut x_mut; - let _y1 = &mut *ref_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut *ref_x; //~ ERROR [E0596] let _y2 = &mut *ref_x_mut; // No error } @@ -43,8 +36,7 @@ fn main() { let ptr_mut_x : *mut _ = &mut x_mut; unsafe { - let _y1 = &mut *ptr_x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let _y1 = &mut *ptr_x; //~ ERROR [E0596] let _y2 = &mut *ptr_mut_x; // No error } } @@ -53,8 +45,6 @@ fn main() { struct Foo<'a> { f: &'a mut i32, g: &'a i32 }; let mut foo = Foo { f: &mut x_mut, g: &x }; let foo_ref = &foo; - let _y = &mut *foo_ref.f; //[ast]~ ERROR [E0389] - //[mir]~^ ERROR [E0596] - // FIXME: Wrong error in MIR + let _y = &mut *foo_ref.f; //~ ERROR [E0596] } } diff --git a/src/test/ui/borrowck/borrowck-access-permissions.mir.stderr b/src/test/ui/borrowck/borrowck-access-permissions.stderr index 12f9ad8276f..e3a35c38a7c 100644 --- a/src/test/ui/borrowck/borrowck-access-permissions.mir.stderr +++ b/src/test/ui/borrowck/borrowck-access-permissions.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:12:19 + --> $DIR/borrowck-access-permissions.rs:9:19 | LL | let x = 1; | - help: consider changing this to be mutable: `mut x` @@ -8,13 +8,13 @@ LL | let _y1 = &mut x; | ^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow immutable static item `static_x` as mutable - --> $DIR/borrowck-access-permissions.rs:18:19 + --> $DIR/borrowck-access-permissions.rs:14:19 | LL | let _y1 = &mut static_x; | ^^^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable - --> $DIR/borrowck-access-permissions.rs:27:19 + --> $DIR/borrowck-access-permissions.rs:22:19 | LL | let box_x = Box::new(1); | ----- help: consider changing this to be mutable: `mut box_x` @@ -23,7 +23,7 @@ LL | let _y1 = &mut *box_x; | ^^^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:36:19 + --> $DIR/borrowck-access-permissions.rs:30:19 | LL | let ref_x = &x; | -- help: consider changing this to be a mutable reference: `&mut x` @@ -32,7 +32,7 @@ LL | let _y1 = &mut *ref_x; | ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer - --> $DIR/borrowck-access-permissions.rs:46:23 + --> $DIR/borrowck-access-permissions.rs:39:23 | LL | let ptr_x : *const _ = &x; | -- help: consider changing this to be a mutable pointer: `&mut x` @@ -41,7 +41,7 @@ LL | let _y1 = &mut *ptr_x; | ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-access-permissions.rs:56:18 + --> $DIR/borrowck-access-permissions.rs:48:18 | LL | let foo_ref = &foo; | ---- help: consider changing this to be a mutable reference: `&mut foo` diff --git a/src/test/ui/borrowck/borrowck-and-init.nll.stderr b/src/test/ui/borrowck/borrowck-and-init.nll.stderr deleted file mode 100644 index 2db07519481..00000000000 --- a/src/test/ui/borrowck/borrowck-and-init.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `i` - --> $DIR/borrowck-and-init.rs:5:20 - | -LL | println!("{}", i); - | ^ use of possibly uninitialized `i` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-and-init.rs b/src/test/ui/borrowck/borrowck-and-init.rs index ff076c55cad..4427e251861 100644 --- a/src/test/ui/borrowck/borrowck-and-init.rs +++ b/src/test/ui/borrowck/borrowck-and-init.rs @@ -2,5 +2,5 @@ fn main() { let i: isize; println!("{}", false && { i = 5; true }); - println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i` } diff --git a/src/test/ui/borrowck/borrowck-and-init.stderr b/src/test/ui/borrowck/borrowck-and-init.stderr index 13696ac8347..2db07519481 100644 --- a/src/test/ui/borrowck/borrowck-and-init.stderr +++ b/src/test/ui/borrowck/borrowck-and-init.stderr @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `i` +error[E0381]: borrow of possibly uninitialized variable: `i` --> $DIR/borrowck-and-init.rs:5:20 | LL | println!("{}", i); diff --git a/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr deleted file mode 100644 index 7a959fb6ec6..00000000000 --- a/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-struct.rs:29:11 - | -LL | Y(ref mut a, _) => a - | --------- first mutable borrow occurs here -... -LL | Y(ref mut b, _) => b - | ^^^^^^^^^ second mutable borrow occurs here -... -LL | *a += 1; - | ------- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr b/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr index efe94dee2e7..7a959fb6ec6 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-struct.stderr @@ -7,8 +7,8 @@ LL | Y(ref mut a, _) => a LL | Y(ref mut b, _) => b | ^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *a += 1; + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr deleted file mode 100644 index 88a8867f5ee..00000000000 --- a/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-tuple.rs:27:10 - | -LL | (ref mut a, _) => a - | --------- first mutable borrow occurs here -... -LL | (ref mut b, _) => b - | ^^^^^^^^^ second mutable borrow occurs here -... -LL | *a += 1; - | ------- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr b/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr index 40f96cb712c..88a8867f5ee 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-tuple.stderr @@ -7,8 +7,8 @@ LL | (ref mut a, _) => a LL | (ref mut b, _) => b | ^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *a += 1; + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr b/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr deleted file mode 100644 index 649fe3e1352..00000000000 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -warning[E0503]: cannot use `y` because it was mutably borrowed - --> $DIR/borrowck-anon-fields-variant.rs:17:7 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here -... -LL | Foo::Y(_, ref mut b) => b, - | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` -... -LL | *a += 1; - | ------- borrow later used here - | - = warning: this error has been downgraded to a warning for backwards compatibility with previous releases - = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future - -error[E0503]: cannot use `y` because it was mutably borrowed - --> $DIR/borrowck-anon-fields-variant.rs:34:7 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- borrow of `y.0` occurs here -... -LL | Foo::Y(ref mut b, _) => b, - | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` -... -LL | *a += 1; - | ------- borrow later used here - -error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-variant.rs:34:14 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- first mutable borrow occurs here -... -LL | Foo::Y(ref mut b, _) => b, - | ^^^^^^^^^ second mutable borrow occurs here -... -LL | *a += 1; - | ------- first borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0499, E0503. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.rs b/src/test/ui/borrowck/borrowck-anon-fields-variant.rs index c27435608c4..695809f58c5 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.rs +++ b/src/test/ui/borrowck/borrowck-anon-fields-variant.rs @@ -1,6 +1,3 @@ -// Tests that we are able to distinguish when loans borrow different -// anonymous fields of an enum variant vs the same anonymous field. - enum Foo { X, Y(usize, usize) } @@ -13,8 +10,14 @@ fn distinct_variant() { Foo::X => panic!() }; + // While `a` and `b` are disjoint, borrowck doesn't know that `a` is not + // also used for the discriminant of `Foo`, which it would be if `a` was a + // reference. let b = match y { Foo::Y(_, ref mut b) => b, + //~^ WARNING cannot use `y` + //~| WARNING this error has been downgraded to a warning + //~| WARNING this warning will become a hard error in the future Foo::X => panic!() }; @@ -31,7 +34,8 @@ fn same_variant() { }; let b = match y { - Foo::Y(ref mut b, _) => b, //~ ERROR cannot borrow + Foo::Y(ref mut b, _) => b, //~ ERROR cannot use `y` + //~| ERROR cannot borrow `y.0` as mutable Foo::X => panic!() }; diff --git a/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr b/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr index 2835cab9092..5e86dcb1232 100644 --- a/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr +++ b/src/test/ui/borrowck/borrowck-anon-fields-variant.stderr @@ -1,5 +1,32 @@ +warning[E0503]: cannot use `y` because it was mutably borrowed + --> $DIR/borrowck-anon-fields-variant.rs:17:7 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- borrow of `y.0` occurs here +... +LL | Foo::Y(_, ref mut b) => b, + | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` +... +LL | *a += 1; + | ------- borrow later used here + | + = warning: this error has been downgraded to a warning for backwards compatibility with previous releases + = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future + +error[E0503]: cannot use `y` because it was mutably borrowed + --> $DIR/borrowck-anon-fields-variant.rs:37:7 + | +LL | Foo::Y(ref mut a, _) => a, + | --------- borrow of `y.0` occurs here +... +LL | Foo::Y(ref mut b, _) => b, + | ^^^^^^^^^^^^^^^^^^^^ use of borrowed `y.0` +... +LL | *a += 1; + | ------- borrow later used here + error[E0499]: cannot borrow `y.0` as mutable more than once at a time - --> $DIR/borrowck-anon-fields-variant.rs:34:14 + --> $DIR/borrowck-anon-fields-variant.rs:37:14 | LL | Foo::Y(ref mut a, _) => a, | --------- first mutable borrow occurs here @@ -7,9 +34,10 @@ LL | Foo::Y(ref mut a, _) => a, LL | Foo::Y(ref mut b, _) => b, | ^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *a += 1; + | ------- first borrow later used here -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0499`. +Some errors have detailed explanations: E0499, E0503. +For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-argument.nll.stderr b/src/test/ui/borrowck/borrowck-argument.nll.stderr deleted file mode 100644 index cf158331409..00000000000 --- a/src/test/ui/borrowck/borrowck-argument.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:10:5 - | -LL | fn func(arg: S) { - | --- help: consider changing this to be mutable: `mut arg` -LL | arg.mutate(); - | ^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:15:9 - | -LL | fn method(&self, arg: S) { - | --- help: consider changing this to be mutable: `mut arg` -LL | arg.mutate(); - | ^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:21:9 - | -LL | fn default(&self, arg: S) { - | --- help: consider changing this to be mutable: `mut arg` -LL | arg.mutate(); - | ^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/borrowck-argument.rs:32:17 - | -LL | (|arg: S| { arg.mutate() })(s); - | --- ^^^ cannot borrow as mutable - | | - | help: consider changing this to be mutable: `mut arg` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-argument.rs b/src/test/ui/borrowck/borrowck-argument.rs index e1f1adec838..5d776d4fca4 100644 --- a/src/test/ui/borrowck/borrowck-argument.rs +++ b/src/test/ui/borrowck/borrowck-argument.rs @@ -7,18 +7,18 @@ impl S { } fn func(arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument + arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } impl S { fn method(&self, arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument + arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } } trait T { fn default(&self, arg: S) { - arg.mutate(); //~ ERROR: cannot borrow immutable argument + arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } } @@ -29,5 +29,6 @@ fn main() { func(s); s.method(s); s.default(s); - (|arg: S| { arg.mutate() })(s); //~ ERROR: cannot borrow immutable argument + (|arg: S| { arg.mutate() })(s); + //~^ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/borrowck/borrowck-argument.stderr b/src/test/ui/borrowck/borrowck-argument.stderr index 6c9c411cbcf..cf158331409 100644 --- a/src/test/ui/borrowck/borrowck-argument.stderr +++ b/src/test/ui/borrowck/borrowck-argument.stderr @@ -1,34 +1,34 @@ -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:10:5 | LL | fn func(arg: S) { - | --- help: make this binding mutable: `mut arg` + | --- help: consider changing this to be mutable: `mut arg` LL | arg.mutate(); - | ^^^ cannot borrow mutably + | ^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:15:9 | LL | fn method(&self, arg: S) { - | --- help: make this binding mutable: `mut arg` + | --- help: consider changing this to be mutable: `mut arg` LL | arg.mutate(); - | ^^^ cannot borrow mutably + | ^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:21:9 | LL | fn default(&self, arg: S) { - | --- help: make this binding mutable: `mut arg` + | --- help: consider changing this to be mutable: `mut arg` LL | arg.mutate(); - | ^^^ cannot borrow mutably + | ^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/borrowck-argument.rs:32:17 | LL | (|arg: S| { arg.mutate() })(s); - | --- ^^^ cannot borrow mutably + | --- ^^^ cannot borrow as mutable | | - | help: make this binding mutable: `mut arg` + | help: consider changing this to be mutable: `mut arg` error: aborting due to 4 previous errors diff --git a/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr b/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr deleted file mode 100644 index 3fb1c9b22cf..00000000000 --- a/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr +++ /dev/null @@ -1,81 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:27:17 - | -LL | let x = &mut 0isize; - | - move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait -LL | unsafe { -LL | asm!("nop" : : "r"(x)); - | - value moved here -LL | } -LL | let z = x; - | ^ value used here after move - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-asm.rs:35:32 - | -LL | let y = &mut x; - | ------ borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : : "r"(x)); - | ^ use of borrowed `x` -... -LL | let z = y; - | - borrow later used here - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:44:31 - | -LL | let x = 3; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | unsafe { -LL | asm!("nop" : "=r"(x)); - | ^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:60:31 - | -LL | let x = 3; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | unsafe { -LL | asm!("nop" : "+r"(x)); - | ^ cannot assign twice to immutable variable - -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:68:32 - | -LL | asm!("nop" : "=*r"(x)); - | ^ use of possibly uninitialized `x` - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:77:31 - | -LL | let y = &*x; - | --- borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : "+r"(x)); - | ^ assignment to borrowed `x` occurs here -... -LL | let z = y; - | - borrow later used here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:86:40 - | -LL | let x = &mut 2; - | - move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait -LL | unsafe { -LL | asm!("nop" : : "r"(x), "r"(x) ); - | - ^ value used here after move - | | - | value moved here - -error: aborting due to 7 previous errors - -Some errors have detailed explanations: E0381, E0382, E0384, E0503, E0506. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-asm.ast.stderr b/src/test/ui/borrowck/borrowck-asm.ast.stderr deleted file mode 100644 index 6d568061f38..00000000000 --- a/src/test/ui/borrowck/borrowck-asm.ast.stderr +++ /dev/null @@ -1,76 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:27:13 - | -LL | asm!("nop" : : "r"(x)); - | - value moved here -LL | } -LL | let z = x; - | ^ value used here after move - | - = note: move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-asm.rs:35:32 - | -LL | let y = &mut x; - | - borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : : "r"(x)); - | ^ use of borrowed `x` - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:44:31 - | -LL | let x = 3; - | - first assignment to `x` -LL | unsafe { -LL | asm!("nop" : "=r"(x)); - | ^ cannot assign twice to immutable variable - -error[E0506]: cannot assign to `a` because it is borrowed - --> $DIR/borrowck-asm.rs:50:31 - | -LL | let b = &*a; - | -- borrow of `a` occurs here -LL | unsafe { -LL | asm!("nop" : "=r"(a)); - | ^ assignment to borrowed `a` occurs here - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:60:31 - | -LL | let x = 3; - | - first assignment to `x` -LL | unsafe { -LL | asm!("nop" : "+r"(x)); - | ^ cannot assign twice to immutable variable - -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:68:32 - | -LL | asm!("nop" : "=*r"(x)); - | ^ use of possibly uninitialized `x` - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:77:31 - | -LL | let y = &*x; - | -- borrow of `x` occurs here -LL | unsafe { -LL | asm!("nop" : "+r"(x)); - | ^ assignment to borrowed `x` occurs here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:86:40 - | -LL | asm!("nop" : : "r"(x), "r"(x) ); - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0381, E0382, E0384, E0503, E0506. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-asm.rs b/src/test/ui/borrowck/borrowck-asm.rs index 560c87c8d72..9c9cc04baaf 100644 --- a/src/test/ui/borrowck/borrowck-asm.rs +++ b/src/test/ui/borrowck/borrowck-asm.rs @@ -6,9 +6,6 @@ // ignore-sparc // ignore-sparc64 -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] #[cfg(any(target_arch = "x86", @@ -24,16 +21,14 @@ mod test_cases { unsafe { asm!("nop" : : "r"(x)); } - let z = x; //[ast]~ ERROR use of moved value: `x` - //[mir]~^ ERROR use of moved value: `x` + let z = x; //~ ERROR use of moved value: `x` } fn in_is_read() { let mut x = 3; let y = &mut x; unsafe { - asm!("nop" : : "r"(x)); //[ast]~ ERROR cannot use - //[mir]~^ ERROR cannot use + asm!("nop" : : "r"(x)); //~ ERROR cannot use } let z = y; } @@ -41,14 +36,12 @@ mod test_cases { fn out_is_assign() { let x = 3; unsafe { - asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - //[mir]~^ ERROR cannot assign twice + asm!("nop" : "=r"(x)); //~ ERROR cannot assign twice } let mut a = &mut 3; let b = &*a; unsafe { - asm!("nop" : "=r"(a)); //[ast]~ ERROR cannot assign to `a` because it is borrowed - // No MIR error, this is a shallow write. + asm!("nop" : "=r"(a)); // OK, Shallow write to `a` } let c = b; let d = *a; @@ -57,16 +50,14 @@ mod test_cases { fn rw_is_assign() { let x = 3; unsafe { - asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - //[mir]~^ ERROR cannot assign twice + asm!("nop" : "+r"(x)); //~ ERROR cannot assign twice } } fn indirect_is_not_init() { let x: i32; unsafe { - asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable - //[mir]~^ ERROR use of possibly uninitialized variable + asm!("nop" : "=*r"(x)); //~ ERROR use of possibly uninitialized variable } } @@ -74,8 +65,7 @@ mod test_cases { let mut x = &mut 3; let y = &*x; unsafe { - asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + asm!("nop" : "+r"(x)); //~ ERROR cannot assign to `x` because it is borrowed } let z = y; } @@ -83,8 +73,7 @@ mod test_cases { fn two_moves() { let x = &mut 2; unsafe { - asm!("nop" : : "r"(x), "r"(x) ); //[ast]~ ERROR use of moved value - //[mir]~^ ERROR use of moved value + asm!("nop" : : "r"(x), "r"(x) ); //~ ERROR use of moved value } } } diff --git a/src/test/ui/borrowck/borrowck-asm.mir.stderr b/src/test/ui/borrowck/borrowck-asm.stderr index 3fb1c9b22cf..c771373022a 100644 --- a/src/test/ui/borrowck/borrowck-asm.mir.stderr +++ b/src/test/ui/borrowck/borrowck-asm.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:27:17 + --> $DIR/borrowck-asm.rs:24:17 | LL | let x = &mut 0isize; | - move occurs because `x` has type `&mut isize`, which does not implement the `Copy` trait @@ -11,19 +11,19 @@ LL | let z = x; | ^ value used here after move error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-asm.rs:35:32 + --> $DIR/borrowck-asm.rs:31:32 | LL | let y = &mut x; | ------ borrow of `x` occurs here LL | unsafe { LL | asm!("nop" : : "r"(x)); | ^ use of borrowed `x` -... +LL | } LL | let z = y; | - borrow later used here error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:44:31 + --> $DIR/borrowck-asm.rs:39:31 | LL | let x = 3; | - @@ -35,7 +35,7 @@ LL | asm!("nop" : "=r"(x)); | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:60:31 + --> $DIR/borrowck-asm.rs:53:31 | LL | let x = 3; | - @@ -47,25 +47,25 @@ LL | asm!("nop" : "+r"(x)); | ^ cannot assign twice to immutable variable error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:68:32 + --> $DIR/borrowck-asm.rs:60:32 | LL | asm!("nop" : "=*r"(x)); | ^ use of possibly uninitialized `x` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:77:31 + --> $DIR/borrowck-asm.rs:68:31 | LL | let y = &*x; | --- borrow of `x` occurs here LL | unsafe { LL | asm!("nop" : "+r"(x)); | ^ assignment to borrowed `x` occurs here -... +LL | } LL | let z = y; | - borrow later used here error[E0382]: use of moved value: `x` - --> $DIR/borrowck-asm.rs:86:40 + --> $DIR/borrowck-asm.rs:76:40 | LL | let x = &mut 2; | - move occurs because `x` has type `&mut i32`, which does not implement the `Copy` trait diff --git a/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr b/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr deleted file mode 100644 index 93f1d8c5258..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-assign-comp-idx.rs:12:5 - | -LL | let q: &isize = &p[0]; - | - immutable borrow occurs here -LL | -LL | p[0] = 5; - | ^ mutable borrow occurs here -LL | -LL | println!("{}", *q); - | -- immutable borrow later used here - -error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-assign-comp-idx.rs:27:9 - | -LL | borrow( - | ------ immutable borrow later used by call -LL | &p, - | -- immutable borrow occurs here -LL | || p[0] = 5); - | ^^ - second borrow occurs due to use of `p` in closure - | | - | mutable borrow occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr b/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr index 0d092e6812d..93f1d8c5258 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr +++ b/src/test/ui/borrowck/borrowck-assign-comp-idx.stderr @@ -6,19 +6,20 @@ LL | let q: &isize = &p[0]; LL | LL | p[0] = 5; | ^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here +LL | +LL | println!("{}", *q); + | -- immutable borrow later used here error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable --> $DIR/borrowck-assign-comp-idx.rs:27:9 | +LL | borrow( + | ------ immutable borrow later used by call LL | &p, - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | || p[0] = 5); - | ^^ - - immutable borrow ends here - | | | - | | borrow occurs due to use of `p` in closure + | ^^ - second borrow occurs due to use of `p` in closure + | | | mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-assign-comp.ast.stderr b/src/test/ui/borrowck/borrowck-assign-comp.ast.stderr deleted file mode 100644 index 4adb19c4c3f..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-comp.ast.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0506]: cannot assign to `p.x` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:13:5 - | -LL | let q = &p; - | - borrow of `p.x` occurs here -... -LL | p.x = 5; - | ^^^^^^^ assignment to borrowed `p.x` occurs here - -error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:24:5 - | -LL | let q = &p.y; - | --- borrow of `p` occurs here -LL | p = Point {x: 5, y: 7}; - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here - -error[E0506]: cannot assign to `p.y` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:36:5 - | -LL | let q = &p.y; - | --- borrow of `p.y` occurs here -LL | p.y = 5; - | ^^^^^^^ assignment to borrowed `p.y` occurs here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-assign-comp.mir.stderr b/src/test/ui/borrowck/borrowck-assign-comp.mir.stderr deleted file mode 100644 index 53af41cfe31..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-comp.mir.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0506]: cannot assign to `p.x` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:13:5 - | -LL | let q = &p; - | -- borrow of `p.x` occurs here -... -LL | p.x = 5; - | ^^^^^^^ assignment to borrowed `p.x` occurs here -LL | -LL | q.x; - | --- borrow later used here - -error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:24:5 - | -LL | let q = &p.y; - | ---- borrow of `p` occurs here -LL | p = Point {x: 5, y: 7}; - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here -... -LL | *q; // stretch loan - | -- borrow later used here - -error[E0506]: cannot assign to `p.y` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:36:5 - | -LL | let q = &p.y; - | ---- borrow of `p.y` occurs here -LL | p.y = 5; - | ^^^^^^^ assignment to borrowed `p.y` occurs here -LL | -LL | *q; - | -- borrow later used here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-assign-comp.rs b/src/test/ui/borrowck/borrowck-assign-comp.rs index 0cacc3882d8..98bb2d85ad7 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp.rs +++ b/src/test/ui/borrowck/borrowck-assign-comp.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct Point { x: isize, y: isize } fn a() { @@ -10,8 +7,7 @@ fn a() { // This assignment is illegal because the field x is not // inherently mutable; since `p` was made immutable, `p.x` is now // immutable. Otherwise the type of &_q.x (&isize) would be wrong. - p.x = 5; //[ast]~ ERROR cannot assign to `p.x` - //[mir]~^ ERROR cannot assign to `p.x` because it is borrowed + p.x = 5; //~ ERROR cannot assign to `p.x` because it is borrowed q.x; } @@ -21,8 +17,7 @@ fn c() { let mut p = Point {x: 3, y: 4}; let q = &p.y; - p = Point {x: 5, y: 7};//[ast]~ ERROR cannot assign to `p` - //[mir]~^ ERROR cannot assign to `p` because it is borrowed + p = Point {x: 5, y: 7};//~ ERROR cannot assign to `p` because it is borrowed p.x; // silence warning *q; // stretch loan } @@ -33,8 +28,7 @@ fn d() { let mut p = Point {x: 3, y: 4}; let q = &p.y; - p.y = 5; //[ast]~ ERROR cannot assign to `p.y` - //[mir]~^ ERROR cannot assign to `p.y` because it is borrowed + p.y = 5; //~ ERROR cannot assign to `p.y` because it is borrowed *q; } diff --git a/src/test/ui/borrowck/borrowck-assign-comp.ast.nll.stderr b/src/test/ui/borrowck/borrowck-assign-comp.stderr index 53af41cfe31..2b7cef7b325 100644 --- a/src/test/ui/borrowck/borrowck-assign-comp.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-assign-comp.stderr @@ -1,34 +1,32 @@ error[E0506]: cannot assign to `p.x` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:13:5 + --> $DIR/borrowck-assign-comp.rs:10:5 | LL | let q = &p; | -- borrow of `p.x` occurs here ... LL | p.x = 5; | ^^^^^^^ assignment to borrowed `p.x` occurs here -LL | LL | q.x; | --- borrow later used here error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:24:5 + --> $DIR/borrowck-assign-comp.rs:20:5 | LL | let q = &p.y; | ---- borrow of `p` occurs here LL | p = Point {x: 5, y: 7}; | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `p` occurs here -... +LL | p.x; // silence warning LL | *q; // stretch loan | -- borrow later used here error[E0506]: cannot assign to `p.y` because it is borrowed - --> $DIR/borrowck-assign-comp.rs:36:5 + --> $DIR/borrowck-assign-comp.rs:31:5 | LL | let q = &p.y; | ---- borrow of `p.y` occurs here LL | p.y = 5; | ^^^^^^^ assignment to borrowed `p.y` occurs here -LL | LL | *q; | -- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr deleted file mode 100644 index 38fcfbfc2a0..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference - --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5 - | -LL | fn a(s: &S) { - | -- help: consider changing this to be a mutable reference: `&mut S<'_>` -LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference - --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 - | -LL | fn c(s: & &mut S) { - | -------- help: consider changing this to be a mutable reference: `&mut &mut S<'_>` -LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr index 5ec1ff2c058..38fcfbfc2a0 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr +++ b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.stderr @@ -1,19 +1,18 @@ -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:9:5 | LL | fn a(s: &S) { - | -- use `&mut S` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut S<'_>` LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment into an immutable reference + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `*s.pointer` which is behind a `&` reference --> $DIR/borrowck-assign-to-andmut-in-aliasable-loc.rs:17:5 | LL | fn c(s: & &mut S) { - | -------- use `&mut &mut S` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&mut &mut S<'_>` LL | *s.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment into an immutable reference + | ^^^^^^^^^^^^^^^ `s` is a `&` reference, so the data it refers to cannot be written error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0389`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr deleted file mode 100644 index d6bd32a2e16..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed - --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ use of borrowed `y` -LL | *z.pointer += 1; - | --------------- borrow later used here - -error[E0506]: cannot assign to `*y.pointer` because it is borrowed - --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 - | -LL | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here -LL | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here -LL | *z.pointer += 1; - | --------------- borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0503, E0506. -For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs index 98080d47c64..f7aee2b8a93 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs +++ b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.rs @@ -15,7 +15,9 @@ fn main() { { let mut y = S { pointer: &mut x }; let z = copy_borrowed_ptr(&mut y); - *y.pointer += 1; //~ ERROR cannot assign + *y.pointer += 1; + //~^ ERROR cannot use `*y.pointer` + //~| ERROR cannot assign to `*y.pointer` *z.pointer += 1; } } diff --git a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr index 10d6ac5464d..0b21d113f74 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr +++ b/src/test/ui/borrowck/borrowck-assign-to-andmut-in-borrowed-loc.stderr @@ -1,11 +1,26 @@ +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed + --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 + | +LL | let z = copy_borrowed_ptr(&mut y); + | ------ borrow of `y` occurs here +LL | *y.pointer += 1; + | ^^^^^^^^^^^^^^^ use of borrowed `y` +... +LL | *z.pointer += 1; + | --------------- borrow later used here + error[E0506]: cannot assign to `*y.pointer` because it is borrowed --> $DIR/borrowck-assign-to-andmut-in-borrowed-loc.rs:18:9 | LL | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here + | ------ borrow of `*y.pointer` occurs here LL | *y.pointer += 1; | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here +... +LL | *z.pointer += 1; + | --------------- borrow later used here -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0506`. +Some errors have detailed explanations: E0503, E0506. +For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.ast.stderr deleted file mode 100644 index 98ff53edc7e..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0594]: cannot assign to immutable static item - --> $DIR/borrowck-assign-to-constants.rs:8:5 - | -LL | foo = 6; - | ^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.mir.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.mir.stderr deleted file mode 100644 index 703a9222c5f..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.mir.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0594]: cannot assign to immutable static item `foo` - --> $DIR/borrowck-assign-to-constants.rs:8:5 - | -LL | foo = 6; - | ^^^^^^^ cannot assign - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.rs b/src/test/ui/borrowck/borrowck-assign-to-constants.rs index 768b2a5f743..5881dccf61a 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.rs +++ b/src/test/ui/borrowck/borrowck-assign-to-constants.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static foo: isize = 5; fn main() { // assigning to various global constants - foo = 6; //[ast]~ ERROR cannot assign to immutable static item - //[mir]~^ ERROR cannot assign to immutable static item `foo` + foo = 6; //~ ERROR cannot assign to immutable static item `foo` } diff --git a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.nll.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.stderr index 703a9222c5f..800003caa0f 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-assign-to-constants.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to immutable static item `foo` - --> $DIR/borrowck-assign-to-constants.rs:8:5 + --> $DIR/borrowck-assign-to-constants.rs:5:5 | LL | foo = 6; | ^^^^^^^ cannot assign diff --git a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr b/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr deleted file mode 100644 index 3ed76c13f6a..00000000000 --- a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:15:5 - | -LL | let x = Foo { x: 3 }; - | - help: consider changing this to be mutable: `mut x` -LL | x.printme(); - | ^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr b/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr index 759b778e35c..3ed76c13f6a 100644 --- a/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr +++ b/src/test/ui/borrowck/borrowck-auto-mut-ref-to-immut-var.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-auto-mut-ref-to-immut-var.rs:15:5 | LL | let x = Foo { x: 3 }; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.printme(); - | ^ cannot borrow mutably + | ^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr b/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr deleted file mode 100644 index c2dfb687e8e..00000000000 --- a/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-autoref-3261.rs:15:9 - | -LL | (&mut x).with( - | -------- ---- first borrow later used by call - | | - | first mutable borrow occurs here -LL | |opt| { - | ^^^^^ second mutable borrow occurs here -... -LL | x = X(Either::Left((0, 0))); - | - second borrow occurs due to use of `x` in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-autoref-3261.stderr b/src/test/ui/borrowck/borrowck-autoref-3261.stderr index 280704a2715..c2dfb687e8e 100644 --- a/src/test/ui/borrowck/borrowck-autoref-3261.stderr +++ b/src/test/ui/borrowck/borrowck-autoref-3261.stderr @@ -2,15 +2,14 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-autoref-3261.rs:15:9 | LL | (&mut x).with( - | - first mutable borrow occurs here + | -------- ---- first borrow later used by call + | | + | first mutable borrow occurs here LL | |opt| { | ^^^^^ second mutable borrow occurs here ... LL | x = X(Either::Left((0, 0))); - | - borrow occurs due to use of `x` in closure -... -LL | }) - | - first borrow ends here + | - second borrow occurs due to use of `x` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr deleted file mode 100644 index e273a778fda..00000000000 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:25:17 - | -LL | add( - | --- immutable borrow later used by call -LL | &*a, - | --- immutable borrow occurs here -LL | rewrite(&mut a)); - | ^^^^^^ mutable borrow occurs here - -error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:32:17 - | -LL | add( - | --- immutable borrow later used by call -LL | &*a, - | --- immutable borrow occurs here -LL | rewrite(&mut a)); - | ^^^^^^ mutable borrow occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr index 06ec2bdac71..e273a778fda 100644 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr +++ b/src/test/ui/borrowck/borrowck-bad-nested-calls-free.stderr @@ -1,22 +1,22 @@ -error[E0502]: cannot borrow `a` as mutable because `*a` is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:25:22 +error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:25:17 | +LL | add( + | --- immutable borrow later used by call LL | &*a, - | -- immutable borrow occurs here + | --- immutable borrow occurs here LL | rewrite(&mut a)); - | ^ - immutable borrow ends here - | | - | mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here -error[E0502]: cannot borrow `a` as mutable because `*a` is also borrowed as immutable - --> $DIR/borrowck-bad-nested-calls-free.rs:32:22 +error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-bad-nested-calls-free.rs:32:17 | +LL | add( + | --- immutable borrow later used by call LL | &*a, - | -- immutable borrow occurs here + | --- immutable borrow occurs here LL | rewrite(&mut a)); - | ^ - immutable borrow ends here - | | - | mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr deleted file mode 100644 index 371bcf2b69c..00000000000 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/borrowck-bad-nested-calls-move.rs:25:9 - | -LL | add( - | --- borrow later used by call -LL | &*a, - | --- borrow of `*a` occurs here -LL | a); - | ^ move out of `a` occurs here - -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/borrowck-bad-nested-calls-move.rs:32:9 - | -LL | add( - | --- borrow later used by call -LL | &*a, - | --- borrow of `*a` occurs here -LL | a); - | ^ move out of `a` occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr index 3b34a61364a..371bcf2b69c 100644 --- a/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr +++ b/src/test/ui/borrowck/borrowck-bad-nested-calls-move.stderr @@ -1,16 +1,20 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:25:9 | +LL | add( + | --- borrow later used by call LL | &*a, - | -- borrow of `*a` occurs here + | --- borrow of `*a` occurs here LL | a); | ^ move out of `a` occurs here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:32:9 | +LL | add( + | --- borrow later used by call LL | &*a, - | -- borrow of `*a` occurs here + | --- borrow of `*a` occurs here LL | a); | ^ move out of `a` occurs here diff --git a/src/test/ui/borrowck/borrowck-block-unint.nll.stderr b/src/test/ui/borrowck/borrowck-block-unint.nll.stderr deleted file mode 100644 index d2a49962baf..00000000000 --- a/src/test/ui/borrowck/borrowck-block-unint.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-block-unint.rs:4:11 - | -LL | force(|| { - | ^^ use of possibly uninitialized `x` -LL | println!("{}", x); - | - borrow occurs due to use in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-block-unint.rs b/src/test/ui/borrowck/borrowck-block-unint.rs index 3c6e9cb5578..1fed2d503bd 100644 --- a/src/test/ui/borrowck/borrowck-block-unint.rs +++ b/src/test/ui/borrowck/borrowck-block-unint.rs @@ -1,7 +1,7 @@ fn force<F>(f: F) where F: FnOnce() { f(); } fn main() { let x: isize; - force(|| { //~ ERROR capture of possibly uninitialized variable: `x` + force(|| { //~ ERROR borrow of possibly uninitialized variable: `x` println!("{}", x); }); } diff --git a/src/test/ui/borrowck/borrowck-block-unint.stderr b/src/test/ui/borrowck/borrowck-block-unint.stderr index ab55d7994d0..d2a49962baf 100644 --- a/src/test/ui/borrowck/borrowck-block-unint.stderr +++ b/src/test/ui/borrowck/borrowck-block-unint.stderr @@ -1,8 +1,10 @@ -error[E0381]: capture of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-block-unint.rs:4:11 | LL | force(|| { | ^^ use of possibly uninitialized `x` +LL | println!("{}", x); + | - borrow occurs due to use in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr deleted file mode 100644 index 134f5107daa..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:18:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:25:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | let _bar2 = &foo.bar1; - | ^^^^^^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:32:17 - | -LL | let bar1 = &foo.bar1; - | --------- immutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:62:21 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | match *foo { -LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} - | ^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:71:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; - | ^^^^^^^^^ immutable borrow occurs here -LL | let _foo2 = &*foo; -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:72:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; -LL | let _foo2 = &*foo; - | ^^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:79:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:86:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo2 = &mut *foo; - | ^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:93:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:100:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo2 = &mut *foo; - | ^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:121:16 - | -LL | let foo = make_foo(); - | --- help: consider changing this to be mutable: `mut foo` -LL | let bar1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error: aborting due to 11 previous errors - -Some errors have detailed explanations: E0499, E0502, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs index 1435837bf3b..353e4e9f75e 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs +++ b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.rs @@ -43,15 +43,17 @@ fn borrow_same_field_twice_imm_imm() { fn borrow_both_fields_mut() { let mut foo = make_foo(); let bar1 = &mut foo.bar1; - let _bar2 = &mut foo.bar2; //~ ERROR cannot borrow + let _bar2 = &mut foo.bar2; *bar1; } fn borrow_both_mut_pattern() { let mut foo = make_foo(); match *foo { - Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} - //~^ ERROR cannot borrow + Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => { + *_bar1; + *_bar2; + } } } @@ -112,8 +114,7 @@ fn borrow_imm_and_base_imm() { fn borrow_mut_and_imm() { let mut foo = make_foo(); let bar1 = &mut foo.bar1; - let _foo1 = &foo.bar2; //~ ERROR cannot borrow - *bar1; + let _foo1 = &foo.bar2; } fn borrow_mut_from_imm() { @@ -125,7 +126,7 @@ fn borrow_mut_from_imm() { fn borrow_long_path_both_mut() { let mut foo = make_foo(); let bar1 = &mut foo.bar1.int1; - let foo1 = &mut foo.bar2.int2; //~ ERROR cannot borrow + let foo1 = &mut foo.bar2.int2; *bar1; *foo1; } diff --git a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr index 95f6f03d4e5..e00d69f89d3 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.stderr @@ -1,168 +1,116 @@ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:18:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:18:17 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:25:18 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:25:17 | LL | let bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here + | ------------- mutable borrow occurs here LL | let _bar2 = &foo.bar1; - | ^^^^^^^^ immutable borrow occurs here + | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:32:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:32:17 | LL | let bar1 = &foo.bar1; - | -------- immutable borrow occurs here + | --------- immutable borrow occurs here LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here - -error[E0499]: cannot borrow `foo` (via `foo.bar2`) as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:46:22 - | -LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here (via `foo.bar1`) -LL | let _bar2 = &mut foo.bar2; - | ^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`) -LL | *bar1; -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `foo` (via `foo.bar2`) as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:53:42 - | -LL | Foo { bar1: ref mut _bar1, bar2: ref mut _bar2 } => {} - | ------------- ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2`) - | | - | first mutable borrow occurs here (via `foo.bar1`) -LL | -LL | } - | - first borrow ends here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:62:21 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:64:21 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | match *foo { LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} | ^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *bar1; + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:71:18 +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:73:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; - | ^^^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &*foo; +LL | *bar1; + | ----- mutable borrow later used here -error[E0502]: cannot borrow `*foo` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:72:18 +error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:74:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; LL | let _foo2 = &*foo; - | ^^^^ immutable borrow occurs here + | ^^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:79:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:81:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:86:22 + --> $DIR/borrowck-borrow-from-owned-ptr.rs:88:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo2 = &mut *foo; - | ^^^^ second mutable borrow occurs here + | ^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:93:22 +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:95:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0502]: cannot borrow `*foo` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:100:22 +error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:102:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo2 = &mut *foo; - | ^^^^ mutable borrow occurs here -LL | *bar1; -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `foo` (via `foo.bar2`) as immutable because `foo` is also borrowed as mutable (via `foo.bar1`) - --> $DIR/borrowck-borrow-from-owned-ptr.rs:115:18 - | -LL | let bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here (via `foo.bar1`) -LL | let _foo1 = &foo.bar2; - | ^^^^^^^^ immutable borrow of `foo.bar2` -- which overlaps with `foo.bar1` -- occurs here + | ^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- immutable borrow later used here -error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:121:21 +error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable + --> $DIR/borrowck-borrow-from-owned-ptr.rs:122:16 | LL | let foo = make_foo(); - | --- help: make this binding mutable: `mut foo` + | --- help: consider changing this to be mutable: `mut foo` LL | let bar1 = &mut foo.bar1; - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0499]: cannot borrow `foo` (via `foo.bar2.int2`) as mutable more than once at a time - --> $DIR/borrowck-borrow-from-owned-ptr.rs:128:21 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here (via `foo.bar1.int1`) -LL | let foo1 = &mut foo.bar2.int2; - | ^^^^^^^^^^^^^ second mutable borrow occurs here (via `foo.bar2.int2`) -... -LL | } - | - first borrow ends here + | ^^^^^^^^^^^^^ cannot borrow as mutable -error: aborting due to 15 previous errors +error: aborting due to 11 previous errors Some errors have detailed explanations: E0499, E0502, E0596. For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr deleted file mode 100644 index ce5ce56dea2..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:18:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:25:17 - | -LL | let bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | let _bar2 = &foo.bar1; - | ^^^^^^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:32:17 - | -LL | let bar1 = &foo.bar1; - | --------- immutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:61:21 - | -LL | let bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | match foo { -LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} // - | ^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:70:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; - | ^^^^^^^^^ immutable borrow occurs here -LL | let _foo2 = &foo; -LL | *bar1; - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:71:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; -LL | let _foo2 = &foo; - | ^^^^ immutable borrow occurs here -LL | *bar1; - | ----- mutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:78:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:85:17 - | -LL | let bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo2 = &mut foo; - | ^^^^^^^^ second mutable borrow occurs here -LL | *bar1; - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:92:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:99:17 - | -LL | let bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo2 = &mut foo; - | ^^^^^^^^ mutable borrow occurs here -LL | *bar1; - | ----- immutable borrow later used here - -error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:120:16 - | -LL | let foo = make_foo(); - | --- help: consider changing this to be mutable: `mut foo` -LL | let bar1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error: aborting due to 11 previous errors - -Some errors have detailed explanations: E0499, E0502, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr index 845aaa22be0..ce5ce56dea2 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.stderr @@ -1,122 +1,114 @@ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:18:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:18:17 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:25:18 + --> $DIR/borrowck-borrow-from-stack-variable.rs:25:17 | LL | let bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here + | ------------- mutable borrow occurs here LL | let _bar2 = &foo.bar1; - | ^^^^^^^^ immutable borrow occurs here + | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:32:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:32:17 | LL | let bar1 = &foo.bar1; - | -------- immutable borrow occurs here + | --------- immutable borrow occurs here LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:61:21 | LL | let bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | match foo { LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} // | ^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | *bar1; + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:70:18 +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:70:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; - | ^^^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &foo; +LL | *bar1; + | ----- mutable borrow later used here -error[E0502]: cannot borrow `foo` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:71:18 +error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:71:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; LL | let _foo2 = &foo; - | ^^^ immutable borrow occurs here + | ^^^^ immutable borrow occurs here LL | *bar1; -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:78:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:78:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/borrowck-borrow-from-stack-variable.rs:85:22 + --> $DIR/borrowck-borrow-from-stack-variable.rs:85:17 | LL | let bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo2 = &mut foo; - | ^^^ second mutable borrow occurs here + | ^^^^^^^^ second mutable borrow occurs here LL | *bar1; -LL | } - | - first borrow ends here + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:92:22 +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:92:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0502]: cannot borrow `foo` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:99:22 +error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:99:17 | LL | let bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo2 = &mut foo; - | ^^^ mutable borrow occurs here + | ^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:120:21 +error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable + --> $DIR/borrowck-borrow-from-stack-variable.rs:120:16 | LL | let foo = make_foo(); - | --- help: make this binding mutable: `mut foo` + | --- help: consider changing this to be mutable: `mut foo` LL | let bar1 = &mut foo.bar1; - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^ cannot borrow as mutable error: aborting due to 11 previous errors diff --git a/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr deleted file mode 100644 index 71bf052c93d..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/borrowck-borrow-from-temporary.rs:10:5 - | -LL | let &Foo(ref x) = &id(Foo(3)); - | ---------- temporary value created here -LL | x - | ^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs b/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs index e7ca1a90f8c..92f3ffd57a1 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs +++ b/src/test/ui/borrowck/borrowck-borrow-from-temporary.rs @@ -6,8 +6,8 @@ fn id<T>(x: T) -> T { x } struct Foo(isize); fn foo<'a>() -> &'a isize { - let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough - x + let &Foo(ref x) = &id(Foo(3)); + x //~ ERROR cannot return value referencing temporary value } pub fn main() { diff --git a/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr b/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr index 6f101f690cd..71bf052c93d 100644 --- a/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-from-temporary.stderr @@ -1,18 +1,11 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-borrow-from-temporary.rs:9:24 +error[E0515]: cannot return value referencing temporary value + --> $DIR/borrowck-borrow-from-temporary.rs:10:5 | LL | let &Foo(ref x) = &id(Foo(3)); - | ^^^^^^^^^^ temporary value does not live long enough + | ---------- temporary value created here LL | x -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 8:8... - --> $DIR/borrowck-borrow-from-temporary.rs:8:8 - | -LL | fn foo<'a>() -> &'a isize { - | ^^ + | ^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr deleted file mode 100644 index 7d7e305a31f..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable - --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5 - | -LL | let a: Box<_> = box A; - | - help: consider changing this to be mutable: `mut a` -LL | a.foo(); - | ^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs index 8d528182c0d..bc820ee9f91 100644 --- a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs +++ b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.rs @@ -10,5 +10,5 @@ impl A { pub fn main() { let a: Box<_> = box A; a.foo(); - //~^ ERROR cannot borrow immutable `Box` content `*a` as mutable + //~^ ERROR cannot borrow `*a` as mutable, as `a` is not declared as mutable [E0596] } diff --git a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr index 2c989b29576..7d7e305a31f 100644 --- a/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-immut-deref-of-box-as-mut.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow immutable `Box` content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable --> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5 | LL | let a: Box<_> = box A; - | - help: make this binding mutable: `mut a` + | - help: consider changing this to be mutable: `mut a` LL | a.foo(); | ^ cannot borrow as mutable diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr deleted file mode 100644 index 8115e3150fb..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0594]: cannot assign to `**t1` which is behind a `&` reference - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 - | -LL | let t1 = t0; - | -- help: consider changing this to be a mutable reference: `&mut &mut isize` -LL | let p: &isize = &**t0; -LL | **t1 = 22; - | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written - -error[E0502]: cannot borrow `**t0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:21 - | -LL | let t1 = &mut *t0; - | -------- mutable borrow occurs here -LL | let p: &isize = &**t0; - | ^^^^^ immutable borrow occurs here -LL | **t1 = 22; - | --------- mutable borrow later used here - -error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:26 - | -LL | fn foo4(t0: & &mut isize) { - | ------------ help: consider changing this to be a mutable reference: `&mut &mut isize` -LL | let x: &mut isize = &mut **t0; - | ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0502, E0596. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr index e2e5fb6d0f8..8115e3150fb 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr @@ -1,29 +1,31 @@ -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `**t1` which is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5 | +LL | let t1 = t0; + | -- help: consider changing this to be a mutable reference: `&mut &mut isize` +LL | let p: &isize = &**t0; LL | **t1 = 22; - | ^^^^^^^^^ assignment into an immutable reference + | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written -error[E0502]: cannot borrow `**t0` as immutable because `*t0` is also borrowed as mutable - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:22 +error[E0502]: cannot borrow `**t0` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:21 | LL | let t1 = &mut *t0; - | --- mutable borrow occurs here + | -------- mutable borrow occurs here LL | let p: &isize = &**t0; - | ^^^^ immutable borrow occurs here + | ^^^^^ immutable borrow occurs here LL | **t1 = 22; -LL | } - | - mutable borrow ends here + | --------- mutable borrow later used here -error[E0389]: cannot borrow data mutably in a `&` reference - --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:31 +error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:26 | LL | fn foo4(t0: & &mut isize) { - | ------------ use `&mut &mut isize` here to make mutable + | ------------ help: consider changing this to be a mutable reference: `&mut &mut isize` LL | let x: &mut isize = &mut **t0; - | ^^^^ assignment into an immutable reference + | ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 3 previous errors -Some errors have detailed explanations: E0389, E0502. -For more information about an error, try `rustc --explain E0389`. +Some errors have detailed explanations: E0502, E0596. +For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr deleted file mode 100644 index fa0ae318e72..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/borrowck-borrow-mut-object-twice.rs:13:5 - | -LL | let y = x.f1(); - | - first mutable borrow occurs here -LL | x.f2(); - | ^ second mutable borrow occurs here -LL | y.use_ref(); - | - first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr index 1b64ad57564..fa0ae318e72 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.stderr @@ -6,8 +6,7 @@ LL | let y = x.f1(); LL | x.f2(); | ^ second mutable borrow occurs here LL | y.use_ref(); -LL | } - | - first borrow ends here + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr deleted file mode 100644 index dc52685363e..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.nll.stderr +++ /dev/null @@ -1,87 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:47:19 - | -LL | let __isize = &mut x.y; - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:51:19 - | -LL | let __isize = &mut x.y; - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:59:5 - | -LL | &mut x.y - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:63:5 - | -LL | &mut x.y - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:67:5 - | -LL | x.y = 3; - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:71:5 - | -LL | x.y = 3; - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:75:5 - | -LL | x.y = 3; - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:83:5 - | -LL | x.set(0, 0); - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:87:5 - | -LL | x.set(0, 0); - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:95:5 - | -LL | x.y_mut() - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:99:5 - | -LL | x.y_mut() - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:103:6 - | -LL | *x.y_mut() = 3; - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:107:6 - | -LL | *x.y_mut() = 3; - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:111:6 - | -LL | *x.y_mut() = 3; - | ^ cannot borrow as mutable - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr index ba799b1cbf6..dc52685363e 100644 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-overloaded-auto-deref.stderr @@ -1,82 +1,82 @@ -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:47:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:47:19 | LL | let __isize = &mut x.y; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:51:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:51:19 | LL | let __isize = &mut x.y; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:59:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:59:5 | LL | &mut x.y - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:63:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:63:5 | LL | &mut x.y - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:67:5 | LL | x.y = 3; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:71:5 | LL | x.y = 3; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:75:5 | LL | x.y = 3; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:83:5 | LL | x.set(0, 0); | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:87:5 | LL | x.set(0, 0); | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:95:5 | LL | x.y_mut() | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:99:5 | LL | x.y_mut() | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:103:6 | LL | *x.y_mut() = 3; | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:107:6 | LL | *x.y_mut() = 3; | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref.rs:111:6 | LL | *x.y_mut() = 3; diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.nll.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.nll.stderr deleted file mode 100644 index 1755b22f59d..00000000000 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.nll.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:23:19 - | -LL | let __isize = &mut *x; - | ^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:27:19 - | -LL | let __isize = &mut *x; - | ^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:35:5 - | -LL | &mut **x - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:39:5 - | -LL | &mut **x - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref.rs:43:5 - | -LL | *x = 3; - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref.rs:47:5 - | -LL | **x = 3; - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref.rs:51:5 - | -LL | **x = 3; - | ^^^^^^^ cannot assign - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr b/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr index c44327df916..1755b22f59d 100644 --- a/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr +++ b/src/test/ui/borrowck/borrowck-borrow-overloaded-deref.stderr @@ -1,44 +1,44 @@ -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:23:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:23:19 | LL | let __isize = &mut *x; - | ^^ cannot borrow as mutable + | ^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:27:24 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:27:19 | LL | let __isize = &mut *x; - | ^^ cannot borrow as mutable + | ^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:35:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:35:5 | LL | &mut **x - | ^^^ cannot borrow as mutable + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/borrowck-borrow-overloaded-deref.rs:39:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/borrowck-borrow-overloaded-deref.rs:39:5 | LL | &mut **x - | ^^^ cannot borrow as mutable + | ^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-deref.rs:43:5 | LL | *x = 3; - | ^^^^^^ cannot borrow as mutable + | ^^^^^^ cannot assign -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-deref.rs:47:5 | LL | **x = 3; - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-borrow-overloaded-deref.rs:51:5 | LL | **x = 3; - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ cannot assign error: aborting due to 7 previous errors diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr deleted file mode 100644 index 1dd18c12fc8..00000000000 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:20:20 - | -LL | let x = defer(&vec!["Goodbye", "world!"]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -LL | x.x[0]; - | ------ borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs index 6e943ffabe3..e384aacb718 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.rs @@ -17,6 +17,6 @@ fn defer<'r>(x: &'r [&'r str]) -> Defer<'r> { } fn main() { - let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR borrowed value does not live long enough + let x = defer(&vec!["Goodbye", "world!"]); //~ ERROR temporary value dropped while borrowed x.x[0]; } diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr index d17cf8a6fac..1dd18c12fc8 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr @@ -1,17 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:20:20 | LL | let x = defer(&vec!["Goodbye", "world!"]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value dropped here while still borrowed + | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use LL | x.x[0]; -LL | } - | - temporary value needs to live until here + | ------ borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr deleted file mode 100644 index c91a4377b4c..00000000000 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-borrowed-uniq-rvalue.rs:10:28 - | -LL | buggy_map.insert(42, &*Box::new(1)); - | ^^^^^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | buggy_map.insert(43, &*tmp); - | --------- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs index 88bd106d6f3..a78c66f47cd 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; fn main() { let tmp: Box<_>; let mut buggy_map: HashMap<usize, &usize> = HashMap::new(); - buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough + buggy_map.insert(42, &*Box::new(1)); //~ ERROR temporary value dropped while borrowed // but it is ok if we use a temporary tmp = box 2; diff --git a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr index 32a86562da7..c91a4377b4c 100644 --- a/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr +++ b/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-borrowed-uniq-rvalue.rs:10:27 +error[E0716]: temporary value dropped while borrowed + --> $DIR/borrowck-borrowed-uniq-rvalue.rs:10:28 | LL | buggy_map.insert(42, &*Box::new(1)); - | ^^^^^^^^^^^^ - borrowed value dropped here while still borrowed - | | - | borrowed value does not live long enough + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | + | creates a temporary which is freed while still in use ... -LL | } - | - borrowed value needs to live until here +LL | buggy_map.insert(43, &*tmp); + | --------- borrow later used here | - = note: consider using a `let` binding to increase its lifetime + = note: consider using a `let` binding to create a longer lived value error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.ast.stderr b/src/test/ui/borrowck/borrowck-box-insensitivity.ast.stderr deleted file mode 100644 index 6e6bc721ca2..00000000000 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.ast.stderr +++ /dev/null @@ -1,165 +0,0 @@ -error[E0382]: use of moved value: `a` - --> $DIR/borrowck-box-insensitivity.rs:37:9 - | -LL | let _x = a.x; - | -- value moved here -LL | -LL | let _y = a.y; - | ^^ value used here after move - | - = note: move occurs because `a.x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `a` - --> $DIR/borrowck-box-insensitivity.rs:46:9 - | -LL | let _x = a.x; - | -- value moved here -LL | -LL | let _y = a.y; - | ^^ value used here after move - | - = note: move occurs because `a.x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `a` - --> $DIR/borrowck-box-insensitivity.rs:55:15 - | -LL | let _x = a.x; - | -- value moved here -LL | -LL | let _y = &a.y; - | ^^^ value used here after move - | - = note: move occurs because `a.x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:63:9 - | -LL | let _x = &a.x; - | --- borrow of `a.x` occurs here -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0503]: cannot use `a.y` because it was mutably borrowed - --> $DIR/borrowck-box-insensitivity.rs:71:9 - | -LL | let _x = &mut a.x; - | --- borrow of `a.x` occurs here -LL | let _y = a.y; - | ^^ use of borrowed `a.x` - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:77:9 - | -LL | let _x = &mut a.x; - | --- borrow of `a.x` occurs here -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0502]: cannot borrow `a` (via `a.y`) as immutable because `a` is also borrowed as mutable (via `a.x`) - --> $DIR/borrowck-box-insensitivity.rs:85:15 - | -LL | let _x = &mut a.x; - | --- mutable borrow occurs here (via `a.x`) -LL | let _y = &a.y; - | ^^^ immutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `a` (via `a.y`) as mutable because `a` is also borrowed as immutable (via `a.x`) - --> $DIR/borrowck-box-insensitivity.rs:92:19 - | -LL | let _x = &a.x; - | --- immutable borrow occurs here (via `a.x`) -LL | let _y = &mut a.y; - | ^^^ mutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here -... -LL | } - | - immutable borrow ends here - -error[E0382]: use of collaterally moved value: `a.y` - --> $DIR/borrowck-box-insensitivity.rs:100:9 - | -LL | let _x = a.x.x; - | -- value moved here -LL | -LL | let _y = a.y; - | ^^ value used here after move - | - = note: move occurs because `a.x.x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of collaterally moved value: `a.y` - --> $DIR/borrowck-box-insensitivity.rs:108:9 - | -LL | let _x = a.x.x; - | -- value moved here -LL | -LL | let _y = a.y; - | ^^ value used here after move - | - = note: move occurs because `a.x.x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of collaterally moved value: `a.y` - --> $DIR/borrowck-box-insensitivity.rs:116:15 - | -LL | let _x = a.x.x; - | -- value moved here -LL | -LL | let _y = &a.y; - | ^^^ value used here after move - | - = note: move occurs because `a.x.x` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:124:9 - | -LL | let _x = &a.x.x; - | ----- borrow of `a.x.x` occurs here -LL | -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0503]: cannot use `a.y` because it was mutably borrowed - --> $DIR/borrowck-box-insensitivity.rs:132:9 - | -LL | let _x = &mut a.x.x; - | ----- borrow of `a.x.x` occurs here -LL | let _y = a.y; - | ^^ use of borrowed `a.x.x` - -error[E0505]: cannot move out of `a.y` because it is borrowed - --> $DIR/borrowck-box-insensitivity.rs:138:9 - | -LL | let _x = &mut a.x.x; - | ----- borrow of `a.x.x` occurs here -LL | let _y = a.y; - | ^^ move out of `a.y` occurs here - -error[E0502]: cannot borrow `a.y` as immutable because `a.x.x` is also borrowed as mutable - --> $DIR/borrowck-box-insensitivity.rs:147:15 - | -LL | let _x = &mut a.x.x; - | ----- mutable borrow occurs here -LL | -LL | let _y = &a.y; - | ^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `a.y` as mutable because `a.x.x` is also borrowed as immutable - --> $DIR/borrowck-box-insensitivity.rs:155:19 - | -LL | let _x = &a.x.x; - | ----- immutable borrow occurs here -LL | -LL | let _y = &mut a.y; - | ^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error: aborting due to 16 previous errors - -Some errors have detailed explanations: E0382, E0502, E0503, E0505. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.mir.stderr b/src/test/ui/borrowck/borrowck-box-insensitivity.mir.stderr deleted file mode 100644 index 0e380e90e75..00000000000 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/borrowck-box-insensitivity.rs:160:1 - | -LL | / fn main() { -LL | | copy_after_move(); -LL | | move_after_move(); -LL | | borrow_after_move(); -... | -LL | | mut_borrow_after_borrow_nested(); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.nll.stderr b/src/test/ui/borrowck/borrowck-box-insensitivity.nll.stderr deleted file mode 100644 index 0e380e90e75..00000000000 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/borrowck-box-insensitivity.rs:160:1 - | -LL | / fn main() { -LL | | copy_after_move(); -LL | | move_after_move(); -LL | | borrow_after_move(); -... | -LL | | mut_borrow_after_borrow_nested(); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/borrowck-box-insensitivity.rs b/src/test/ui/borrowck/borrowck-box-sensitivity.rs index e72048d0ea4..e5591f50038 100644 --- a/src/test/ui/borrowck/borrowck-box-insensitivity.rs +++ b/src/test/ui/borrowck/borrowck-box-sensitivity.rs @@ -1,14 +1,9 @@ -// This test is an artifact of the old policy that `Box<T>` should not -// be treated specially by the AST-borrowck. -// -// NLL goes back to treating `Box<T>` specially (namely, knowing that -// it uniquely owns the data it holds). See rust-lang/rfcs#130. - -// revisions: ast mir -//[ast] compile-flags: -Z borrowck=ast -//[mir] compile-flags: -Z borrowck=mir -// ignore-compare-mode-nll -#![feature(box_syntax, rustc_attrs)] +// Test that `Box<T>` is treated specially by borrow checking. This is the case +// because NLL reverted the deicision in rust-lang/rfcs#130. + +// run-pass + +#![feature(box_syntax)] struct A { x: Box<isize>, @@ -33,131 +28,101 @@ struct D { fn copy_after_move() { let a: Box<_> = box A { x: box 0, y: 1 }; let _x = a.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of moved - //[ast]~^ move occurs because `a.x` has type `std::boxed::Box<isize>` - //[ast]~| value used here after move + let _y = a.y; } fn move_after_move() { let a: Box<_> = box B { x: box 0, y: box 1 }; let _x = a.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of moved - //[ast]~^ move occurs because `a.x` has type `std::boxed::Box<isize>` - //[ast]~| value used here after move + let _y = a.y; } fn borrow_after_move() { let a: Box<_> = box A { x: box 0, y: 1 }; let _x = a.x; - //[ast]~^ value moved here - let _y = &a.y; //[ast]~ ERROR use of moved - //[ast]~^ move occurs because `a.x` has type `std::boxed::Box<isize>` - //[ast]~| value used here after move + let _y = &a.y; } fn move_after_borrow() { let a: Box<_> = box B { x: box 0, y: box 1 }; let _x = &a.x; let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_imm(_x); } fn copy_after_mut_borrow() { let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &mut a.x; - let _y = a.y; //[ast]~ ERROR cannot use + let _y = a.y; use_mut(_x); } fn move_after_mut_borrow() { let mut a: Box<_> = box B { x: box 0, y: box 1 }; let _x = &mut a.x; let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_mut(_x); } fn borrow_after_mut_borrow() { let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &mut a.x; - let _y = &a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ immutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here + let _y = &a.y; use_mut(_x); } fn mut_borrow_after_borrow() { let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &a.x; - let _y = &mut a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ mutable borrow of `a.y` -- which overlaps with `a.x` -- occurs here + let _y = &mut a.y; use_imm(_x); } fn copy_after_move_nested() { let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = a.x.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of collaterally moved - //[ast]~| value used here after move + let _y = a.y; } fn move_after_move_nested() { let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = a.x.x; - //[ast]~^ value moved here - let _y = a.y; //[ast]~ ERROR use of collaterally moved - //[ast]~| value used here after move + let _y = a.y; } fn borrow_after_move_nested() { let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = a.x.x; - //[ast]~^ value moved here - let _y = &a.y; //[ast]~ ERROR use of collaterally moved - //[ast]~| value used here after move + let _y = &a.y; } fn move_after_borrow_nested() { let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = &a.x.x; - //[ast]~^ borrow of `a.x.x` occurs here let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_imm(_x); } fn copy_after_mut_borrow_nested() { let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &mut a.x.x; - let _y = a.y; //[ast]~ ERROR cannot use + let _y = a.y; use_mut(_x); } fn move_after_mut_borrow_nested() { let mut a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = &mut a.x.x; let _y = a.y; - //[ast]~^ ERROR cannot move - //[ast]~| move out of use_mut(_x); } fn borrow_after_mut_borrow_nested() { let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &mut a.x.x; - //[ast]~^ mutable borrow occurs here - let _y = &a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ immutable borrow occurs here + let _y = &a.y; use_mut(_x); } fn mut_borrow_after_borrow_nested() { let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &a.x.x; - //[ast]~^ immutable borrow occurs here - let _y = &mut a.y; //[ast]~ ERROR cannot borrow - //[ast]~^ mutable borrow occurs here + let _y = &mut a.y; use_imm(_x); } -#[rustc_error] -fn main() { //[mir]~ ERROR compilation successful + +fn main() { copy_after_move(); move_after_move(); borrow_after_move(); diff --git a/src/test/ui/borrowck/borrowck-break-uninit-2.nll.stderr b/src/test/ui/borrowck/borrowck-break-uninit-2.nll.stderr deleted file mode 100644 index e40d8d9dfcc..00000000000 --- a/src/test/ui/borrowck/borrowck-break-uninit-2.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-break-uninit-2.rs:9:20 - | -LL | println!("{}", x); - | ^ use of possibly uninitialized `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-break-uninit-2.rs b/src/test/ui/borrowck/borrowck-break-uninit-2.rs index 95ccb2e1b93..dad5325cb87 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit-2.rs +++ b/src/test/ui/borrowck/borrowck-break-uninit-2.rs @@ -6,7 +6,7 @@ fn foo() -> isize { x = 0; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` return 17; } diff --git a/src/test/ui/borrowck/borrowck-break-uninit-2.stderr b/src/test/ui/borrowck/borrowck-break-uninit-2.stderr index a6c3dfef9e8..e40d8d9dfcc 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit-2.stderr +++ b/src/test/ui/borrowck/borrowck-break-uninit-2.stderr @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-break-uninit-2.rs:9:20 | LL | println!("{}", x); diff --git a/src/test/ui/borrowck/borrowck-break-uninit.nll.stderr b/src/test/ui/borrowck/borrowck-break-uninit.nll.stderr deleted file mode 100644 index bbf9b9f1241..00000000000 --- a/src/test/ui/borrowck/borrowck-break-uninit.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-break-uninit.rs:9:20 - | -LL | println!("{}", x); - | ^ use of possibly uninitialized `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-break-uninit.rs b/src/test/ui/borrowck/borrowck-break-uninit.rs index 827637cfb95..9af02b387d8 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit.rs +++ b/src/test/ui/borrowck/borrowck-break-uninit.rs @@ -6,7 +6,7 @@ fn foo() -> isize { x = 0; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` return 17; } diff --git a/src/test/ui/borrowck/borrowck-break-uninit.stderr b/src/test/ui/borrowck/borrowck-break-uninit.stderr index dcb024a3e1a..bbf9b9f1241 100644 --- a/src/test/ui/borrowck/borrowck-break-uninit.stderr +++ b/src/test/ui/borrowck/borrowck-break-uninit.stderr @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-break-uninit.rs:9:20 | LL | println!("{}", x); diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.stderr deleted file mode 100644 index d506599eb68..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.stderr +++ /dev/null @@ -1,96 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:21:14 - | -LL | let c1 = || x = 4; - | -- - previous borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; - | ^^ - borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:29:14 - | -LL | let c1 = || set(&mut x); - | -- - previous borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || get(&x); - | ^^ - borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:37:14 - | -LL | let c1 = || set(&mut x); - | -- - previous borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; - | ^^ - borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:45:5 - | -LL | let c2 = || x * 5; - | -- borrow of `x` occurs here -LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:53:5 - | -LL | let c1 = || get(&x); - | -- borrow of `x` occurs here -LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here - -error[E0506]: cannot assign to `*x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:61:5 - | -LL | let c1 = || get(&*x); - | -- borrow of `*x` occurs here -LL | *x = 5; - | ^^^^^^ assignment to borrowed `*x` occurs here - -error[E0506]: cannot assign to `*x.f` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:73:5 - | -LL | let c1 = || get(&*x.f); - | -- borrow of `*x.f` occurs here -LL | *x.f = 5; - | ^^^^^^^^ assignment to borrowed `*x.f` occurs here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-mut-and-imm.rs:85:14 - | -LL | let c1 = || get(&*x.f); - | -- - previous borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | let c2 = || *x.f = 5; - | ^^ - borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0502, E0506. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr deleted file mode 100644 index a41738f6ca8..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:21:14 - | -LL | let c1 = || x = 4; - | -- - first borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; - | ^^ - second borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | -LL | drop(c1); - | -- mutable borrow later used here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:29:14 - | -LL | let c1 = || set(&mut x); - | -- - first borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || get(&x); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | -LL | drop(c1); - | -- mutable borrow later used here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:37:14 - | -LL | let c1 = || set(&mut x); - | -- - first borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | let c2 = || x * 5; - | ^^ - second borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | -LL | drop(c1); - | -- mutable borrow later used here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:45:5 - | -LL | let c2 = || x * 5; - | -- - borrow occurs due to use in closure - | | - | borrow of `x` occurs here -LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here -LL | -LL | drop(c2); - | -- borrow later used here - -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:53:5 - | -LL | let c1 = || get(&x); - | -- - borrow occurs due to use in closure - | | - | borrow of `x` occurs here -LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here -LL | -LL | drop(c1); - | -- borrow later used here - -error[E0506]: cannot assign to `*x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:61:5 - | -LL | let c1 = || get(&*x); - | -- - borrow occurs due to use in closure - | | - | borrow of `*x` occurs here -LL | *x = 5; - | ^^^^^^ assignment to borrowed `*x` occurs here -LL | -LL | drop(c1); - | -- borrow later used here - -error[E0506]: cannot assign to `*x.f` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:73:5 - | -LL | let c1 = || get(&*x.f); - | -- - borrow occurs due to use in closure - | | - | borrow of `*x.f` occurs here -LL | *x.f = 5; - | ^^^^^^^^ assignment to borrowed `*x.f` occurs here -LL | -LL | drop(c1); - | -- borrow later used here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-mut-and-imm.rs:85:14 - | -LL | let c1 = || get(&*x.f); - | -- - first borrow occurs due to use of `x` in closure - | | - | immutable borrow occurs here -LL | let c2 = || *x.f = 5; - | ^^ - second borrow occurs due to use of `x` in closure - | | - | mutable borrow occurs here -LL | -LL | drop(c1); - | -- immutable borrow later used here - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0502, E0506. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs index 3a802bcbb3e..2dc405ffcd4 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs +++ b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.rs @@ -1,10 +1,6 @@ // Tests that two closures cannot simultaneously have mutable // and immutable access to the variable. Issue #6801. -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] fn get(x: &isize) -> isize { @@ -18,48 +14,48 @@ fn set(x: &mut isize) { fn a() { let mut x = 3; let c1 = || x = 4; - let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + let c2 = || x * 5; + //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable drop(c1); } fn b() { let mut x = 3; let c1 = || set(&mut x); - let c2 = || get(&x); //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + let c2 = || get(&x); + //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable drop(c1); } fn c() { let mut x = 3; let c1 = || set(&mut x); - let c2 = || x * 5; //[ast]~ ERROR cannot borrow `x` - //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable + let c2 = || x * 5; + //~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable drop(c1); } fn d() { let mut x = 3; let c2 = || x * 5; - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = 5; + //~^ ERROR cannot assign to `x` because it is borrowed drop(c2); } fn e() { let mut x = 3; let c1 = || get(&x); - x = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = 5; + //~^ ERROR cannot assign to `x` because it is borrowed drop(c1); } fn f() { let mut x: Box<_> = box 3; let c1 = || get(&*x); - *x = 5; //[ast]~ ERROR cannot assign to `*x` - //[mir]~^ ERROR cannot assign to `*x` because it is borrowed + *x = 5; + //~^ ERROR cannot assign to `*x` because it is borrowed drop(c1); } @@ -70,8 +66,8 @@ fn g() { let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); - *x.f = 5; //[ast]~ ERROR cannot assign to `*x.f` - //[mir]~^ ERROR cannot assign to `*x.f` because it is borrowed + *x.f = 5; + //~^ ERROR cannot assign to `*x.f` because it is borrowed drop(c1); } @@ -82,8 +78,8 @@ fn h() { let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); - let c2 = || *x.f = 5; //[ast]~ ERROR cannot borrow `x` as mutable - //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + let c2 = || *x.f = 5; + //~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable drop(c1); } diff --git a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.stderr index a41738f6ca8..edeb21c16d3 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:21:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:17:14 | LL | let c1 = || x = 4; | -- - first borrow occurs due to use of `x` in closure @@ -14,7 +14,7 @@ LL | drop(c1); | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:29:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:25:14 | LL | let c1 = || set(&mut x); | -- - first borrow occurs due to use of `x` in closure @@ -29,7 +29,7 @@ LL | drop(c1); | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-mut-and-imm.rs:37:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:33:14 | LL | let c1 = || set(&mut x); | -- - first borrow occurs due to use of `x` in closure @@ -44,7 +44,7 @@ LL | drop(c1); | -- mutable borrow later used here error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:45:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:41:5 | LL | let c2 = || x * 5; | -- - borrow occurs due to use in closure @@ -57,7 +57,7 @@ LL | drop(c2); | -- borrow later used here error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:53:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:49:5 | LL | let c1 = || get(&x); | -- - borrow occurs due to use in closure @@ -70,7 +70,7 @@ LL | drop(c1); | -- borrow later used here error[E0506]: cannot assign to `*x` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:61:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:57:5 | LL | let c1 = || get(&*x); | -- - borrow occurs due to use in closure @@ -83,7 +83,7 @@ LL | drop(c1); | -- borrow later used here error[E0506]: cannot assign to `*x.f` because it is borrowed - --> $DIR/borrowck-closures-mut-and-imm.rs:73:5 + --> $DIR/borrowck-closures-mut-and-imm.rs:69:5 | LL | let c1 = || get(&*x.f); | -- - borrow occurs due to use in closure @@ -96,7 +96,7 @@ LL | drop(c1); | -- borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-mut-and-imm.rs:85:14 + --> $DIR/borrowck-closures-mut-and-imm.rs:81:14 | LL | let c1 = || get(&*x.f); | -- - first borrow occurs due to use of `x` in closure diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr deleted file mode 100644 index 3be7d725eda..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:13:25 - | -LL | let mut c1 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-closures-mut-of-imm.rs:15:25 - | -LL | let mut c2 = || set(&mut *x); - | ^^^^^^^ cannot borrow as mutable - -error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-mut-of-imm.rs:15:18 - | -LL | let mut c1 = || set(&mut *x); - | -- - first borrow occurs due to use of `x` in closure - | | - | first closure is constructed here -LL | -LL | let mut c2 = || set(&mut *x); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second closure is constructed here -... -LL | c2(); c1(); - | -- first borrow later used here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr index 9890c04057e..3be7d725eda 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-imm.stderr @@ -1,30 +1,30 @@ +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-closures-mut-of-imm.rs:13:25 + | +LL | let mut c1 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-closures-mut-of-imm.rs:15:25 + | +LL | let mut c2 = || set(&mut *x); + | ^^^^^^^ cannot borrow as mutable + error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-mut-of-imm.rs:15:18 | LL | let mut c1 = || set(&mut *x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first closure is constructed here LL | LL | let mut c2 = || set(&mut *x); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second closure is constructed here ... -LL | } - | - borrow from first closure ends here - -error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:13:30 - | -LL | let mut c1 = || set(&mut *x); - | ^^ cannot borrow as mutable - -error[E0596]: cannot borrow immutable borrowed content `***x` as mutable - --> $DIR/borrowck-closures-mut-of-imm.rs:15:30 - | -LL | let mut c2 = || set(&mut *x); - | ^^ cannot borrow as mutable +LL | c2(); c1(); + | -- first borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr deleted file mode 100644 index a1743887121..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-mut-of-mut.rs:14:18 - | -LL | let mut c1 = || set(&mut *x); - | -- - first borrow occurs due to use of `x` in closure - | | - | first closure is constructed here -LL | let mut c2 = || set(&mut *x); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second closure is constructed here -LL | -LL | c2(); c1(); - | -- first borrow later used here - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr index efdcedb5f1d..a1743887121 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr +++ b/src/test/ui/borrowck/borrowck-closures-mut-of-mut.stderr @@ -2,16 +2,16 @@ error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-mut-of-mut.rs:14:18 | LL | let mut c1 = || set(&mut *x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first closure is constructed here LL | let mut c2 = || set(&mut *x); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second closure is constructed here -... -LL | } - | - borrow from first closure ends here +LL | +LL | c2(); c1(); + | -- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr deleted file mode 100644 index 07f477d1786..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:16:24 - | -LL | let c1 = to_fn_mut(|| x = 4); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| x = 5); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:27:24 - | -LL | let c1 = to_fn_mut(|| set(&mut x)); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:34:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:41:24 - | -LL | let c1 = to_fn_mut(|| x = 5); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | -LL | c1; - | -- first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-closures-two-mut-fail.rs:53:24 - | -LL | let c1 = to_fn_mut(|| set(&mut *x.f)); - | -- - first borrow occurs due to use of `x` in closure - | | - | first mutable borrow occurs here -LL | let c2 = to_fn_mut(|| set(&mut *x.f)); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second mutable borrow occurs here -LL | -LL | c1; - | -- first borrow later used here - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr index 7399f8360dc..07f477d1786 100644 --- a/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr +++ b/src/test/ui/borrowck/borrowck-closures-two-mut-fail.stderr @@ -2,76 +2,73 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:16:24 | LL | let c1 = to_fn_mut(|| x = 4); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| x = 5); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here LL | c1; -LL | } - | - first borrow ends here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:27:24 | LL | let c1 = to_fn_mut(|| set(&mut x)); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here LL | c1; -LL | } - | - first borrow ends here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:34:24 | LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| set(&mut x)); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here LL | c1; -LL | } - | - first borrow ends here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:41:24 | LL | let c1 = to_fn_mut(|| x = 5); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure) - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... -LL | } - | - first borrow ends here +LL | +LL | c1; + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:53:24 | LL | let c1 = to_fn_mut(|| set(&mut *x.f)); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here LL | let c2 = to_fn_mut(|| set(&mut *x.f)); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here -... -LL | } - | - first borrow ends here +LL | +LL | c1; + | -- first borrow later used here error: aborting due to 5 previous errors diff --git a/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr b/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr deleted file mode 100644 index b8bbb31a355..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `this.x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-unique-imm.rs:11:9 - | -LL | let p = &this.x; - | ------- immutable borrow occurs here -LL | &mut this.x; - | ^^^^^^^^^^^ mutable borrow occurs here -LL | p.use_ref(); - | - immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr b/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr index 3cdc9b9d4fd..b8bbb31a355 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr +++ b/src/test/ui/borrowck/borrowck-closures-unique-imm.stderr @@ -1,13 +1,12 @@ error[E0502]: cannot borrow `this.x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-closures-unique-imm.rs:11:14 + --> $DIR/borrowck-closures-unique-imm.rs:11:9 | LL | let p = &this.x; - | ------ immutable borrow occurs here + | ------- immutable borrow occurs here LL | &mut this.x; - | ^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^ mutable borrow occurs here LL | p.use_ref(); -LL | }; - | - immutable borrow ends here + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr b/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr deleted file mode 100644 index ea5250a5658..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error[E0500]: closure requires unique access to `x` but it is already borrowed - --> $DIR/borrowck-closures-unique.rs:26:14 - | -LL | let c1 = || get(x); - | -- - first borrow occurs due to use of `x` in closure - | | - | borrow occurs here -LL | let c2 = || set(x); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | closure construction occurs here -LL | c1; - | -- first borrow later used here - -error[E0500]: closure requires unique access to `x` but it is already borrowed - --> $DIR/borrowck-closures-unique.rs:32:14 - | -LL | let c1 = || get(x); - | -- - first borrow occurs due to use of `x` in closure - | | - | borrow occurs here -LL | let c2 = || { get(x); set(x); }; - | ^^ - second borrow occurs due to use of `x` in closure - | | - | closure construction occurs here -LL | c1; - | -- first borrow later used here - -error[E0524]: two closures require unique access to `x` at the same time - --> $DIR/borrowck-closures-unique.rs:38:14 - | -LL | let c1 = || set(x); - | -- - first borrow occurs due to use of `x` in closure - | | - | first closure is constructed here -LL | let c2 = || set(x); - | ^^ - second borrow occurs due to use of `x` in closure - | | - | second closure is constructed here -LL | c1; - | -- first borrow later used here - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/borrowck-closures-unique.rs:47:38 - | -LL | fn e(x: &'static mut isize) { - | - help: consider changing this to be mutable: `mut x` -LL | let c1 = |y: &'static mut isize| x = y; - | ^^^^^ cannot assign - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-closures-unique.rs b/src/test/ui/borrowck/borrowck-closures-unique.rs index a4655ebba11..67f91dfa842 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique.rs +++ b/src/test/ui/borrowck/borrowck-closures-unique.rs @@ -39,17 +39,14 @@ fn d(x: &mut isize) { c1; } -// This test was originally encoded in the form shown as `fn f` below. -// However, since MIR-borrowck and thus NLL takes more control-flow information -// into account, it was necessary to change the test in order to witness the -// same (expected) error under both AST-borrowck and NLL. fn e(x: &'static mut isize) { - let c1 = |y: &'static mut isize| x = y; //~ ERROR closure cannot assign to immutable argument + let c1 = |y: &'static mut isize| x = y; + //~^ ERROR cannot assign to `x`, as it is not declared as mutable c1; } fn f(x: &'static mut isize) { - let c1 = || x = panic!(); //~ ERROR closure cannot assign to immutable argument + let c1 = || x = panic!(); // OK assignment is unreachable. c1; } diff --git a/src/test/ui/borrowck/borrowck-closures-unique.stderr b/src/test/ui/borrowck/borrowck-closures-unique.stderr index 09dcb2c7779..9b53af4c01f 100644 --- a/src/test/ui/borrowck/borrowck-closures-unique.stderr +++ b/src/test/ui/borrowck/borrowck-closures-unique.stderr @@ -2,68 +2,52 @@ error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/borrowck-closures-unique.rs:26:14 | LL | let c1 = || get(x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | borrow occurs here LL | let c2 = || set(x); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | closure construction occurs here LL | c1; -LL | } - | - borrow ends here + | -- first borrow later used here error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/borrowck-closures-unique.rs:32:14 | LL | let c1 = || get(x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | borrow occurs here LL | let c2 = || { get(x); set(x); }; - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | closure construction occurs here LL | c1; -LL | } - | - borrow ends here + | -- first borrow later used here error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-unique.rs:38:14 | LL | let c1 = || set(x); - | -- - previous borrow occurs due to use of `x` in closure + | -- - first borrow occurs due to use of `x` in closure | | | first closure is constructed here LL | let c2 = || set(x); - | ^^ - borrow occurs due to use of `x` in closure + | ^^ - second borrow occurs due to use of `x` in closure | | | second closure is constructed here LL | c1; -LL | } - | - borrow from first closure ends here + | -- first borrow later used here -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/borrowck-closures-unique.rs:47:14 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/borrowck-closures-unique.rs:43:38 | +LL | fn e(x: &'static mut isize) { + | - help: consider changing this to be mutable: `mut x` LL | let c1 = |y: &'static mut isize| x = y; - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x - | ^ - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/borrowck-closures-unique.rs:52:14 - | -LL | let c1 = || x = panic!(); - | ^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x - | ^ + | ^^^^^ cannot assign -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0500, E0595. -For more information about an error, try `rustc --explain E0500`. +For more information about this error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr b/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr deleted file mode 100644 index a6dbcf36077..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-closures-use-after-free.rs:22:8 - | -LL | let mut test = |foo: &Foo| { - | ----------- mutable borrow occurs here -LL | ptr = box Foo { x: ptr.x + 1 }; - | --- first borrow occurs due to use of `ptr` in closure -LL | }; -LL | test(&*ptr); - | ---- ^^^^^ immutable borrow occurs here - | | - | mutable borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr b/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr index 9e77d8ce188..a6dbcf36077 100644 --- a/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr +++ b/src/test/ui/borrowck/borrowck-closures-use-after-free.stderr @@ -1,15 +1,15 @@ -error[E0502]: cannot borrow `*ptr` as immutable because `ptr` is also borrowed as mutable - --> $DIR/borrowck-closures-use-after-free.rs:22:9 +error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-closures-use-after-free.rs:22:8 | LL | let mut test = |foo: &Foo| { | ----------- mutable borrow occurs here LL | ptr = box Foo { x: ptr.x + 1 }; - | --- previous borrow occurs due to use of `ptr` in closure + | --- first borrow occurs due to use of `ptr` in closure LL | }; LL | test(&*ptr); - | ^^^^ immutable borrow occurs here -LL | } - | - mutable borrow ends here + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-consume-unsize-vec.nll.stderr b/src/test/ui/borrowck/borrowck-consume-unsize-vec.nll.stderr deleted file mode 100644 index c69237fa95f..00000000000 --- a/src/test/ui/borrowck/borrowck-consume-unsize-vec.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `b` - --> $DIR/borrowck-consume-unsize-vec.rs:8:13 - | -LL | fn foo(b: Box<[i32;5]>) { - | - move occurs because `b` has type `std::boxed::Box<[i32; 5]>`, which does not implement the `Copy` trait -LL | consume(b); - | - value moved here -LL | consume(b); - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr index 02644b82f57..c69237fa95f 100644 --- a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr +++ b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `b` --> $DIR/borrowck-consume-unsize-vec.rs:8:13 | +LL | fn foo(b: Box<[i32;5]>) { + | - move occurs because `b` has type `std::boxed::Box<[i32; 5]>`, which does not implement the `Copy` trait LL | consume(b); | - value moved here LL | consume(b); | ^ value used here after move - | - = note: move occurs because `b` has type `std::boxed::Box<[i32; 5]>`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.nll.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.nll.stderr deleted file mode 100644 index e8194ad6944..00000000000 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `b` - --> $DIR/borrowck-consume-upcast-box.rs:10:13 - | -LL | fn foo(b: Box<Foo+Send>) { - | - move occurs because `b` has type `std::boxed::Box<dyn Foo + std::marker::Send>`, which does not implement the `Copy` trait -LL | consume(b); - | - value moved here -LL | consume(b); - | ^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr index 7267a99b869..e8194ad6944 100644 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr +++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `b` --> $DIR/borrowck-consume-upcast-box.rs:10:13 | +LL | fn foo(b: Box<Foo+Send>) { + | - move occurs because `b` has type `std::boxed::Box<dyn Foo + std::marker::Send>`, which does not implement the `Copy` trait LL | consume(b); | - value moved here LL | consume(b); | ^ value used here after move - | - = note: move occurs because `b` has type `std::boxed::Box<(dyn Foo + std::marker::Send + 'static)>`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr deleted file mode 100644 index beb009dbfe4..00000000000 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr +++ /dev/null @@ -1,246 +0,0 @@ -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:43:9 - | -LL | let x = f.x(); - | - borrow of `f` occurs here -LL | f.x; - | ^^^ use of borrowed `f` - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:51:9 - | -LL | let x = g.x(); - | - borrow of `g` occurs here -LL | g.0; - | ^^^ use of borrowed `g` - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:59:9 - | -LL | let x = &mut h.0; - | --- borrow of `h.0` occurs here -LL | h.0; - | ^^^ use of borrowed `h.0` - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:68:20 - | -LL | let x = e.x(); - | - borrow of `e` occurs here -LL | match e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `e` - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:78:9 - | -LL | let x = &mut u.a; - | --- borrow of `u.a` occurs here -LL | u.a; - | ^^^ use of borrowed `u.a` - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:86:9 - | -LL | let x = f.x(); - | - borrow of `*f` occurs here -LL | f.x; - | ^^^ use of borrowed `*f` - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:94:9 - | -LL | let x = g.x(); - | - borrow of `*g` occurs here -LL | g.0; - | ^^^ use of borrowed `*g` - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:102:9 - | -LL | let x = &mut h.0; - | --- borrow of `h.0` occurs here -LL | h.0; - | ^^^ use of borrowed `h.0` - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:111:20 - | -LL | let x = e.x(); - | - borrow of `*e` occurs here -LL | match *e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `*e` - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:121:9 - | -LL | let x = &mut u.a; - | --- borrow of `u.a` occurs here -LL | u.a; - | ^^^ use of borrowed `u.a` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:130:15 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -LL | match v { -LL | &[x, _, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:136:18 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, x, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:142:25 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, _, .., x, _] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:148:28 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, _, .., _, x] => println!("{}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:160:15 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -LL | match v { -LL | &[x..] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:166:18 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, x..] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:172:15 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:178:18 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -... -LL | &[_, x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` - -error[E0502]: cannot borrow `e.0` as immutable because `e` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:192:18 - | -LL | let x = &mut e; - | - mutable borrow occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `e.x` as immutable because `e` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:197:23 - | -LL | let x = &mut e; - | - mutable borrow occurs here -... -LL | E::B { x: ref bx } => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:211:22 - | -LL | let x = &mut s; - | - mutable borrow occurs here -LL | match s { -LL | S { y: (ref y0, _), .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:218:28 - | -LL | let x = &mut s; - | - mutable borrow occurs here -... -LL | S { x: F { y: ref x0, .. }, .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0503]: cannot use `v[..].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 - | -LL | let x = &mut v; - | - borrow of `v` occurs here -LL | v[0].y; - | ^^^^^^ use of borrowed `v` - -error[E0499]: cannot borrow `**x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:285:18 - | -LL | let y = &mut x; - | - first mutable borrow occurs here -LL | &mut x; - | ^ second mutable borrow occurs here -... -LL | }; - | - first borrow ends here - -error[E0499]: cannot borrow `**x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:296:25 - | -LL | let y = &mut x; - | - first mutable borrow occurs here -LL | &mut x; - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:307:22 - | -LL | drop(x); - | - value moved here -LL | drop(x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait - -error: aborting due to 26 previous errors - -Some errors have detailed explanations: E0382, E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr deleted file mode 100644 index 595c3f6b0c5..00000000000 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr +++ /dev/null @@ -1,377 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:285:13 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | &mut x; - | ^^^^^^ second mutable borrow occurs here -LL | -LL | *y = 1; - | ------ first borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:296:20 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | &mut x; - | ^^^^^^ second mutable borrow occurs here -LL | -LL | *y = 1; - | ------ first borrow later used here - -error: captured variable cannot escape `FnMut` closure body - --> $DIR/borrowck-describe-lvalue.rs:294:16 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | / || { -LL | | let y = &mut x; -LL | | &mut x; -LL | | -LL | | *y = 1; -LL | | drop(y); -LL | | } - | |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body - | - = note: `FnMut` closures only have access to their captured variables while they are executing... - = note: ...therefore, they cannot allow references to captured variables to escape - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:43:9 - | -LL | let x = f.x(); - | - borrow of `f` occurs here -LL | f.x; - | ^^^ use of borrowed `f` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:51:9 - | -LL | let x = g.x(); - | - borrow of `g` occurs here -LL | g.0; - | ^^^ use of borrowed `g` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:59:9 - | -LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here -LL | h.0; - | ^^^ use of borrowed `h.0` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:68:20 - | -LL | let x = e.x(); - | - borrow of `e` occurs here -LL | match e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:78:9 - | -LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a; - | ^^^ use of borrowed `u.a` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:86:9 - | -LL | let x = f.x(); - | - borrow of `*f` occurs here -LL | f.x; - | ^^^ use of borrowed `*f` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:94:9 - | -LL | let x = g.x(); - | - borrow of `*g` occurs here -LL | g.0; - | ^^^ use of borrowed `*g` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:102:9 - | -LL | let x = &mut h.0; - | -------- borrow of `h.0` occurs here -LL | h.0; - | ^^^ use of borrowed `h.0` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:111:20 - | -LL | let x = e.x(); - | - borrow of `*e` occurs here -LL | match *e { -LL | Baz::X(value) => value - | ^^^^^ use of borrowed `*e` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:121:9 - | -LL | let x = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a; - | ^^^ use of borrowed `u.a` -LL | -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:130:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { -LL | &[x, _, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:136:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x, .., _, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:142:25 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, _, .., x, _] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:148:28 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, _, .., _, x] => println!("{}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:160:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { -LL | &[x..] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:166:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x..] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:172:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:178:18 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | &[_, x.., _] => println!("{:?}", x), - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:192:13 - | -LL | let x = &mut e; - | ------ borrow of `e` occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^^^^^^^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - -error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:192:18 - | -LL | let x = &mut e; - | ------ mutable borrow occurs here -LL | match e { -LL | E::A(ref ax) => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:197:23 - | -LL | let x = &mut e; - | ------ mutable borrow occurs here -... -LL | E::B { x: ref bx } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:211:22 - | -LL | let x = &mut s; - | ------ mutable borrow occurs here -LL | match s { -LL | S { y: (ref y0, _), .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:218:28 - | -LL | let x = &mut s; - | ------ mutable borrow occurs here -... -LL | S { x: F { y: ref x0, .. }, .. } => - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0503]: cannot use `*v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | v[0].y; - | ^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `v[_].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | v[0].y; - | ^^^^^^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - -error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:273:24 - | -LL | let x = &mut v; - | ------ mutable borrow occurs here -LL | match v { -LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), - | ^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:235:29 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p: &'a u8 = &*block.current; - | ^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:250:33 - | -LL | let x = &mut block; - | ---------- mutable borrow occurs here -LL | let p : *const u8 = &*(*block).current; - | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here -... -LL | drop(x); - | - mutable borrow later used here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:307:22 - | -LL | drop(x); - | - value moved here -LL | drop(x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec<i32>`, which does not implement the `Copy` trait - -error: aborting due to 32 previous errors - -Some errors have detailed explanations: E0382, E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.rs b/src/test/ui/borrowck/borrowck-describe-lvalue.rs index eb622ac10ad..c8dbf4e6918 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.rs +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.rs @@ -1,6 +1,4 @@ // ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir #![feature(slice_patterns)] @@ -40,24 +38,21 @@ fn main() { { let mut f = Foo { x: 22 }; let x = f.x(); - f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed + f.x; //~ ERROR cannot use `f.x` because it was mutably borrowed drop(x); } // Local and field from tuple-struct { let mut g = Bar(22); let x = g.x(); - g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed + g.0; //~ ERROR cannot use `g.0` because it was mutably borrowed drop(x); } // Local and field from tuple { let mut h = (22, 23); let x = &mut h.0; - h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed + h.0; //~ ERROR cannot use `h.0` because it was mutably borrowed drop(x); } // Local and field from enum @@ -65,9 +60,7 @@ fn main() { let mut e = Baz::X(2); let x = e.x(); match e { - Baz::X(value) => value - //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed + Baz::X(value) => value //~ ERROR cannot use `e.0` because it was mutably borrowed }; drop(x); } @@ -75,32 +68,28 @@ fn main() { unsafe { let mut u = U { b: 0 }; let x = &mut u.a; - u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed + u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed drop(x); } // Deref and field from struct { let mut f = Box::new(Foo { x: 22 }); let x = f.x(); - f.x; //[ast]~ ERROR cannot use `f.x` because it was mutably borrowed - //[mir]~^ ERROR cannot use `f.x` because it was mutably borrowed + f.x; //~ ERROR cannot use `f.x` because it was mutably borrowed drop(x); } // Deref and field from tuple-struct { let mut g = Box::new(Bar(22)); let x = g.x(); - g.0; //[ast]~ ERROR cannot use `g.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `g.0` because it was mutably borrowed + g.0; //~ ERROR cannot use `g.0` because it was mutably borrowed drop(x); } // Deref and field from tuple { let mut h = Box::new((22, 23)); let x = &mut h.0; - h.0; //[ast]~ ERROR cannot use `h.0` because it was mutably borrowed - //[mir]~^ ERROR cannot use `h.0` because it was mutably borrowed + h.0; //~ ERROR cannot use `h.0` because it was mutably borrowed drop(x); } // Deref and field from enum @@ -109,8 +98,7 @@ fn main() { let x = e.x(); match *e { Baz::X(value) => value - //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed + //~^ ERROR cannot use `e.0` because it was mutably borrowed }; drop(x); } @@ -118,8 +106,7 @@ fn main() { unsafe { let mut u = Box::new(U { b: 0 }); let x = &mut u.a; - u.a; //[ast]~ ERROR cannot use `u.a` because it was mutably borrowed - //[mir]~^ ERROR cannot use `u.a` because it was mutably borrowed + u.a; //~ ERROR cannot use `u.a` because it was mutably borrowed drop(x); } // Constant index @@ -128,26 +115,22 @@ fn main() { let x = &mut v; match v { &[x, _, .., _, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, x, .., _, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, _, .., x, _] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, _, .., _, x] => println!("{}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } drop(x); @@ -158,26 +141,22 @@ fn main() { let x = &mut v; match v { &[x..] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, x..] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[x.., _] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } match v { &[_, x.., _] => println!("{:?}", x), - //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed + //~^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } drop(x); @@ -190,13 +169,11 @@ fn main() { let x = &mut e; match e { E::A(ref ax) => - //[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable - //[mir]~| ERROR cannot use `e` because it was mutably borrowed + //~^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable + //~| ERROR cannot use `e` because it was mutably borrowed println!("e.ax: {:?}", ax), E::B { x: ref bx } => - //[ast]~^ ERROR cannot borrow `e.x` as immutable because `e` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `e.x` as immutable because it is also borrowed as mutable println!("e.bx: {:?}", bx), } drop(x); @@ -209,15 +186,13 @@ fn main() { let x = &mut s; match s { S { y: (ref y0, _), .. } => - //[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable println!("y0: {:?}", y0), _ => panic!("other case"), } match s { S { x: F { y: ref x0, .. }, .. } => - //[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable println!("x0: {:?}", x0), _ => panic!("other case"), } @@ -233,8 +208,10 @@ fn main() { fn bump<'a>(mut block: &mut Block<'a>) { let x = &mut block; let p: &'a u8 = &*block.current; - //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable - // No errors in AST because of issue rust#38899 + //~^ WARNING cannot borrow `*block.current` as immutable because it is also borrowed as mutable + //~| this error has been downgraded + //~| this warning will become a hard error in the future + // Warning because of issue rust#38899 drop(x); } } @@ -248,8 +225,10 @@ fn main() { unsafe fn bump2(mut block: *mut Block2) { let x = &mut block; let p : *const u8 = &*(*block).current; - //[mir]~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable - // No errors in AST because of issue rust#38899 + //~^ WARNING cannot borrow `*block.current` as immutable because it is also borrowed as mutable + //~| this error has been downgraded + //~| this warning will become a hard error in the future + // Warning because of issue rust#38899 drop(x); } } @@ -259,9 +238,8 @@ fn main() { let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; let x = &mut v; v[0].y; - //[ast]~^ ERROR cannot use `v[..].y` because it was mutably borrowed - //[mir]~^^ ERROR cannot use `v[_].y` because it was mutably borrowed - //[mir]~| ERROR cannot use `*v` because it was mutably borrowed + //~^ ERROR cannot use `v[_].y` because it was mutably borrowed + //~| ERROR cannot use `*v` because it was mutably borrowed drop(x); } // Field of constant index @@ -271,8 +249,7 @@ fn main() { let x = &mut v; match v { &[_, F {x: ref xf, ..}] => println!("{}", xf), - //[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - // No errors in AST + //~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable _ => panic!("other case") } drop(x); @@ -282,8 +259,7 @@ fn main() { let mut x = 0; || { let y = &mut x; - &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time + &mut x; //~ ERROR cannot borrow `x` as mutable more than once at a time *y = 1; }; } @@ -291,10 +267,9 @@ fn main() { { let mut x = 0; || { - || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body + || { //~ ERROR captured variable cannot escape `FnMut` closure body let y = &mut x; - &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time - //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time + &mut x; //~ ERROR cannot borrow `x` as mutable more than once at a time *y = 1; drop(y); } @@ -304,8 +279,7 @@ fn main() { fn foo(x: Vec<i32>) { let c = || { drop(x); - drop(x); //[ast]~ ERROR use of moved value: `x` - //[mir]~^ ERROR use of moved value: `x` + drop(x); //~ ERROR use of moved value: `x` }; c(); } diff --git a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr b/src/test/ui/borrowck/borrowck-describe-lvalue.stderr index 1883da59ebb..fb42e5fbca8 100644 --- a/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-describe-lvalue.stderr @@ -1,34 +1,31 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:285:13 + --> $DIR/borrowck-describe-lvalue.rs:262:13 | LL | let y = &mut x; | ------ first mutable borrow occurs here LL | &mut x; | ^^^^^^ second mutable borrow occurs here -LL | LL | *y = 1; | ------ first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-describe-lvalue.rs:296:20 + --> $DIR/borrowck-describe-lvalue.rs:272:20 | LL | let y = &mut x; | ------ first mutable borrow occurs here LL | &mut x; | ^^^^^^ second mutable borrow occurs here -LL | LL | *y = 1; | ------ first borrow later used here error: captured variable cannot escape `FnMut` closure body - --> $DIR/borrowck-describe-lvalue.rs:294:16 + --> $DIR/borrowck-describe-lvalue.rs:270:16 | LL | || { | - inferred to be a `FnMut` closure LL | / || { LL | | let y = &mut x; LL | | &mut x; -LL | | LL | | *y = 1; LL | | drop(y); LL | | } @@ -38,96 +35,89 @@ LL | | } = note: ...therefore, they cannot allow references to captured variables to escape error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:43:9 + --> $DIR/borrowck-describe-lvalue.rs:41:9 | LL | let x = f.x(); | - borrow of `f` occurs here LL | f.x; | ^^^ use of borrowed `f` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:51:9 + --> $DIR/borrowck-describe-lvalue.rs:48:9 | LL | let x = g.x(); | - borrow of `g` occurs here LL | g.0; | ^^^ use of borrowed `g` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:59:9 + --> $DIR/borrowck-describe-lvalue.rs:55:9 | LL | let x = &mut h.0; | -------- borrow of `h.0` occurs here LL | h.0; | ^^^ use of borrowed `h.0` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:68:20 + --> $DIR/borrowck-describe-lvalue.rs:63:20 | LL | let x = e.x(); | - borrow of `e` occurs here LL | match e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `e` -... +LL | }; LL | drop(x); | - borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:78:9 + --> $DIR/borrowck-describe-lvalue.rs:71:9 | LL | let x = &mut u.a; | -------- borrow of `u.a` occurs here LL | u.a; | ^^^ use of borrowed `u.a` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `f.x` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:86:9 + --> $DIR/borrowck-describe-lvalue.rs:78:9 | LL | let x = f.x(); | - borrow of `*f` occurs here LL | f.x; | ^^^ use of borrowed `*f` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `g.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:94:9 + --> $DIR/borrowck-describe-lvalue.rs:85:9 | LL | let x = g.x(); | - borrow of `*g` occurs here LL | g.0; | ^^^ use of borrowed `*g` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `h.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:102:9 + --> $DIR/borrowck-describe-lvalue.rs:92:9 | LL | let x = &mut h.0; | -------- borrow of `h.0` occurs here LL | h.0; | ^^^ use of borrowed `h.0` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `e.0` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:111:20 + --> $DIR/borrowck-describe-lvalue.rs:100:20 | LL | let x = e.x(); | - borrow of `*e` occurs here @@ -139,18 +129,17 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:121:9 + --> $DIR/borrowck-describe-lvalue.rs:109:9 | LL | let x = &mut u.a; | -------- borrow of `u.a` occurs here LL | u.a; | ^^^ use of borrowed `u.a` -LL | LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:130:15 + --> $DIR/borrowck-describe-lvalue.rs:117:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -162,7 +151,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:136:18 + --> $DIR/borrowck-describe-lvalue.rs:122:18 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -174,7 +163,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:142:25 + --> $DIR/borrowck-describe-lvalue.rs:127:25 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -186,7 +175,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:148:28 + --> $DIR/borrowck-describe-lvalue.rs:132:28 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -198,7 +187,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:160:15 + --> $DIR/borrowck-describe-lvalue.rs:143:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -210,7 +199,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:166:18 + --> $DIR/borrowck-describe-lvalue.rs:148:18 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -222,7 +211,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:172:15 + --> $DIR/borrowck-describe-lvalue.rs:153:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -234,7 +223,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[..]` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:178:18 + --> $DIR/borrowck-describe-lvalue.rs:158:18 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -246,7 +235,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:192:13 + --> $DIR/borrowck-describe-lvalue.rs:171:13 | LL | let x = &mut e; | ------ borrow of `e` occurs here @@ -258,7 +247,7 @@ LL | drop(x); | - borrow later used here error[E0502]: cannot borrow `e.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:192:18 + --> $DIR/borrowck-describe-lvalue.rs:171:18 | LL | let x = &mut e; | ------ mutable borrow occurs here @@ -270,7 +259,7 @@ LL | drop(x); | - mutable borrow later used here error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:197:23 + --> $DIR/borrowck-describe-lvalue.rs:175:23 | LL | let x = &mut e; | ------ mutable borrow occurs here @@ -282,7 +271,7 @@ LL | drop(x); | - mutable borrow later used here error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:211:22 + --> $DIR/borrowck-describe-lvalue.rs:188:22 | LL | let x = &mut s; | ------ mutable borrow occurs here @@ -294,7 +283,7 @@ LL | drop(x); | - mutable borrow later used here error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:218:28 + --> $DIR/borrowck-describe-lvalue.rs:194:28 | LL | let x = &mut s; | ------ mutable borrow occurs here @@ -306,7 +295,7 @@ LL | drop(x); | - mutable borrow later used here error[E0503]: cannot use `*v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 + --> $DIR/borrowck-describe-lvalue.rs:240:9 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -317,7 +306,7 @@ LL | drop(x); | - borrow later used here error[E0503]: cannot use `v[_].y` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:261:9 + --> $DIR/borrowck-describe-lvalue.rs:240:9 | LL | let x = &mut v; | ------ borrow of `v` occurs here @@ -328,7 +317,7 @@ LL | drop(x); | - borrow later used here error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:273:24 + --> $DIR/borrowck-describe-lvalue.rs:251:24 | LL | let x = &mut v; | ------ mutable borrow occurs here @@ -340,7 +329,7 @@ LL | drop(x); | - mutable borrow later used here warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:235:29 + --> $DIR/borrowck-describe-lvalue.rs:210:29 | LL | let x = &mut block; | ---------- mutable borrow occurs here @@ -354,7 +343,7 @@ LL | drop(x); = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-describe-lvalue.rs:250:33 + --> $DIR/borrowck-describe-lvalue.rs:227:33 | LL | let x = &mut block; | ---------- mutable borrow occurs here @@ -368,7 +357,7 @@ LL | drop(x); = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future error[E0382]: use of moved value: `x` - --> $DIR/borrowck-describe-lvalue.rs:307:22 + --> $DIR/borrowck-describe-lvalue.rs:282:22 | LL | drop(x); | - value moved here diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr deleted file mode 100644 index 3195120cba2..00000000000 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function - --> $DIR/borrowck-escaping-closure-error-1.rs:13:11 - | -LL | spawn(|| books.push(4)); - | ^^ ----- `books` is borrowed here - | | - | may outlive borrowed value `books` - | -note: function requires argument type to outlive `'static` - --> $DIR/borrowck-escaping-closure-error-1.rs:13:5 - | -LL | spawn(|| books.push(4)); - | ^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword - | -LL | spawn(move || books.push(4)); - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr index 16ba61d9972..3195120cba2 100644 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr +++ b/src/test/ui/borrowck/borrowck-escaping-closure-error-1.stderr @@ -5,6 +5,12 @@ LL | spawn(|| books.push(4)); | ^^ ----- `books` is borrowed here | | | may outlive borrowed value `books` + | +note: function requires argument type to outlive `'static` + --> $DIR/borrowck-escaping-closure-error-1.rs:13:5 + | +LL | spawn(|| books.push(4)); + | ^^^^^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword | LL | spawn(move || books.push(4)); diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr deleted file mode 100644 index 3227aa9bb68..00000000000 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function - --> $DIR/borrowck-escaping-closure-error-2.rs:11:14 - | -LL | Box::new(|| books.push(4)) - | ^^ ----- `books` is borrowed here - | | - | may outlive borrowed value `books` - | -note: closure is returned here - --> $DIR/borrowck-escaping-closure-error-2.rs:11:5 - | -LL | Box::new(|| books.push(4)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword - | -LL | Box::new(move || books.push(4)) - | ^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr index 960f65da5f0..3227aa9bb68 100644 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr +++ b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.stderr @@ -5,6 +5,12 @@ LL | Box::new(|| books.push(4)) | ^^ ----- `books` is borrowed here | | | may outlive borrowed value `books` + | +note: closure is returned here + --> $DIR/borrowck-escaping-closure-error-2.rs:11:5 + | +LL | Box::new(|| books.push(4)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword | LL | Box::new(move || books.push(4)) diff --git a/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr b/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr deleted file mode 100644 index 89523235481..00000000000 --- a/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr +++ /dev/null @@ -1,132 +0,0 @@ -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:8:10 - | -LL | drop(x.b); - | --- value moved here -LL | drop(*x.b); - | ^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:14:10 - | -LL | let y = A { a: 3, .. x }; - | ---------------- value moved here -LL | drop(*x.b); - | ^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:20:13 - | -LL | drop(x.b); - | --- value moved here -LL | let p = &x.b; - | ^^^^ value borrowed here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:27:13 - | -LL | let _y = A { a: 3, .. x }; - | ---------------- value moved here -LL | let p = &x.b; - | ^^^^ value borrowed here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `x.b` because it is borrowed - --> $DIR/borrowck-field-sensitivity.rs:34:10 - | -LL | let p = &x.b; - | ---- borrow of `x.b` occurs here -LL | drop(x.b); - | ^^^ move out of `x.b` occurs here -LL | drop(**p); - | --- borrow later used here - -error[E0505]: cannot move out of `x.b` because it is borrowed - --> $DIR/borrowck-field-sensitivity.rs:41:14 - | -LL | let p = &x.b; - | ---- borrow of `x.b` occurs here -LL | let _y = A { a: 3, .. x }; - | ^^^^^^^^^^^^^^^^ move out of `x.b` occurs here -LL | drop(**p); - | --- borrow later used here - -error[E0499]: cannot borrow `x.a` as mutable more than once at a time - --> $DIR/borrowck-field-sensitivity.rs:48:13 - | -LL | let p = &mut x.a; - | -------- first mutable borrow occurs here -LL | let q = &mut x.a; - | ^^^^^^^^ second mutable borrow occurs here -LL | drop(*p); - | -- first borrow later used here - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:56:10 - | -LL | drop(x.b); - | --- value moved here -LL | drop(x.b); - | ^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:62:10 - | -LL | let _y = A { a: 3, .. x }; - | ---------------- value moved here -LL | drop(x.b); - | ^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:68:14 - | -LL | drop(x.b); - | --- value moved here -LL | let _z = A { a: 3, .. x }; - | ^^^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:74:14 - | -LL | let _y = A { a: 3, .. x }; - | ---------------- value moved here -LL | let _z = A { a: 4, .. x }; - | ^^^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/borrowck-field-sensitivity.rs:81:5 - | -LL | x.a = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/borrowck-field-sensitivity.rs:87:5 - | -LL | x.a = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/borrowck-field-sensitivity.rs:94:5 - | -LL | x.b = box 1; - | ^^^ use of possibly uninitialized `x` - -error: aborting due to 14 previous errors - -Some errors have detailed explanations: E0381, E0382, E0499, E0505. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-field-sensitivity.rs b/src/test/ui/borrowck/borrowck-field-sensitivity.rs index 1e9e6d68a51..88f74d1ed33 100644 --- a/src/test/ui/borrowck/borrowck-field-sensitivity.rs +++ b/src/test/ui/borrowck/borrowck-field-sensitivity.rs @@ -5,26 +5,26 @@ struct A { a: isize, b: Box<isize> } fn deref_after_move() { let x = A { a: 1, b: box 2 }; drop(x.b); - drop(*x.b); //~ ERROR use of moved value: `*x.b` + drop(*x.b); //~ ERROR use of moved value: `x.b` } fn deref_after_fu_move() { let x = A { a: 1, b: box 2 }; let y = A { a: 3, .. x }; - drop(*x.b); //~ ERROR use of moved value: `*x.b` + drop(*x.b); //~ ERROR use of moved value: `x.b` } fn borrow_after_move() { let x = A { a: 1, b: box 2 }; drop(x.b); - let p = &x.b; //~ ERROR use of moved value: `x.b` + let p = &x.b; //~ ERROR borrow of moved value: `x.b` drop(**p); } fn borrow_after_fu_move() { let x = A { a: 1, b: box 2 }; let _y = A { a: 3, .. x }; - let p = &x.b; //~ ERROR use of moved value: `x.b` + let p = &x.b; //~ ERROR borrow of moved value: `x.b` drop(**p); } @@ -78,21 +78,21 @@ fn fu_move_after_fu_move() { fn copy_after_field_assign_after_uninit() { let mut x: A; - x.a = 1; - drop(x.a); //~ ERROR use of possibly uninitialized variable: `x.a` + x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + drop(x.a); } fn borrow_after_field_assign_after_uninit() { let mut x: A; - x.a = 1; - let p = &x.a; //~ ERROR use of possibly uninitialized variable: `x.a` + x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + let p = &x.a; drop(*p); } fn move_after_field_assign_after_uninit() { let mut x: A; - x.b = box 1; - drop(x.b); //~ ERROR use of possibly uninitialized variable: `x.b` + x.b = box 1; //~ ERROR assign to part of possibly uninitialized variable: `x` + drop(x.b); } fn main() { diff --git a/src/test/ui/borrowck/borrowck-field-sensitivity.stderr b/src/test/ui/borrowck/borrowck-field-sensitivity.stderr index d345d0a2fb1..89523235481 100644 --- a/src/test/ui/borrowck/borrowck-field-sensitivity.stderr +++ b/src/test/ui/borrowck/borrowck-field-sensitivity.stderr @@ -1,4 +1,4 @@ -error[E0382]: use of moved value: `*x.b` +error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:8:10 | LL | drop(x.b); @@ -8,33 +8,33 @@ LL | drop(*x.b); | = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `*x.b` +error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:14:10 | LL | let y = A { a: 3, .. x }; - | - value moved here + | ---------------- value moved here LL | drop(*x.b); | ^^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:20:14 +error[E0382]: borrow of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:20:13 | LL | drop(x.b); | --- value moved here LL | let p = &x.b; - | ^^^ value used here after move + | ^^^^ value borrowed here after move | = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:27:14 +error[E0382]: borrow of moved value: `x.b` + --> $DIR/borrowck-field-sensitivity.rs:27:13 | LL | let _y = A { a: 3, .. x }; - | - value moved here + | ---------------- value moved here LL | let p = &x.b; - | ^^^ value used here after move + | ^^^^ value borrowed here after move | = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait @@ -42,28 +42,31 @@ error[E0505]: cannot move out of `x.b` because it is borrowed --> $DIR/borrowck-field-sensitivity.rs:34:10 | LL | let p = &x.b; - | --- borrow of `x.b` occurs here + | ---- borrow of `x.b` occurs here LL | drop(x.b); | ^^^ move out of `x.b` occurs here +LL | drop(**p); + | --- borrow later used here error[E0505]: cannot move out of `x.b` because it is borrowed - --> $DIR/borrowck-field-sensitivity.rs:41:27 + --> $DIR/borrowck-field-sensitivity.rs:41:14 | LL | let p = &x.b; - | --- borrow of `x.b` occurs here + | ---- borrow of `x.b` occurs here LL | let _y = A { a: 3, .. x }; - | ^ move out of `x.b` occurs here + | ^^^^^^^^^^^^^^^^ move out of `x.b` occurs here +LL | drop(**p); + | --- borrow later used here error[E0499]: cannot borrow `x.a` as mutable more than once at a time - --> $DIR/borrowck-field-sensitivity.rs:48:18 + --> $DIR/borrowck-field-sensitivity.rs:48:13 | LL | let p = &mut x.a; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let q = &mut x.a; - | ^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^ second mutable borrow occurs here +LL | drop(*p); + | -- first borrow later used here error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:56:10 @@ -79,49 +82,49 @@ error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:62:10 | LL | let _y = A { a: 3, .. x }; - | - value moved here + | ---------------- value moved here LL | drop(x.b); | ^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:68:27 + --> $DIR/borrowck-field-sensitivity.rs:68:14 | LL | drop(x.b); | --- value moved here LL | let _z = A { a: 3, .. x }; - | ^ value used here after move + | ^^^^^^^^^^^^^^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:74:27 + --> $DIR/borrowck-field-sensitivity.rs:74:14 | LL | let _y = A { a: 3, .. x }; - | - value moved here + | ---------------- value moved here LL | let _z = A { a: 4, .. x }; - | ^ value used here after move + | ^^^^^^^^^^^^^^^^ value used here after move | = note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait -error[E0381]: use of possibly uninitialized variable: `x.a` - --> $DIR/borrowck-field-sensitivity.rs:82:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:81:5 | -LL | drop(x.a); - | ^^^ use of possibly uninitialized `x.a` +LL | x.a = 1; + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x.a` - --> $DIR/borrowck-field-sensitivity.rs:88:14 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:87:5 | -LL | let p = &x.a; - | ^^^ use of possibly uninitialized `x.a` +LL | x.a = 1; + | ^^^^^^^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x.b` - --> $DIR/borrowck-field-sensitivity.rs:95:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:94:5 | -LL | drop(x.b); - | ^^^ use of possibly uninitialized `x.b` +LL | x.b = box 1; + | ^^^ use of possibly uninitialized `x` error: aborting due to 14 previous errors diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-a.mir.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-a.mir.stderr deleted file mode 100644 index 16c62fc1c7e..00000000000 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-fn-in-const-a.rs:9:16 - | -LL | return *x - | ^^ cannot move out of borrowed content - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-a.rs b/src/test/ui/borrowck/borrowck-fn-in-const-a.rs index 17663a30ca7..faa56cc7f2a 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.rs +++ b/src/test/ui/borrowck/borrowck-fn-in-const-a.rs @@ -1,13 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Check that we check fns appearing in constant declarations. // Issue #22382. const MOVE: fn(&String) -> String = { fn broken(x: &String) -> String { - return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] - //[mir]~^ ERROR [E0507] + return *x //~ ERROR cannot move out of borrowed content [E0507] } broken }; diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-a.stderr index 16c62fc1c7e..fff28359c14 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.stderr +++ b/src/test/ui/borrowck/borrowck-fn-in-const-a.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-fn-in-const-a.rs:9:16 + --> $DIR/borrowck-fn-in-const-a.rs:6:16 | LL | return *x | ^^ cannot move out of borrowed content diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr deleted file mode 100644 index d48866dce04..00000000000 --- a/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0713]: borrow may still be in use when destructor runs - --> $DIR/borrowck-fn-in-const-c.rs:17:16 - | -LL | return &local.inner; - | ^^^^^^^^^^^^ returning this value requires that `local.inner` is borrowed for `'static` -LL | } - | - here, drop of `local` needs exclusive access to `local.inner`, because the type `DropString` implements the `Drop` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-c.rs b/src/test/ui/borrowck/borrowck-fn-in-const-c.rs index d0a2e5b037d..c638cd08bc9 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-c.rs +++ b/src/test/ui/borrowck/borrowck-fn-in-const-c.rs @@ -14,7 +14,7 @@ impl Drop for DropString { const LOCAL_REF: fn() -> &'static str = { fn broken() -> &'static str { let local = DropString { inner: format!("Some local string") }; - return &local.inner; //~ ERROR does not live long enough + return &local.inner; //~ borrow may still be in use when destructor runs } broken }; diff --git a/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr index d2ddf808d11..d48866dce04 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr +++ b/src/test/ui/borrowck/borrowck-fn-in-const-c.stderr @@ -1,13 +1,11 @@ -error[E0597]: `local.inner` does not live long enough - --> $DIR/borrowck-fn-in-const-c.rs:17:17 +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/borrowck-fn-in-const-c.rs:17:16 | LL | return &local.inner; - | ^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^ returning this value requires that `local.inner` is borrowed for `'static` LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - here, drop of `local` needs exclusive access to `local.inner`, because the type `DropString` implements the `Drop` trait error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff --git a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr deleted file mode 100644 index 08cafa7da7a..00000000000 --- a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:15 - | -LL | for &a in x.iter() { - | -- ^^^^^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `a` - | -note: move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:10 - | -LL | for &a in x.iter() { - | ^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:15 - | -LL | for &a in &f.a { - | -- ^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `a` - | -note: move occurs because `a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:10 - | -LL | for &a in &f.a { - | ^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15 - | -LL | for &a in x.iter() { - | -- ^^^^^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `a` - | -note: move occurs because `a` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10 - | -LL | for &a in x.iter() { - | ^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr index fb53b13a58d..08cafa7da7a 100644 --- a/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr +++ b/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.stderr @@ -1,29 +1,47 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:9 + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:15 | LL | for &a in x.iter() { - | ^- + | -- ^^^^^^^^ cannot move out of borrowed content | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of borrowed content + | |data moved here + | help: consider removing the `&`: `a` + | +note: move occurs because `a` has type `&mut i32`, which does not implement the `Copy` trait + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:12:10 + | +LL | for &a in x.iter() { + | ^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:9 + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:15 | LL | for &a in &f.a { - | ^- + | -- ^^^^ cannot move out of borrowed content | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of borrowed content + | |data moved here + | help: consider removing the `&`: `a` + | +note: move occurs because `a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:18:10 + | +LL | for &a in &f.a { + | ^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:9 + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15 | LL | for &a in x.iter() { - | ^- + | -- ^^^^^^^^ cannot move out of borrowed content | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of borrowed content + | |data moved here + | help: consider removing the `&`: `a` + | +note: move occurs because `a` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10 + | +LL | for &a in x.iter() { + | ^ error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr deleted file mode 100644 index f47dce45369..00000000000 --- a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-for-loop-head-linkage.rs:7:9 - | -LL | for &x in &vector { - | ------- - | | - | immutable borrow occurs here - | immutable borrow later used here -LL | let cap = vector.capacity(); -LL | vector.extend(repeat(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here - -error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-for-loop-head-linkage.rs:8:9 - | -LL | for &x in &vector { - | ------- - | | - | immutable borrow occurs here - | immutable borrow later used here -... -LL | vector[1] = 5; - | ^^^^^^ mutable borrow occurs here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr index a2d8908c4dd..f47dce45369 100644 --- a/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr +++ b/src/test/ui/borrowck/borrowck-for-loop-head-linkage.stderr @@ -2,22 +2,22 @@ error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as i --> $DIR/borrowck-for-loop-head-linkage.rs:7:9 | LL | for &x in &vector { - | ------ - | | | - | | immutable borrow ends here - | immutable borrow occurs here + | ------- + | | + | immutable borrow occurs here + | immutable borrow later used here LL | let cap = vector.capacity(); LL | vector.extend(repeat(0)); - | ^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here error[E0502]: cannot borrow `vector` as mutable because it is also borrowed as immutable --> $DIR/borrowck-for-loop-head-linkage.rs:8:9 | LL | for &x in &vector { - | ------ - | | | - | | immutable borrow ends here - | immutable borrow occurs here + | ------- + | | + | immutable borrow occurs here + | immutable borrow later used here ... LL | vector[1] = 5; | ^^^^^^ mutable borrow occurs here diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr deleted file mode 100644 index 43c3c3371ff..00000000000 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `_a` because it is borrowed - --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:9:9 - | -LL | let b = &mut _a; - | -- borrow of `_a` occurs here -... -LL | _a = 4; - | ^^^^^^ assignment to borrowed `_a` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr deleted file mode 100644 index 88b43c1350b..00000000000 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `_a` because it is borrowed - --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:9:9 - | -LL | let b = &mut _a; - | ------- borrow of `_a` occurs here -... -LL | _a = 4; - | ^^^^^^ assignment to borrowed `_a` occurs here -... -LL | drop(b); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs index 334d2e008b9..97107c2e30f 100644 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs +++ b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs @@ -1,13 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let mut _a = 3; let b = &mut _a; { let c = &*b; - _a = 4; //[ast]~ ERROR cannot assign to `_a` - //[mir]~^ ERROR cannot assign to `_a` because it is borrowed + _a = 4; //~ ERROR cannot assign to `_a` because it is borrowed drop(c); } drop(b); diff --git a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr index 88b43c1350b..a66db05ccc5 100644 --- a/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.stderr @@ -1,5 +1,5 @@ error[E0506]: cannot assign to `_a` because it is borrowed - --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:9:9 + --> $DIR/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.rs:6:9 | LL | let b = &mut _a; | ------- borrow of `_a` occurs here diff --git a/src/test/ui/borrowck/borrowck-in-static.nll.stderr b/src/test/ui/borrowck/borrowck-in-static.nll.stderr deleted file mode 100644 index da639a837aa..00000000000 --- a/src/test/ui/borrowck/borrowck-in-static.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/borrowck-in-static.rs:5:17 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | Box::new(|| x) - | ^ cannot move out of captured variable in an `Fn` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-in-static.rs b/src/test/ui/borrowck/borrowck-in-static.rs index c08f4138bfb..43bb652a024 100644 --- a/src/test/ui/borrowck/borrowck-in-static.rs +++ b/src/test/ui/borrowck/borrowck-in-static.rs @@ -2,7 +2,7 @@ static FN : &'static (Fn() -> (Box<Fn()->Box<i32>>) + Sync) = &|| { let x = Box::new(0); - Box::new(|| x) //~ ERROR cannot move out of captured outer variable + Box::new(|| x) //~ ERROR cannot move out of captured variable in an `Fn` closure }; fn main() { diff --git a/src/test/ui/borrowck/borrowck-in-static.stderr b/src/test/ui/borrowck/borrowck-in-static.stderr index 6eeaf428c5f..da639a837aa 100644 --- a/src/test/ui/borrowck/borrowck-in-static.stderr +++ b/src/test/ui/borrowck/borrowck-in-static.stderr @@ -1,10 +1,10 @@ -error[E0507]: cannot move out of captured outer variable in an `Fn` closure +error[E0507]: cannot move out of captured variable in an `Fn` closure --> $DIR/borrowck-in-static.rs:5:17 | LL | let x = Box::new(0); | - captured outer variable LL | Box::new(|| x) - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr deleted file mode 100644 index 35649b1bb2a..00000000000 --- a/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `origin` - --> $DIR/borrowck-init-in-fru.rs:12:5 - | -LL | origin = Point { x: 10, ..origin }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `origin.y` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.ast.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.ast.stderr deleted file mode 100644 index 3ba01098766..00000000000 --- a/src/test/ui/borrowck/borrowck-init-in-fru.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `origin.y` - --> $DIR/borrowck-init-in-fru.rs:12:31 - | -LL | origin = Point { x: 10, ..origin }; - | ^^^^^^ use of possibly uninitialized `origin.y` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.rs b/src/test/ui/borrowck/borrowck-init-in-fru.rs index 9a06c7ab772..6da3098dc93 100644 --- a/src/test/ui/borrowck/borrowck-init-in-fru.rs +++ b/src/test/ui/borrowck/borrowck-init-in-fru.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #[derive(Clone)] struct Point { x: isize, @@ -10,7 +7,6 @@ struct Point { fn main() { let mut origin: Point; origin = Point { x: 10, ..origin }; - //[ast]~^ ERROR use of possibly uninitialized variable: `origin.y` [E0381] - //[mir]~^^ ERROR [E0381] + //~^ ERROR use of possibly uninitialized variable: `origin` [E0381] origin.clone(); } diff --git a/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.stderr index 35649b1bb2a..fe55bc2fd95 100644 --- a/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr +++ b/src/test/ui/borrowck/borrowck-init-in-fru.stderr @@ -1,5 +1,5 @@ error[E0381]: use of possibly uninitialized variable: `origin` - --> $DIR/borrowck-init-in-fru.rs:12:5 + --> $DIR/borrowck-init-in-fru.rs:9:5 | LL | origin = Point { x: 10, ..origin }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `origin.y` diff --git a/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr b/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr deleted file mode 100644 index 200ce8ff44e..00000000000 --- a/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0501]: cannot borrow `*f` as mutable because previous closure requires unique access - --> $DIR/borrowck-insert-during-each.rs:16:3 - | -LL | f.foo( - | ^ --- first borrow later used by call - | ___| - | | -LL | | |a| { - | | --- closure construction occurs here -LL | | f.n.insert(*a); - | | - first borrow occurs due to use of `f` in closure -LL | | }) - | |__________^ second borrow occurs here - -error[E0500]: closure requires unique access to `f` but it is already borrowed - --> $DIR/borrowck-insert-during-each.rs:17:9 - | -LL | f.foo( - | - --- first borrow later used by call - | | - | borrow occurs here -LL | |a| { - | ^^^ closure construction occurs here -LL | f.n.insert(*a); - | - second borrow occurs due to use of `f` in closure - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0500, E0501. -For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-insert-during-each.rs b/src/test/ui/borrowck/borrowck-insert-during-each.rs index 025da4d613d..df967e61189 100644 --- a/src/test/ui/borrowck/borrowck-insert-during-each.rs +++ b/src/test/ui/borrowck/borrowck-insert-during-each.rs @@ -13,7 +13,8 @@ impl Foo { } fn bar(f: &mut Foo) { - f.foo( + f.foo( + //~^ ERROR cannot borrow `*f` as mutable |a| { //~ ERROR closure requires unique access to `f` f.n.insert(*a); }) diff --git a/src/test/ui/borrowck/borrowck-insert-during-each.stderr b/src/test/ui/borrowck/borrowck-insert-during-each.stderr index 3b6339757c9..796390c093b 100644 --- a/src/test/ui/borrowck/borrowck-insert-during-each.stderr +++ b/src/test/ui/borrowck/borrowck-insert-during-each.stderr @@ -1,15 +1,32 @@ -error[E0500]: closure requires unique access to `f` but `*f` is already borrowed - --> $DIR/borrowck-insert-during-each.rs:17:9 +error[E0501]: cannot borrow `*f` as mutable because previous closure requires unique access + --> $DIR/borrowck-insert-during-each.rs:16:5 | -LL | f.foo( - | - borrow occurs here +LL | f.foo( + | ^ --- first borrow later used by call + | _____| + | | +LL | | +LL | | |a| { + | | --- closure construction occurs here +LL | | f.n.insert(*a); + | | - first borrow occurs due to use of `f` in closure +LL | | }) + | |__________^ second borrow occurs here + +error[E0500]: closure requires unique access to `f` but it is already borrowed + --> $DIR/borrowck-insert-during-each.rs:18:9 + | +LL | f.foo( + | - --- first borrow later used by call + | | + | borrow occurs here +LL | LL | |a| { | ^^^ closure construction occurs here LL | f.n.insert(*a); - | - borrow occurs due to use of `f` in closure -LL | }) - | - borrow ends here + | - second borrow occurs due to use of `f` in closure -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0500`. +Some errors have detailed explanations: E0500, E0501. +For more information about an error, try `rustc --explain E0500`. diff --git a/src/test/ui/borrowck/borrowck-issue-14498.ast.stderr b/src/test/ui/borrowck/borrowck-issue-14498.ast.stderr deleted file mode 100644 index 18391cfced7..00000000000 --- a/src/test/ui/borrowck/borrowck-issue-14498.ast.stderr +++ /dev/null @@ -1,82 +0,0 @@ -error[E0389]: cannot assign to data in a `&` reference - --> $DIR/borrowck-issue-14498.rs:19:5 - | -LL | ***p = 2; - | ^^^^^^^^ assignment into an immutable reference - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:29:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:40:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:51:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:62:5 - | -LL | let p = &y; - | - borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:73:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:84:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:95:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:106:5 - | -LL | let p = &y.a; - | --- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here - -error: aborting due to 9 previous errors - -Some errors have detailed explanations: E0389, E0506. -For more information about an error, try `rustc --explain E0389`. diff --git a/src/test/ui/borrowck/borrowck-issue-14498.mir.stderr b/src/test/ui/borrowck/borrowck-issue-14498.mir.stderr deleted file mode 100644 index 59576a2837e..00000000000 --- a/src/test/ui/borrowck/borrowck-issue-14498.mir.stderr +++ /dev/null @@ -1,107 +0,0 @@ -error[E0594]: cannot assign to `***p` which is behind a `&` reference - --> $DIR/borrowck-issue-14498.rs:19:5 - | -LL | let p = &y; - | -- help: consider changing this to be a mutable reference: `&mut y` -LL | ***p = 2; - | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:29:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:40:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:51:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:62:5 - | -LL | let p = &y; - | -- borrow of `**y` occurs here -LL | let q = &***p; -LL | **y = 2; - | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:73:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:84:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:95:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:106:5 - | -LL | let p = &y.a; - | ---- borrow of `**y.a` occurs here -LL | let q = &***p; -LL | **y.a = 2; - | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | -LL | drop(p); - | - borrow later used here - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-issue-14498.rs b/src/test/ui/borrowck/borrowck-issue-14498.rs index da62c5a9507..e8c9019264f 100644 --- a/src/test/ui/borrowck/borrowck-issue-14498.rs +++ b/src/test/ui/borrowck/borrowck-issue-14498.rs @@ -4,9 +4,6 @@ // Also includes tests of the errors reported when the Box in question // is immutable (#14270). -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] struct A { a: isize } @@ -16,8 +13,7 @@ fn indirect_write_to_imm_box() { let mut x: isize = 1; let y: Box<_> = box &mut x; let p = &y; - ***p = 2; //[ast]~ ERROR cannot assign to data in a `&` reference - //[mir]~^ ERROR cannot assign to `***p` + ***p = 2; //~ ERROR cannot assign to `***p` drop(p); } @@ -26,8 +22,7 @@ fn borrow_in_var_from_var() { let mut y: Box<_> = box &mut x; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -37,8 +32,7 @@ fn borrow_in_var_from_var_via_imm_box() { let y: Box<_> = box &mut x; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -48,8 +42,7 @@ fn borrow_in_var_from_field() { let mut y: Box<_> = box &mut x.a; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -59,8 +52,7 @@ fn borrow_in_var_from_field_via_imm_box() { let y: Box<_> = box &mut x.a; let p = &y; let q = &***p; - **y = 2; //[ast]~ ERROR cannot assign to `**y` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y` because it is borrowed + **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed drop(p); drop(q); } @@ -70,8 +62,7 @@ fn borrow_in_field_from_var() { let mut y = B { a: box &mut x }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -81,8 +72,7 @@ fn borrow_in_field_from_var_via_imm_box() { let y = B { a: box &mut x }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -92,8 +82,7 @@ fn borrow_in_field_from_field() { let mut y = B { a: box &mut x.a }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } @@ -103,8 +92,7 @@ fn borrow_in_field_from_field_via_imm_box() { let y = B { a: box &mut x.a }; let p = &y.a; let q = &***p; - **y.a = 2; //[ast]~ ERROR cannot assign to `**y.a` because it is borrowed - //[mir]~^ ERROR cannot assign to `**y.a` because it is borrowed + **y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed drop(p); drop(q); } diff --git a/src/test/ui/borrowck/borrowck-issue-14498.ast.nll.stderr b/src/test/ui/borrowck/borrowck-issue-14498.stderr index 59576a2837e..fec4c27520c 100644 --- a/src/test/ui/borrowck/borrowck-issue-14498.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-issue-14498.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `***p` which is behind a `&` reference - --> $DIR/borrowck-issue-14498.rs:19:5 + --> $DIR/borrowck-issue-14498.rs:16:5 | LL | let p = &y; | -- help: consider changing this to be a mutable reference: `&mut y` @@ -7,98 +7,90 @@ LL | ***p = 2; | ^^^^^^^^ `p` is a `&` reference, so the data it refers to cannot be written error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:29:5 + --> $DIR/borrowck-issue-14498.rs:25:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; LL | **y = 2; | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:40:5 + --> $DIR/borrowck-issue-14498.rs:35:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; LL | **y = 2; | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:51:5 + --> $DIR/borrowck-issue-14498.rs:45:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; LL | **y = 2; | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:62:5 + --> $DIR/borrowck-issue-14498.rs:55:5 | LL | let p = &y; | -- borrow of `**y` occurs here LL | let q = &***p; LL | **y = 2; | ^^^^^^^ assignment to borrowed `**y` occurs here -LL | LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:73:5 + --> $DIR/borrowck-issue-14498.rs:65:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; LL | **y.a = 2; | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:84:5 + --> $DIR/borrowck-issue-14498.rs:75:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; LL | **y.a = 2; | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:95:5 + --> $DIR/borrowck-issue-14498.rs:85:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; LL | **y.a = 2; | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | LL | drop(p); | - borrow later used here error[E0506]: cannot assign to `**y.a` because it is borrowed - --> $DIR/borrowck-issue-14498.rs:106:5 + --> $DIR/borrowck-issue-14498.rs:95:5 | LL | let p = &y.a; | ---- borrow of `**y.a` occurs here LL | let q = &***p; LL | **y.a = 2; | ^^^^^^^^^ assignment to borrowed `**y.a` occurs here -LL | LL | drop(p); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-issue-2657-1.nll.stderr b/src/test/ui/borrowck/borrowck-issue-2657-1.nll.stderr deleted file mode 100644 index 4ea4eb8f007..00000000000 --- a/src/test/ui/borrowck/borrowck-issue-2657-1.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-issue-2657-1.rs:9:18 - | -LL | Some(ref _y) => { - | ------ borrow of `x.0` occurs here -LL | let _a = x; - | ^ move out of `x` occurs here -LL | _y.use_ref(); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-issue-2657-1.stderr b/src/test/ui/borrowck/borrowck-issue-2657-1.stderr index d9ad86b4f88..4ea4eb8f007 100644 --- a/src/test/ui/borrowck/borrowck-issue-2657-1.stderr +++ b/src/test/ui/borrowck/borrowck-issue-2657-1.stderr @@ -1,10 +1,12 @@ error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-issue-2657-1.rs:9:13 + --> $DIR/borrowck-issue-2657-1.rs:9:18 | LL | Some(ref _y) => { | ------ borrow of `x.0` occurs here LL | let _a = x; - | ^^ move out of `x` occurs here + | ^ move out of `x` occurs here +LL | _y.use_ref(); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr b/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr deleted file mode 100644 index 4ef36df52df..00000000000 --- a/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-issue-2657-2.rs:7:18 - | -LL | let _b = *y; - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `y` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-issue-2657-2.stderr b/src/test/ui/borrowck/borrowck-issue-2657-2.stderr index 1314b1a14f4..4ef36df52df 100644 --- a/src/test/ui/borrowck/borrowck-issue-2657-2.stderr +++ b/src/test/ui/borrowck/borrowck-issue-2657-2.stderr @@ -5,7 +5,7 @@ LL | let _b = *y; | ^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*y` + | help: consider removing the `*`: `y` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr deleted file mode 100644 index 68a82bdb57c..00000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-lend-flow-if.rs:29:16 - | -LL | _w = &v; - | -- immutable borrow occurs here -LL | } -LL | borrow_mut(&mut *v); - | ^^^^^^^ mutable borrow occurs here -LL | _w.use_ref(); - | -- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-if.stderr b/src/test/ui/borrowck/borrowck-lend-flow-if.stderr index 1acd47ce58b..68a82bdb57c 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-if.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-if.stderr @@ -1,14 +1,13 @@ -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-if.rs:29:21 +error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-lend-flow-if.rs:29:16 | LL | _w = &v; - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | } LL | borrow_mut(&mut *v); - | ^^ mutable borrow occurs here + | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr deleted file mode 100644 index 83462ecd06b..00000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.ast.stderr +++ /dev/null @@ -1,93 +0,0 @@ -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:35:17 - | -LL | let mut x = &mut v; - | - mutable borrow occurs here -... -LL | borrow(&*v); - | ^^ immutable borrow occurs here -LL | } -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:45:17 - | -LL | let mut x = &mut v; - | - mutable borrow occurs here -LL | for _ in 0..3 { -LL | borrow(&*v); - | ^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:57:25 - | -LL | borrow_mut(&mut *v); - | ^^ mutable borrow occurs here -LL | _x = &v; - | - immutable borrow occurs here -LL | } -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:69:25 - | -LL | borrow_mut(&mut *v); - | ^^ mutable borrow occurs here -LL | _x = &v; - | - immutable borrow occurs here -LL | } -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:86:21 - | -LL | _x = &v; - | - immutable borrow occurs here -... -LL | borrow_mut(&mut *v); - | ^^ mutable borrow occurs here -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-loop.rs:100:21 - | -LL | _x = &v; - | - immutable borrow occurs here -... -LL | borrow_mut(&mut *v); - | ^^ mutable borrow occurs here -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:109:17 - | -LL | borrow(&*v); - | ^^ immutable borrow occurs here -... -LL | x = &mut v; - | - mutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/borrowck-lend-flow-loop.rs:112:22 - | -LL | x = &mut v; - | ^ mutable borrow starts here in previous iteration of loop -... -LL | } - | - mutable borrow ends here - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.rs b/src/test/ui/borrowck/borrowck-lend-flow-loop.rs index 7008e5cef4b..b650df91ca2 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.rs +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.rs @@ -1,19 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// Note: the borrowck analysis was originally a flow-insensitive pass -// over the AST. Therefore, some of these (AST) errors are marked as -// spurious and are corrected by the flow-sensitive (NLL) analysis. -// The others are either genuine or would require more advanced -// changes. The latter cases are noted. - #![feature(box_syntax)] fn borrow(_v: &isize) {} @@ -26,13 +10,13 @@ fn inc(v: &mut Box<isize>) { } fn loop_overarching_alias_mut() { - // In this instance, the borrow encompasses the entire loop. + // In this instance, the borrow ends on the line before the loop let mut v: Box<_> = box 3; let mut x = &mut v; **x += 1; loop { - borrow(&*v); //[ast]~ ERROR cannot borrow + borrow(&*v); // OK } } @@ -42,38 +26,37 @@ fn block_overarching_alias_mut() { let mut v: Box<_> = box 3; let mut x = &mut v; for _ in 0..3 { - borrow(&*v); //[ast]~ ERROR cannot borrow - //[nll]~^ ERROR cannot borrow + borrow(&*v); //~ ERROR cannot borrow } *x = box 5; } fn loop_aliased_mut() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; let mut _x = &w; loop { - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK _x = &v; } } fn while_aliased_mut() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; let mut _x = &w; while cond() { - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK _x = &v; } } fn loop_aliased_mut_break() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; @@ -83,11 +66,11 @@ fn loop_aliased_mut_break() { _x = &v; break; } - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK } fn while_aliased_mut_break() { - // In this instance, the borrow is carried through the loop. + // In this instance, the borrow ends right after each assignment to _x let mut v: Box<_> = box 3; let mut w: Box<_> = box 4; @@ -97,7 +80,7 @@ fn while_aliased_mut_break() { _x = &v; break; } - borrow_mut(&mut *v); //[ast]~ ERROR cannot borrow + borrow_mut(&mut *v); // OK } fn while_aliased_mut_cond(cond: bool, cond2: bool) { @@ -106,10 +89,9 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) { let mut x = &mut w; while cond { **x += 1; - borrow(&*v); //[ast]~ ERROR cannot borrow - //[nll]~^ ERROR cannot borrow + borrow(&*v); //~ ERROR cannot borrow if cond2 { - x = &mut v; //[ast]~ ERROR cannot borrow + x = &mut v; // OK } } } diff --git a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-loop.stderr index 6dd6c1fc26a..f02c357f48b 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-loop.stderr @@ -1,24 +1,24 @@ error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:45:16 + --> $DIR/borrowck-lend-flow-loop.rs:29:16 | LL | let mut x = &mut v; | ------ mutable borrow occurs here LL | for _ in 0..3 { LL | borrow(&*v); | ^^^ immutable borrow occurs here -... +LL | } LL | *x = box 5; | -- mutable borrow later used here error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-lend-flow-loop.rs:109:16 + --> $DIR/borrowck-lend-flow-loop.rs:92:16 | LL | **x += 1; | -------- mutable borrow later used here LL | borrow(&*v); | ^^^ immutable borrow occurs here -... -LL | x = &mut v; +LL | if cond2 { +LL | x = &mut v; // OK | ------ mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.stderr deleted file mode 100644 index 734f965195c..00000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-lend-flow-match.rs:18:13 - | -LL | Some(ref r) => { - | ----- borrow of `x` occurs here -LL | x = Some(1); - | ^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | -LL | drop(r); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.ast.stderr deleted file mode 100644 index 236bc11f2bb..00000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-lend-flow-match.rs:18:13 - | -LL | Some(ref r) => { - | ----- borrow of `x` occurs here -LL | x = Some(1); - | ^^^^^^^^^^^ assignment to borrowed `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.rs b/src/test/ui/borrowck/borrowck-lend-flow-match.rs index 4cd2a239b4e..9737bc7695d 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.rs +++ b/src/test/ui/borrowck/borrowck-lend-flow-match.rs @@ -1,11 +1,5 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![allow(unused_variables)] -#![allow(unused_assignments)] - fn separate_arms() { - // Here both arms perform assignments, but only is illegal. + // Here both arms perform assignments, but only one is illegal. let mut x = None; match x { @@ -15,12 +9,10 @@ fn separate_arms() { x = Some(0); } Some(ref r) => { - x = Some(1); //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = Some(1); //~ ERROR cannot assign to `x` because it is borrowed drop(r); } } - x.clone(); // just to prevent liveness warnings } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-lend-flow-match.mir.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.stderr index 734f965195c..66f1cd9bd56 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.mir.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow-match.stderr @@ -1,11 +1,10 @@ error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-lend-flow-match.rs:18:13 + --> $DIR/borrowck-lend-flow-match.rs:12:13 | LL | Some(ref r) => { | ----- borrow of `x` occurs here LL | x = Some(1); | ^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | LL | drop(r); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr deleted file mode 100644 index 07b11b3e728..00000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-lend-flow.rs:24:16 - | -LL | let _w = &v; - | -- immutable borrow occurs here -LL | borrow_mut(&mut *v); - | ^^^^^^^ mutable borrow occurs here -LL | _w.use_ref(); - | -- immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-lend-flow.stderr b/src/test/ui/borrowck/borrowck-lend-flow.stderr index e39fb6c8600..07b11b3e728 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow.stderr +++ b/src/test/ui/borrowck/borrowck-lend-flow.stderr @@ -1,13 +1,12 @@ -error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow.rs:24:21 +error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-lend-flow.rs:24:16 | LL | let _w = &v; - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | borrow_mut(&mut *v); - | ^^ mutable borrow occurs here + | ^^^^^^^ mutable borrow occurs here LL | _w.use_ref(); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.nll.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.nll.stderr deleted file mode 100644 index 4497cfb71d1..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:14:19 - | -LL | let w = &v; - | -- borrow of `v` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `v` occurs here -LL | println!("v={}", *v); - | - move occurs due to use in closure -... -LL | w.use_ref(); - | - borrow later used here - -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 - | -LL | let w = &v; - | -- borrow of `v` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `v` occurs here -LL | println!("v={}", *v); - | - move occurs due to use in closure -... -LL | w.use_ref(); - | - borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs index 29a20473f48..9fa46563fdf 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs +++ b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.rs @@ -12,8 +12,8 @@ fn box_imm() { let v: Box<_> = box 3; let w = &v; thread::spawn(move|| { + //~^ ERROR cannot move out of `v` because it is borrowed println!("v={}", *v); - //~^ ERROR cannot move `v` into closure }); w.use_ref(); } @@ -22,8 +22,8 @@ fn box_imm_explicit() { let v: Box<_> = box 3; let w = &v; thread::spawn(move|| { + //~^ ERROR cannot move println!("v={}", *v); - //~^ ERROR cannot move }); w.use_ref(); } diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr index b170635b4b9..2acbcd94f8b 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr +++ b/src/test/ui/borrowck/borrowck-loan-blocks-move-cc.stderr @@ -1,21 +1,31 @@ -error[E0504]: cannot move `v` into closure because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:15:27 +error[E0505]: cannot move out of `v` because it is borrowed + --> $DIR/borrowck-loan-blocks-move-cc.rs:14:19 | LL | let w = &v; - | - borrow of `v` occurs here + | -- borrow of `v` occurs here LL | thread::spawn(move|| { + | ^^^^^^ move out of `v` occurs here +LL | LL | println!("v={}", *v); - | ^ move into closure occurs here + | - move occurs due to use in closure +LL | }); +LL | w.use_ref(); + | - borrow later used here -error[E0504]: cannot move `v` into closure because it is borrowed - --> $DIR/borrowck-loan-blocks-move-cc.rs:25:27 +error[E0505]: cannot move out of `v` because it is borrowed + --> $DIR/borrowck-loan-blocks-move-cc.rs:24:19 | LL | let w = &v; - | - borrow of `v` occurs here + | -- borrow of `v` occurs here LL | thread::spawn(move|| { + | ^^^^^^ move out of `v` occurs here +LL | LL | println!("v={}", *v); - | ^ move into closure occurs here + | - move occurs due to use in closure +LL | }); +LL | w.use_ref(); + | - borrow later used here error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0504`. +For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move.nll.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move.nll.stderr deleted file mode 100644 index 615660febbc..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/borrowck-loan-blocks-move.rs:11:10 - | -LL | let w = &v; - | -- borrow of `v` occurs here -LL | take(v); - | ^ move out of `v` occurs here -LL | w.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr index e6f0a691eca..615660febbc 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr +++ b/src/test/ui/borrowck/borrowck-loan-blocks-move.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `v` because it is borrowed --> $DIR/borrowck-loan-blocks-move.rs:11:10 | LL | let w = &v; - | - borrow of `v` occurs here + | -- borrow of `v` occurs here LL | take(v); | ^ move out of `v` occurs here +LL | w.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr deleted file mode 100644 index 1d1522a15b1..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-loan-blocks-mut-uniq.rs:10:12 - | -LL | borrow(&*v, - | ------ --- immutable borrow occurs here - | | - | immutable borrow later used by call -LL | |w| { - | ^^^ mutable borrow occurs here -LL | v = box 4; - | - second borrow occurs due to use of `v` in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr index c916b7efc08..1d1522a15b1 100644 --- a/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr +++ b/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.stderr @@ -1,15 +1,14 @@ -error[E0502]: cannot borrow `v` as mutable because `*v` is also borrowed as immutable +error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-blocks-mut-uniq.rs:10:12 | LL | borrow(&*v, - | -- immutable borrow occurs here + | ------ --- immutable borrow occurs here + | | + | immutable borrow later used by call LL | |w| { | ^^^ mutable borrow occurs here LL | v = box 4; - | - borrow occurs due to use of `v` in closure -... -LL | }) - | - immutable borrow ends here + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.nll.stderr b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.nll.stderr deleted file mode 100644 index 095ae7f56b2..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/borrowck-loan-in-overloaded-op.rs:21:20 - | -LL | let x = Foo(box 3); - | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait -LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur - | - ^ value borrowed here after move - | | - | value moved here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs index 464f01ca74c..1baa94edfbe 100644 --- a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs +++ b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.rs @@ -19,5 +19,5 @@ impl Add for Foo { fn main() { let x = Foo(box 3); let _y = {x} + x.clone(); // the `{x}` forces a move to occur - //~^ ERROR use of moved value: `x` + //~^ ERROR borrow of moved value: `x` } diff --git a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr index b6147aae8da..095ae7f56b2 100644 --- a/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr +++ b/src/test/ui/borrowck/borrowck-loan-in-overloaded-op.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/borrowck-loan-in-overloaded-op.rs:21:20 | +LL | let x = Foo(box 3); + | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur - | - ^ value used here after move + | - ^ value borrowed here after move | | | value moved here - | - = note: move occurs because `x` has type `Foo`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr b/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr deleted file mode 100644 index 6994c837dfc..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `*s` because it is borrowed - --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:16:5 - | -LL | let alias: &'static mut String = s; - | ------------------- - borrow of `*s` occurs here - | | - | type annotation requires that `*s` is borrowed for `'static` -... -LL | *s = String::new(); - | ^^ assignment to borrowed `*s` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr b/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr index c9d36a7f938..6994c837dfc 100644 --- a/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr +++ b/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.stderr @@ -2,10 +2,12 @@ error[E0506]: cannot assign to `*s` because it is borrowed --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:16:5 | LL | let alias: &'static mut String = s; - | - borrow of `*s` occurs here + | ------------------- - borrow of `*s` occurs here + | | + | type annotation requires that `*s` is borrowed for `'static` ... LL | *s = String::new(); - | ^^^^^^^^^^^^^^^^^^ assignment to borrowed `*s` occurs here + | ^^ assignment to borrowed `*s` occurs here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr deleted file mode 100644 index aa874c34a22..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0503]: cannot use `p` because it was mutably borrowed - --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:38:5 - | -LL | let q = &mut p; - | ------ borrow of `p` occurs here -LL | -LL | p + 3; - | ^ use of borrowed `p` -... -LL | *q + 3; // OK to use the new alias `q` - | -- borrow later used here - -error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:39:5 - | -LL | let q = &mut p; - | ------ mutable borrow occurs here -... -LL | p.times(3); - | ^ immutable borrow occurs here -LL | -LL | *q + 3; // OK to use the new alias `q` - | -- mutable borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0502, E0503. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr index fee3c7992ea..aa874c34a22 100644 --- a/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr +++ b/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.stderr @@ -2,22 +2,25 @@ error[E0503]: cannot use `p` because it was mutably borrowed --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:38:5 | LL | let q = &mut p; - | - borrow of `p` occurs here + | ------ borrow of `p` occurs here LL | LL | p + 3; | ^ use of borrowed `p` +... +LL | *q + 3; // OK to use the new alias `q` + | -- borrow later used here error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable --> $DIR/borrowck-loan-rcvr-overloaded-op.rs:39:5 | LL | let q = &mut p; - | - mutable borrow occurs here + | ------ mutable borrow occurs here ... LL | p.times(3); | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here +LL | +LL | *q + 3; // OK to use the new alias `q` + | -- mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr deleted file mode 100644 index ec3edc80323..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-loan-rcvr.rs:23:14 - | -LL | p.blockm(|| { - | - ------ ^^ mutable borrow occurs here - | | | - | | immutable borrow later used by call - | immutable borrow occurs here -LL | p.x = 10; - | - second borrow occurs due to use of `p` in closure - -error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-loan-rcvr.rs:34:5 - | -LL | let l = &mut p; - | ------ mutable borrow occurs here -LL | p.impurem(); - | ^ immutable borrow occurs here -LL | -LL | l.x += 1; - | -------- mutable borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-rcvr.stderr b/src/test/ui/borrowck/borrowck-loan-rcvr.stderr index 56d33eff73f..ec3edc80323 100644 --- a/src/test/ui/borrowck/borrowck-loan-rcvr.stderr +++ b/src/test/ui/borrowck/borrowck-loan-rcvr.stderr @@ -2,24 +2,23 @@ error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immuta --> $DIR/borrowck-loan-rcvr.rs:23:14 | LL | p.blockm(|| { - | - ^^ mutable borrow occurs here - | | + | - ------ ^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call | immutable borrow occurs here LL | p.x = 10; - | - borrow occurs due to use of `p` in closure -LL | }) - | - immutable borrow ends here + | - second borrow occurs due to use of `p` in closure error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable --> $DIR/borrowck-loan-rcvr.rs:34:5 | LL | let l = &mut p; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | p.impurem(); | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here +LL | +LL | l.x += 1; + | -------- mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr b/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr deleted file mode 100644 index 6691a2396a1..00000000000 --- a/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-loan-vec-content.rs:18:9 - | -LL | takes_imm_elt( - | ------------- immutable borrow later used by call -LL | &v[0], - | - immutable borrow occurs here -LL | || { - | ^^ mutable borrow occurs here -LL | v[1] = 4; - | - second borrow occurs due to use of `v` in closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-loan-vec-content.stderr b/src/test/ui/borrowck/borrowck-loan-vec-content.stderr index eea6a09f0fc..6691a2396a1 100644 --- a/src/test/ui/borrowck/borrowck-loan-vec-content.stderr +++ b/src/test/ui/borrowck/borrowck-loan-vec-content.stderr @@ -1,14 +1,14 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-vec-content.rs:18:9 | +LL | takes_imm_elt( + | ------------- immutable borrow later used by call LL | &v[0], | - immutable borrow occurs here LL | || { | ^^ mutable borrow occurs here LL | v[1] = 4; - | - borrow occurs due to use of `v` in closure -LL | }) - | - immutable borrow ends here + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr deleted file mode 100644 index 6eda8a439ba..00000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/borrowck-local-borrow-outlives-fn.rs:5:6 - | -LL | &x - | ^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr deleted file mode 100644 index df89e85ebe2..00000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0515]: cannot return reference to function parameter `x` - --> $DIR/borrowck-local-borrow-outlives-fn.rs:5:5 - | -LL | &x - | ^^ returns a reference to data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs index 6137ac914dd..b6eebd4e325 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs +++ b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn cplusplus_mode(x: isize) -> &'static isize { &x - //[ast]~^ ERROR `x` does not live long enough [E0597] - //[mir]~^^ ERROR cannot return reference to function parameter `x` [E0515] + //~^ ERROR cannot return reference to function parameter `x` [E0515] } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.stderr index df89e85ebe2..9d19de211a5 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.stderr @@ -1,5 +1,5 @@ error[E0515]: cannot return reference to function parameter `x` - --> $DIR/borrowck-local-borrow-outlives-fn.rs:5:5 + --> $DIR/borrowck-local-borrow-outlives-fn.rs:2:5 | LL | &x | ^^ returns a reference to data owned by the current function diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr deleted file mode 100644 index ac9e73fadec..00000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `z.1` does not live long enough - --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:6:15 - | -LL | *x = Some(&mut z.1); - | ----------^^^^^^^^- - | | | - | | borrowed value does not live long enough - | assignment requires that `z.1` is borrowed for `'static` -... -LL | } - | - `z.1` dropped here while still borrowed - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr deleted file mode 100644 index 89a0e6cd829..00000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `z.1` does not live long enough - --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:6:20 - | -LL | *x = Some(&mut z.1); - | ^^^ borrowed value does not live long enough -... -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs index 9ead465eada..ffb2da28023 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs +++ b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.rs @@ -1,11 +1,7 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn cplusplus_mode_exceptionally_unsafe(x: &mut Option<&'static mut isize>) { let mut z = (0, 0); *x = Some(&mut z.1); - //[ast]~^ ERROR `z.1` does not live long enough [E0597] - //[mir]~^^ ERROR `z.1` does not live long enough [E0597] + //~^ ERROR `z.1` does not live long enough [E0597] panic!("catch me for a dangling pointer!") } diff --git a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr index ac9e73fadec..6ea6951ad96 100644 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr +++ b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr @@ -1,5 +1,5 @@ error[E0597]: `z.1` does not live long enough - --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:6:15 + --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:3:15 | LL | *x = Some(&mut z.1); | ----------^^^^^^^^- diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr b/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr deleted file mode 100644 index ecbfeec822c..00000000000 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error[E0503]: cannot use `foo` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:13:9 - | -LL | let p = &mut foo; - | -------- borrow of `foo` occurs here -LL | let _ = match foo { -LL | Foo::B => 1, - | ^^^^^^ use of borrowed `foo` -... -LL | drop(p); - | - borrow later used here - -error[E0503]: cannot use `foo.0` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:15:16 - | -LL | let p = &mut foo; - | -------- borrow of `foo` occurs here -... -LL | Foo::A(x) => x - | ^ use of borrowed `foo` -... -LL | drop(p); - | - borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:26:9 - | -LL | let r = &mut x; - | ------ borrow of `x` occurs here -LL | let _ = match x { -LL | x => x + 1, - | ^ use of borrowed `x` -... -LL | drop(r); - | - borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:28:9 - | -LL | let r = &mut x; - | ------ borrow of `x` occurs here -... -LL | y => y + 2, - | ^ use of borrowed `x` -... -LL | drop(r); - | - borrow later used here - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr b/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr deleted file mode 100644 index a5da1fc5b20..00000000000 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0503]: cannot use `(foo as Foo::A).0` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:15:16 - | -LL | let p = &mut foo; - | --- borrow of `foo` occurs here -... -LL | Foo::A(x) => x - | ^ use of borrowed `foo` - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:26:9 - | -LL | let r = &mut x; - | - borrow of `x` occurs here -LL | let _ = match x { -LL | x => x + 1, - | ^ use of borrowed `x` - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:28:9 - | -LL | let r = &mut x; - | - borrow of `x` occurs here -... -LL | y => y + 2, - | ^ use of borrowed `x` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.rs b/src/test/ui/borrowck/borrowck-match-already-borrowed.rs index 7f4cdbd0e7c..c766e6c1080 100644 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.rs +++ b/src/test/ui/borrowck/borrowck-match-already-borrowed.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - enum Foo { A(i32), B @@ -10,10 +7,9 @@ fn match_enum() { let mut foo = Foo::B; let p = &mut foo; let _ = match foo { - Foo::B => 1, //[mir]~ ERROR [E0503] + Foo::B => 1, //~ ERROR [E0503] _ => 2, - Foo::A(x) => x //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] + Foo::A(x) => x //~ ERROR [E0503] }; drop(p); } @@ -23,10 +19,8 @@ fn main() { let mut x = 1; let r = &mut x; let _ = match x { - x => x + 1, //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] - y => y + 2, //[ast]~ ERROR [E0503] - //[mir]~^ ERROR [E0503] + x => x + 1, //~ ERROR [E0503] + y => y + 2, //~ ERROR [E0503] }; drop(r); } diff --git a/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr b/src/test/ui/borrowck/borrowck-match-already-borrowed.stderr index ecbfeec822c..286a925bb7f 100644 --- a/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr +++ b/src/test/ui/borrowck/borrowck-match-already-borrowed.stderr @@ -1,5 +1,5 @@ error[E0503]: cannot use `foo` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:13:9 + --> $DIR/borrowck-match-already-borrowed.rs:10:9 | LL | let p = &mut foo; | -------- borrow of `foo` occurs here @@ -11,19 +11,19 @@ LL | drop(p); | - borrow later used here error[E0503]: cannot use `foo.0` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:15:16 + --> $DIR/borrowck-match-already-borrowed.rs:12:16 | LL | let p = &mut foo; | -------- borrow of `foo` occurs here ... LL | Foo::A(x) => x | ^ use of borrowed `foo` -... +LL | }; LL | drop(p); | - borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:26:9 + --> $DIR/borrowck-match-already-borrowed.rs:22:9 | LL | let r = &mut x; | ------ borrow of `x` occurs here @@ -35,14 +35,14 @@ LL | drop(r); | - borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:28:9 + --> $DIR/borrowck-match-already-borrowed.rs:23:9 | LL | let r = &mut x; | ------ borrow of `x` occurs here ... LL | y => y + 2, | ^ use of borrowed `x` -... +LL | }; LL | drop(r); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.stderr deleted file mode 100644 index 5f43302e0ef..00000000000 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:17:13 - | -LL | x => { - | - first assignment to `x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:24:13 - | -LL | E::Foo(x) => { - | - first assignment to `x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:31:13 - | -LL | S { bar: x } => { - | - first assignment to `x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 - | -LL | (x,) => { - | - first assignment to `x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:45:13 - | -LL | [x,_,_] => { - | - first assignment to `x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.stderr deleted file mode 100644 index 2ac05393e02..00000000000 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:17:13 - | -LL | x => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:24:13 - | -LL | E::Foo(x) => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:31:13 - | -LL | S { bar: x } => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 - | -LL | (x,) => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:45:13 - | -LL | [x,_,_] => { - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs index 2c9c41ca10e..064bf69ae79 100644 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs +++ b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Test that immutable pattern bindings cannot be reassigned. enum E { @@ -14,36 +11,31 @@ struct S { pub fn main() { match 1 { x => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match E::Foo(1) { E::Foo(x) => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match (S { bar: 1 }) { S { bar: x } => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match (1,) { (x,) => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } match [1,2,3] { [x,_,_] => { - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable `x` - //[mir]~^ ERROR [E0384] + x += 1; //~ ERROR [E0384] } } } diff --git a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr index 2ac05393e02..5661ca52cba 100644 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr @@ -1,5 +1,5 @@ error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:17:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:14:13 | LL | x => { | - @@ -10,7 +10,7 @@ LL | x += 1; | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:24:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:20:13 | LL | E::Foo(x) => { | - @@ -21,7 +21,7 @@ LL | x += 1; | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:31:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:26:13 | LL | S { bar: x } => { | - @@ -32,7 +32,7 @@ LL | x += 1; | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:32:13 | LL | (x,) => { | - @@ -43,7 +43,7 @@ LL | x += 1; | ^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-match-binding-is-assignment.rs:45:13 + --> $DIR/borrowck-match-binding-is-assignment.rs:38:13 | LL | [x,_,_] => { | - diff --git a/src/test/ui/borrowck/borrowck-move-by-capture.nll.stderr b/src/test/ui/borrowck/borrowck-move-by-capture.nll.stderr deleted file mode 100644 index 38f6ca7be75..00000000000 --- a/src/test/ui/borrowck/borrowck-move-by-capture.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/borrowck-move-by-capture.rs:9:29 - | -LL | let bar: Box<_> = box 3; - | --- captured outer variable -LL | let _g = to_fn_mut(|| { -LL | let _h = to_fn_once(move || -> isize { *bar }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of captured variable in an `FnMut` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-by-capture.stderr b/src/test/ui/borrowck/borrowck-move-by-capture.stderr index d845a576b3d..38f6ca7be75 100644 --- a/src/test/ui/borrowck/borrowck-move-by-capture.stderr +++ b/src/test/ui/borrowck/borrowck-move-by-capture.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of captured outer variable in an `FnMut` closure +error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/borrowck-move-by-capture.rs:9:29 | LL | let bar: Box<_> = box 3; | --- captured outer variable LL | let _g = to_fn_mut(|| { LL | let _h = to_fn_once(move || -> isize { *bar }); - | ^^^^^^^^^^^^^^^^ cannot move out of captured outer variable in an `FnMut` closure + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of captured variable in an `FnMut` closure error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr b/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr deleted file mode 100644 index de75210fcd2..00000000000 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-error-with-note.rs:11:11 - | -LL | match *f { - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `f` -LL | -LL | Foo::Foo1(num1, - | ---- data moved here -LL | num2) => (), - | ---- ...and here -LL | Foo::Foo2(num) => (), - | --- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-move-error-with-note.rs:13:19 - | -LL | Foo::Foo1(num1, - | ^^^^ -LL | num2) => (), - | ^^^^ -LL | Foo::Foo2(num) => (), - | ^^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-error-with-note.rs:29:11 - | -LL | match (S {f: "foo".to_string(), g: "bar".to_string()}) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here -... -LL | f: _s, - | -- data moved here -LL | g: _t - | -- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-move-error-with-note.rs:32:16 - | -LL | f: _s, - | ^^ -LL | g: _t - | ^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-error-with-note.rs:47:11 - | -LL | match a.a { - | ^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&a.a` -LL | -LL | n => { - | - data moved here - | -note: move occurs because `n` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-error-with-note.rs:49:9 - | -LL | n => { - | ^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0507, E0509. -For more information about an error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.rs b/src/test/ui/borrowck/borrowck-move-error-with-note.rs index d2dab2eacca..b21f13a983c 100644 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.rs +++ b/src/test/ui/borrowck/borrowck-move-error-with-note.rs @@ -27,8 +27,9 @@ impl Drop for S { fn move_in_match() { match (S {f: "foo".to_string(), g: "bar".to_string()}) { - S { //~ ERROR cannot move out of type `S`, which implements the `Drop` trait + //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait //~| cannot move out of here + S { f: _s, g: _t } => {} diff --git a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr index 55edb79296e..8438320891c 100644 --- a/src/test/ui/borrowck/borrowck-move-error-with-note.stderr +++ b/src/test/ui/borrowck/borrowck-move-error-with-note.stderr @@ -2,35 +2,64 @@ error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-move-error-with-note.rs:11:11 | LL | match *f { - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `f` LL | LL | Foo::Foo1(num1, - | ---- hint: to prevent move, use `ref num1` or `ref mut num1` + | ---- data moved here LL | num2) => (), - | ---- ...and here (use `ref num2` or `ref mut num2`) + | ---- ...and here LL | Foo::Foo2(num) => (), - | --- ...and here (use `ref num` or `ref mut num`) + | --- ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-move-error-with-note.rs:13:19 + | +LL | Foo::Foo1(num1, + | ^^^^ +LL | num2) => (), + | ^^^^ +LL | Foo::Foo2(num) => (), + | ^^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-error-with-note.rs:30:9 - | -LL | / S { -LL | | -LL | | f: _s, - | | -- hint: to prevent move, use `ref _s` or `ref mut _s` -LL | | g: _t - | | -- ...and here (use `ref _t` or `ref mut _t`) -LL | | } => {} - | |_________^ cannot move out of here + --> $DIR/borrowck-move-error-with-note.rs:29:11 + | +LL | match (S {f: "foo".to_string(), g: "bar".to_string()}) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here +... +LL | f: _s, + | -- data moved here +LL | g: _t + | -- ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-move-error-with-note.rs:33:16 + | +LL | f: _s, + | ^^ +LL | g: _t + | ^^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-error-with-note.rs:47:11 + --> $DIR/borrowck-move-error-with-note.rs:48:11 | LL | match a.a { - | ^ cannot move out of borrowed content + | ^^^ + | | + | cannot move out of borrowed content + | help: consider borrowing here: `&a.a` LL | LL | n => { - | - hint: to prevent move, use `ref n` or `ref mut n` + | - data moved here + | +note: move occurs because `n` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-error-with-note.rs:50:9 + | +LL | n => { + | ^ error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.nll.stderr b/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.nll.stderr deleted file mode 100644 index e4840fba672..00000000000 --- a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `*a` because it is borrowed - --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:12:13 - | -LL | let b = &a; - | -- borrow of `a` occurs here -LL | -LL | let z = *a; - | ^^ move out of `*a` occurs here -LL | b.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr b/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr index 5e2428ef4a3..e4840fba672 100644 --- a/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr +++ b/src/test/ui/borrowck/borrowck-move-from-subpath-of-borrowed-path.stderr @@ -1,11 +1,13 @@ error[E0505]: cannot move out of `*a` because it is borrowed - --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:12:9 + --> $DIR/borrowck-move-from-subpath-of-borrowed-path.rs:12:13 | LL | let b = &a; - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | LL | let z = *a; - | ^ move out of `*a` occurs here + | ^^ move out of `*a` occurs here +LL | b.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr deleted file mode 100644 index 615e3fd1800..00000000000 --- a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of dereference of raw pointer - --> $DIR/borrowck-move-from-unsafe-ptr.rs:2:13 - | -LL | let y = *x; - | ^^ - | | - | cannot move out of dereference of raw pointer - | help: consider removing the `*`: `x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr index c23c5bb9c4c..615e3fd1800 100644 --- a/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.stderr @@ -5,7 +5,7 @@ LL | let y = *x; | ^^ | | | cannot move out of dereference of raw pointer - | help: consider using a reference instead: `&*x` + | help: consider removing the `*`: `x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr deleted file mode 100644 index c18fce9f4fd..00000000000 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:13 - | -LL | fn arg_item(&_x: &String) {} - | ^-- - | || - | |data moved here - | cannot move out of borrowed content - | help: consider removing the `&`: `_x` - | -note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:14 - | -LL | fn arg_item(&_x: &String) {} - | ^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:11 - | -LL | with(|&_x| ()) - | ^-- - | || - | |data moved here - | cannot move out of borrowed content - | help: consider removing the `&`: `_x` - | -note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:12 - | -LL | with(|&_x| ()) - | ^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:15 - | -LL | let &_x = &"hi".to_string(); - | --- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content - | || - | |data moved here - | help: consider removing the `&`: `_x` - | -note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:10 - | -LL | let &_x = &"hi".to_string(); - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.stderr b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.stderr deleted file mode 100644 index 019ed96661f..00000000000 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:13 - | -LL | fn arg_item(&_x: &String) {} - | ^-- - | || - | |hint: to prevent move, use `ref _x` or `ref mut _x` - | cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:11 - | -LL | with(|&_x| ()) - | ^-- - | || - | |hint: to prevent move, use `ref _x` or `ref mut _x` - | cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:9 - | -LL | let &_x = &"hi".to_string(); - | ^-- - | || - | |hint: to prevent move, use `ref _x` or `ref mut _x` - | cannot move out of borrowed content - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs index c63f4f60bef..f4f402dd96a 100644 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs +++ b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs @@ -1,22 +1,16 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn with<F>(f: F) where F: FnOnce(&String) {} fn arg_item(&_x: &String) {} - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] fn arg_closure() { with(|&_x| ()) - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] } fn let_pat() { let &_x = &"hi".to_string(); - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] } pub fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.mir.stderr b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.stderr index c18fce9f4fd..d38c05ca36e 100644 --- a/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.mir.stderr +++ b/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:13 + --> $DIR/borrowck-move-in-irrefut-pat.rs:3:13 | LL | fn arg_item(&_x: &String) {} | ^-- @@ -9,13 +9,13 @@ LL | fn arg_item(&_x: &String) {} | help: consider removing the `&`: `_x` | note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:6:14 + --> $DIR/borrowck-move-in-irrefut-pat.rs:3:14 | LL | fn arg_item(&_x: &String) {} | ^^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:11 + --> $DIR/borrowck-move-in-irrefut-pat.rs:7:11 | LL | with(|&_x| ()) | ^-- @@ -25,13 +25,13 @@ LL | with(|&_x| ()) | help: consider removing the `&`: `_x` | note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:11:12 + --> $DIR/borrowck-move-in-irrefut-pat.rs:7:12 | LL | with(|&_x| ()) | ^^ error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:15 + --> $DIR/borrowck-move-in-irrefut-pat.rs:12:15 | LL | let &_x = &"hi".to_string(); | --- ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content @@ -40,7 +40,7 @@ LL | let &_x = &"hi".to_string(); | help: consider removing the `&`: `_x` | note: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-in-irrefut-pat.rs:17:10 + --> $DIR/borrowck-move-in-irrefut-pat.rs:12:10 | LL | let &_x = &"hi".to_string(); | ^^ diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.stderr deleted file mode 100644 index 48651eeae20..00000000000 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: capture of moved value: `t` - --> $DIR/borrowck-move-moved-value-into-closure.rs:14:22 - | -LL | call_f(move|| { *t + 1 }); - | ------ value moved (into closure) here -LL | call_f(move|| { *t + 1 }); - | ^ value captured here after move - | - = note: move occurs because `t` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.mir.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.mir.stderr deleted file mode 100644 index 874c38cb789..00000000000 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.mir.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0382]: use of moved value: `t` - --> $DIR/borrowck-move-moved-value-into-closure.rs:14:12 - | -LL | let t: Box<_> = box 3; - | - move occurs because `t` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait -LL | -LL | call_f(move|| { *t + 1 }); - | ------ - variable moved due to use in closure - | | - | value moved into closure here -LL | call_f(move|| { *t + 1 }); - | ^^^^^^ - use occurs due to use in closure - | | - | value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs index 271553370e3..233d0a733e3 100644 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs +++ b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] fn call_f<F:FnOnce() -> isize>(f: F) -> isize { @@ -11,6 +8,5 @@ fn main() { let t: Box<_> = box 3; call_f(move|| { *t + 1 }); - call_f(move|| { *t + 1 }); //[ast]~ ERROR capture of moved value - //[mir]~^ ERROR use of moved value + call_f(move|| { *t + 1 }); //~ ERROR use of moved value } diff --git a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.stderr index 874c38cb789..557e27aae50 100644 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `t` - --> $DIR/borrowck-move-moved-value-into-closure.rs:14:12 + --> $DIR/borrowck-move-moved-value-into-closure.rs:11:12 | LL | let t: Box<_> = box 3; | - move occurs because `t` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait diff --git a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-move-mut-base-ptr.nll.stderr deleted file mode 100644 index 77f5b72e51c..00000000000 --- a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `t0` because it is borrowed - --> $DIR/borrowck-move-mut-base-ptr.rs:10:14 - | -LL | let p: &isize = &*t0; // Freezes `*t0` - | ---- borrow of `*t0` occurs here -LL | let t1 = t0; - | ^^ move out of `t0` occurs here -LL | *t1 = 22; -LL | p.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr b/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr index d3853832c92..77f5b72e51c 100644 --- a/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-move-mut-base-ptr.stderr @@ -1,10 +1,13 @@ error[E0505]: cannot move out of `t0` because it is borrowed - --> $DIR/borrowck-move-mut-base-ptr.rs:10:9 + --> $DIR/borrowck-move-mut-base-ptr.rs:10:14 | LL | let p: &isize = &*t0; // Freezes `*t0` - | --- borrow of `*t0` occurs here + | ---- borrow of `*t0` occurs here LL | let t1 = t0; - | ^^ move out of `t0` occurs here + | ^^ move out of `t0` occurs here +LL | *t1 = 22; +LL | p.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array.mir.stderr deleted file mode 100644 index 88a1ab2f906..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-from-array.mir.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:10:14 - | -LL | let [_, _x] = a; - | -- value moved here -LL | let [.., _y] = a; - | ^^ value used here after move - | - = note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:17:10 - | -LL | let [_x, _] = a; - | -- value moved here -LL | let [_y..] = a; - | ^^ value used here after move - | - = note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.rs b/src/test/ui/borrowck/borrowck-move-out-from-array.rs index 503e7b99525..856b03edd2d 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array.rs +++ b/src/test/ui/borrowck/borrowck-move-out-from-array.rs @@ -1,21 +1,16 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(box_syntax)] #![feature(slice_patterns)] fn move_out_from_begin_and_end() { let a = [box 1, box 2]; let [_, _x] = a; - let [.., _y] = a; //[ast]~ ERROR [E0382] - //[mir]~^ ERROR [E0382] + let [.., _y] = a; //~ ERROR [E0382] } fn move_out_by_const_index_and_subslice() { let a = [box 1, box 2]; let [_x, _] = a; - let [_y..] = a; //[ast]~ ERROR [E0382] - //[mir]~^ ERROR [E0382] + let [_y..] = a; //~ ERROR [E0382] } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-from-array.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr index 88a1ab2f906..16722a456de 100644 --- a/src/test/ui/borrowck/borrowck-move-out-from-array.ast.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-from-array.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:10:14 + --> $DIR/borrowck-move-out-from-array.rs:7:14 | LL | let [_, _x] = a; | -- value moved here @@ -9,7 +9,7 @@ LL | let [.., _y] = a; = note: move occurs because `a[..]` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait error[E0382]: use of moved value: `a[..]` - --> $DIR/borrowck-move-out-from-array.rs:17:10 + --> $DIR/borrowck-move-out-from-array.rs:13:10 | LL | let [_x, _] = a; | -- value moved here diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr deleted file mode 100644 index e55898aca5c..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:7:14 - | -LL | let _x = Rc::new(vec![1, 2]).into_iter(); - | ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr deleted file mode 100644 index 81afb104c9d..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of an `Rc` - --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:7:14 - | -LL | let _x = Rc::new(vec![1, 2]).into_iter(); - | ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs index 5ced89478dc..0b9e7102cd5 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::rc::Rc; pub fn main() { let _x = Rc::new(vec![1, 2]).into_iter(); - //[ast]~^ ERROR cannot move out of borrowed content [E0507] - //[mir]~^^ ERROR [E0507] + //~^ ERROR [E0507] } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr index 81afb104c9d..7dc8e1749b5 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of an `Rc` - --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:7:14 + --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:4:14 | LL | let _x = Rc::new(vec![1, 2]).into_iter(); | ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc` diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr deleted file mode 100644 index e6af992c4d9..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of an `Rc` - --> $DIR/borrowck-move-out-of-overloaded-deref.rs:4:14 - | -LL | let _x = *Rc::new("hi".to_string()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | cannot move out of an `Rc` - | help: consider removing the `*`: `Rc::new("hi".to_string())` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs index d5b60139fa6..ecb135f68d5 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.rs @@ -2,5 +2,5 @@ use std::rc::Rc; pub fn main() { let _x = *Rc::new("hi".to_string()); - //~^ ERROR cannot move out of borrowed content + //~^ ERROR cannot move out of an `Rc` } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr index cd8d146ab1e..e6af992c4d9 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of an `Rc` --> $DIR/borrowck-move-out-of-overloaded-deref.rs:4:14 | LL | let _x = *Rc::new("hi".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | cannot move out of borrowed content - | help: consider using a reference instead: `&*Rc::new("hi".to_string())` + | cannot move out of an `Rc` + | help: consider removing the `*`: `Rc::new("hi".to_string())` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-out-of-static-item.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-of-static-item.mir.stderr deleted file mode 100644 index 26d06c081dc..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-static-item.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of static item - --> $DIR/borrowck-move-out-of-static-item.rs:18:10 - | -LL | test(BAR); - | ^^^ cannot move out of static item - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs b/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs index d68d5de5c01..8bb48a1d45f 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-static-item.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Ensure that moves out of static items is forbidden struct Foo { @@ -15,6 +12,5 @@ fn test(f: Foo) { } fn main() { - test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] - //[mir]~^ ERROR [E0507] + test(BAR); //~ ERROR cannot move out of static item [E0507] } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-of-static-item.stderr index 26d06c081dc..5b38c1e3e12 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-static-item.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of static item - --> $DIR/borrowck-move-out-of-static-item.rs:18:10 + --> $DIR/borrowck-move-out-of-static-item.rs:15:10 | LL | test(BAR); | ^^^ cannot move out of static item diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr deleted file mode 100644 index c1c04ca9142..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.nll.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:10:11 - | -LL | match (S {f:"foo".to_string()}) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here -LL | -LL | S {f:_s} => {} - | -- data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:12:14 - | -LL | S {f:_s} => {} - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:20 - | -LL | let S {f:_s} = S {f:"foo".to_string()}; - | -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here - | | - | data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:14 - | -LL | let S {f:_s} = S {f:"foo".to_string()}; - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:19 - | -LL | fn move_in_fn_arg(S {f:_s}: S) { - | ^^^^^--^ - | | | - | | data moved here - | cannot move out of here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:24 - | -LL | fn move_in_fn_arg(S {f:_s}: S) { - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr deleted file mode 100644 index 0b025fa175a..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:12:9 - | -LL | S {f:_s} => {} - | ^^^^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:9 - | -LL | let S {f:_s} = S {f:"foo".to_string()}; - | ^^^^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:19 - | -LL | fn move_in_fn_arg(S {f:_s}: S) { - | ^^^^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs index cdd71d889ab..a429f4bc33b 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct S {f:String} impl Drop for S { fn drop(&mut self) { println!("{}", self.f); } @@ -8,21 +5,18 @@ impl Drop for S { fn move_in_match() { match (S {f:"foo".to_string()}) { - //[mir]~^ ERROR [E0509] + //~^ ERROR [E0509] S {f:_s} => {} - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] } } fn move_in_let() { let S {f:_s} = S {f:"foo".to_string()}; - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn move_in_fn_arg(S {f:_s}: S) { - //[ast]~^ ERROR cannot move out of type `S`, which implements the `Drop` trait [E0509] - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.stderr index c1c04ca9142..059aa3081fc 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.stderr @@ -1,5 +1,5 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:10:11 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:7:11 | LL | match (S {f:"foo".to_string()}) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here @@ -8,13 +8,13 @@ LL | S {f:_s} => {} | -- data moved here | note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:12:14 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:9:14 | LL | S {f:_s} => {} | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:20 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:14:20 | LL | let S {f:_s} = S {f:"foo".to_string()}; | -- ^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here @@ -22,13 +22,13 @@ LL | let S {f:_s} = S {f:"foo".to_string()}; | data moved here | note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:14 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:14:14 | LL | let S {f:_s} = S {f:"foo".to_string()}; | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:19 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:19 | LL | fn move_in_fn_arg(S {f:_s}: S) { | ^^^^^--^ @@ -37,7 +37,7 @@ LL | fn move_in_fn_arg(S {f:_s}: S) { | cannot move out of here | note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:23:24 + --> $DIR/borrowck-move-out-of-struct-with-dtor.rs:18:24 | LL | fn move_in_fn_arg(S {f:_s}: S) { | ^^ diff --git a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr deleted file mode 100644 index cecba15acce..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.nll.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:7:11 - | -LL | match S("foo".to_string()) { - | ^^^^^^^^^^^^^^^^^^^^ cannot move out of here -LL | S(_s) => {} - | -- data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:8:11 - | -LL | S(_s) => {} - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:17 - | -LL | let S(_s) = S("foo".to_string()); - | -- ^^^^^^^^^^^^^^^^^^^^ cannot move out of here - | | - | data moved here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:11 - | -LL | let S(_s) = S("foo".to_string()); - | ^^ - -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:19 - | -LL | fn move_in_fn_arg(S(_s): S) { - | ^^--^ - | | | - | | data moved here - | cannot move out of here - | -note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:21 - | -LL | fn move_in_fn_arg(S(_s): S) { - | ^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs index bb294111add..5bd32f82ebc 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.rs @@ -5,8 +5,8 @@ impl Drop for S { fn move_in_match() { match S("foo".to_string()) { - S(_s) => {} //~^ ERROR cannot move out of type `S`, which implements the `Drop` trait + S(_s) => {} } } diff --git a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr index 134b5e3481e..a11bda0a006 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-tuple-struct-with-dtor.stderr @@ -1,20 +1,31 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:8:9 + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:7:11 | +LL | match S("foo".to_string()) { + | ^^^^^^^^^^^^^^^^^^^^ cannot move out of here +LL | LL | S(_s) => {} - | ^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here + | -- data moved here + | +note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:9:11 + | +LL | S(_s) => {} + | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:9 + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:17 | LL | let S(_s) = S("foo".to_string()); - | ^^--^ - | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` - | cannot move out of here + | -- ^^^^^^^^^^^^^^^^^^^^ cannot move out of here + | | + | data moved here + | +note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:14:11 + | +LL | let S(_s) = S("foo".to_string()); + | ^^ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:19 @@ -22,8 +33,14 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait LL | fn move_in_fn_arg(S(_s): S) { | ^^--^ | | | - | | hint: to prevent move, use `ref _s` or `ref mut _s` + | | data moved here | cannot move out of here + | +note: move occurs because `_s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/borrowck-move-out-of-tuple-struct-with-dtor.rs:18:21 + | +LL | fn move_in_fn_arg(S(_s): S) { + | ^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr deleted file mode 100644 index 51caf60da6e..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0508]: cannot move out of type `[Foo]`, a non-copy slice - --> $DIR/borrowck-move-out-of-vec-tail.rs:19:19 - | -LL | match tail { - | ^^^^ cannot move out of here -LL | &[Foo { string: a }, - | - data moved here -... -LL | Foo { string: b }] => { - | - ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-move-out-of-vec-tail.rs:20:33 - | -LL | &[Foo { string: a }, - | ^ -... -LL | Foo { string: b }] => { - | ^ -help: consider removing the `&` - | -LL | [Foo { string: a }, -LL | -LL | -LL | -LL | Foo { string: b }] => { - | - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs index 5f6e01f2df0..cc524c1ac3e 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs +++ b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.rs @@ -17,10 +17,8 @@ pub fn main() { match *x { [_, ref tail..] => { match tail { + //~^ ERROR cannot move out of type `[Foo]` &[Foo { string: a }, - //~^ ERROR cannot move out of type `[Foo]` - //~| cannot move out - //~| to prevent move Foo { string: b }] => { } _ => { diff --git a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr index 5ec0dabfde5..9f0670c6bc7 100644 --- a/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr +++ b/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.stderr @@ -1,17 +1,26 @@ error[E0508]: cannot move out of type `[Foo]`, a non-copy slice - --> $DIR/borrowck-move-out-of-vec-tail.rs:20:18 + --> $DIR/borrowck-move-out-of-vec-tail.rs:19:19 + | +LL | match tail { + | ^^^^ cannot move out of here +LL | +LL | &[Foo { string: a }, + | - data moved here +LL | Foo { string: b }] => { + | - ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-move-out-of-vec-tail.rs:21:33 + | +LL | &[Foo { string: a }, + | ^ +LL | Foo { string: b }] => { + | ^ +help: consider removing the `&` + | +LL | [Foo { string: a }, +LL | Foo { string: b }] => { | -LL | &[Foo { string: a }, - | ^ - hint: to prevent move, use `ref a` or `ref mut a` - | __________________| - | | -LL | | -LL | | -LL | | -LL | | Foo { string: b }] => { - | |_________________________________-__^ cannot move out of here - | | - | ...and here (use `ref b` or `ref mut b`) error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-move-subcomponent.nll.stderr b/src/test/ui/borrowck/borrowck-move-subcomponent.nll.stderr deleted file mode 100644 index 8c9083fcf13..00000000000 --- a/src/test/ui/borrowck/borrowck-move-subcomponent.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `a.x` because it is borrowed - --> $DIR/borrowck-move-subcomponent.rs:15:14 - | -LL | let pb = &a; - | -- borrow of `a` occurs here -LL | let S { x: ax } = a; - | ^^ move out of `a.x` occurs here -LL | f(pb); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-move-subcomponent.stderr b/src/test/ui/borrowck/borrowck-move-subcomponent.stderr index fd3deef6df5..8c9083fcf13 100644 --- a/src/test/ui/borrowck/borrowck-move-subcomponent.stderr +++ b/src/test/ui/borrowck/borrowck-move-subcomponent.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `a.x` because it is borrowed --> $DIR/borrowck-move-subcomponent.rs:15:14 | LL | let pb = &a; - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | let S { x: ax } = a; | ^^ move out of `a.x` occurs here +LL | f(pb); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-multiple-captures.nll.stderr b/src/test/ui/borrowck/borrowck-multiple-captures.nll.stderr deleted file mode 100644 index b6b46e4fe6b..00000000000 --- a/src/test/ui/borrowck/borrowck-multiple-captures.nll.stderr +++ /dev/null @@ -1,103 +0,0 @@ -error[E0505]: cannot move out of `x1` because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:12:19 - | -LL | let p1 = &x1; - | --- borrow of `x1` occurs here -... -LL | thread::spawn(move|| { - | ^^^^^^ move out of `x1` occurs here -LL | drop(x1); - | -- move occurs due to use in closure -... -LL | borrow(&*p1); - | ---- borrow later used here - -error[E0505]: cannot move out of `x2` because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:12:19 - | -LL | let p2 = &x2; - | --- borrow of `x2` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `x2` occurs here -LL | drop(x1); -LL | drop(x2); - | -- move occurs due to use in closure -... -LL | borrow(&*p2); - | ---- borrow later used here - -error[E0382]: use of moved value: `x1` - --> $DIR/borrowck-multiple-captures.rs:25:19 - | -LL | let x1: Box<_> = box 1; - | -- move occurs because `x1` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait -LL | drop(x1); - | -- value moved here -... -LL | thread::spawn(move|| { - | ^^^^^^ value used here after move -LL | drop(x1); - | -- use occurs due to use in closure - -error[E0382]: use of moved value: `x2` - --> $DIR/borrowck-multiple-captures.rs:25:19 - | -LL | let x2: Box<_> = box 2; - | -- move occurs because `x2` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait -LL | drop(x2); - | -- value moved here -LL | thread::spawn(move|| { - | ^^^^^^ value used here after move -LL | drop(x1); -LL | drop(x2); - | -- use occurs due to use in closure - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:36:14 - | -LL | drop(x); - | - value moved here -LL | drop(x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:34:19 - | -LL | let p = &x; - | -- borrow of `x` occurs here -LL | thread::spawn(move|| { - | ^^^^^^ move out of `x` occurs here -LL | drop(x); - | - move occurs due to use in closure -... -LL | borrow(&*p); - | --- borrow later used here - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:46:14 - | -LL | drop(x); - | - value moved here -LL | drop(x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:44:19 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait -LL | drop(x); - | - value moved here -LL | thread::spawn(move|| { - | ^^^^^^ value used here after move -LL | drop(x); - | - use occurs due to use in closure - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0382, E0505. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-multiple-captures.rs b/src/test/ui/borrowck/borrowck-multiple-captures.rs index ad753781cd6..9f09f8442c0 100644 --- a/src/test/ui/borrowck/borrowck-multiple-captures.rs +++ b/src/test/ui/borrowck/borrowck-multiple-captures.rs @@ -10,8 +10,10 @@ fn different_vars_after_borrows() { let x2: Box<_> = box 2; let p2 = &x2; thread::spawn(move|| { - drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed - drop(x2); //~ ERROR cannot move `x2` into closure because it is borrowed + //~^ ERROR cannot move out of `x1` because it is borrowed + //~| ERROR cannot move out of `x2` because it is borrowed + drop(x1); + drop(x2); }); borrow(&*p1); borrow(&*p2); @@ -23,8 +25,10 @@ fn different_vars_after_moves() { let x2: Box<_> = box 2; drop(x2); thread::spawn(move|| { - drop(x1); //~ ERROR capture of moved value: `x1` - drop(x2); //~ ERROR capture of moved value: `x2` + //~^ ERROR use of moved value: `x1` + //~| ERROR use of moved value: `x2` + drop(x1); + drop(x2); }); } @@ -32,7 +36,8 @@ fn same_var_after_borrow() { let x: Box<_> = box 1; let p = &x; thread::spawn(move|| { - drop(x); //~ ERROR cannot move `x` into closure because it is borrowed + //~^ ERROR cannot move out of `x` because it is borrowed + drop(x); drop(x); //~ ERROR use of moved value: `x` }); borrow(&*p); @@ -42,7 +47,8 @@ fn same_var_after_move() { let x: Box<_> = box 1; drop(x); thread::spawn(move|| { - drop(x); //~ ERROR capture of moved value: `x` + //~^ ERROR use of moved value: `x` + drop(x); drop(x); //~ ERROR use of moved value: `x` }); } diff --git a/src/test/ui/borrowck/borrowck-multiple-captures.stderr b/src/test/ui/borrowck/borrowck-multiple-captures.stderr index fba42010fd0..298482b3c58 100644 --- a/src/test/ui/borrowck/borrowck-multiple-captures.stderr +++ b/src/test/ui/borrowck/borrowck-multiple-captures.stderr @@ -1,54 +1,61 @@ -error[E0504]: cannot move `x1` into closure because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:13:14 +error[E0505]: cannot move out of `x1` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:12:19 | LL | let p1 = &x1; - | -- borrow of `x1` occurs here + | --- borrow of `x1` occurs here +... +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x1` occurs here ... LL | drop(x1); - | ^^ move into closure occurs here + | -- move occurs due to use in closure +... +LL | borrow(&*p1); + | ---- borrow later used here -error[E0504]: cannot move `x2` into closure because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:14:14 +error[E0505]: cannot move out of `x2` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:12:19 | LL | let p2 = &x2; - | -- borrow of `x2` occurs here + | --- borrow of `x2` occurs here +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x2` occurs here ... LL | drop(x2); - | ^^ move into closure occurs here + | -- move occurs due to use in closure +... +LL | borrow(&*p2); + | ---- borrow later used here -error[E0382]: capture of moved value: `x1` - --> $DIR/borrowck-multiple-captures.rs:26:14 +error[E0382]: use of moved value: `x1` + --> $DIR/borrowck-multiple-captures.rs:27:19 | +LL | let x1: Box<_> = box 1; + | -- move occurs because `x1` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait LL | drop(x1); | -- value moved here ... +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move +... LL | drop(x1); - | ^^ value captured here after move - | - = note: move occurs because `x1` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait + | -- use occurs due to use in closure -error[E0382]: capture of moved value: `x2` - --> $DIR/borrowck-multiple-captures.rs:27:14 +error[E0382]: use of moved value: `x2` + --> $DIR/borrowck-multiple-captures.rs:27:19 | +LL | let x2: Box<_> = box 2; + | -- move occurs because `x2` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait LL | drop(x2); | -- value moved here +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move ... LL | drop(x2); - | ^^ value captured here after move - | - = note: move occurs because `x2` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait - -error[E0504]: cannot move `x` into closure because it is borrowed - --> $DIR/borrowck-multiple-captures.rs:35:14 - | -LL | let p = &x; - | - borrow of `x` occurs here -LL | thread::spawn(move|| { -LL | drop(x); - | ^ move into closure occurs here + | -- use occurs due to use in closure error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:36:14 + --> $DIR/borrowck-multiple-captures.rs:41:14 | LL | drop(x); | - value moved here @@ -57,19 +64,22 @@ LL | drop(x); | = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait -error[E0382]: capture of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:45:14 +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/borrowck-multiple-captures.rs:38:19 | -LL | drop(x); - | - value moved here +LL | let p = &x; + | -- borrow of `x` occurs here LL | thread::spawn(move|| { + | ^^^^^^ move out of `x` occurs here +LL | LL | drop(x); - | ^ value captured here after move - | - = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait + | - move occurs due to use in closure +... +LL | borrow(&*p); + | --- borrow later used here error[E0382]: use of moved value: `x` - --> $DIR/borrowck-multiple-captures.rs:46:14 + --> $DIR/borrowck-multiple-captures.rs:52:14 | LL | drop(x); | - value moved here @@ -78,7 +88,20 @@ LL | drop(x); | = note: move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait +error[E0382]: use of moved value: `x` + --> $DIR/borrowck-multiple-captures.rs:49:19 + | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box<i32>`, which does not implement the `Copy` trait +LL | drop(x); + | - value moved here +LL | thread::spawn(move|| { + | ^^^^^^ value used here after move +LL | +LL | drop(x); + | - use occurs due to use in closure + error: aborting due to 8 previous errors -Some errors have detailed explanations: E0382, E0504. +Some errors have detailed explanations: E0382, E0505. For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr b/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr deleted file mode 100644 index d58548f2204..00000000000 --- a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-mut-addr-of-imm-var.rs:3:25 - | -LL | let x: isize = 3; - | - help: consider changing this to be mutable: `mut x` -LL | let y: &mut isize = &mut x; - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr b/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr index aa3b39c395d..d58548f2204 100644 --- a/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr +++ b/src/test/ui/borrowck/borrowck-mut-addr-of-imm-var.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/borrowck-mut-addr-of-imm-var.rs:3:30 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/borrowck-mut-addr-of-imm-var.rs:3:25 | LL | let x: isize = 3; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | let y: &mut isize = &mut x; - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr deleted file mode 100644 index cee61db38f3..00000000000 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:13:35 - | -LL | 1 => { addr.push(&mut x); } - | ^ mutable borrow starts here in previous iteration of loop -... -LL | } - | - mutable borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:15:35 - | -LL | 1 => { addr.push(&mut x); } - | - first mutable borrow occurs here -LL | -LL | 2 => { addr.push(&mut x); } - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:17:35 - | -LL | 1 => { addr.push(&mut x); } - | - first mutable borrow occurs here -... -LL | _ => { addr.push(&mut x); } - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr deleted file mode 100644 index a6e7d74af1d..00000000000 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:13:30 - | -LL | 1 => { addr.push(&mut x); } - | ---- ^^^^^^ second mutable borrow occurs here - | | - | first borrow later used here -... -LL | _ => { addr.push(&mut x); } - | ------ first mutable borrow occurs here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:15:30 - | -LL | 1 => { addr.push(&mut x); } - | ---- first borrow later used here -LL | -LL | 2 => { addr.push(&mut x); } - | ^^^^^^ second mutable borrow occurs here -LL | -LL | _ => { addr.push(&mut x); } - | ------ first mutable borrow occurs here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:17:30 - | -LL | _ => { addr.push(&mut x); } - | ^^^^^^ mutable borrow starts here in previous iteration of loop - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs index bb0b26ecf06..e3d76398bc2 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.rs @@ -2,20 +2,14 @@ // conflicts with a new loan, as opposed to every issued loan. This keeps us // down to O(n) errors (for n problem lines), instead of O(n^2) errors. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let mut x = 1; let mut addr = vec![]; loop { match 1 { - 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] - 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] - _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - //[mir]~^ ERROR [E0499] + 1 => { addr.push(&mut x); } //~ ERROR [E0499] + 2 => { addr.push(&mut x); } //~ ERROR [E0499] + _ => { addr.push(&mut x); } //~ ERROR [E0499] } } } diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr index a6e7d74af1d..a8d00d15234 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr @@ -1,28 +1,26 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:13:30 + --> $DIR/borrowck-mut-borrow-linear-errors.rs:10:30 | LL | 1 => { addr.push(&mut x); } | ---- ^^^^^^ second mutable borrow occurs here | | | first borrow later used here -... +LL | 2 => { addr.push(&mut x); } LL | _ => { addr.push(&mut x); } | ------ first mutable borrow occurs here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:15:30 + --> $DIR/borrowck-mut-borrow-linear-errors.rs:11:30 | LL | 1 => { addr.push(&mut x); } | ---- first borrow later used here -LL | LL | 2 => { addr.push(&mut x); } | ^^^^^^ second mutable borrow occurs here -LL | LL | _ => { addr.push(&mut x); } | ------ first mutable borrow occurs here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-linear-errors.rs:17:30 + --> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30 | LL | _ => { addr.push(&mut x); } | ^^^^^^ mutable borrow starts here in previous iteration of loop diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr deleted file mode 100644 index f2baee09376..00000000000 --- a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:18 - | -LL | let p: &isize = &*t0; // Freezes `*t0` - | ---- immutable borrow occurs here -LL | let mut t2 = &mut t0; - | ^^^^^^^ mutable borrow occurs here -LL | **t2 += 1; // Mutates `*t0` -LL | p.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `t0` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18 - | -LL | let p: &mut isize = &mut *t0; // Claims `*t0` - | -------- first mutable borrow occurs here -LL | let mut t2 = &mut t0; - | ^^^^^^^ second mutable borrow occurs here -LL | **t2 += 1; // Mutates `*t0` but not through `*p` -LL | p.use_mut(); - | - first borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr index 96fa571006a..f2baee09376 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.stderr @@ -1,24 +1,24 @@ -error[E0502]: cannot borrow `t0` as mutable because `*t0` is also borrowed as immutable - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:23 +error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:11:18 | LL | let p: &isize = &*t0; // Freezes `*t0` - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let mut t2 = &mut t0; - | ^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^ mutable borrow occurs here +LL | **t2 += 1; // Mutates `*t0` +LL | p.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `t0` as mutable more than once at a time - --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:23 + --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:19:18 | LL | let p: &mut isize = &mut *t0; // Claims `*t0` - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let mut t2 = &mut t0; - | ^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^ second mutable borrow occurs here +LL | **t2 += 1; // Mutates `*t0` but not through `*p` +LL | p.use_mut(); + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr b/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr deleted file mode 100644 index 8e7ffdc6819..00000000000 --- a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable - --> $DIR/borrowck-mut-slice-of-imm-vec.rs:7:11 - | -LL | let v = vec![1, 2, 3]; - | - help: consider changing this to be mutable: `mut v` -LL | write(&mut v); - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr b/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr index 416091920ad..8e7ffdc6819 100644 --- a/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr +++ b/src/test/ui/borrowck/borrowck-mut-slice-of-imm-vec.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `v` as mutable - --> $DIR/borrowck-mut-slice-of-imm-vec.rs:7:16 +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable + --> $DIR/borrowck-mut-slice-of-imm-vec.rs:7:11 | LL | let v = vec![1, 2, 3]; - | - help: make this binding mutable: `mut v` + | - help: consider changing this to be mutable: `mut v` LL | write(&mut v); - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr b/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr deleted file mode 100644 index f44c76534a2..00000000000 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0302]: cannot assign in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:10:25 - | -LL | Enum::A(_) if { x = Enum::B(false); false } => 1, - | ^^^^^^^^^^^^^^^^^^ assignment in pattern guard - -error[E0301]: cannot mutably borrow in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:12:38 - | -LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - | ^ borrowed mutably in pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error[E0302]: cannot assign in a pattern guard - --> $DIR/borrowck-mutate-in-guard.rs:12:41 - | -LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, - | ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0301, E0302. -For more information about an error, try `rustc --explain E0301`. diff --git a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr index b475116b49b..f44c76534a2 100644 --- a/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr +++ b/src/test/ui/borrowck/borrowck-mutate-in-guard.stderr @@ -9,6 +9,8 @@ error[E0301]: cannot mutably borrow in a pattern guard | LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, | ^ borrowed mutably in pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error[E0302]: cannot assign in a pattern guard --> $DIR/borrowck-mutate-in-guard.rs:12:41 diff --git a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr b/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr deleted file mode 100644 index 3462b7610d3..00000000000 --- a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-no-cycle-in-exchange-heap.rs:16:15 - | -LL | Cycle::Node(ref mut y) => { - | --------- borrow of `x.0` occurs here -LL | y.a = x; - | --- ^ move out of `x` occurs here - | | - | borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr b/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr index 5fc169490c7..3462b7610d3 100644 --- a/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr +++ b/src/test/ui/borrowck/borrowck-no-cycle-in-exchange-heap.stderr @@ -4,7 +4,9 @@ error[E0505]: cannot move out of `x` because it is borrowed LL | Cycle::Node(ref mut y) => { | --------- borrow of `x.0` occurs here LL | y.a = x; - | ^ move out of `x` occurs here + | --- ^ move out of `x` occurs here + | | + | borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr b/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr deleted file mode 100644 index cf94c74dec2..00000000000 --- a/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-object-lifetime.rs:20:13 - | -LL | let y = x.borrowed(); - | - immutable borrow occurs here -LL | let z = x.mut_borrowed(); - | ^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | y.use_ref(); - | - immutable borrow later used here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-object-lifetime.rs:26:13 - | -LL | let y = x.borrowed(); - | - immutable borrow occurs here -LL | let z = &mut x; - | ^^^^^^ mutable borrow occurs here -LL | y.use_ref(); - | - immutable borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-object-lifetime.stderr b/src/test/ui/borrowck/borrowck-object-lifetime.stderr index 8f6c8e072e5..cf94c74dec2 100644 --- a/src/test/ui/borrowck/borrowck-object-lifetime.stderr +++ b/src/test/ui/borrowck/borrowck-object-lifetime.stderr @@ -4,21 +4,19 @@ error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immut LL | let y = x.borrowed(); | - immutable borrow occurs here LL | let z = x.mut_borrowed(); - | ^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | y.use_ref(); -LL | } - | - immutable borrow ends here + | - immutable borrow later used here -error[E0502]: cannot borrow `x` as mutable because `*x` is also borrowed as immutable - --> $DIR/borrowck-object-lifetime.rs:26:18 +error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-object-lifetime.rs:26:13 | LL | let y = x.borrowed(); | - immutable borrow occurs here LL | let z = &mut x; - | ^ mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); -LL | } - | - immutable borrow ends here + | - immutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-or-init.nll.stderr b/src/test/ui/borrowck/borrowck-or-init.nll.stderr deleted file mode 100644 index 122f5192720..00000000000 --- a/src/test/ui/borrowck/borrowck-or-init.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `i` - --> $DIR/borrowck-or-init.rs:5:20 - | -LL | println!("{}", i); - | ^ use of possibly uninitialized `i` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-or-init.rs b/src/test/ui/borrowck/borrowck-or-init.rs index 5b1487831a6..c0d6c9c2739 100644 --- a/src/test/ui/borrowck/borrowck-or-init.rs +++ b/src/test/ui/borrowck/borrowck-or-init.rs @@ -2,5 +2,5 @@ fn main() { let i: isize; println!("{}", false || { i = 5; true }); - println!("{}", i); //~ ERROR use of possibly uninitialized variable: `i` + println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i` } diff --git a/src/test/ui/borrowck/borrowck-or-init.stderr b/src/test/ui/borrowck/borrowck-or-init.stderr index a2b69b187b9..122f5192720 100644 --- a/src/test/ui/borrowck/borrowck-or-init.stderr +++ b/src/test/ui/borrowck/borrowck-or-init.stderr @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `i` +error[E0381]: borrow of possibly uninitialized variable: `i` --> $DIR/borrowck-or-init.rs:5:20 | LL | println!("{}", i); diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr deleted file mode 100644 index ddb63b5ec0f..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-call.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-call.rs:59:5 - | -LL | let sp = &mut s; - | ------ mutable borrow occurs here -LL | s(3); - | ^ immutable borrow occurs here -LL | use_mut(sp); - | -- mutable borrow later used here - -error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable - --> $DIR/borrowck-overloaded-call.rs:67:5 - | -LL | let s = SFnMut { - | - help: consider changing this to be mutable: `mut s` -... -LL | s(3); - | ^ cannot borrow as mutable - -error[E0382]: use of moved value: `s` - --> $DIR/borrowck-overloaded-call.rs:75:5 - | -LL | let s = SFnOnce { - | - move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait -... -LL | s(" world".to_string()); - | - value moved here -LL | s(" world".to_string()); - | ^ value used here after move - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0382, E0502, E0596. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.rs b/src/test/ui/borrowck/borrowck-overloaded-call.rs index 8601449b331..7b16bf666d0 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-call.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-call.rs @@ -64,7 +64,7 @@ fn g() { x: 1, y: 2, }; - s(3); //~ ERROR cannot borrow immutable local variable `s` as mutable + s(3); //~ ERROR cannot borrow `s` as mutable, as it is not declared as mutable } fn h() { diff --git a/src/test/ui/borrowck/borrowck-overloaded-call.stderr b/src/test/ui/borrowck/borrowck-overloaded-call.stderr index 1a32c55be79..ddb63b5ec0f 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-call.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-call.stderr @@ -2,31 +2,31 @@ error[E0502]: cannot borrow `s` as immutable because it is also borrowed as muta --> $DIR/borrowck-overloaded-call.rs:59:5 | LL | let sp = &mut s; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | s(3); | ^ immutable borrow occurs here LL | use_mut(sp); -LL | } - | - mutable borrow ends here + | -- mutable borrow later used here -error[E0596]: cannot borrow immutable local variable `s` as mutable +error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable --> $DIR/borrowck-overloaded-call.rs:67:5 | LL | let s = SFnMut { - | - help: make this binding mutable: `mut s` + | - help: consider changing this to be mutable: `mut s` ... LL | s(3); - | ^ cannot borrow mutably + | ^ cannot borrow as mutable error[E0382]: use of moved value: `s` --> $DIR/borrowck-overloaded-call.rs:75:5 | +LL | let s = SFnOnce { + | - move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait +... LL | s(" world".to_string()); | - value moved here LL | s(" world".to_string()); | ^ value used here after move - | - = note: move occurs because `s` has type `SFnOnce`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr deleted file mode 100644 index f33fb55f9cd..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `v` because it is borrowed - --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:34:5 - | -LL | let i = &v[0].f; - | - borrow of `v` occurs here -LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here -... -LL | read(*i); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr deleted file mode 100644 index 59841ee2dbe..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `v` because it is borrowed - --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:34:5 - | -LL | let i = &v[0].f; - | - borrow of `v` occurs here -LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs index 348d99f4f98..0e3e01a9332 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.rs @@ -3,9 +3,6 @@ // operator. The accounting of the all the implicit things going on // here is rather subtle. Issue #20232. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::ops::{Deref, Index}; struct MyVec<T> { x: T } @@ -32,8 +29,7 @@ fn main() { let mut v = MyVec { x: MyPtr { x: Foo { f: 22 } } }; let i = &v[0].f; v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; - //[ast]~^ ERROR cannot assign to `v` - //[mir]~^^ ERROR cannot assign to `v` because it is borrowed + //~^ ERROR cannot assign to `v` because it is borrowed read(*i); } diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr index f33fb55f9cd..5d52e491918 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `v` because it is borrowed - --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:34:5 + --> $DIR/borrowck-overloaded-index-and-overloaded-deref.rs:31:5 | LL | let i = &v[0].f; | - borrow of `v` occurs here LL | v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `v` occurs here -... +LL | LL | read(*i); | -- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr deleted file mode 100644 index 978e1291722..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr +++ /dev/null @@ -1,84 +0,0 @@ -error[E0502]: cannot borrow `*f` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-autoderef.rs:37:14 - | -LL | let p = &mut f[&s]; - | - mutable borrow occurs here -LL | let q = &f[&s]; - | ^ immutable borrow occurs here -LL | p.use_mut(); - | - mutable borrow later used here - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/borrowck-overloaded-index-autoderef.rs:43:18 - | -LL | let p = &mut f[&s]; - | - first mutable borrow occurs here -LL | let q = &mut f[&s]; - | ^ second mutable borrow occurs here -LL | p.use_mut(); - | - first borrow later used here - -error[E0499]: cannot borrow `f.foo` as mutable more than once at a time - --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 - | -LL | let p = &mut f.foo[&s]; - | ----- first mutable borrow occurs here -LL | let q = &mut f.foo[&s]; - | ^^^^^ second mutable borrow occurs here -LL | p.use_mut(); - | - first borrow later used here - -error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-overloaded-index-autoderef.rs:65:18 - | -LL | let p = &f.foo[&s]; - | ----- immutable borrow occurs here -LL | let q = &mut f.foo[&s]; - | ^^^^^ mutable borrow occurs here -LL | p.use_ref(); - | - immutable borrow later used here - -error[E0506]: cannot assign to `f.foo` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:71:5 - | -LL | let p = &f.foo[&s]; - | ----- borrow of `f.foo` occurs here -LL | f.foo = g; - | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here -LL | p.use_ref(); - | - borrow later used here - -error[E0506]: cannot assign to `*f` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:77:5 - | -LL | let p = &f.foo[&s]; - | ----- borrow of `*f` occurs here -LL | *f = g; - | ^^^^^^ assignment to borrowed `*f` occurs here -LL | p.use_ref(); - | - borrow later used here - -error[E0506]: cannot assign to `f.foo` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:83:5 - | -LL | let p = &mut f.foo[&s]; - | ----- borrow of `f.foo` occurs here -LL | f.foo = g; - | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here -LL | p.use_mut(); - | - borrow later used here - -error[E0506]: cannot assign to `*f` because it is borrowed - --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 - | -LL | let p = &mut f.foo[&s]; - | ----- borrow of `*f` occurs here -LL | *f = g; - | ^^^^^^ assignment to borrowed `*f` occurs here -LL | p.use_mut(); - | - borrow later used here - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0499, E0502, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr index ae763be718c..978e1291722 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.stderr @@ -6,8 +6,7 @@ LL | let p = &mut f[&s]; LL | let q = &f[&s]; | ^ immutable borrow occurs here LL | p.use_mut(); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:43:18 @@ -17,8 +16,7 @@ LL | let p = &mut f[&s]; LL | let q = &mut f[&s]; | ^ second mutable borrow occurs here LL | p.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error[E0499]: cannot borrow `f.foo` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 @@ -28,8 +26,7 @@ LL | let p = &mut f.foo[&s]; LL | let q = &mut f.foo[&s]; | ^^^^^ second mutable borrow occurs here LL | p.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-overloaded-index-autoderef.rs:65:18 @@ -39,8 +36,7 @@ LL | let p = &f.foo[&s]; LL | let q = &mut f.foo[&s]; | ^^^^^ mutable borrow occurs here LL | p.use_ref(); -LL | } - | - immutable borrow ends here + | - immutable borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:71:5 @@ -49,6 +45,8 @@ LL | let p = &f.foo[&s]; | ----- borrow of `f.foo` occurs here LL | f.foo = g; | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here +LL | p.use_ref(); + | - borrow later used here error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:77:5 @@ -57,6 +55,8 @@ LL | let p = &f.foo[&s]; | ----- borrow of `*f` occurs here LL | *f = g; | ^^^^^^ assignment to borrowed `*f` occurs here +LL | p.use_ref(); + | - borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:83:5 @@ -65,6 +65,8 @@ LL | let p = &mut f.foo[&s]; | ----- borrow of `f.foo` occurs here LL | f.foo = g; | ^^^^^^^^^ assignment to borrowed `f.foo` occurs here +LL | p.use_mut(); + | - borrow later used here error[E0506]: cannot assign to `*f` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:89:5 @@ -73,6 +75,8 @@ LL | let p = &mut f.foo[&s]; | ----- borrow of `*f` occurs here LL | *f = g; | ^^^^^^ assignment to borrowed `*f` occurs here +LL | p.use_mut(); + | - borrow later used here error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr deleted file mode 100644 index dbd805f1d26..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/borrowck-overloaded-index-move-from-vec.rs:20:15 - | -LL | let bad = v[0]; - | ^^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&v[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs index 76dd97ea242..b3060824f87 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.rs @@ -18,5 +18,5 @@ fn main() { let v = MyVec::<Box<_>> { data: vec![box 1, box 2, box 3] }; let good = &v[0]; // Shouldn't fail here let bad = v[0]; - //~^ ERROR cannot move out of indexed content + //~^ ERROR cannot move out of borrowed content } diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr index fe655dc8b13..dbd805f1d26 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-overloaded-index-move-from-vec.rs:20:15 | LL | let bad = v[0]; | ^^^^ | | - | cannot move out of indexed content - | help: consider using a reference instead: `&v[0]` + | cannot move out of borrowed content + | help: consider borrowing here: `&v[0]` error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr deleted file mode 100644 index 5414b01cb0d..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.nll.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0505]: cannot move out of `s` because it is borrowed - --> $DIR/borrowck-overloaded-index-move-index.rs:50:22 - | -LL | let rs = &mut s; - | ------ borrow of `s` occurs here -LL | -LL | println!("{}", f[s]); - | ^ move out of `s` occurs here -... -LL | use_mut(rs); - | -- borrow later used here - -error[E0505]: cannot move out of `s` because it is borrowed - --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 - | -LL | let rs = &mut s; - | ------ borrow of `s` occurs here -... -LL | f[s] = 10; - | ^ move out of `s` occurs here -... -LL | use_mut(rs); - | -- borrow later used here - -error[E0382]: use of moved value: `s` - --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 - | -LL | let mut s = "hello".to_string(); - | ----- move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | println!("{}", f[s]); - | - value moved here -... -LL | f[s] = 10; - | ^ value used here after move - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0382, E0505. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr index e84cbcad06a..5414b01cb0d 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-move-index.stderr @@ -2,30 +2,37 @@ error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:50:22 | LL | let rs = &mut s; - | - borrow of `s` occurs here + | ------ borrow of `s` occurs here LL | LL | println!("{}", f[s]); | ^ move out of `s` occurs here +... +LL | use_mut(rs); + | -- borrow later used here error[E0505]: cannot move out of `s` because it is borrowed --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 | LL | let rs = &mut s; - | - borrow of `s` occurs here + | ------ borrow of `s` occurs here ... LL | f[s] = 10; | ^ move out of `s` occurs here +... +LL | use_mut(rs); + | -- borrow later used here error[E0382]: use of moved value: `s` --> $DIR/borrowck-overloaded-index-move-index.rs:53:7 | +LL | let mut s = "hello".to_string(); + | ----- move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait +... LL | println!("{}", f[s]); | - value moved here ... LL | f[s] = 10; | ^ value used here after move - | - = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.stderr deleted file mode 100644 index 251b5cd8b32..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0594]: cannot assign to immutable indexed content - --> $DIR/borrowck-overloaded-index-ref-index.rs:61:5 - | -LL | s[2] = 20; - | ^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `Bar` - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:52:23 - | -LL | let rs = &mut s; - | - mutable borrow occurs here -LL | println!("{}", f[&s]); - | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:55:8 - | -LL | let rs = &mut s; - | - mutable borrow occurs here -... -LL | f[&s] = 10; - | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr deleted file mode 100644 index d09ce5d1805..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:52:22 - | -LL | let rs = &mut s; - | ------ mutable borrow occurs here -LL | println!("{}", f[&s]); - | ^^ immutable borrow occurs here -... -LL | drop(rs); - | -- mutable borrow later used here - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:55:7 - | -LL | let rs = &mut s; - | ------ mutable borrow occurs here -... -LL | f[&s] = 10; - | ^^ immutable borrow occurs here -... -LL | drop(rs); - | -- mutable borrow later used here - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-overloaded-index-ref-index.rs:61:5 - | -LL | s[2] = 20; - | ^^^^^^^^^ cannot assign - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs index 53cab520e43..cb20873432b 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs +++ b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::ops::{Index, IndexMut}; struct Foo { @@ -50,16 +47,13 @@ fn main() { let mut s = "hello".to_string(); let rs = &mut s; println!("{}", f[&s]); - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable f[&s] = 10; - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable let s = Bar { x: 1, }; s[2] = 20; - //[ast]~^ ERROR cannot assign to immutable indexed content - //[mir]~^^ ERROR cannot assign to data in a `&` reference + //~^ ERROR cannot assign to data in a `&` reference drop(rs); } diff --git a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.stderr index d09ce5d1805..fcbfe72a34b 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:52:22 + --> $DIR/borrowck-overloaded-index-ref-index.rs:49:22 | LL | let rs = &mut s; | ------ mutable borrow occurs here @@ -10,7 +10,7 @@ LL | drop(rs); | -- mutable borrow later used here error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-overloaded-index-ref-index.rs:55:7 + --> $DIR/borrowck-overloaded-index-ref-index.rs:51:7 | LL | let rs = &mut s; | ------ mutable borrow occurs here @@ -22,7 +22,7 @@ LL | drop(rs); | -- mutable borrow later used here error[E0594]: cannot assign to data in a `&` reference - --> $DIR/borrowck-overloaded-index-ref-index.rs:61:5 + --> $DIR/borrowck-overloaded-index-ref-index.rs:56:5 | LL | s[2] = 20; | ^^^^^^^^^ cannot assign diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-1.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-1.nll.stderr deleted file mode 100644 index 65f2bd6cfbd..00000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-1.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0382]: assign of moved value: `t` - --> $DIR/borrowck-partial-reinit-1.rs:27:5 - | -LL | let mut t = Test2 { b: None }; - | ----- move occurs because `t` has type `Test2`, which does not implement the `Copy` trait -LL | let u = Test; -LL | drop(t); - | - value moved here -LL | t.b = Some(u); - | ^^^ value assigned here after move - -error[E0382]: assign of moved value: `t` - --> $DIR/borrowck-partial-reinit-1.rs:33:5 - | -LL | let mut t = Test3(None); - | ----- move occurs because `t` has type `Test3`, which does not implement the `Copy` trait -LL | let u = Test; -LL | drop(t); - | - value moved here -LL | t.0 = Some(u); - | ^^^ value assigned here after move - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-1.rs b/src/test/ui/borrowck/borrowck-partial-reinit-1.rs index f763759152c..4e695158154 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-1.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-1.rs @@ -25,13 +25,13 @@ fn stuff() { let u = Test; drop(t); t.b = Some(u); - //~^ ERROR partial reinitialization of uninitialized structure `t` + //~^ ERROR assign of moved value: `t` let mut t = Test3(None); let u = Test; drop(t); t.0 = Some(u); - //~^ ERROR partial reinitialization of uninitialized structure `t` + //~^ ERROR assign of moved value: `t` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr index 23f5035369d..65f2bd6cfbd 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-1.stderr @@ -1,15 +1,25 @@ -error[E0383]: partial reinitialization of uninitialized structure `t` +error[E0382]: assign of moved value: `t` --> $DIR/borrowck-partial-reinit-1.rs:27:5 | +LL | let mut t = Test2 { b: None }; + | ----- move occurs because `t` has type `Test2`, which does not implement the `Copy` trait +LL | let u = Test; +LL | drop(t); + | - value moved here LL | t.b = Some(u); - | ^^^^^^^^^^^^^ + | ^^^ value assigned here after move -error[E0383]: partial reinitialization of uninitialized structure `t` +error[E0382]: assign of moved value: `t` --> $DIR/borrowck-partial-reinit-1.rs:33:5 | +LL | let mut t = Test3(None); + | ----- move occurs because `t` has type `Test3`, which does not implement the `Copy` trait +LL | let u = Test; +LL | drop(t); + | - value moved here LL | t.0 = Some(u); - | ^^^^^^^^^^^^^ + | ^^^ value assigned here after move error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-2.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-2.nll.stderr deleted file mode 100644 index 36a871fbb12..00000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-2.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: assign of moved value: `t` - --> $DIR/borrowck-partial-reinit-2.rs:15:5 - | -LL | let mut t = Test { a: 1, b: None}; - | ----- move occurs because `t` has type `Test`, which does not implement the `Copy` trait -LL | let mut u = Test { a: 2, b: Some(Box::new(t))}; - | - value moved here -LL | t.b = Some(Box::new(u)); - | ^^^ value assigned here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-2.rs b/src/test/ui/borrowck/borrowck-partial-reinit-2.rs index 986c20e361c..06cd322e77e 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-2.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-2.rs @@ -13,7 +13,7 @@ fn stuff() { let mut t = Test { a: 1, b: None}; let mut u = Test { a: 2, b: Some(Box::new(t))}; t.b = Some(Box::new(u)); - //~^ ERROR partial reinitialization of uninitialized structure `t` + //~^ ERROR assign of moved value: `t` println!("done"); } diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr index 891f6088508..36a871fbb12 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-2.stderr @@ -1,9 +1,13 @@ -error[E0383]: partial reinitialization of uninitialized structure `t` +error[E0382]: assign of moved value: `t` --> $DIR/borrowck-partial-reinit-2.rs:15:5 | +LL | let mut t = Test { a: 1, b: None}; + | ----- move occurs because `t` has type `Test`, which does not implement the `Copy` trait +LL | let mut u = Test { a: 2, b: Some(Box::new(t))}; + | - value moved here LL | t.b = Some(Box::new(u)); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ value assigned here after move error: aborting due to previous error -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-3.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-3.nll.stderr deleted file mode 100644 index 05f5411eed6..00000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-3.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: assign of moved value: `x.0` - --> $DIR/borrowck-partial-reinit-3.rs:11:5 - | -LL | mem::drop(x.0); - | --- value moved here -LL | x.0.f = 3; - | ^^^^^^^^^ value assigned here after move - | - = note: move occurs because `x.0` has type `Test`, which does not implement the `Copy` trait - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-3.rs b/src/test/ui/borrowck/borrowck-partial-reinit-3.rs index c7fbd7fc881..ca484315ba5 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-3.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-3.rs @@ -9,5 +9,5 @@ fn main() { let mut x = (Test { f: 2 }, Test { f: 4 }); mem::drop(x.0); x.0.f = 3; - //~^ ERROR partial reinitialization of uninitialized structure `x.0` + //~^ ERROR assign of moved value: `x.0` } diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr index 262317444cb..05f5411eed6 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-3.stderr @@ -1,9 +1,13 @@ -error[E0383]: partial reinitialization of uninitialized structure `x.0` +error[E0382]: assign of moved value: `x.0` --> $DIR/borrowck-partial-reinit-3.rs:11:5 | +LL | mem::drop(x.0); + | --- value moved here LL | x.0.f = 3; - | ^^^^^^^^^ + | ^^^^^^^^^ value assigned here after move + | + = note: move occurs because `x.0` has type `Test`, which does not implement the `Copy` trait error: aborting due to previous error -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-4.nll.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-4.nll.stderr deleted file mode 100644 index f0a9a7dd5e2..00000000000 --- a/src/test/ui/borrowck/borrowck-partial-reinit-4.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: assign of possibly uninitialized variable: `x.0` - --> $DIR/borrowck-partial-reinit-4.rs:17:5 - | -LL | (x.0).0 = Some(Test); - | ^^^^^^^ use of possibly uninitialized `x.0` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-4.rs b/src/test/ui/borrowck/borrowck-partial-reinit-4.rs index ffa6b11b6fa..0fb955d201d 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-4.rs +++ b/src/test/ui/borrowck/borrowck-partial-reinit-4.rs @@ -15,7 +15,7 @@ impl Drop for Test2 { fn stuff() { let mut x : (Test2, Test2); (x.0).0 = Some(Test); - //~^ ERROR partial reinitialization of uninitialized structure `x.0` + //~^ ERROR assign of possibly uninitialized variable: `x.0` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr b/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr index 8ca8e7e13c6..f0a9a7dd5e2 100644 --- a/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr +++ b/src/test/ui/borrowck/borrowck-partial-reinit-4.stderr @@ -1,9 +1,9 @@ -error[E0383]: partial reinitialization of uninitialized structure `x.0` +error[E0381]: assign of possibly uninitialized variable: `x.0` --> $DIR/borrowck-partial-reinit-4.rs:17:5 | LL | (x.0).0 = Some(Test); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ use of possibly uninitialized `x.0` error: aborting due to previous error -For more information about this error, try `rustc --explain E0383`. +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr deleted file mode 100644 index f0e16838c8a..00000000000 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-pat-reassign-binding.rs:13:11 - | -LL | Some(ref i) => { - | ----- borrow of `x` occurs here -LL | // But on this branch, `i` is an outstanding borrow -LL | x = Some(*i+1); - | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | -LL | drop(i); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.stderr deleted file mode 100644 index d7bce40edcf..00000000000 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-pat-reassign-binding.rs:13:11 - | -LL | Some(ref i) => { - | ----- borrow of `x` occurs here -LL | // But on this branch, `i` is an outstanding borrow -LL | x = Some(*i+1); - | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs b/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs index 9befa9162d5..f02c46fb8f0 100644 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs +++ b/src/test/ui/borrowck/borrowck-pat-reassign-binding.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let mut x: Option<isize> = None; match x { @@ -10,8 +7,7 @@ fn main() { } Some(ref i) => { // But on this branch, `i` is an outstanding borrow - x = Some(*i+1); //[ast]~ ERROR cannot assign to `x` - //[mir]~^ ERROR cannot assign to `x` because it is borrowed + x = Some(*i+1); //~ ERROR cannot assign to `x` because it is borrowed drop(i); } } diff --git a/src/test/ui/borrowck/borrowck-pat-reassign-binding.mir.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.stderr index f0e16838c8a..9e65ccf5a19 100644 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.mir.stderr +++ b/src/test/ui/borrowck/borrowck-pat-reassign-binding.stderr @@ -1,12 +1,11 @@ error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-pat-reassign-binding.rs:13:11 + --> $DIR/borrowck-pat-reassign-binding.rs:10:11 | LL | Some(ref i) => { | ----- borrow of `x` occurs here LL | // But on this branch, `i` is an outstanding borrow LL | x = Some(*i+1); | ^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here -LL | LL | drop(i); | - borrow later used here diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr deleted file mode 100644 index 284cab29608..00000000000 --- a/src/test/ui/borrowck/borrowck-reborrow-from-mut.nll.stderr +++ /dev/null @@ -1,116 +0,0 @@ -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:13:17 - | -LL | let _bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:18:17 - | -LL | let _bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | let _bar2 = &foo.bar1; - | ^^^^^^^^^ immutable borrow occurs here -LL | use_mut(_bar1); - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:23:17 - | -LL | let _bar1 = &foo.bar1; - | --------- immutable borrow occurs here -LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | use_imm(_bar1); - | ----- immutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:45:21 - | -LL | let _bar1 = &mut foo.bar1; - | ------------- first mutable borrow occurs here -LL | match *foo { -LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} - | ^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:52:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; - | ^^^^^^^^^ immutable borrow occurs here -LL | let _foo2 = &*foo; -LL | use_mut(_bar1); - | ----- mutable borrow later used here - -error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:53:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ mutable borrow occurs here -LL | let _foo1 = &foo.bar1; -LL | let _foo2 = &*foo; - | ^^^^^ immutable borrow occurs here -LL | use_mut(_bar1); - | ----- mutable borrow later used here - -error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:58:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ second mutable borrow occurs here -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:63:17 - | -LL | let _bar1 = &mut foo.bar1.int1; - | ------------------ first mutable borrow occurs here -LL | let _foo2 = &mut *foo; - | ^^^^^^^^^ second mutable borrow occurs here -LL | use_mut(_bar1); - | ----- first borrow later used here - -error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:68:17 - | -LL | let _bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ mutable borrow occurs here -LL | use_imm(_bar1); - | ----- immutable borrow later used here - -error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:73:17 - | -LL | let _bar1 = &foo.bar1.int1; - | -------------- immutable borrow occurs here -LL | let _foo2 = &mut *foo; - | ^^^^^^^^^ mutable borrow occurs here -LL | use_imm(_bar1); - | ----- immutable borrow later used here - -error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-reborrow-from-mut.rs:88:17 - | -LL | fn borrow_mut_from_imm(foo: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut Foo` -LL | let _bar1 = &mut foo.bar1; - | ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 11 previous errors - -Some errors have detailed explanations: E0499, E0502, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr b/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr index bcb239494e0..284cab29608 100644 --- a/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr +++ b/src/test/ui/borrowck/borrowck-reborrow-from-mut.stderr @@ -1,122 +1,114 @@ error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:13:22 + --> $DIR/borrowck-reborrow-from-mut.rs:13:17 | LL | let _bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:18:18 + --> $DIR/borrowck-reborrow-from-mut.rs:18:17 | LL | let _bar1 = &mut foo.bar1; - | -------- mutable borrow occurs here + | ------------- mutable borrow occurs here LL | let _bar2 = &foo.bar1; - | ^^^^^^^^ immutable borrow occurs here + | ^^^^^^^^^ immutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:23:22 + --> $DIR/borrowck-reborrow-from-mut.rs:23:17 | LL | let _bar1 = &foo.bar1; - | -------- immutable borrow occurs here + | --------- immutable borrow occurs here LL | let _bar2 = &mut foo.bar1; - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | use_imm(_bar1); -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-reborrow-from-mut.rs:45:21 | LL | let _bar1 = &mut foo.bar1; - | -------- first mutable borrow occurs here + | ------------- first mutable borrow occurs here LL | match *foo { LL | Foo { bar1: ref mut _bar1, bar2: _ } => {} | ^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | use_mut(_bar1); + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:52:18 +error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:52:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; - | ^^^^^^^^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^^^^^^^^ immutable borrow occurs here +LL | let _foo2 = &*foo; +LL | use_mut(_bar1); + | ----- mutable borrow later used here -error[E0502]: cannot borrow `*foo` as immutable because `foo.bar1.int1` is also borrowed as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:53:18 +error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-reborrow-from-mut.rs:53:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- mutable borrow occurs here + | ------------------ mutable borrow occurs here LL | let _foo1 = &foo.bar1; LL | let _foo2 = &*foo; - | ^^^^ immutable borrow occurs here + | ^^^^^ immutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - mutable borrow ends here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:58:22 + --> $DIR/borrowck-reborrow-from-mut.rs:58:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^ second mutable borrow occurs here + | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - first borrow ends here + | ----- first borrow later used here error[E0499]: cannot borrow `*foo` as mutable more than once at a time - --> $DIR/borrowck-reborrow-from-mut.rs:63:22 + --> $DIR/borrowck-reborrow-from-mut.rs:63:17 | LL | let _bar1 = &mut foo.bar1.int1; - | ------------- first mutable borrow occurs here + | ------------------ first mutable borrow occurs here LL | let _foo2 = &mut *foo; - | ^^^^ second mutable borrow occurs here + | ^^^^^^^^^ second mutable borrow occurs here LL | use_mut(_bar1); -LL | } - | - first borrow ends here + | ----- first borrow later used here -error[E0502]: cannot borrow `foo.bar1` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:68:22 +error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:68:17 | LL | let _bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo1 = &mut foo.bar1; - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^ mutable borrow occurs here LL | use_imm(_bar1); -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0502]: cannot borrow `*foo` as mutable because `foo.bar1.int1` is also borrowed as immutable - --> $DIR/borrowck-reborrow-from-mut.rs:73:22 +error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-reborrow-from-mut.rs:73:17 | LL | let _bar1 = &foo.bar1.int1; - | ------------- immutable borrow occurs here + | -------------- immutable borrow occurs here LL | let _foo2 = &mut *foo; - | ^^^^ mutable borrow occurs here + | ^^^^^^^^^ mutable borrow occurs here LL | use_imm(_bar1); -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used here -error[E0596]: cannot borrow field `foo.bar1` of immutable binding as mutable - --> $DIR/borrowck-reborrow-from-mut.rs:88:22 +error[E0596]: cannot borrow `foo.bar1` as mutable, as it is behind a `&` reference + --> $DIR/borrowck-reborrow-from-mut.rs:88:17 | LL | fn borrow_mut_from_imm(foo: &Foo) { - | ---- use `&mut Foo` here to make mutable + | ---- help: consider changing this to be a mutable reference: `&mut Foo` LL | let _bar1 = &mut foo.bar1; - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 11 previous errors diff --git a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.nll.stderr b/src/test/ui/borrowck/borrowck-ref-mut-of-imm.nll.stderr deleted file mode 100644 index e744fc6b54b..00000000000 --- a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/borrowck-ref-mut-of-imm.rs:4:12 - | -LL | fn destructure(x: Option<isize>) -> isize { - | - help: consider changing this to be mutable: `mut x` -... -LL | Some(ref mut v) => *v - | ^^^^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr b/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr index 6e0d2f69945..e744fc6b54b 100644 --- a/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr +++ b/src/test/ui/borrowck/borrowck-ref-mut-of-imm.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow field `(x as std::prelude::v1::Some).0` of immutable binding as mutable +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-ref-mut-of-imm.rs:4:12 | LL | fn destructure(x: Option<isize>) -> isize { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... LL | Some(ref mut v) => *v - | ^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr deleted file mode 100644 index db73d4c04ac..00000000000 --- a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:8:13 - | -LL | let y = &mut x; - | ------ mutable borrow occurs here -LL | -LL | let z = &x; - | ^^ immutable borrow occurs here -... -LL | y.use_mut(); - | - mutable borrow later used here - -error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21 - | -LL | let y = &x; - | -- immutable borrow occurs here -LL | -LL | let z = &mut x; - | ^^^^^^ mutable borrow occurs here -... -LL | y.use_ref(); - | - immutable borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | -LL | let z = &mut x; - | ^^^^^^ second mutable borrow occurs here -... -LL | y.use_mut(); - | - first borrow later used here - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr index a3e6682453a..db73d4c04ac 100644 --- a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr +++ b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.stderr @@ -1,38 +1,38 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:8:14 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:8:13 | LL | let y = &mut x; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | LL | let z = &x; - | ^ immutable borrow occurs here + | ^^ immutable borrow occurs here ... -LL | } - | - mutable borrow ends here +LL | y.use_mut(); + | - mutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:26 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:21:21 | LL | let y = &x; - | - immutable borrow occurs here + | -- immutable borrow occurs here LL | LL | let z = &mut x; - | ^ mutable borrow occurs here + | ^^^^^^ mutable borrow occurs here ... -LL | } - | - immutable borrow ends here +LL | y.use_ref(); + | - immutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:22 + --> $DIR/borrowck-report-with-custom-diagnostic.rs:36:17 | LL | let y = &mut x; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | LL | let z = &mut x; - | ^ second mutable borrow occurs here + | ^^^^^^ second mutable borrow occurs here ... -LL | }; - | - first borrow ends here +LL | y.use_mut(); + | - first borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr deleted file mode 100644 index d54449ac4ad..00000000000 --- a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing function parameter `x` - --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:7:5 - | -LL | (&x).clone() - | ----^^^^^^^^ - | | - | returns a value referencing data owned by the current function - | `x` is borrowed here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs index f8cdc3ed97c..75e5e7fd421 100644 --- a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs +++ b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.rs @@ -4,7 +4,7 @@ // Issue #19261. fn leak<'a, T>(x: T) -> &'a T { - (&x).clone() //~ ERROR `x` does not live long enough + (&x).clone() //~ ERROR cannot return value referencing function parameter `x` } fn main() { } diff --git a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr index 4d4244ba5ef..d54449ac4ad 100644 --- a/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr +++ b/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.stderr @@ -1,17 +1,12 @@ -error[E0597]: `x` does not live long enough - --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:7:7 +error[E0515]: cannot return value referencing function parameter `x` + --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:7:5 | LL | (&x).clone() - | ^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 6:9... - --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:6:9 - | -LL | fn leak<'a, T>(x: T) -> &'a T { - | ^^ + | ----^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `x` is borrowed here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.stderr deleted file mode 100644 index bc0a954b46d..00000000000 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:15:25 - | -LL | let _s2 = S{a: 2, ..s0}; - | ^^ cannot move out of here - -error[E0509]: cannot move out of type `T`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:21:25 - | -LL | let _s2 = T{a: 2, ..s0}; - | ^^ cannot move out of here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.stderr deleted file mode 100644 index dbc9ece0c8f..00000000000 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:15:15 - | -LL | let _s2 = S{a: 2, ..s0}; - | ^^^^^^^^^^^^^ cannot move out of here - -error[E0509]: cannot move out of type `T`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:21:15 - | -LL | let _s2 = T{a: 2, ..s0}; - | ^^^^^^^^^^^^^ cannot move out of here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs index da5bb636631..1f6ed6d46aa 100644 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs +++ b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Issue 4691: Ensure that functional-struct-update can only copy, not // move, when the struct implements Drop. @@ -13,14 +10,12 @@ impl Drop for T { fn drop(&mut self) { } } fn f(s0:S) { let _s2 = S{a: 2, ..s0}; - //[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn g(s0:T) { let _s2 = T{a: 2, ..s0}; - //[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait - //[mir]~^^ ERROR [E0509] + //~^ ERROR [E0509] } fn main() { } diff --git a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.stderr index dbc9ece0c8f..ea16502ebe5 100644 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.stderr @@ -1,11 +1,11 @@ error[E0509]: cannot move out of type `S`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:15:15 + --> $DIR/borrowck-struct-update-with-dtor.rs:12:15 | LL | let _s2 = S{a: 2, ..s0}; | ^^^^^^^^^^^^^ cannot move out of here error[E0509]: cannot move out of type `T`, which implements the `Drop` trait - --> $DIR/borrowck-struct-update-with-dtor.rs:21:15 + --> $DIR/borrowck-struct-update-with-dtor.rs:17:15 | LL | let _s2 = T{a: 2, ..s0}; | ^^^^^^^^^^^^^ cannot move out of here diff --git a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr deleted file mode 100644 index 1c55953c91f..00000000000 --- a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-swap-mut-base-ptr.rs:13:10 - | -LL | let p: &isize = &*t0; // Freezes `*t0` - | ---- immutable borrow occurs here -LL | swap(&mut t0, &mut t1); - | ^^^^^^^ mutable borrow occurs here -LL | *t1 = 22; -LL | p.use_ref(); - | - immutable borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr index 9efd249caf8..1c55953c91f 100644 --- a/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr +++ b/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.stderr @@ -1,13 +1,13 @@ -error[E0502]: cannot borrow `t0` as mutable because `*t0` is also borrowed as immutable - --> $DIR/borrowck-swap-mut-base-ptr.rs:13:15 +error[E0502]: cannot borrow `t0` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-swap-mut-base-ptr.rs:13:10 | LL | let p: &isize = &*t0; // Freezes `*t0` - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | swap(&mut t0, &mut t1); - | ^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^ mutable borrow occurs here +LL | *t1 = 22; +LL | p.use_ref(); + | - immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr deleted file mode 100644 index d2b6e060569..00000000000 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0712]: thread-local variable borrowed past end of function - --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:11:20 - | -LL | assert_static(&FOO); - | ^^^^ thread-local variables cannot be borrowed beyond the end of the function -LL | -LL | } - | - end of enclosing function is here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0712`. diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr deleted file mode 100644 index ce7b5e681c6..00000000000 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.ast.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:11:21 - | -LL | assert_static(&FOO); - | ^^^ - borrowed value only lives until here - | | - | borrowed value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs index 6fd6acc8346..1cf8d187c25 100644 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs +++ b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(thread_local)] #[thread_local] @@ -8,6 +5,5 @@ static FOO: u8 = 3; fn assert_static(_t: &'static u8) {} fn main() { - assert_static(&FOO); //[ast]~ ERROR [E0597] - //[mir]~^ ERROR [E0712] + assert_static(&FOO); //~ ERROR [E0712] } diff --git a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr index d2b6e060569..26453b42fa9 100644 --- a/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr +++ b/src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr @@ -1,9 +1,8 @@ error[E0712]: thread-local variable borrowed past end of function - --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:11:20 + --> $DIR/borrowck-thread-local-static-borrow-outlives-fn.rs:8:20 | LL | assert_static(&FOO); | ^^^^ thread-local variables cannot be borrowed beyond the end of the function -LL | LL | } | - end of enclosing function is here diff --git a/src/test/ui/borrowck/borrowck-unary-move.ast.stderr b/src/test/ui/borrowck/borrowck-unary-move.ast.stderr deleted file mode 100644 index e05b110a2c0..00000000000 --- a/src/test/ui/borrowck/borrowck-unary-move.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-unary-move.rs:7:10 - | -LL | let y = &*x; - | -- borrow of `*x` occurs here -LL | free(x); - | ^ move out of `x` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-unary-move.mir.stderr b/src/test/ui/borrowck/borrowck-unary-move.mir.stderr deleted file mode 100644 index c29ff538304..00000000000 --- a/src/test/ui/borrowck/borrowck-unary-move.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-unary-move.rs:7:10 - | -LL | let y = &*x; - | --- borrow of `*x` occurs here -LL | free(x); - | ^ move out of `x` occurs here -LL | -LL | *y - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/borrowck/borrowck-unary-move.rs b/src/test/ui/borrowck/borrowck-unary-move.rs index 4e023ac8599..3b4c0731fc5 100644 --- a/src/test/ui/borrowck/borrowck-unary-move.rs +++ b/src/test/ui/borrowck/borrowck-unary-move.rs @@ -1,11 +1,6 @@ -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn foo(x: Box<isize>) -> isize { let y = &*x; - free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed - //[mir]~^ ERROR cannot move out of `x` because it is borrowed + free(x); //~ ERROR cannot move out of `x` because it is borrowed *y } diff --git a/src/test/ui/borrowck/borrowck-unary-move.ast.nll.stderr b/src/test/ui/borrowck/borrowck-unary-move.stderr index c29ff538304..aab225ed4a4 100644 --- a/src/test/ui/borrowck/borrowck-unary-move.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-unary-move.stderr @@ -1,11 +1,10 @@ error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/borrowck-unary-move.rs:7:10 + --> $DIR/borrowck-unary-move.rs:3:10 | LL | let y = &*x; | --- borrow of `*x` occurs here LL | free(x); | ^ move out of `x` occurs here -LL | LL | *y | -- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr deleted file mode 100644 index 40b8e313484..00000000000 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-unboxed-closures.rs:3:5 - | -LL | let g = &mut f; - | ------ mutable borrow occurs here -LL | f(1, 2); - | ^ immutable borrow occurs here -LL | use_mut(g); - | - mutable borrow later used here - -error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable - --> $DIR/borrowck-unboxed-closures.rs:7:5 - | -LL | fn b<F:FnMut(isize, isize) -> isize>(f: F) { - | - help: consider changing this to be mutable: `mut f` -LL | f(1, 2); - | ^ cannot borrow as mutable - -error[E0382]: use of moved value: `f` - --> $DIR/borrowck-unboxed-closures.rs:12:5 - | -LL | fn c<F:FnOnce(isize, isize) -> isize>(f: F) { - | - - move occurs because `f` has type `F`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | f(1, 2); - | - value moved here -LL | f(1, 2); - | ^ value used here after move - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0382, E0502, E0596. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.rs b/src/test/ui/borrowck/borrowck-unboxed-closures.rs index bfd0fbb3050..f0048dd7de0 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.rs +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.rs @@ -4,7 +4,7 @@ fn a<F:Fn(isize, isize) -> isize>(mut f: F) { use_mut(g); } fn b<F:FnMut(isize, isize) -> isize>(f: F) { - f(1, 2); //~ ERROR cannot borrow immutable argument + f(1, 2); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable } fn c<F:FnOnce(isize, isize) -> isize>(f: F) { diff --git a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr index 0be9e5aa2f0..40b8e313484 100644 --- a/src/test/ui/borrowck/borrowck-unboxed-closures.stderr +++ b/src/test/ui/borrowck/borrowck-unboxed-closures.stderr @@ -2,30 +2,31 @@ error[E0502]: cannot borrow `f` as immutable because it is also borrowed as muta --> $DIR/borrowck-unboxed-closures.rs:3:5 | LL | let g = &mut f; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | f(1, 2); | ^ immutable borrow occurs here LL | use_mut(g); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here -error[E0596]: cannot borrow immutable argument `f` as mutable +error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable --> $DIR/borrowck-unboxed-closures.rs:7:5 | LL | fn b<F:FnMut(isize, isize) -> isize>(f: F) { - | - help: make this binding mutable: `mut f` + | - help: consider changing this to be mutable: `mut f` LL | f(1, 2); - | ^ cannot borrow mutably + | ^ cannot borrow as mutable error[E0382]: use of moved value: `f` --> $DIR/borrowck-unboxed-closures.rs:12:5 | +LL | fn c<F:FnOnce(isize, isize) -> isize>(f: F) { + | - - move occurs because `f` has type `F`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | f(1, 2); | - value moved here LL | f(1, 2); | ^ value used here after move - | - = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr b/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr deleted file mode 100644 index da4d016bc2a..00000000000 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-field-access.rs:24:13 - | -LL | let _ = a.x + 1; - | ^^^ use of possibly uninitialized `a.x` - -error[E0382]: use of moved value: `line1.origin` - --> $DIR/borrowck-uninit-field-access.rs:29:13 - | -LL | let _moved = line1.origin; - | ------------ value moved here -LL | let _ = line1.origin.x + 1; - | ^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `line2` - --> $DIR/borrowck-uninit-field-access.rs:34:5 - | -LL | let _moved = (line2.origin, line2.middle); - | ------------ value moved here -LL | line2.consume(); - | ^^^^^ value used here after partial move - | - = note: move occurs because `line2.middle` has type `Point`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0381, E0382. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.stderr b/src/test/ui/borrowck/borrowck-uninit-field-access.ast.stderr deleted file mode 100644 index 00cacfe8a31..00000000000 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `a.x` - --> $DIR/borrowck-uninit-field-access.rs:24:13 - | -LL | let _ = a.x + 1; - | ^^^ use of possibly uninitialized `a.x` - -error[E0382]: use of moved value: `line1.origin.x` - --> $DIR/borrowck-uninit-field-access.rs:29:13 - | -LL | let _moved = line1.origin; - | ------ value moved here -LL | let _ = line1.origin.x + 1; - | ^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait - -error[E0382]: use of partially moved value: `line2` - --> $DIR/borrowck-uninit-field-access.rs:34:5 - | -LL | let _moved = (line2.origin, line2.middle); - | ------------ value moved here -LL | line2.consume(); - | ^^^^^ value used here after move - | - = note: move occurs because `line2.origin` has type `Point`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0381, E0382. -For more information about an error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.rs b/src/test/ui/borrowck/borrowck-uninit-field-access.rs index ab19b2d7735..bc931eef93a 100644 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.rs +++ b/src/test/ui/borrowck/borrowck-uninit-field-access.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Check that do not allow access to fields of uninitialized or moved // structs. @@ -21,16 +18,13 @@ impl Line { fn consume(self) { } } fn main() { let mut a: Point; - let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` - //[mir]~^ ERROR [E0381] + let _ = a.x + 1; //~ ERROR [E0381] let mut line1 = Line::default(); let _moved = line1.origin; - let _ = line1.origin.x + 1; //[ast]~ ERROR use of moved value: `line1.origin.x` - //[mir]~^ [E0382] + let _ = line1.origin.x + 1; //~ ERROR [E0382] let mut line2 = Line::default(); let _moved = (line2.origin, line2.middle); - line2.consume(); //[ast]~ ERROR use of partially moved value: `line2` [E0382] - //[mir]~^ [E0382] + line2.consume(); //~ ERROR [E0382] } diff --git a/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr b/src/test/ui/borrowck/borrowck-uninit-field-access.stderr index da4d016bc2a..aa214f9c2f5 100644 --- a/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr +++ b/src/test/ui/borrowck/borrowck-uninit-field-access.stderr @@ -1,11 +1,11 @@ error[E0381]: use of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-field-access.rs:24:13 + --> $DIR/borrowck-uninit-field-access.rs:21:13 | LL | let _ = a.x + 1; | ^^^ use of possibly uninitialized `a.x` error[E0382]: use of moved value: `line1.origin` - --> $DIR/borrowck-uninit-field-access.rs:29:13 + --> $DIR/borrowck-uninit-field-access.rs:25:13 | LL | let _moved = line1.origin; | ------------ value moved here @@ -15,7 +15,7 @@ LL | let _ = line1.origin.x + 1; = note: move occurs because `line1.origin` has type `Point`, which does not implement the `Copy` trait error[E0382]: use of moved value: `line2` - --> $DIR/borrowck-uninit-field-access.rs:34:5 + --> $DIR/borrowck-uninit-field-access.rs:29:5 | LL | let _moved = (line2.origin, line2.middle); | ------------ value moved here diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.stderr b/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.stderr deleted file mode 100644 index 8cb3f3bf89f..00000000000 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `**x` - --> $DIR/borrowck-uninit-ref-chain.rs:11:15 - | -LL | let _y = &**x; - | ^^^ use of possibly uninitialized `**x` - -error[E0381]: use of possibly uninitialized variable: `**x` - --> $DIR/borrowck-uninit-ref-chain.rs:15:15 - | -LL | let _y = &**x; - | ^^^ use of possibly uninitialized `**x` - -error[E0381]: use of possibly uninitialized variable: `**x` - --> $DIR/borrowck-uninit-ref-chain.rs:19:15 - | -LL | let _y = &**x; - | ^^^ use of possibly uninitialized `**x` - -error[E0381]: use of possibly uninitialized variable: `a.x` - --> $DIR/borrowck-uninit-ref-chain.rs:25:15 - | -LL | let _b = &a.x; - | ^^^ use of possibly uninitialized `a.x` - -error[E0381]: use of possibly uninitialized variable: `**a.x` - --> $DIR/borrowck-uninit-ref-chain.rs:30:15 - | -LL | let _b = &**a.x; - | ^^^^^ use of possibly uninitialized `**a.x` - -error[E0381]: use of possibly uninitialized variable: `a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:36:15 - | -LL | let _b = &a.y; - | ^^^ use of possibly uninitialized `a.y` - -error[E0381]: use of possibly uninitialized variable: `**a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:41:15 - | -LL | let _b = &**a.y; - | ^^^^^ use of possibly uninitialized `**a.y` - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr b/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr deleted file mode 100644 index a5cf59c945a..00000000000 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:11:14 - | -LL | let _y = &**x; - | ^^^^ use of possibly uninitialized `**x` - -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:15:14 - | -LL | let _y = &**x; - | ^^^^ use of possibly uninitialized `**x` - -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:19:14 - | -LL | let _y = &**x; - | ^^^^ use of possibly uninitialized `**x` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:24:5 - | -LL | a.x = 0; - | ^^^^^^^ use of possibly uninitialized `a` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:29:5 - | -LL | a.x = &&0; - | ^^^^^^^^^ use of possibly uninitialized `a` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:35:5 - | -LL | a.x = 0; - | ^^^^^^^ use of possibly uninitialized `a` - -error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:40:5 - | -LL | a.x = &&0; - | ^^^^^^^^^ use of possibly uninitialized `a` - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs b/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs index 562012a23da..fa9148f9840 100644 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs +++ b/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct S<X, Y> { x: X, y: Y, @@ -8,36 +5,29 @@ struct S<X, Y> { fn main() { let x: &&Box<i32>; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] + let _y = &**x; //~ [E0381] let x: &&S<i32, i32>; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] + let _y = &**x; //~ [E0381] let x: &&i32; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] + let _y = &**x; //~ [E0381] let mut a: S<i32, i32>; - a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] - + a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &a.x; let mut a: S<&&i32, &&i32>; - a.x = &&0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] - + a.x = &&0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &**a.x; let mut a: S<i32, i32>; - a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] - + a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &a.y; let mut a: S<&&i32, &&i32>; - a.x = &&0; //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381] - let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] - + a.x = &&0; //~ assign to part of possibly uninitialized variable: `a` [E0381] + let _b = &**a.y; } diff --git a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr b/src/test/ui/borrowck/borrowck-uninit-ref-chain.stderr index a5cf59c945a..d87621f04d6 100644 --- a/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-uninit-ref-chain.stderr @@ -1,41 +1,41 @@ error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:11:14 + --> $DIR/borrowck-uninit-ref-chain.rs:8:14 | LL | let _y = &**x; | ^^^^ use of possibly uninitialized `**x` error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:15:14 + --> $DIR/borrowck-uninit-ref-chain.rs:11:14 | LL | let _y = &**x; | ^^^^ use of possibly uninitialized `**x` error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-uninit-ref-chain.rs:19:14 + --> $DIR/borrowck-uninit-ref-chain.rs:14:14 | LL | let _y = &**x; | ^^^^ use of possibly uninitialized `**x` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:24:5 + --> $DIR/borrowck-uninit-ref-chain.rs:18:5 | LL | a.x = 0; | ^^^^^^^ use of possibly uninitialized `a` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:29:5 + --> $DIR/borrowck-uninit-ref-chain.rs:22:5 | LL | a.x = &&0; | ^^^^^^^^^ use of possibly uninitialized `a` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:35:5 + --> $DIR/borrowck-uninit-ref-chain.rs:27:5 | LL | a.x = 0; | ^^^^^^^ use of possibly uninitialized `a` error[E0381]: assign to part of possibly uninitialized variable: `a` - --> $DIR/borrowck-uninit-ref-chain.rs:40:5 + --> $DIR/borrowck-uninit-ref-chain.rs:31:5 | LL | a.x = &&0; | ^^^^^^^^^ use of possibly uninitialized `a` diff --git a/src/test/ui/borrowck/borrowck-union-borrow-nested.nll.stderr b/src/test/ui/borrowck/borrowck-union-borrow-nested.nll.stderr deleted file mode 100644 index 61569b9cac1..00000000000 --- a/src/test/ui/borrowck/borrowck-union-borrow-nested.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0503]: cannot use `u.c` because it was mutably borrowed - --> $DIR/borrowck-union-borrow-nested.rs:24:21 - | -LL | let ra = &mut u.s.a; - | ---------- borrow of `u.s.a` occurs here -LL | let b = u.c; - | ^^^ use of borrowed `u.s.a` -LL | ra.use_mut(); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr b/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr index 71fae6f8d63..61569b9cac1 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr +++ b/src/test/ui/borrowck/borrowck-union-borrow-nested.stderr @@ -1,10 +1,12 @@ error[E0503]: cannot use `u.c` because it was mutably borrowed - --> $DIR/borrowck-union-borrow-nested.rs:24:17 + --> $DIR/borrowck-union-borrow-nested.rs:24:21 | LL | let ra = &mut u.s.a; - | ----- borrow of `u.s.a` occurs here + | ---------- borrow of `u.s.a` occurs here LL | let b = u.c; - | ^ use of borrowed `u.s.a` + | ^^^ use of borrowed `u.s.a` +LL | ra.use_mut(); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-union-borrow.nll.stderr b/src/test/ui/borrowck/borrowck-union-borrow.nll.stderr deleted file mode 100644 index ca10e299c58..00000000000 --- a/src/test/ui/borrowck/borrowck-union-borrow.nll.stderr +++ /dev/null @@ -1,131 +0,0 @@ -error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-union-borrow.rs:25:23 - | -LL | let ra = &u.a; - | ---- immutable borrow occurs here -LL | let rma = &mut u.a; - | ^^^^^^^^ mutable borrow occurs here -LL | drop(ra); - | -- immutable borrow later used here - -error[E0506]: cannot assign to `u.a` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:30:13 - | -LL | let ra = &u.a; - | ---- borrow of `u.a` occurs here -LL | u.a = 1; - | ^^^^^^^ assignment to borrowed `u.a` occurs here -LL | drop(ra); - | -- borrow later used here - -error[E0502]: cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:46:23 - | -LL | let ra = &u.a; - | ---- immutable borrow occurs here (via `u.a`) -LL | let rmb = &mut u.b; - | ^^^^^^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here -LL | drop(ra); - | -- immutable borrow later used here - | - = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` - -error[E0506]: cannot assign to `u.b` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:51:13 - | -LL | let ra = &u.a; - | ---- borrow of `u.b` occurs here -LL | u.b = 1; - | ^^^^^^^ assignment to borrowed `u.b` occurs here -LL | drop(ra); - | -- borrow later used here - -error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-union-borrow.rs:57:22 - | -LL | let rma = &mut u.a; - | -------- mutable borrow occurs here -LL | let ra = &u.a; - | ^^^^ immutable borrow occurs here -LL | drop(rma); - | --- mutable borrow later used here - -error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:62:21 - | -LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | let a = u.a; - | ^^^ use of borrowed `u.a` -LL | drop(ra); - | -- borrow later used here - -error[E0499]: cannot borrow `u.a` as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:67:24 - | -LL | let rma = &mut u.a; - | -------- first mutable borrow occurs here -LL | let rma2 = &mut u.a; - | ^^^^^^^^ second mutable borrow occurs here -LL | drop(rma); - | --- first borrow later used here - -error[E0506]: cannot assign to `u.a` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:72:13 - | -LL | let rma = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | u.a = 1; - | ^^^^^^^ assignment to borrowed `u.a` occurs here -LL | drop(rma); - | --- borrow later used here - -error[E0502]: cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:78:22 - | -LL | let rma = &mut u.a; - | -------- mutable borrow occurs here (via `u.a`) -LL | let rb = &u.b; - | ^^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here -LL | drop(rma); - | --- mutable borrow later used here - | - = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` - -error[E0503]: cannot use `u.b` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:83:21 - | -LL | let ra = &mut u.a; - | -------- borrow of `u.a` occurs here -LL | let b = u.b; - | ^^^ use of borrowed `u.a` -LL | -LL | drop(ra); - | -- borrow later used here - -error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:89:24 - | -LL | let rma = &mut u.a; - | -------- first mutable borrow occurs here (via `u.a`) -LL | let rmb2 = &mut u.b; - | ^^^^^^^^ second mutable borrow occurs here (via `u.b`) -LL | drop(rma); - | --- first borrow later used here - | - = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` - -error[E0506]: cannot assign to `u.b` because it is borrowed - --> $DIR/borrowck-union-borrow.rs:94:13 - | -LL | let rma = &mut u.a; - | -------- borrow of `u.b` occurs here -LL | u.b = 1; - | ^^^^^^^ assignment to borrowed `u.b` occurs here -LL | drop(rma); - | --- borrow later used here - -error: aborting due to 12 previous errors - -Some errors have detailed explanations: E0499, E0502, E0503, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-union-borrow.rs b/src/test/ui/borrowck/borrowck-union-borrow.rs index 8afc0be8b55..63901680bd1 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow.rs +++ b/src/test/ui/borrowck/borrowck-union-borrow.rs @@ -43,7 +43,7 @@ fn main() { } { let ra = &u.a; - let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) + let rmb = &mut u.b; //~ ERROR cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`) drop(ra); } { @@ -75,7 +75,7 @@ fn main() { // Mut borrow, other field { let rma = &mut u.a; - let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) + let rb = &u.b; //~ ERROR cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`) drop(rma); } { diff --git a/src/test/ui/borrowck/borrowck-union-borrow.stderr b/src/test/ui/borrowck/borrowck-union-borrow.stderr index a8fd5ae0603..ca10e299c58 100644 --- a/src/test/ui/borrowck/borrowck-union-borrow.stderr +++ b/src/test/ui/borrowck/borrowck-union-borrow.stderr @@ -1,116 +1,129 @@ error[E0502]: cannot borrow `u.a` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-union-borrow.rs:25:28 + --> $DIR/borrowck-union-borrow.rs:25:23 | LL | let ra = &u.a; - | --- immutable borrow occurs here + | ---- immutable borrow occurs here LL | let rma = &mut u.a; - | ^^^ mutable borrow occurs here + | ^^^^^^^^ mutable borrow occurs here LL | drop(ra); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:30:13 | LL | let ra = &u.a; - | --- borrow of `u.a` occurs here + | ---- borrow of `u.a` occurs here LL | u.a = 1; | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | drop(ra); + | -- borrow later used here -error[E0502]: cannot borrow `u` (via `u.b`) as mutable because `u` is also borrowed as immutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:46:28 +error[E0502]: cannot borrow `u` (via `u.b`) as mutable because it is also borrowed as immutable (via `u.a`) + --> $DIR/borrowck-union-borrow.rs:46:23 | LL | let ra = &u.a; - | --- immutable borrow occurs here (via `u.a`) + | ---- immutable borrow occurs here (via `u.a`) LL | let rmb = &mut u.b; - | ^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here + | ^^^^^^^^ mutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here LL | drop(ra); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here + | + = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:51:13 | LL | let ra = &u.a; - | --- borrow of `u.b` occurs here + | ---- borrow of `u.b` occurs here LL | u.b = 1; | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | drop(ra); + | -- borrow later used here error[E0502]: cannot borrow `u.a` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-union-borrow.rs:57:23 + --> $DIR/borrowck-union-borrow.rs:57:22 | LL | let rma = &mut u.a; - | --- mutable borrow occurs here + | -------- mutable borrow occurs here LL | let ra = &u.a; - | ^^^ immutable borrow occurs here + | ^^^^ immutable borrow occurs here LL | drop(rma); -LL | } - | - mutable borrow ends here + | --- mutable borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:62:17 + --> $DIR/borrowck-union-borrow.rs:62:21 | LL | let ra = &mut u.a; - | --- borrow of `u.a` occurs here + | -------- borrow of `u.a` occurs here LL | let a = u.a; - | ^ use of borrowed `u.a` + | ^^^ use of borrowed `u.a` +LL | drop(ra); + | -- borrow later used here error[E0499]: cannot borrow `u.a` as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:67:29 + --> $DIR/borrowck-union-borrow.rs:67:24 | LL | let rma = &mut u.a; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let rma2 = &mut u.a; - | ^^^ second mutable borrow occurs here + | ^^^^^^^^ second mutable borrow occurs here LL | drop(rma); -LL | } - | - first borrow ends here + | --- first borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:72:13 | LL | let rma = &mut u.a; - | --- borrow of `u.a` occurs here + | -------- borrow of `u.a` occurs here LL | u.a = 1; | ^^^^^^^ assignment to borrowed `u.a` occurs here +LL | drop(rma); + | --- borrow later used here -error[E0502]: cannot borrow `u` (via `u.b`) as immutable because `u` is also borrowed as mutable (via `u.a`) - --> $DIR/borrowck-union-borrow.rs:78:23 +error[E0502]: cannot borrow `u` (via `u.b`) as immutable because it is also borrowed as mutable (via `u.a`) + --> $DIR/borrowck-union-borrow.rs:78:22 | LL | let rma = &mut u.a; - | --- mutable borrow occurs here (via `u.a`) + | -------- mutable borrow occurs here (via `u.a`) LL | let rb = &u.b; - | ^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here + | ^^^^ immutable borrow of `u.b` -- which overlaps with `u.a` -- occurs here LL | drop(rma); -LL | } - | - mutable borrow ends here + | --- mutable borrow later used here + | + = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` error[E0503]: cannot use `u.b` because it was mutably borrowed - --> $DIR/borrowck-union-borrow.rs:83:17 + --> $DIR/borrowck-union-borrow.rs:83:21 | LL | let ra = &mut u.a; - | --- borrow of `u.a` occurs here + | -------- borrow of `u.a` occurs here LL | let b = u.b; - | ^ use of borrowed `u.a` + | ^^^ use of borrowed `u.a` +LL | +LL | drop(ra); + | -- borrow later used here error[E0499]: cannot borrow `u` (via `u.b`) as mutable more than once at a time - --> $DIR/borrowck-union-borrow.rs:89:29 + --> $DIR/borrowck-union-borrow.rs:89:24 | LL | let rma = &mut u.a; - | --- first mutable borrow occurs here (via `u.a`) + | -------- first mutable borrow occurs here (via `u.a`) LL | let rmb2 = &mut u.b; - | ^^^ second mutable borrow occurs here (via `u.b`) + | ^^^^^^^^ second mutable borrow occurs here (via `u.b`) LL | drop(rma); -LL | } - | - first borrow ends here + | --- first borrow later used here + | + = note: `u.b` is a field of the union `U`, so it overlaps the field `u.a` error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:94:13 | LL | let rma = &mut u.a; - | --- borrow of `u.b` occurs here + | -------- borrow of `u.b` occurs here LL | u.b = 1; | ^^^^^^^ assignment to borrowed `u.b` occurs here +LL | drop(rma); + | --- borrow later used here error: aborting due to 12 previous errors diff --git a/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr b/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr deleted file mode 100644 index 0b1714fd75d..00000000000 --- a/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move-assign.rs:17:21 - | -LL | let mut u = U { a: A }; - | ----- move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = u.a; - | --- value moved here -LL | let a = u.a; - | ^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-union-move-assign.rs b/src/test/ui/borrowck/borrowck-union-move-assign.rs index 1bb43252036..a24f42d2ddf 100644 --- a/src/test/ui/borrowck/borrowck-union-move-assign.rs +++ b/src/test/ui/borrowck/borrowck-union-move-assign.rs @@ -14,7 +14,7 @@ fn main() { { let mut u = U { a: A }; let a = u.a; - let a = u.a; //~ ERROR use of moved value: `u.a` + let a = u.a; //~ ERROR use of moved value: `u` } { let mut u = U { a: A }; diff --git a/src/test/ui/borrowck/borrowck-union-move-assign.stderr b/src/test/ui/borrowck/borrowck-union-move-assign.stderr index 04e67fcb929..0b1714fd75d 100644 --- a/src/test/ui/borrowck/borrowck-union-move-assign.stderr +++ b/src/test/ui/borrowck/borrowck-union-move-assign.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `u.a` - --> $DIR/borrowck-union-move-assign.rs:17:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move-assign.rs:17:21 | +LL | let mut u = U { a: A }; + | ----- move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = u.a; - | - value moved here + | --- value moved here LL | let a = u.a; - | ^ value used here after move - | - = note: move occurs because `u.a` has type `A`, which does not implement the `Copy` trait + | ^^^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-union-move.nll.stderr b/src/test/ui/borrowck/borrowck-union-move.nll.stderr deleted file mode 100644 index abbb0142a9c..00000000000 --- a/src/test/ui/borrowck/borrowck-union-move.nll.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:26:21 - | -LL | let mut u = Unn { n1: NonCopy }; - | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -LL | let a = u.n1; - | ---- value moved here -LL | let a = u.n1; - | ^^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:31:21 - | -LL | let mut u = Unn { n1: NonCopy }; - | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -LL | let a = u.n1; - | ---- value moved here -LL | let a = u; - | ^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:36:21 - | -LL | let mut u = Unn { n1: NonCopy }; - | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -LL | let a = u.n1; - | ---- value moved here -LL | let a = u.n2; - | ^^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:63:21 - | -LL | let mut u = Ucn { c: Copy }; - | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait -LL | let a = u.n; - | --- value moved here -LL | let a = u.n; - | ^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:68:21 - | -LL | let mut u = Ucn { c: Copy }; - | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait -LL | let a = u.n; - | --- value moved here -LL | let a = u.c; - | ^^^ value used here after move - -error[E0382]: use of moved value: `u` - --> $DIR/borrowck-union-move.rs:83:21 - | -LL | let mut u = Ucn { c: Copy }; - | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait -LL | let a = u.n; - | --- value moved here -LL | let a = u; - | ^ value used here after move - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/borrowck-union-move.rs b/src/test/ui/borrowck/borrowck-union-move.rs index e2480604f29..d0aa6dff744 100644 --- a/src/test/ui/borrowck/borrowck-union-move.rs +++ b/src/test/ui/borrowck/borrowck-union-move.rs @@ -23,17 +23,17 @@ fn main() { { let mut u = Unn { n1: NonCopy }; let a = u.n1; - let a = u.n1; //~ ERROR use of moved value: `u.n1` + let a = u.n1; //~ ERROR use of moved value: `u` } { let mut u = Unn { n1: NonCopy }; let a = u.n1; - let a = u; //~ ERROR use of partially moved value: `u` + let a = u; //~ ERROR use of moved value: `u` } { let mut u = Unn { n1: NonCopy }; let a = u.n1; - let a = u.n2; //~ ERROR use of moved value: `u.n2` + let a = u.n2; //~ ERROR use of moved value: `u` } // 2 Copy { @@ -60,12 +60,12 @@ fn main() { { let mut u = Ucn { c: Copy }; let a = u.n; - let a = u.n; //~ ERROR use of moved value: `u.n` + let a = u.n; //~ ERROR use of moved value: `u` } { let mut u = Ucn { c: Copy }; let a = u.n; - let a = u.c; //~ ERROR use of moved value: `u.c` + let a = u.c; //~ ERROR use of moved value: `u` } { let mut u = Ucn { c: Copy }; @@ -80,7 +80,7 @@ fn main() { { let mut u = Ucn { c: Copy }; let a = u.n; - let a = u; //~ ERROR use of partially moved value: `u` + let a = u; //~ ERROR use of moved value: `u` } } } diff --git a/src/test/ui/borrowck/borrowck-union-move.stderr b/src/test/ui/borrowck/borrowck-union-move.stderr index 4ce372aedc3..abbb0142a9c 100644 --- a/src/test/ui/borrowck/borrowck-union-move.stderr +++ b/src/test/ui/borrowck/borrowck-union-move.stderr @@ -1,62 +1,62 @@ -error[E0382]: use of moved value: `u.n1` - --> $DIR/borrowck-union-move.rs:26:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:26:21 | +LL | let mut u = Unn { n1: NonCopy }; + | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait LL | let a = u.n1; - | - value moved here + | ---- value moved here LL | let a = u.n1; - | ^ value used here after move - | - = note: move occurs because `u.n1` has type `NonCopy`, which does not implement the `Copy` trait + | ^^^^ value used here after move -error[E0382]: use of partially moved value: `u` - --> $DIR/borrowck-union-move.rs:31:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:31:21 | +LL | let mut u = Unn { n1: NonCopy }; + | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait LL | let a = u.n1; - | - value moved here + | ---- value moved here LL | let a = u; - | ^ value used here after move - | - = note: move occurs because `u.n2` has type `[type error]`, which does not implement the `Copy` trait + | ^ value used here after move -error[E0382]: use of moved value: `u.n2` - --> $DIR/borrowck-union-move.rs:36:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:36:21 | +LL | let mut u = Unn { n1: NonCopy }; + | ----- move occurs because `u` has type `Unn`, which does not implement the `Copy` trait LL | let a = u.n1; - | - value moved here + | ---- value moved here LL | let a = u.n2; - | ^ value used here after move - | - = note: move occurs because `u.n2` has type `[type error]`, which does not implement the `Copy` trait + | ^^^^ value used here after move -error[E0382]: use of moved value: `u.n` - --> $DIR/borrowck-union-move.rs:63:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:63:21 | +LL | let mut u = Ucn { c: Copy }; + | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait LL | let a = u.n; - | - value moved here + | --- value moved here LL | let a = u.n; - | ^ value used here after move - | - = note: move occurs because `u.n` has type `NonCopy`, which does not implement the `Copy` trait + | ^^^ value used here after move -error[E0382]: use of moved value: `u.c` - --> $DIR/borrowck-union-move.rs:68:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:68:21 | +LL | let mut u = Ucn { c: Copy }; + | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait LL | let a = u.n; - | - value moved here + | --- value moved here LL | let a = u.c; - | ^ value used here after move - | - = note: move occurs because `u.c` has type `[type error]`, which does not implement the `Copy` trait + | ^^^ value used here after move -error[E0382]: use of partially moved value: `u` - --> $DIR/borrowck-union-move.rs:83:17 +error[E0382]: use of moved value: `u` + --> $DIR/borrowck-union-move.rs:83:21 | +LL | let mut u = Ucn { c: Copy }; + | ----- move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait LL | let a = u.n; - | - value moved here + | --- value moved here LL | let a = u; - | ^ value used here after move - | - = note: move occurs because `u.c` has type `[type error]`, which does not implement the `Copy` trait + | ^ value used here after move error: aborting due to 6 previous errors diff --git a/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr b/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr deleted file mode 100644 index 06c884e2446..00000000000 --- a/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `s` - --> $DIR/borrowck-union-uninitialized.rs:13:9 - | -LL | s.a = 0; - | ^^^^^^^ use of possibly uninitialized `s` - -error[E0381]: assign to part of possibly uninitialized variable: `u` - --> $DIR/borrowck-union-uninitialized.rs:14:9 - | -LL | u.a = 0; - | ^^^^^^^ use of possibly uninitialized `u` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-union-uninitialized.rs b/src/test/ui/borrowck/borrowck-union-uninitialized.rs index e7d456ea746..9cab0b19202 100644 --- a/src/test/ui/borrowck/borrowck-union-uninitialized.rs +++ b/src/test/ui/borrowck/borrowck-union-uninitialized.rs @@ -10,9 +10,9 @@ fn main() { unsafe { let mut s: S; let mut u: U; - s.a = 0; - u.a = 0; - let sa = s.a; //~ ERROR use of possibly uninitialized variable: `s.a` - let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` + s.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `s` + u.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `u` + let sa = s.a; + let ua = u.a; } } diff --git a/src/test/ui/borrowck/borrowck-union-uninitialized.stderr b/src/test/ui/borrowck/borrowck-union-uninitialized.stderr index 6a1401ff32b..06c884e2446 100644 --- a/src/test/ui/borrowck/borrowck-union-uninitialized.stderr +++ b/src/test/ui/borrowck/borrowck-union-uninitialized.stderr @@ -1,14 +1,14 @@ -error[E0381]: use of possibly uninitialized variable: `s.a` - --> $DIR/borrowck-union-uninitialized.rs:15:13 +error[E0381]: assign to part of possibly uninitialized variable: `s` + --> $DIR/borrowck-union-uninitialized.rs:13:9 | -LL | let sa = s.a; - | ^^ use of possibly uninitialized `s.a` +LL | s.a = 0; + | ^^^^^^^ use of possibly uninitialized `s` -error[E0381]: use of possibly uninitialized variable: `u.a` - --> $DIR/borrowck-union-uninitialized.rs:16:13 +error[E0381]: assign to part of possibly uninitialized variable: `u` + --> $DIR/borrowck-union-uninitialized.rs:14:9 | -LL | let ua = u.a; - | ^^ use of possibly uninitialized `u.a` +LL | u.a = 0; + | ^^^^^^^ use of possibly uninitialized `u` error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr b/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr deleted file mode 100644 index 923edc8edae..00000000000 --- a/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:36:12 - | -LL | let w = &mut v; - | ------ mutable borrow occurs here -LL | borrow(&*v); - | ^^^ immutable borrow occurs here -LL | w.use_mut(); - | - mutable borrow later used here - -error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:53:12 - | -LL | x = &mut v; - | ------ mutable borrow occurs here -LL | borrow(&*v); - | ^^^ immutable borrow occurs here -LL | x.use_mut(); - | - mutable borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr b/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr index 00fd77ed718..923edc8edae 100644 --- a/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr +++ b/src/test/ui/borrowck/borrowck-uniq-via-lend.stderr @@ -1,24 +1,22 @@ -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:36:13 +error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-uniq-via-lend.rs:36:12 | LL | let w = &mut v; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | borrow(&*v); - | ^^ immutable borrow occurs here + | ^^^ immutable borrow occurs here LL | w.use_mut(); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here -error[E0502]: cannot borrow `*v` as immutable because `v` is also borrowed as mutable - --> $DIR/borrowck-uniq-via-lend.rs:53:13 +error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable + --> $DIR/borrowck-uniq-via-lend.rs:53:12 | LL | x = &mut v; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | borrow(&*v); - | ^^ immutable borrow occurs here + | ^^^ immutable borrow occurs here LL | x.use_mut(); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.stderr b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.stderr deleted file mode 100644 index e235bdfa8a9..00000000000 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `*w` - --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 - | -LL | w[5] = 0; - | ^^^^^^^^ use of possibly uninitialized `*w` - -error[E0381]: use of possibly uninitialized variable: `*w` - --> $DIR/borrowck-use-in-index-lvalue.rs:10:5 - | -LL | w[5] = 0; - | ^^^^^^^^ use of possibly uninitialized `*w` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr deleted file mode 100644 index c5e4f89f777..00000000000 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 - | -LL | w[5] = 0; - | ^^^^ use of possibly uninitialized `*w` - -error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:10:5 - | -LL | w[5] = 0; - | ^^^^ use of possibly uninitialized `*w` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs index f953dec444a..d30b1de5cd0 100644 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs +++ b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.rs @@ -1,14 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn test() { let w: &mut [isize]; - w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - //[mir]~^ ERROR [E0381] + w[5] = 0; //~ ERROR [E0381] let mut w: &mut [isize]; - w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] - //[mir]~^ ERROR [E0381] + w[5] = 0; //~ ERROR [E0381] } fn main() { test(); } diff --git a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.stderr index c5e4f89f777..c03ef759f57 100644 --- a/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-use-in-index-lvalue.stderr @@ -1,11 +1,11 @@ error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 + --> $DIR/borrowck-use-in-index-lvalue.rs:3:5 | LL | w[5] = 0; | ^^^^ use of possibly uninitialized `*w` error[E0381]: use of possibly uninitialized variable: `w` - --> $DIR/borrowck-use-in-index-lvalue.rs:10:5 + --> $DIR/borrowck-use-in-index-lvalue.rs:6:5 | LL | w[5] = 0; | ^^^^ use of possibly uninitialized `*w` diff --git a/src/test/ui/borrowck/borrowck-use-mut-borrow.nll.stderr b/src/test/ui/borrowck/borrowck-use-mut-borrow.nll.stderr deleted file mode 100644 index 91d69c51e81..00000000000 --- a/src/test/ui/borrowck/borrowck-use-mut-borrow.nll.stderr +++ /dev/null @@ -1,95 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:11:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(x); - | ^ use of borrowed `x` -LL | *p = 2; - | ------ borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:18:10 - | -LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here -LL | drop(x); - | ^ use of borrowed `x.a` -LL | *p = 3; - | ------ borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:25:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(x.a); - | ^^^ use of borrowed `x` -LL | p.a = 3; - | ------- borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:32:10 - | -LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here -LL | drop(x.a); - | ^^^ use of borrowed `x.a` -LL | *p = 3; - | ------ borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:39:13 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | let y = A { b: 3, .. x }; - | ^^^^^^^^^^^^^^^^ use of borrowed `x` -LL | drop(y); -LL | p.a = 4; - | ------- borrow later used here - -error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:47:13 - | -LL | let p = &mut x.a; - | -------- borrow of `x.a` occurs here -LL | let y = A { b: 3, .. x }; - | ^^^^^^^^^^^^^^^^ use of borrowed `x.a` -LL | drop(y); -LL | *p = 4; - | ------ borrow later used here - -error[E0503]: cannot use `*x` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:55:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(*x); - | ^^ use of borrowed `x` -LL | **p = 2; - | ------- borrow later used here - -error[E0503]: cannot use `*x.b` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:62:10 - | -LL | let p = &mut x; - | ------ borrow of `x` occurs here -LL | drop(*x.b); - | ^^^^ use of borrowed `x` -LL | p.a = 3; - | ------- borrow later used here - -error[E0503]: cannot use `*x.b` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:69:10 - | -LL | let p = &mut x.b; - | -------- borrow of `x.b` occurs here -LL | drop(*x.b); - | ^^^^ use of borrowed `x.b` -LL | **p = 3; - | ------- borrow later used here - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr b/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr index 5c1d7269176..91d69c51e81 100644 --- a/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr +++ b/src/test/ui/borrowck/borrowck-use-mut-borrow.stderr @@ -2,73 +2,93 @@ error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:11:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(x); | ^ use of borrowed `x` +LL | *p = 2; + | ------ borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:18:10 | LL | let p = &mut x.a; - | --- borrow of `x.a` occurs here + | -------- borrow of `x.a` occurs here LL | drop(x); | ^ use of borrowed `x.a` +LL | *p = 3; + | ------ borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:25:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(x.a); | ^^^ use of borrowed `x` +LL | p.a = 3; + | ------- borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:32:10 | LL | let p = &mut x.a; - | --- borrow of `x.a` occurs here + | -------- borrow of `x.a` occurs here LL | drop(x.a); | ^^^ use of borrowed `x.a` +LL | *p = 3; + | ------ borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:39:26 + --> $DIR/borrowck-use-mut-borrow.rs:39:13 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | let y = A { b: 3, .. x }; - | ^ use of borrowed `x` + | ^^^^^^^^^^^^^^^^ use of borrowed `x` +LL | drop(y); +LL | p.a = 4; + | ------- borrow later used here error[E0503]: cannot use `x.a` because it was mutably borrowed - --> $DIR/borrowck-use-mut-borrow.rs:47:26 + --> $DIR/borrowck-use-mut-borrow.rs:47:13 | LL | let p = &mut x.a; - | --- borrow of `x.a` occurs here + | -------- borrow of `x.a` occurs here LL | let y = A { b: 3, .. x }; - | ^ use of borrowed `x.a` + | ^^^^^^^^^^^^^^^^ use of borrowed `x.a` +LL | drop(y); +LL | *p = 4; + | ------ borrow later used here error[E0503]: cannot use `*x` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:55:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(*x); | ^^ use of borrowed `x` +LL | **p = 2; + | ------- borrow later used here error[E0503]: cannot use `*x.b` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:62:10 | LL | let p = &mut x; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | drop(*x.b); | ^^^^ use of borrowed `x` +LL | p.a = 3; + | ------- borrow later used here error[E0503]: cannot use `*x.b` because it was mutably borrowed --> $DIR/borrowck-use-mut-borrow.rs:69:10 | LL | let p = &mut x.b; - | --- borrow of `x.b` occurs here + | -------- borrow of `x.b` occurs here LL | drop(*x.b); | ^^^^ use of borrowed `x.b` +LL | **p = 3; + | ------- borrow later used here error: aborting due to 9 previous errors diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr deleted file mode 100644 index a208dc486ec..00000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:12:13 - | -LL | let y = x as *const Foo; - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr deleted file mode 100644 index 49a43003f60..00000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `*x` - --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:12:13 - | -LL | let y = x as *const Foo; - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs index 518228a50ff..1e272372f6c 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Variation on `borrowck-use-uninitialized-in-cast` in which we do a // trait cast from an uninitialized source. Issue #20791. @@ -9,6 +6,5 @@ impl Foo for i32 { } fn main() { let x: &i32; - let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` - //[mir]~^ ERROR [E0381] + let y = x as *const Foo; //~ ERROR [E0381] } diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr index a208dc486ec..df610cbb561 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr @@ -1,5 +1,5 @@ error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:12:13 + --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13 | LL | let y = x as *const Foo; | ^ use of possibly uninitialized `*x` diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr deleted file mode 100644 index d8137387862..00000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `*x` - --> $DIR/borrowck-use-uninitialized-in-cast.rs:10:13 - | -LL | let y = x as *const i32; - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr deleted file mode 100644 index 0f62c3ae2c7..00000000000 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast.rs:10:13 - | -LL | let y = x as *const i32; - | ^ use of possibly uninitialized `*x` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs index e15479bde28..a355a546dc6 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.rs @@ -1,12 +1,8 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Check that we detect unused values that are cast to other things. // The problem was specified to casting to `*`, as creating unsafe // pointers was not being fully checked. Issue #20791. fn main() { let x: &i32; - let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] - //[mir]~^ ERROR [E0381] + let y = x as *const i32; //~ ERROR [E0381] } diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.stderr index 0f62c3ae2c7..84e717a4639 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.stderr @@ -1,5 +1,5 @@ error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/borrowck-use-uninitialized-in-cast.rs:10:13 + --> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13 | LL | let y = x as *const i32; | ^ use of possibly uninitialized `*x` diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr deleted file mode 100644 index da6d9293b40..00000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-element-loan.rs:10:5 - | -LL | let vec: &[isize] = &vec; - | ---- `vec` is borrowed here -... -LL | tail - | ^^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-element-loan.rs:20:5 - | -LL | let vec: &[isize] = &vec; - | ---- `vec` is borrowed here -... -LL | init - | ^^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-element-loan.rs:30:5 - | -LL | let vec: &[isize] = &vec; - | ---- `vec` is borrowed here -... -LL | slice - | ^^^^^ returns a value referencing data owned by the current function - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs index 0de5132466b..100384d78c8 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.rs @@ -2,32 +2,32 @@ fn a<'a>() -> &'a [isize] { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough + let vec: &[isize] = &vec; let tail = match vec { &[_, ref tail..] => tail, _ => panic!("a") }; - tail + tail //~ ERROR cannot return value referencing local variable `vec` } fn b<'a>() -> &'a [isize] { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough + let vec: &[isize] = &vec; let init = match vec { &[ref init.., _] => init, _ => panic!("b") }; - init + init //~ ERROR cannot return value referencing local variable `vec` } fn c<'a>() -> &'a [isize] { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR does not live long enough + let vec: &[isize] = &vec; let slice = match vec { &[_, ref slice.., _] => slice, _ => panic!("c") }; - slice + slice //~ ERROR cannot return value referencing local variable `vec` } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr index b0eaee79074..da6d9293b40 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.stderr @@ -1,48 +1,30 @@ -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:5:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:10:5 | LL | let vec: &[isize] = &vec; - | ^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 3:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:3:6 - | -LL | fn a<'a>() -> &'a [isize] { - | ^^ +LL | tail + | ^^^^ returns a value referencing data owned by the current function -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:15:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:20:5 | LL | let vec: &[isize] = &vec; - | ^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:13:6 - | -LL | fn b<'a>() -> &'a [isize] { - | ^^ +LL | init + | ^^^^ returns a value referencing data owned by the current function -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:25:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:30:5 | LL | let vec: &[isize] = &vec; - | ^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:23:6 - | -LL | fn c<'a>() -> &'a [isize] { - | ^^ +LL | slice + | ^^^^^ returns a value referencing data owned by the current function error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr deleted file mode 100644 index 251f4459290..00000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/borrowck-vec-pattern-loan-from-mut.rs:8:13 - | -LL | let vb: &mut [isize] = &mut v; - | ------ first mutable borrow occurs here -... -LL | v.push(tail[0] + tail[1]); - | ^ ------- first borrow later used here - | | - | second mutable borrow occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr index 1ce6a3bddce..251f4459290 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.stderr @@ -2,13 +2,12 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/borrowck-vec-pattern-loan-from-mut.rs:8:13 | LL | let vb: &mut [isize] = &mut v; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here ... LL | v.push(tail[0] + tail[1]); - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^ ------- first borrow later used here + | | + | second mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.stderr deleted file mode 100644 index 1207d4a1095..00000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `a[..]` because it is borrowed - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 - | -LL | [1, 2, ref tail..] => tail, - | -------- borrow of `a[..]` occurs here -... -LL | a[2] = 0; - | ^^^^^^^^ assignment to borrowed `a[..]` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr deleted file mode 100644 index f764d5fb528..00000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.cmp.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0506]: cannot assign to `a[..]` because it is borrowed (Ast) - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 - | -LL | [1, 2, ref tail..] => tail, - | -------- borrow of `a[..]` occurs here -... -LL | a[2] = 0; - | ^^^^^^^^ assignment to borrowed `a[..]` occurs here - -error[E0506]: cannot assign to `a[_]` because it is borrowed (Mir) - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 - | -LL | [1, 2, ref tail..] => tail, - | -------- borrow of `a[_]` occurs here -... -LL | a[2] = 0; - | ^^^^^^^^ assignment to borrowed `a[_]` occurs here -... -LL | println!("t[0]: {}", t[0]); - | ---- borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs index e14ecd90d56..efc52530716 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.rs @@ -1,8 +1,4 @@ // http://rust-lang.org/COPYRIGHT. -// - -// revisions: ast cmp -//[cmp]compile-flags: -Z borrowck=compare #![feature(slice_patterns)] @@ -13,9 +9,7 @@ fn main() { _ => unreachable!() }; println!("t[0]: {}", t[0]); - a[2] = 0; //[ast]~ ERROR cannot assign to `a[..]` because it is borrowed - //[cmp]~^ ERROR cannot assign to `a[..]` because it is borrowed (Ast) - //[cmp]~| ERROR cannot assign to `a[_]` because it is borrowed (Mir) + a[2] = 0; //~ ERROR cannot assign to `a[_]` because it is borrowed println!("t[0]: {}", t[0]); t[0]; } diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.stderr index 7d0d8882ded..b2f553ba49f 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-move-tail.stderr @@ -1,12 +1,11 @@ error[E0506]: cannot assign to `a[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-move-tail.rs:16:5 + --> $DIR/borrowck-vec-pattern-move-tail.rs:12:5 | LL | [1, 2, ref tail..] => tail, | -------- borrow of `a[_]` occurs here ... LL | a[2] = 0; | ^^^^^^^^ assignment to borrowed `a[_]` occurs here -... LL | println!("t[0]: {}", t[0]); | ---- borrow later used here diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr deleted file mode 100644 index d0bbe10d052..00000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.nll.stderr +++ /dev/null @@ -1,117 +0,0 @@ -error[E0506]: cannot assign to `vec[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:10:13 - | -LL | [box ref _a, _, _] => { - | ------ borrow of `vec[_]` occurs here -LL | -LL | vec[0] = box 4; - | ^^^^^^ assignment to borrowed `vec[_]` occurs here -LL | -LL | _a.use_ref(); - | -- borrow later used here - -error[E0506]: cannot assign to `vec[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 - | -LL | &mut [ref _b..] => { - | ------ borrow of `vec[_]` occurs here -LL | -LL | vec[0] = box 4; - | ^^^^^^ assignment to borrowed `vec[_]` occurs here -LL | -LL | _b.use_ref(); - | -- borrow later used here - -error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:33:11 - | -LL | match vec { - | ^^^ cannot move out of here -LL | &mut [_a, - | -- data moved here - | -note: move occurs because `_a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - --> $DIR/borrowck-vec-pattern-nesting.rs:34:15 - | -LL | &mut [_a, - | ^^ -help: consider removing the `&mut` - | -LL | [_a, -LL | -LL | -LL | .. -LL | ] => { - | - -error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:47:13 - | -LL | let a = vec[0]; - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&vec[0]` - -error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:54:11 - | -LL | match vec { - | ^^^ cannot move out of here -... -LL | _b] => {} - | -- data moved here - | -note: move occurs because `_b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait - --> $DIR/borrowck-vec-pattern-nesting.rs:57:10 - | -LL | _b] => {} - | ^^ -help: consider removing the `&mut` - | -LL | [ -LL | -LL | _b] => {} - | - -error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:60:13 - | -LL | let a = vec[0]; - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&vec[0]` - -error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:67:11 - | -LL | match vec { - | ^^^ cannot move out of here -LL | &mut [_a, _b, _c] => {} - | ----------------- - | | | | | - | | | | ...and here - | | | ...and here - | | data moved here - | help: consider removing the `&mut`: `[_a, _b, _c]` - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/borrowck-vec-pattern-nesting.rs:68:15 - | -LL | &mut [_a, _b, _c] => {} - | ^^ ^^ ^^ - -error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:72:13 - | -LL | let a = vec[0]; - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&vec[0]` - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0506, E0508. -For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs index 46203b7a3de..3e2935f6df1 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.rs @@ -6,10 +6,11 @@ fn a() { let mut vec = [box 1, box 2, box 3]; match vec { [box ref _a, _, _] => { - //~^ borrow of `vec[..]` occurs here + //~^ NOTE borrow of `vec[_]` occurs here vec[0] = box 4; //~ ERROR cannot assign - //~^ assignment to borrowed `vec[..]` occurs here + //~^ NOTE assignment to borrowed `vec[_]` occurs here _a.use_ref(); + //~^ NOTE borrow later used here } } } @@ -19,10 +20,11 @@ fn b() { let vec: &mut [Box<isize>] = &mut vec; match vec { &mut [ref _b..] => { - //~^ borrow of `vec[..]` occurs here + //~^ borrow of `vec[_]` occurs here vec[0] = box 4; //~ ERROR cannot assign - //~^ assignment to borrowed `vec[..]` occurs here + //~^ NOTE assignment to borrowed `vec[_]` occurs here _b.use_ref(); + //~^ NOTE borrow later used here } } } @@ -31,46 +33,57 @@ fn c() { let mut vec = vec![box 1, box 2, box 3]; let vec: &mut [Box<isize>] = &mut vec; match vec { - &mut [_a, //~ ERROR cannot move out - //~| cannot move out - //~| to prevent move + //~^ ERROR cannot move out + //~| NOTE cannot move out + &mut [_a, + //~^ NOTE data moved here + //~| NOTE move occurs because `_a` has type + //~| HELP consider removing the `&mut` .. ] => { - // Note: `_a` is *moved* here, but `b` is borrowing, - // hence illegal. - // - // See comment in middle/borrowck/gather_loans/mod.rs - // in the case covering these sorts of vectors. } _ => {} } let a = vec[0]; //~ ERROR cannot move out - //~| cannot move out of here + //~| NOTE cannot move out of here + //~| HELP consider borrowing here } fn d() { let mut vec = vec![box 1, box 2, box 3]; let vec: &mut [Box<isize>] = &mut vec; match vec { - &mut [ //~ ERROR cannot move out - //~^ cannot move out + //~^ ERROR cannot move out + //~| NOTE cannot move out + &mut [ + //~^ HELP consider removing the `&mut` _b] => {} + //~^ NOTE data moved here + //~| NOTE move occurs because `_b` has type _ => {} } let a = vec[0]; //~ ERROR cannot move out - //~| cannot move out of here + //~| NOTE cannot move out of here + //~| HELP consider borrowing here } fn e() { let mut vec = vec![box 1, box 2, box 3]; let vec: &mut [Box<isize>] = &mut vec; match vec { - &mut [_a, _b, _c] => {} //~ ERROR cannot move out - //~| cannot move out + //~^ ERROR cannot move out + //~| NOTE cannot move out + &mut [_a, _b, _c] => {} + //~^ NOTE data moved here + //~| NOTE and here + //~| NOTE and here + //~| HELP consider removing the `&mut` + //~| NOTE move occurs because these variables have types _ => {} } let a = vec[0]; //~ ERROR cannot move out - //~| cannot move out of here + //~| NOTE cannot move out of here + //~| HELP consider borrowing here } fn main() {} diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 8f6c31b8bc0..78c26cac9c1 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -1,33 +1,50 @@ -error[E0506]: cannot assign to `vec[..]` because it is borrowed +error[E0506]: cannot assign to `vec[_]` because it is borrowed --> $DIR/borrowck-vec-pattern-nesting.rs:10:13 | LL | [box ref _a, _, _] => { - | ------ borrow of `vec[..]` occurs here + | ------ borrow of `vec[_]` occurs here LL | LL | vec[0] = box 4; - | ^^^^^^^^^^^^^^ assignment to borrowed `vec[..]` occurs here + | ^^^^^^ assignment to borrowed `vec[_]` occurs here +LL | +LL | _a.use_ref(); + | -- borrow later used here -error[E0506]: cannot assign to `vec[..]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 +error[E0506]: cannot assign to `vec[_]` because it is borrowed + --> $DIR/borrowck-vec-pattern-nesting.rs:24:13 | LL | &mut [ref _b..] => { - | ------ borrow of `vec[..]` occurs here + | ------ borrow of `vec[_]` occurs here LL | LL | vec[0] = box 4; - | ^^^^^^^^^^^^^^ assignment to borrowed `vec[..]` occurs here + | ^^^^^^ assignment to borrowed `vec[_]` occurs here +LL | +LL | _b.use_ref(); + | -- borrow later used here error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:34:14 - | -LL | &mut [_a, - | ^-- hint: to prevent move, use `ref _a` or `ref mut _a` - | ______________| - | | -LL | | -LL | | -LL | | .. -LL | | ] => { - | |_________^ cannot move out of here + --> $DIR/borrowck-vec-pattern-nesting.rs:35:11 + | +LL | match vec { + | ^^^ cannot move out of here +... +LL | &mut [_a, + | -- data moved here + | +note: move occurs because `_a` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait + --> $DIR/borrowck-vec-pattern-nesting.rs:38:15 + | +LL | &mut [_a, + | ^^ +help: consider removing the `&mut` + | +LL | [_a, +LL | +LL | +LL | +LL | .. +LL | ] => { + | error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice --> $DIR/borrowck-vec-pattern-nesting.rs:47:13 @@ -36,47 +53,66 @@ LL | let a = vec[0]; | ^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&vec[0]` + | help: consider borrowing here: `&vec[0]` error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:55:14 - | -LL | &mut [ - | ______________^ -LL | | -LL | | _b] => {} - | |__________--^ cannot move out of here - | | - | hint: to prevent move, use `ref _b` or `ref mut _b` + --> $DIR/borrowck-vec-pattern-nesting.rs:55:11 + | +LL | match vec { + | ^^^ cannot move out of here +... +LL | _b] => {} + | -- data moved here + | +note: move occurs because `_b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait + --> $DIR/borrowck-vec-pattern-nesting.rs:60:10 + | +LL | _b] => {} + | ^^ +help: consider removing the `&mut` + | +LL | [ +LL | +LL | _b] => {} + | error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:60:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:65:13 | LL | let a = vec[0]; | ^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&vec[0]` + | help: consider borrowing here: `&vec[0]` error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:68:14 + --> $DIR/borrowck-vec-pattern-nesting.rs:73:11 + | +LL | match vec { + | ^^^ cannot move out of here +... +LL | &mut [_a, _b, _c] => {} + | ----------------- + | | | | | + | | | | ...and here + | | | ...and here + | | data moved here + | help: consider removing the `&mut`: `[_a, _b, _c]` + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/borrowck-vec-pattern-nesting.rs:76:15 | LL | &mut [_a, _b, _c] => {} - | ^--^^--^^--^ - | || | | - | || | ...and here (use `ref _c` or `ref mut _c`) - | || ...and here (use `ref _b` or `ref mut _b`) - | |hint: to prevent move, use `ref _a` or `ref mut _a` - | cannot move out of here + | ^^ ^^ ^^ error[E0508]: cannot move out of type `[std::boxed::Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:72:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:84:13 | LL | let a = vec[0]; | ^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&vec[0]` + | help: consider borrowing here: `&vec[0]` error: aborting due to 8 previous errors diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr deleted file mode 100644 index c1290a6f63f..00000000000 --- a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local variable `vec` - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:10:5 - | -LL | let vec: &[isize] = &vec; - | ---- `vec` is borrowed here -... -LL | tail - | ^^^^ returns a value referencing data owned by the current function - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs index b18052a6899..e602e75886d 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.rs @@ -2,12 +2,12 @@ fn a<'a>() -> &'a isize { let vec = vec![1, 2, 3, 4]; - let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough + let vec: &[isize] = &vec; let tail = match vec { &[_a, ref tail..] => &tail[0], _ => panic!("foo") }; - tail + tail //~ ERROR cannot return value referencing local variable `vec` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr index 0a5f773159f..c1290a6f63f 100644 --- a/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr +++ b/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.stderr @@ -1,18 +1,12 @@ -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:5:26 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:10:5 | LL | let vec: &[isize] = &vec; - | ^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 3:6... - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:3:6 - | -LL | fn a<'a>() -> &'a isize { - | ^^ +LL | tail + | ^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/borrowck-while-break.nll.stderr b/src/test/ui/borrowck/borrowck-while-break.nll.stderr deleted file mode 100644 index 0fe3cdc96a8..00000000000 --- a/src/test/ui/borrowck/borrowck-while-break.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `v` - --> $DIR/borrowck-while-break.rs:7:20 - | -LL | println!("{}", v); - | ^ use of possibly uninitialized `v` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/borrowck-while-break.rs b/src/test/ui/borrowck/borrowck-while-break.rs index 293760efba5..e16bc58656d 100644 --- a/src/test/ui/borrowck/borrowck-while-break.rs +++ b/src/test/ui/borrowck/borrowck-while-break.rs @@ -4,7 +4,7 @@ fn test(cond: bool) { v = 3; break; } - println!("{}", v); //~ ERROR use of possibly uninitialized variable: `v` + println!("{}", v); //~ ERROR borrow of possibly uninitialized variable: `v` } fn main() { diff --git a/src/test/ui/borrowck/borrowck-while-break.stderr b/src/test/ui/borrowck/borrowck-while-break.stderr index 55969b8fb1f..0fe3cdc96a8 100644 --- a/src/test/ui/borrowck/borrowck-while-break.stderr +++ b/src/test/ui/borrowck/borrowck-while-break.stderr @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `v` +error[E0381]: borrow of possibly uninitialized variable: `v` --> $DIR/borrowck-while-break.rs:7:20 | LL | println!("{}", v); diff --git a/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr b/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr deleted file mode 100644 index 4b29beb02b3..00000000000 --- a/src/test/ui/borrowck/index-mut-help-with-impl.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/index-mut-help-with-impl.rs:9:5 - | -LL | Index::index(&v, 1..2).make_ascii_uppercase(); - | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/index-mut-help-with-impl.stderr b/src/test/ui/borrowck/index-mut-help-with-impl.stderr index 6e6efc67061..4b29beb02b3 100644 --- a/src/test/ui/borrowck/index-mut-help-with-impl.stderr +++ b/src/test/ui/borrowck/index-mut-help-with-impl.stderr @@ -1,8 +1,10 @@ -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/index-mut-help-with-impl.rs:9:5 | LL | Index::index(&v, 1..2).make_ascii_uppercase(); | ^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable + | + = help: trait `IndexMut` is required to modify indexed content error: aborting due to previous error diff --git a/src/test/ui/borrowck/index-mut-help.nll.stderr b/src/test/ui/borrowck/index-mut-help.nll.stderr deleted file mode 100644 index fbc427a6e6d..00000000000 --- a/src/test/ui/borrowck/index-mut-help.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/index-mut-help.rs:11:5 - | -LL | map["peter"].clear(); - | ^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/index-mut-help.rs:12:5 - | -LL | map["peter"] = "0".to_string(); - | ^^^^^^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/index-mut-help.rs:13:13 - | -LL | let _ = &mut map["peter"]; - | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/index-mut-help.stderr b/src/test/ui/borrowck/index-mut-help.stderr index 11663fdbe86..fbc427a6e6d 100644 --- a/src/test/ui/borrowck/index-mut-help.stderr +++ b/src/test/ui/borrowck/index-mut-help.stderr @@ -1,4 +1,4 @@ -error[E0596]: cannot borrow immutable indexed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/index-mut-help.rs:11:5 | LL | map["peter"].clear(); @@ -6,19 +6,17 @@ LL | map["peter"].clear(); | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` -error[E0594]: cannot assign to immutable indexed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/index-mut-help.rs:12:5 | LL | map["peter"] = "0".to_string(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` + | ^^^^^^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable indexed content as mutable - --> $DIR/index-mut-help.rs:13:18 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/index-mut-help.rs:13:13 | LL | let _ = &mut map["peter"]; - | ^^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^^^^^^^ cannot borrow as mutable | = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap<&str, std::string::String>` diff --git a/src/test/ui/borrowck/issue-45983.ast.stderr b/src/test/ui/borrowck/issue-45983.ast.stderr deleted file mode 100644 index 9cb83c92cae..00000000000 --- a/src/test/ui/borrowck/issue-45983.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: borrowed data cannot be stored outside of its closure - --> $DIR/issue-45983.rs:26:27 - | -LL | let x = None; - | - borrowed data cannot be stored into here... -LL | give_any(|y| x = Some(y)); - | --- ^ cannot be stored outside of its closure - | | - | ...because it cannot outlive this closure - -error: aborting due to previous error - diff --git a/src/test/ui/borrowck/issue-45983.migrate.stderr b/src/test/ui/borrowck/issue-45983.migrate.stderr index 9cb83c92cae..3a6b2f69a1f 100644 --- a/src/test/ui/borrowck/issue-45983.migrate.stderr +++ b/src/test/ui/borrowck/issue-45983.migrate.stderr @@ -1,5 +1,5 @@ error: borrowed data cannot be stored outside of its closure - --> $DIR/issue-45983.rs:26:27 + --> $DIR/issue-45983.rs:19:27 | LL | let x = None; | - borrowed data cannot be stored into here... diff --git a/src/test/ui/borrowck/issue-45983.nll.stderr b/src/test/ui/borrowck/issue-45983.nll.stderr index 3e5ae451970..94360b65ffe 100644 --- a/src/test/ui/borrowck/issue-45983.nll.stderr +++ b/src/test/ui/borrowck/issue-45983.nll.stderr @@ -1,5 +1,5 @@ error[E0521]: borrowed data escapes outside of closure - --> $DIR/issue-45983.rs:26:18 + --> $DIR/issue-45983.rs:19:18 | LL | let x = None; | - `x` is declared here, outside of the closure body @@ -9,7 +9,7 @@ LL | give_any(|y| x = Some(y)); | `y` is a reference that is only valid in the closure body error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-45983.rs:26:18 + --> $DIR/issue-45983.rs:19:18 | LL | let x = None; | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/borrowck/issue-45983.rs b/src/test/ui/borrowck/issue-45983.rs index 4dac67d9ae9..a2656f5939a 100644 --- a/src/test/ui/borrowck/issue-45983.rs +++ b/src/test/ui/borrowck/issue-45983.rs @@ -1,21 +1,14 @@ // As documented in Issue #45983, this test is evaluating the quality // of our diagnostics on erroneous code using higher-ranked closures. -// -// However, as documented on Issue #53026, this test also became a -// prime example of our need to test the NLL migration mode -// *separately* from the existing test suites that focus solely on -// AST-borrwock and NLL. -// revisions: ast migrate nll +// revisions: migrate nll // Since we are testing nll (and migration) explicitly as a separate // revisions, don't worry about the --compare-mode=nll on this test. // ignore-compare-mode-nll -//[ast]compile-flags: -Z borrowck=ast -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) { f(&()); @@ -24,8 +17,7 @@ fn give_any<F: for<'r> FnOnce(&'r ())>(f: F) { fn main() { let x = None; give_any(|y| x = Some(y)); - //[ast]~^ ERROR borrowed data cannot be stored outside of its closure - //[migrate]~^^ ERROR borrowed data cannot be stored outside of its closure - //[nll]~^^^ ERROR borrowed data escapes outside of closure + //[migrate]~^ ERROR borrowed data cannot be stored outside of its closure + //[nll]~^^ ERROR borrowed data escapes outside of closure //[nll]~| ERROR cannot assign to `x`, as it is not declared as mutable } diff --git a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.nll.stderr b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.nll.stderr deleted file mode 100644 index eb71ab0b7ec..00000000000 --- a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of static item - --> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 - | -LL | let mut x = X; - | ^ - | | - | cannot move out of static item - | help: consider borrowing here: `&X` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs index 7477947b89c..48dd14c4976 100644 --- a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs +++ b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs @@ -14,7 +14,7 @@ static mut X: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::AtomicUsiz fn main() { unsafe { - let mut x = X; //~ ERROR cannot move out of thread-local static item [E0507] + let mut x = X; //~ ERROR cannot move out of static item [E0507] let _y = x.get_mut(); } } diff --git a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr index b09028e6c7c..eb71ab0b7ec 100644 --- a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr +++ b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of thread-local static item +error[E0507]: cannot move out of static item --> $DIR/issue-47215-ice-from-drop-elab.rs:17:21 | LL | let mut x = X; | ^ | | - | cannot move out of thread-local static item - | help: consider using a reference instead: `&X` + | cannot move out of static item + | help: consider borrowing here: `&X` error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-51117.nll.stderr b/src/test/ui/borrowck/issue-51117.nll.stderr deleted file mode 100644 index f8a9608ad37..00000000000 --- a/src/test/ui/borrowck/issue-51117.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `*bar` as mutable more than once at a time - --> $DIR/issue-51117.rs:10:13 - | -LL | Some(baz) => { - | --- first mutable borrow occurs here -LL | bar.take(); - | ^^^ second mutable borrow occurs here -LL | drop(baz); - | --- first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/issue-51117.stderr b/src/test/ui/borrowck/issue-51117.stderr index 8f2a78672c6..f8a9608ad37 100644 --- a/src/test/ui/borrowck/issue-51117.stderr +++ b/src/test/ui/borrowck/issue-51117.stderr @@ -5,9 +5,8 @@ LL | Some(baz) => { | --- first mutable borrow occurs here LL | bar.take(); | ^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here +LL | drop(baz); + | --- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-51415.nll.stderr b/src/test/ui/borrowck/issue-51415.nll.stderr deleted file mode 100644 index b025374257f..00000000000 --- a/src/test/ui/borrowck/issue-51415.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-51415.rs:6:42 - | -LL | let opt = a.iter().enumerate().find(|(_, &s)| { - | ^^^^^-^ - | | | - | | data moved here - | cannot move out of borrowed content - | -note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/issue-51415.rs:6:47 - | -LL | let opt = a.iter().enumerate().find(|(_, &s)| { - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/issue-51415.stderr b/src/test/ui/borrowck/issue-51415.stderr index 895c35e4e77..b025374257f 100644 --- a/src/test/ui/borrowck/issue-51415.stderr +++ b/src/test/ui/borrowck/issue-51415.stderr @@ -1,11 +1,17 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/issue-51415.rs:6:46 + --> $DIR/issue-51415.rs:6:42 | LL | let opt = a.iter().enumerate().find(|(_, &s)| { - | ^- - | || - | |hint: to prevent move, use `ref s` or `ref mut s` - | cannot move out of borrowed content + | ^^^^^-^ + | | | + | | data moved here + | cannot move out of borrowed content + | +note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/issue-51415.rs:6:47 + | +LL | let opt = a.iter().enumerate().find(|(_, &s)| { + | ^ error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs b/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs index dcf047c545f..fc8a075540b 100644 --- a/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs +++ b/src/test/ui/borrowck/issue-52967-edition-2018-needs-two-phase-borrows.rs @@ -2,9 +2,8 @@ // the initial deployment of NLL for the 2018 edition, I forgot to // turn on two-phase-borrows in addition to `-Z borrowck=migrate`. -// revisions: ast zflags edition -//[zflags]compile-flags: -Z borrowck=migrate -Z two-phase-borrows -//[edition]edition:2018 +// revisions: edition2015 edition2018 +//[edition2018]edition:2018 // run-pass diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr deleted file mode 100644 index d72cc20971b..00000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `t.0` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:31 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.0` - -error[E0381]: use of possibly uninitialized variable: `t.1` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:36 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.1` - -error[E0381]: use of possibly uninitialized variable: `u.0` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:31 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.0` - -error[E0381]: use of possibly uninitialized variable: `u.1` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:36 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.1` - -error[E0381]: use of possibly uninitialized variable: `v.x` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:31 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.x` - -error[E0381]: use of possibly uninitialized variable: `v.y` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:36 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.y` - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs index 4358e8e4402..8d8ac279b23 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -20,30 +10,24 @@ fn main() { { let mut t: Tuple; t.0 = S(1); - //[nll]~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] t.1 = 2; println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381] } { let mut u: Tpair; u.0 = S(1); - //[nll]~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] u.1 = 2; println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381] } { let mut v: Spair; v.x = S(1); - //[nll]~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] v.y = 2; println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381] } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.stderr index ebc6c7fca62..6f18ff16137 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.stderr @@ -1,17 +1,17 @@ error[E0381]: assign to part of possibly uninitialized variable: `t` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:22:9 + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:12:9 | LL | t.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `t` error[E0381]: assign to part of possibly uninitialized variable: `u` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:32:9 + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:20:9 | LL | u.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `u` error[E0381]: assign to part of possibly uninitialized variable: `v` - --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:42:9 + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:28:9 | LL | v.x = S(1); | ^^^^^^^^^^ use of possibly uninitialized `v` diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr deleted file mode 100644 index 4f845d87aa2..00000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0382]: use of moved value: `t.0` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:26:31 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `t.1` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:26:36 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.0` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:37:31 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.1` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:37:36 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.x` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:48:31 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.y` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:48:36 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs index 358a5dd1cbd..f7fb2fd4da9 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -21,32 +11,26 @@ fn main() { let mut t: Tuple = (S(0), 0); drop(t); t.0 = S(1); - //[nll]~^ ERROR assign to part of moved value + //~^ ERROR assign to part of moved value t.1 = 2; println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of moved value - //[ast]~^^ ERROR use of moved value } { let mut u: Tpair = Tpair(S(0), 0); drop(u); u.0 = S(1); - //[nll]~^ ERROR assign to part of moved value + //~^ ERROR assign to part of moved value u.1 = 2; println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of moved value - //[ast]~^^ ERROR use of moved value } { let mut v: Spair = Spair { x: S(0), y: 0 }; drop(v); v.x = S(1); - //[nll]~^ ERROR assign to part of moved value + //~^ ERROR assign to part of moved value v.y = 2; println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of moved value - //[ast]~^^ ERROR use of moved value } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.stderr index 42aa0381702..b188766e221 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.stderr @@ -1,5 +1,5 @@ error[E0382]: assign to part of moved value: `t` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:23:9 + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:13:9 | LL | let mut t: Tuple = (S(0), 0); | ----- move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | t.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `u` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:34:9 + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:22:9 | LL | let mut u: Tpair = Tpair(S(0), 0); | ----- move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait @@ -19,7 +19,7 @@ LL | u.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0382]: assign to part of moved value: `v` - --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:45:9 + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:31:9 | LL | let mut v: Spair = Spair { x: S(0), y: 0 }; | ----- move occurs because `v` has type `Spair`, which does not implement the `Copy` trait diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr deleted file mode 100644 index a9c091d391c..00000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr +++ /dev/null @@ -1,123 +0,0 @@ -error[E0594]: cannot assign to field `t.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 - | -LL | let t: Tuple = (S(0), 0); - | - help: make this binding mutable: `mut t` -LL | drop(t); -LL | t.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `t.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 - | -LL | let t: Tuple = (S(0), 0); - | - help: make this binding mutable: `mut t` -... -LL | t.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 - | -LL | let u: Tpair = Tpair(S(0), 0); - | - help: make this binding mutable: `mut u` -LL | drop(u); -LL | u.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:42:9 - | -LL | let u: Tpair = Tpair(S(0), 0); - | - help: make this binding mutable: `mut u` -... -LL | u.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.x` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 - | -LL | let v: Spair = Spair { x: S(0), y: 0 }; - | - help: make this binding mutable: `mut v` -LL | drop(v); -LL | v.x = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.y` of immutable binding - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:57:9 - | -LL | let v: Spair = Spair { x: S(0), y: 0 }; - | - help: make this binding mutable: `mut v` -... -LL | v.y = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0382]: use of moved value: `t.0` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:31 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `t.1` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:36 - | -LL | drop(t); - | - value moved here -... -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ value used here after move - | - = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.0` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:31 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `u.1` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:36 - | -LL | drop(u); - | - value moved here -... -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ value used here after move - | - = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.x` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:31 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `v.y` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:36 - | -LL | drop(v); - | - value moved here -... -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ value used here after move - | - = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs index b19dcd65a6c..498ca01e972 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -21,44 +11,32 @@ fn main() { let t: Tuple = (S(0), 0); drop(t); t.0 = S(1); - //[ast]~^ ERROR cannot assign to field `t.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of moved value: `t` [E0382] - //[nll]~| ERROR cannot assign to `t.0`, as `t` is not declared as mutable [E0594] + //~^ ERROR assign to part of moved value: `t` [E0382] + //~| ERROR cannot assign to `t.0`, as `t` is not declared as mutable [E0594] t.1 = 2; - //[ast]~^ ERROR cannot assign to field `t.1` of immutable binding [E0594] - //[nll]~^^ ERROR cannot assign to `t.1`, as `t` is not declared as mutable [E0594] + //~^ ERROR cannot assign to `t.1`, as `t` is not declared as mutable [E0594] println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of moved value: `t.0` [E0382] - //[ast]~| ERROR use of moved value: `t.1` [E0382] } { let u: Tpair = Tpair(S(0), 0); drop(u); u.0 = S(1); - //[ast]~^ ERROR cannot assign to field `u.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of moved value: `u` [E0382] - //[nll]~| ERROR cannot assign to `u.0`, as `u` is not declared as mutable [E0594] + //~^ ERROR assign to part of moved value: `u` [E0382] + //~| ERROR cannot assign to `u.0`, as `u` is not declared as mutable [E0594] u.1 = 2; - //[ast]~^ ERROR cannot assign to field `u.1` of immutable binding [E0594] - //[nll]~^^ ERROR cannot assign to `u.1`, as `u` is not declared as mutable [E0594] + //~^ ERROR cannot assign to `u.1`, as `u` is not declared as mutable [E0594] println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of moved value: `u.0` [E0382] - //[ast]~| ERROR use of moved value: `u.1` [E0382] } { let v: Spair = Spair { x: S(0), y: 0 }; drop(v); v.x = S(1); - //[ast]~^ ERROR cannot assign to field `v.x` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of moved value: `v` [E0382] - //[nll]~| ERROR cannot assign to `v.x`, as `v` is not declared as mutable [E0594] + //~^ ERROR assign to part of moved value: `v` [E0382] + //~| ERROR cannot assign to `v.x`, as `v` is not declared as mutable [E0594] v.y = 2; - //[ast]~^ ERROR cannot assign to field `v.y` of immutable binding [E0594] - //[nll]~^^ ERROR cannot assign to `v.y`, as `v` is not declared as mutable [E0594] + //~^ ERROR cannot assign to `v.y`, as `v` is not declared as mutable [E0594] println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of moved value: `v.x` [E0382] - //[ast]~| ERROR use of moved value: `v.y` [E0382] } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.stderr index ec150c5ea48..7dfd71c81c3 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `t.0`, as `t` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9 | LL | let t: Tuple = (S(0), 0); | - help: consider changing this to be mutable: `mut t` @@ -8,7 +8,7 @@ LL | t.0 = S(1); | ^^^^^^^^^^ cannot assign error[E0382]: assign to part of moved value: `t` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:13:9 | LL | let t: Tuple = (S(0), 0); | - move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait @@ -18,7 +18,7 @@ LL | t.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0594]: cannot assign to `t.1`, as `t` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:16:9 | LL | let t: Tuple = (S(0), 0); | - help: consider changing this to be mutable: `mut t` @@ -27,7 +27,7 @@ LL | t.1 = 2; | ^^^^^^^ cannot assign error[E0594]: cannot assign to `u.0`, as `u` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9 | LL | let u: Tpair = Tpair(S(0), 0); | - help: consider changing this to be mutable: `mut u` @@ -36,7 +36,7 @@ LL | u.0 = S(1); | ^^^^^^^^^^ cannot assign error[E0382]: assign to part of moved value: `u` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:24:9 | LL | let u: Tpair = Tpair(S(0), 0); | - move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait @@ -46,7 +46,7 @@ LL | u.0 = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0594]: cannot assign to `u.1`, as `u` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:42:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 | LL | let u: Tpair = Tpair(S(0), 0); | - help: consider changing this to be mutable: `mut u` @@ -55,7 +55,7 @@ LL | u.1 = 2; | ^^^^^^^ cannot assign error[E0594]: cannot assign to `v.x`, as `v` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9 | LL | let v: Spair = Spair { x: S(0), y: 0 }; | - help: consider changing this to be mutable: `mut v` @@ -64,7 +64,7 @@ LL | v.x = S(1); | ^^^^^^^^^^ cannot assign error[E0382]: assign to part of moved value: `v` - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:35:9 | LL | let v: Spair = Spair { x: S(0), y: 0 }; | - move occurs because `v` has type `Spair`, which does not implement the `Copy` trait @@ -74,7 +74,7 @@ LL | v.x = S(1); | ^^^^^^^^^^ value partially assigned here after move error[E0594]: cannot assign to `v.y`, as `v` is not declared as mutable - --> $DIR/issue-54499-field-mutation-of-moved-out.rs:57:9 + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 | LL | let v: Spair = Spair { x: S(0), y: 0 }; | - help: consider changing this to be mutable: `mut v` diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr deleted file mode 100644 index 36e20077226..00000000000 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr +++ /dev/null @@ -1,90 +0,0 @@ -error[E0594]: cannot assign to field `t.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:22:9 - | -LL | let t: Tuple; - | - help: make this binding mutable: `mut t` -LL | t.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `t.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:25:9 - | -LL | let t: Tuple; - | - help: make this binding mutable: `mut t` -... -LL | t.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.0` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:34:9 - | -LL | let u: Tpair; - | - help: make this binding mutable: `mut u` -LL | u.0 = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `u.1` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:37:9 - | -LL | let u: Tpair; - | - help: make this binding mutable: `mut u` -... -LL | u.1 = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.x` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:46:9 - | -LL | let v: Spair; - | - help: make this binding mutable: `mut v` -LL | v.x = S(1); - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `v.y` of immutable binding - --> $DIR/issue-54499-field-mutation-of-never-init.rs:49:9 - | -LL | let v: Spair; - | - help: make this binding mutable: `mut v` -... -LL | v.y = 2; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0381]: use of possibly uninitialized variable: `t.0` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:27:31 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.0` - -error[E0381]: use of possibly uninitialized variable: `t.1` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:27:36 - | -LL | println!("{:?} {:?}", t.0, t.1); - | ^^^ use of possibly uninitialized `t.1` - -error[E0381]: use of possibly uninitialized variable: `u.0` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:39:31 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.0` - -error[E0381]: use of possibly uninitialized variable: `u.1` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:39:36 - | -LL | println!("{:?} {:?}", u.0, u.1); - | ^^^ use of possibly uninitialized `u.1` - -error[E0381]: use of possibly uninitialized variable: `v.x` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:51:31 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.x` - -error[E0381]: use of possibly uninitialized variable: `v.y` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:51:36 - | -LL | println!("{:?} {:?}", v.x, v.y); - | ^^^ use of possibly uninitialized `v.y` - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs index 03eb9621ee2..1a1b376bf9b 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs @@ -1,13 +1,3 @@ -// revisions: ast nll - -// Since we are testing nll migration explicitly as a separate -// revision, don't worry about the --compare-mode=nll on this test. - -// ignore-compare-mode-nll - -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - #![warn(unused)] #[derive(Debug)] struct S(i32); @@ -20,36 +10,24 @@ fn main() { { let t: Tuple; t.0 = S(1); - //[ast]~^ ERROR cannot assign to field `t.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] t.1 = 2; - //[ast]~^ ERROR cannot assign to field `t.1` of immutable binding [E0594] println!("{:?} {:?}", t.0, t.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381] } { let u: Tpair; u.0 = S(1); - //[ast]~^ ERROR cannot assign to field `u.0` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] u.1 = 2; - //[ast]~^ ERROR cannot assign to field `u.1` of immutable binding [E0594] println!("{:?} {:?}", u.0, u.1); - //[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381] } { let v: Spair; v.x = S(1); - //[ast]~^ ERROR cannot assign to field `v.x` of immutable binding [E0594] - //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] + //~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] v.y = 2; - //[ast]~^ ERROR cannot assign to field `v.y` of immutable binding [E0594] println!("{:?} {:?}", v.x, v.y); - //[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381] - //[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381] } } diff --git a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.stderr index 3dc2b5b3b8f..68873ac5c02 100644 --- a/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr +++ b/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.stderr @@ -1,17 +1,17 @@ error[E0381]: assign to part of possibly uninitialized variable: `t` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:22:9 + --> $DIR/issue-54499-field-mutation-of-never-init.rs:12:9 | LL | t.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `t` error[E0381]: assign to part of possibly uninitialized variable: `u` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:34:9 + --> $DIR/issue-54499-field-mutation-of-never-init.rs:20:9 | LL | u.0 = S(1); | ^^^^^^^^^^ use of possibly uninitialized `u` error[E0381]: assign to part of possibly uninitialized variable: `v` - --> $DIR/issue-54499-field-mutation-of-never-init.rs:46:9 + --> $DIR/issue-54499-field-mutation-of-never-init.rs:28:9 | LL | v.x = S(1); | ^^^^^^^^^^ use of possibly uninitialized `v` diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr deleted file mode 100644 index f3e9ce364d9..00000000000 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:22 - | -LL | let mut c1 = |y: &'static mut isize| x = y; - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x - | - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:32:22 - | -LL | let mut c1 = |z: &'static mut isize| { - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | x - | - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:9 - | -LL | pub fn capture_assign_whole(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { x = (1,); }; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:9 - | -LL | pub fn capture_assign_part(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { x.0 = 1; }; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:58:9 - | -LL | pub fn capture_reborrow_whole(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { &mut x; }; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:9 - | -LL | pub fn capture_reborrow_part(x: (i32,)) { - | - help: make this binding mutable: `mut x` -LL | || { &mut x.0; }; - | ^^ cannot borrow mutably - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0595`. diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr index 26efff2286e..f1d28eed922 100644 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr +++ b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:19:46 | LL | pub fn e(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -8,7 +8,7 @@ LL | let mut c1 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:34:50 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50 | LL | pub fn ee(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -17,7 +17,7 @@ LL | let mut c2 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:42:14 | LL | pub fn capture_assign_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -25,7 +25,7 @@ LL | || { x = (1,); }; | ^^^^^^^^ cannot assign error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:47:14 | LL | pub fn capture_assign_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -33,7 +33,7 @@ LL | || { x.0 = 1; }; | ^^^^^^^ cannot assign error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:58:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 | LL | pub fn capture_reborrow_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -41,7 +41,7 @@ LL | || { &mut x; }; | ^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:57:14 | LL | pub fn capture_reborrow_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr index 26efff2286e..f1d28eed922 100644 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr +++ b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:19:46 | LL | pub fn e(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -8,7 +8,7 @@ LL | let mut c1 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:34:50 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50 | LL | pub fn ee(x: &'static mut isize) { | - help: consider changing this to be mutable: `mut x` @@ -17,7 +17,7 @@ LL | let mut c2 = |y: &'static mut isize| x = y; | ^^^^^ cannot assign error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:42:14 | LL | pub fn capture_assign_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -25,7 +25,7 @@ LL | || { x = (1,); }; | ^^^^^^^^ cannot assign error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:47:14 | LL | pub fn capture_assign_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -33,7 +33,7 @@ LL | || { x.0 = 1; }; | ^^^^^^^ cannot assign error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:58:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:52:14 | LL | pub fn capture_reborrow_whole(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` @@ -41,7 +41,7 @@ LL | || { &mut x; }; | ^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:64:14 + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:57:14 | LL | pub fn capture_reborrow_part(x: (i32,)) { | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs index 2bd71ec25f8..751a911a6bb 100644 --- a/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs +++ b/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs @@ -2,16 +2,14 @@ // analysis of a closure body may only be caught when AST-borrowck // looks at some parent. -// revisions: ast migrate nll +// revisions: migrate nll // Since we are testing nll (and migration) explicitly as a separate // revisions, don't worry about the --compare-mode=nll on this test. // ignore-compare-mode-nll -//[ast]compile-flags: -Z borrowck=ast -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir // transcribed from borrowck-closures-unique.rs @@ -21,7 +19,6 @@ mod borrowck_closures_unique { let mut c1 = |y: &'static mut isize| x = y; //[migrate]~^ ERROR is not declared as mutable //[nll]~^^ ERROR is not declared as mutable - //[ast]~^^^ closure cannot assign to immutable unsafe { c1(&mut Y); } } } @@ -30,7 +27,6 @@ mod borrowck_closures_unique_grandparent { pub fn ee(x: &'static mut isize) { static mut Z: isize = 3; let mut c1 = |z: &'static mut isize| { - //[ast]~^ closure cannot assign to immutable let mut c2 = |y: &'static mut isize| x = y; //[migrate]~^ ERROR is not declared as mutable //[nll]~^^ ERROR is not declared as mutable @@ -44,27 +40,23 @@ mod borrowck_closures_unique_grandparent { mod mutability_errors { pub fn capture_assign_whole(x: (i32,)) { || { x = (1,); }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } pub fn capture_assign_part(x: (i32,)) { || { x.0 = 1; }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } pub fn capture_reborrow_whole(x: (i32,)) { || { &mut x; }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } pub fn capture_reborrow_part(x: (i32,)) { || { &mut x.0; }; - //[ast]~^ ERROR immutable argument - //[migrate]~^^ ERROR is not declared as mutable - //[nll]~^^^ ERROR is not declared as mutable + //[migrate]~^ ERROR is not declared as mutable + //[nll]~^^ ERROR is not declared as mutable } } diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.ast.stderr b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.ast.stderr deleted file mode 100644 index 9e0b0aac1e3..00000000000 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `**greeting` does not live long enough - --> $DIR/issue-58776-borrowck-scans-children.rs:10:24 - | -LL | let res = (|| (|| &greeting)())(); - | -- ^^^^^^^^ - borrowed value only lives until here - | | | - | | borrowed value does not live long enough - | capture occurs here -... -LL | } - | - borrowed value needs to live until here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr index 1c227b5b0db..efd4e1a1716 100644 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr +++ b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.migrate.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:13:5 + --> $DIR/issue-58776-borrowck-scans-children.rs:11:5 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure | | | borrow of `greeting` occurs here -... +LL | LL | greeting = "DEALLOCATED".to_string(); | ^^^^^^^^ assignment to borrowed `greeting` occurs here ... @@ -13,7 +13,7 @@ LL | println!("thread result: {:?}", res); | --- borrow later used here error[E0505]: cannot move out of `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:16:10 + --> $DIR/issue-58776-borrowck-scans-children.rs:14:10 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr index 1c227b5b0db..efd4e1a1716 100644 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr +++ b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.nll.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:13:5 + --> $DIR/issue-58776-borrowck-scans-children.rs:11:5 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure | | | borrow of `greeting` occurs here -... +LL | LL | greeting = "DEALLOCATED".to_string(); | ^^^^^^^^ assignment to borrowed `greeting` occurs here ... @@ -13,7 +13,7 @@ LL | println!("thread result: {:?}", res); | --- borrow later used here error[E0505]: cannot move out of `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:16:10 + --> $DIR/issue-58776-borrowck-scans-children.rs:14:10 | LL | let res = (|| (|| &greeting)())(); | -- -------- borrow occurs due to use in closure diff --git a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs index 378969f9a18..0f3f1a639f7 100644 --- a/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs +++ b/src/test/ui/borrowck/issue-58776-borrowck-scans-children.rs @@ -1,14 +1,12 @@ // ignore-compare-mode-nll -// revisions: ast migrate nll +// revisions: migrate nll -//[migrate]compile-flags: -Z borrowck=migrate #![cfg_attr(nll, feature(nll))] fn main() { let mut greeting = "Hello world!".to_string(); let res = (|| (|| &greeting)())(); - //[ast]~^ ERROR does not live long enough greeting = "DEALLOCATED".to_string(); //[migrate]~^ ERROR cannot assign diff --git a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr deleted file mode 100644 index 14078b76897..00000000000 --- a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:15:23 - | -LL | static Y: usize = get(*&X); - | ^^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:17:22 - | -LL | const Z: usize = get(*&X); - | ^^^ cannot move out of borrowed content - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs index a7b17f7d651..c2a59a1054c 100644 --- a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs +++ b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Regression test for #38520. Check that moves of `Foo` are not // permitted as `Foo` is not copy (even in a static/const // initializer). @@ -12,10 +9,8 @@ const fn get(x: Foo) -> usize { } const X: Foo = Foo(22); -static Y: usize = get(*&X); //[ast]~ ERROR E0507 - //[mir]~^ ERROR [E0507] -const Z: usize = get(*&X); //[ast]~ ERROR E0507 - //[mir]~^ ERROR [E0507] +static Y: usize = get(*&X); //~ ERROR [E0507] +const Z: usize = get(*&X); //~ ERROR [E0507] fn main() { } diff --git a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.stderr index 14078b76897..9dcefac1b70 100644 --- a/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr +++ b/src/test/ui/borrowck/move-in-static-initializer-issue-38520.stderr @@ -1,11 +1,11 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:15:23 + --> $DIR/move-in-static-initializer-issue-38520.rs:12:23 | LL | static Y: usize = get(*&X); | ^^^ cannot move out of borrowed content error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:17:22 + --> $DIR/move-in-static-initializer-issue-38520.rs:13:22 | LL | const Z: usize = get(*&X); | ^^^ cannot move out of borrowed content diff --git a/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr b/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr deleted file mode 100644 index eda2f518f92..00000000000 --- a/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0499]: cannot borrow `*arg` as mutable more than once at a time - --> $DIR/mut-borrow-in-loop.rs:10:25 - | -LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | -- lifetime `'a` defined here -... -LL | (self.func)(arg) - | ------------^^^- - | | | - | | mutable borrow starts here in previous iteration of loop - | argument requires that `*arg` is borrowed for `'a` - -error[E0499]: cannot borrow `*arg` as mutable more than once at a time - --> $DIR/mut-borrow-in-loop.rs:16:25 - | -LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | -- lifetime `'a` defined here -... -LL | (self.func)(arg) - | ------------^^^- - | | | - | | mutable borrow starts here in previous iteration of loop - | argument requires that `*arg` is borrowed for `'a` - -error[E0499]: cannot borrow `*arg` as mutable more than once at a time - --> $DIR/mut-borrow-in-loop.rs:23:25 - | -LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | -- lifetime `'a` defined here -... -LL | (self.func)(arg) - | ------------^^^- - | | | - | | mutable borrow starts here in previous iteration of loop - | argument requires that `*arg` is borrowed for `'a` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/mut-borrow-in-loop.stderr b/src/test/ui/borrowck/mut-borrow-in-loop.stderr index 478d586d03e..eda2f518f92 100644 --- a/src/test/ui/borrowck/mut-borrow-in-loop.stderr +++ b/src/test/ui/borrowck/mut-borrow-in-loop.stderr @@ -1,29 +1,38 @@ error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:10:25 | +LL | impl<'a, T : 'a> FuncWrapper<'a, T> { + | -- lifetime `'a` defined here +... LL | (self.func)(arg) - | ^^^ mutable borrow starts here in previous iteration of loop -LL | } -LL | } - | - mutable borrow ends here + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:16:25 | +LL | impl<'a, T : 'a> FuncWrapper<'a, T> { + | -- lifetime `'a` defined here +... LL | (self.func)(arg) - | ^^^ mutable borrow starts here in previous iteration of loop -LL | } -LL | } - | - mutable borrow ends here + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:23:25 | +LL | impl<'a, T : 'a> FuncWrapper<'a, T> { + | -- lifetime `'a` defined here +... LL | (self.func)(arg) - | ^^^ mutable borrow starts here in previous iteration of loop -LL | } -LL | } - | - mutable borrow ends here + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error: aborting due to 3 previous errors diff --git a/src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr b/src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr deleted file mode 100644 index 09dabbc89b4..00000000000 --- a/src/test/ui/borrowck/mut-borrow-of-mut-ref.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable - --> $DIR/mut-borrow-of-mut-ref.rs:8:7 - | -LL | fn f(b: &mut i32) { - | - help: consider changing this to be mutable: `mut b` -LL | g(&mut b) - | ^^^^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr b/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr index 4653c353cad..09dabbc89b4 100644 --- a/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr +++ b/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr @@ -1,12 +1,10 @@ -error[E0596]: cannot borrow immutable argument `b` as mutable - --> $DIR/mut-borrow-of-mut-ref.rs:8:12 +error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable + --> $DIR/mut-borrow-of-mut-ref.rs:8:7 | +LL | fn f(b: &mut i32) { + | - help: consider changing this to be mutable: `mut b` LL | g(&mut b) - | ^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | g(b) - | ^ + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr b/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr deleted file mode 100644 index 4fcb693f1bf..00000000000 --- a/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0499]: cannot borrow `void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:7:18 - | -LL | let first = &mut void; - | --------- first mutable borrow occurs here -LL | let second = &mut void; - | ^^^^^^^^^ second mutable borrow occurs here -LL | first.use_mut(); - | ----- first borrow later used here - -error[E0499]: cannot borrow `inner_void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:15:28 - | -LL | let inner_first = &mut inner_void; - | --------------- first mutable borrow occurs here -LL | let inner_second = &mut inner_void; - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -LL | inner_second.use_mut(); -LL | inner_first.use_mut(); - | ----------- first borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/mut-borrow-outside-loop.stderr b/src/test/ui/borrowck/mut-borrow-outside-loop.stderr index 45db962fbd0..4fcb693f1bf 100644 --- a/src/test/ui/borrowck/mut-borrow-outside-loop.stderr +++ b/src/test/ui/borrowck/mut-borrow-outside-loop.stderr @@ -1,24 +1,23 @@ error[E0499]: cannot borrow `void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:7:23 + --> $DIR/mut-borrow-outside-loop.rs:7:18 | LL | let first = &mut void; - | ---- first mutable borrow occurs here + | --------- first mutable borrow occurs here LL | let second = &mut void; - | ^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^^ second mutable borrow occurs here +LL | first.use_mut(); + | ----- first borrow later used here error[E0499]: cannot borrow `inner_void` as mutable more than once at a time - --> $DIR/mut-borrow-outside-loop.rs:15:33 + --> $DIR/mut-borrow-outside-loop.rs:15:28 | LL | let inner_first = &mut inner_void; - | ---------- first mutable borrow occurs here + | --------------- first mutable borrow occurs here LL | let inner_second = &mut inner_void; - | ^^^^^^^^^^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^^^^^^^^^^ second mutable borrow occurs here +LL | inner_second.use_mut(); +LL | inner_first.use_mut(); + | ----------- first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/borrowck/mutability-errors.nll.stderr b/src/test/ui/borrowck/mutability-errors.nll.stderr deleted file mode 100644 index 545de5d0e75..00000000000 --- a/src/test/ui/borrowck/mutability-errors.nll.stderr +++ /dev/null @@ -1,378 +0,0 @@ -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/mutability-errors.rs:9:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -LL | *x = (1,); - | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `x.0` which is behind a `&` reference - --> $DIR/mutability-errors.rs:10:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -LL | *x = (1,); -LL | x.0 = 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/mutability-errors.rs:11:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -... -LL | &mut *x; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference - --> $DIR/mutability-errors.rs:12:5 - | -LL | fn named_ref(x: &(i32,)) { - | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` -... -LL | &mut x.0; - | ^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/mutability-errors.rs:16:5 - | -LL | *f() = (1,); - | ^^^^^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `&` reference - --> $DIR/mutability-errors.rs:17:5 - | -LL | f().0 = 1; - | ^^^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/mutability-errors.rs:18:5 - | -LL | &mut *f(); - | ^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/mutability-errors.rs:19:5 - | -LL | &mut f().0; - | ^^^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `*x` which is behind a `*const` pointer - --> $DIR/mutability-errors.rs:23:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -LL | *x = (1,); - | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written - -error[E0594]: cannot assign to `x.0` which is behind a `*const` pointer - --> $DIR/mutability-errors.rs:24:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -LL | *x = (1,); -LL | (*x).0 = 1; - | ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer - --> $DIR/mutability-errors.rs:25:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -... -LL | &mut *x; - | ^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer - --> $DIR/mutability-errors.rs:26:5 - | -LL | unsafe fn named_ptr(x: *const (i32,)) { - | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` -... -LL | &mut (*x).0; - | ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable - -error[E0594]: cannot assign to data in a `*const` pointer - --> $DIR/mutability-errors.rs:30:5 - | -LL | *f() = (1,); - | ^^^^^^^^^^^ cannot assign - -error[E0594]: cannot assign to data in a `*const` pointer - --> $DIR/mutability-errors.rs:31:5 - | -LL | (*f()).0 = 1; - | ^^^^^^^^^^^^ cannot assign - -error[E0596]: cannot borrow data in a `*const` pointer as mutable - --> $DIR/mutability-errors.rs:32:5 - | -LL | &mut *f(); - | ^^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow data in a `*const` pointer as mutable - --> $DIR/mutability-errors.rs:33:5 - | -LL | &mut (*f()).0; - | ^^^^^^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:40:9 - | -LL | x = (1,); - | ^^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:41:9 - | -LL | x.0 = 1; - | ^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:42:9 - | -LL | &mut x; - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:43:9 - | -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:39:12 - | -LL | fn_ref(|| { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:46:9 - | -LL | x = (1,); - | ^^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:47:9 - | -LL | x.0 = 1; - | ^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/mutability-errors.rs:48:9 - | -LL | &mut x; - | ^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables - --> $DIR/mutability-errors.rs:49:9 - | -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/mutability-errors.rs:45:12 - | -LL | fn_ref(move || { - | ____________^ -LL | | x = (1,); -LL | | x.0 = 1; -LL | | &mut x; -LL | | &mut x.0; -LL | | }); - | |_____^ - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/mutability-errors.rs:54:5 - | -LL | fn imm_local(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -LL | &mut x; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:55:5 - | -LL | fn imm_local(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -LL | &mut x; -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/mutability-errors.rs:60:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -LL | || { -LL | x = (1,); - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:61:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | x.0 = 1; - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/mutability-errors.rs:62:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:63:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/mutability-errors.rs:66:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | x = (1,); - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:67:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | x.0 = 1; - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/mutability-errors.rs:68:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable - --> $DIR/mutability-errors.rs:69:9 - | -LL | fn imm_capture(x: (i32,)) { - | - help: consider changing this to be mutable: `mut x` -... -LL | &mut x.0; - | ^^^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to immutable static item `X` - --> $DIR/mutability-errors.rs:76:5 - | -LL | X = (1,); - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `X.0`, as `X` is an immutable static item - --> $DIR/mutability-errors.rs:77:5 - | -LL | X.0 = 1; - | ^^^^^^^ cannot assign - -error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/mutability-errors.rs:78:5 - | -LL | &mut X; - | ^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item - --> $DIR/mutability-errors.rs:79:5 - | -LL | &mut X.0; - | ^^^^^^^^ cannot borrow as mutable - -error: aborting due to 38 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/mutability-errors.rs b/src/test/ui/borrowck/mutability-errors.rs index 26f7f605ebe..5be0df13761 100644 --- a/src/test/ui/borrowck/mutability-errors.rs +++ b/src/test/ui/borrowck/mutability-errors.rs @@ -56,11 +56,11 @@ fn imm_local(x: (i32,)) { } fn imm_capture(x: (i32,)) { - || { //~ ERROR - x = (1,); - x.0 = 1; - &mut x; - &mut x.0; + || { + x = (1,); //~ ERROR + x.0 = 1; //~ ERROR + &mut x; //~ ERROR + &mut x.0; //~ ERROR }; move || { x = (1,); //~ ERROR diff --git a/src/test/ui/borrowck/mutability-errors.stderr b/src/test/ui/borrowck/mutability-errors.stderr index 561acadfc08..545de5d0e75 100644 --- a/src/test/ui/borrowck/mutability-errors.stderr +++ b/src/test/ui/borrowck/mutability-errors.stderr @@ -1,117 +1,128 @@ -error[E0594]: cannot assign to immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/mutability-errors.rs:9:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` LL | *x = (1,); - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0` which is behind a `&` reference --> $DIR/mutability-errors.rs:10:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` LL | *x = (1,); LL | x.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable - --> $DIR/mutability-errors.rs:11:10 +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference + --> $DIR/mutability-errors.rs:11:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` ... LL | &mut *x; - | ^^ cannot borrow as mutable + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:12:10 +error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `&` reference + --> $DIR/mutability-errors.rs:12:5 | LL | fn named_ref(x: &(i32,)) { - | ------- use `&mut (i32,)` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut (i32,)` ... LL | &mut x.0; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0594]: cannot assign to immutable borrowed content +error[E0594]: cannot assign to data in a `&` reference --> $DIR/mutability-errors.rs:16:5 | LL | *f() = (1,); - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `&` reference --> $DIR/mutability-errors.rs:17:5 | LL | f().0 = 1; - | ^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable borrowed content as mutable - --> $DIR/mutability-errors.rs:18:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/mutability-errors.rs:18:5 | LL | &mut *f(); - | ^^^^ cannot borrow as mutable + | ^^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/mutability-errors.rs:19:10 +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/mutability-errors.rs:19:5 | LL | &mut f().0; - | ^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to immutable dereference of raw pointer `*x` +error[E0594]: cannot assign to `*x` which is behind a `*const` pointer --> $DIR/mutability-errors.rs:23:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` LL | *x = (1,); - | ^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0` which is behind a `*const` pointer --> $DIR/mutability-errors.rs:24:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` +LL | *x = (1,); LL | (*x).0 = 1; - | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be written -error[E0596]: cannot borrow immutable dereference of raw pointer `*x` as mutable - --> $DIR/mutability-errors.rs:25:10 +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `*const` pointer + --> $DIR/mutability-errors.rs:25:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` +... LL | &mut *x; - | ^^ cannot borrow as mutable + | ^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:26:10 +error[E0596]: cannot borrow `x.0` as mutable, as it is behind a `*const` pointer + --> $DIR/mutability-errors.rs:26:5 | +LL | unsafe fn named_ptr(x: *const (i32,)) { + | ------------- help: consider changing this to be a mutable pointer: `*mut (i32,)` +... LL | &mut (*x).0; - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable -error[E0594]: cannot assign to immutable dereference of raw pointer +error[E0594]: cannot assign to data in a `*const` pointer --> $DIR/mutability-errors.rs:30:5 | LL | *f() = (1,); - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to data in a `*const` pointer --> $DIR/mutability-errors.rs:31:5 | LL | (*f()).0 = 1; - | ^^^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable dereference of raw pointer as mutable - --> $DIR/mutability-errors.rs:32:10 +error[E0596]: cannot borrow data in a `*const` pointer as mutable + --> $DIR/mutability-errors.rs:32:5 | LL | &mut *f(); - | ^^^^ cannot borrow as mutable + | ^^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/mutability-errors.rs:33:10 +error[E0596]: cannot borrow data in a `*const` pointer as mutable + --> $DIR/mutability-errors.rs:33:5 | LL | &mut (*f()).0; - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^ cannot borrow as mutable -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:40:9 | LL | x = (1,); - | ^^^^^^^^ + | ^^^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -123,13 +134,13 @@ LL | | &mut x.0; LL | | }); | |_____^ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:41:9 | LL | x.0 = 1; - | ^^^^^^^ + | ^^^^^^^ cannot assign | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -141,13 +152,13 @@ LL | | &mut x.0; LL | | }); | |_____^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/mutability-errors.rs:42:14 +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/mutability-errors.rs:42:9 | LL | &mut x; - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -159,13 +170,13 @@ LL | | &mut x.0; LL | | }); | |_____^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/mutability-errors.rs:43:14 +error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables + --> $DIR/mutability-errors.rs:43:9 | LL | &mut x.0; - | ^^^ + | ^^^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:39:12 | LL | fn_ref(|| { @@ -177,14 +188,13 @@ LL | | &mut x.0; LL | | }); | |_____^ -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure --> $DIR/mutability-errors.rs:46:9 | LL | x = (1,); - | ^^^^^^^^ + | ^^^^^^^^ cannot assign | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:45:12 | LL | fn_ref(move || { @@ -196,19 +206,31 @@ LL | | &mut x.0; LL | | }); | |_____^ -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0`, as `Fn` closures cannot mutate their captured variables --> $DIR/mutability-errors.rs:47:9 | LL | x.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/mutability-errors.rs:45:12 + | +LL | fn_ref(move || { + | ____________^ +LL | | x = (1,); +LL | | x.0 = 1; +LL | | &mut x; +LL | | &mut x.0; +LL | | }); + | |_____^ -error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable - --> $DIR/mutability-errors.rs:48:14 +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/mutability-errors.rs:48:9 | LL | &mut x; - | ^ + | ^^^^^^ cannot borrow as mutable | -help: consider changing this closure to take self by mutable reference +help: consider changing this to accept closures that implement `FnMut` --> $DIR/mutability-errors.rs:45:12 | LL | fn_ref(move || { @@ -220,89 +242,137 @@ LL | | &mut x.0; LL | | }); | |_____^ -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:49:14 +error[E0596]: cannot borrow `x.0` as mutable, as `Fn` closures cannot mutate their captured variables + --> $DIR/mutability-errors.rs:49:9 | LL | &mut x.0; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/mutability-errors.rs:45:12 + | +LL | fn_ref(move || { + | ____________^ +LL | | x = (1,); +LL | | x.0 = 1; +LL | | &mut x; +LL | | &mut x.0; +LL | | }); + | |_____^ -error[E0596]: cannot borrow immutable argument `x` as mutable - --> $DIR/mutability-errors.rs:54:10 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/mutability-errors.rs:54:5 | LL | fn imm_local(x: (i32,)) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | &mut x; - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:55:10 +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:55:5 | LL | fn imm_local(x: (i32,)) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | &mut x; LL | &mut x.0; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0595]: closure cannot assign to immutable argument `x` - --> $DIR/mutability-errors.rs:59:5 +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/mutability-errors.rs:60:9 | LL | fn imm_capture(x: (i32,)) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | || { - | ^^ cannot borrow mutably +LL | x = (1,); + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:61:9 + | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... +LL | x.0 = 1; + | ^^^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/mutability-errors.rs:62:9 + | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... +LL | &mut x; + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:63:9 + | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... +LL | &mut x.0; + | ^^^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/mutability-errors.rs:66:9 | LL | fn imm_capture(x: (i32,)) { - | - help: consider making `x` mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... LL | x = (1,); - | ^^^^^^^^ + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable --> $DIR/mutability-errors.rs:67:9 | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... LL | x.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable - --> $DIR/mutability-errors.rs:68:14 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/mutability-errors.rs:68:9 | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... LL | &mut x; - | ^ + | ^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `x.0` of immutable binding as mutable - --> $DIR/mutability-errors.rs:69:14 +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/mutability-errors.rs:69:9 | +LL | fn imm_capture(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +... LL | &mut x.0; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to immutable static item +error[E0594]: cannot assign to immutable static item `X` --> $DIR/mutability-errors.rs:76:5 | LL | X = (1,); - | ^^^^^^^^ + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to field of immutable binding +error[E0594]: cannot assign to `X.0`, as `X` is an immutable static item --> $DIR/mutability-errors.rs:77:5 | LL | X.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/mutability-errors.rs:78:10 +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/mutability-errors.rs:78:5 | LL | &mut X; - | ^ + | ^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/mutability-errors.rs:79:10 +error[E0596]: cannot borrow `X.0` as mutable, as `X` is an immutable static item + --> $DIR/mutability-errors.rs:79:5 | LL | &mut X.0; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error: aborting due to 35 previous errors +error: aborting due to 38 previous errors -Some errors have detailed explanations: E0387, E0595, E0596. -For more information about an error, try `rustc --explain E0387`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr deleted file mode 100644 index 60af4123735..00000000000 --- a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:6:5 - | -LL | let ref mut x = 1234543; - | ------- temporary value created here -LL | x - | ^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:11:5 - | -LL | let (ref mut x, ) = (1234543, ); - | ----------- temporary value created here -LL | x - | ^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:5 - | -LL | match 1234543 { - | ^ ------- temporary value created here - | _____| - | | -LL | | ref mut x => x -LL | | } - | |_____^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 - | -LL | match (123443,) { - | ^ --------- temporary value created here - | _____| - | | -LL | | (ref mut x,) => x, -LL | | } - | |_____^ returns a value referencing data owned by the current function - -error[E0515]: cannot return reference to temporary value - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:5 - | -LL | &mut 1234543 - | ^^^^^------- - | | | - | | temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs index ae305b68941..3576734de3c 100644 --- a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs +++ b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.rs @@ -2,24 +2,24 @@ // mut` borrow. fn gimme_static_mut_let() -> &'static mut u32 { - let ref mut x = 1234543; //~ ERROR - x + let ref mut x = 1234543; + x //~ ERROR } fn gimme_static_mut_let_nested() -> &'static mut u32 { - let (ref mut x, ) = (1234543, ); //~ ERROR - x + let (ref mut x, ) = (1234543, ); + x //~ ERROR } fn gimme_static_mut_match() -> &'static mut u32 { - match 1234543 { - ref mut x => x //~ ERROR + match 1234543 { //~ ERROR + ref mut x => x } } fn gimme_static_mut_match_nested() -> &'static mut u32 { - match (123443,) { - (ref mut x,) => x, //~ ERROR + match (123443,) { //~ ERROR + (ref mut x,) => x, } } diff --git a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr index ae68df72aa7..60af4123735 100644 --- a/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr +++ b/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.stderr @@ -1,57 +1,50 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:5:9 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:6:5 | LL | let ref mut x = 1234543; - | ^^^^^^^^^ temporary value does not live long enough + | ------- temporary value created here LL | x -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:10:10 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:11:5 | LL | let (ref mut x, ) = (1234543, ); - | ^^^^^^^^^ borrowed value does not live long enough + | ----------- temporary value created here LL | x -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:16:9 - | -LL | ref mut x => x - | ^^^^^^^^^ temporary value does not live long enough -LL | } -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:5 + | +LL | match 1234543 { + | ^ ------- temporary value created here + | _____| + | | +LL | | ref mut x => x +LL | | } + | |_____^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:22:10 - | -LL | (ref mut x,) => x, - | ^^^^^^^^^ borrowed value does not live long enough -LL | } -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 + | +LL | match (123443,) { + | ^ --------- temporary value created here + | _____| + | | +LL | | (ref mut x,) => x, +LL | | } + | |_____^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:10 +error[E0515]: cannot return reference to temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:5 | LL | &mut 1234543 - | ^^^^^^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^^^^^------- + | | | + | | temporary value created here + | returns a reference to data owned by the current function error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr b/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr deleted file mode 100644 index d455a8f0787..00000000000 --- a/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields.rs:7:5 - | -LL | x.0 = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields.rs:15:5 - | -LL | x.0 = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields.rs b/src/test/ui/borrowck/reassignment_immutable_fields.rs index 4529e32a692..fd2ab62a40f 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields.rs +++ b/src/test/ui/borrowck/reassignment_immutable_fields.rs @@ -5,16 +5,16 @@ fn assign_both_fields_and_use() { let x: (u32, u32); x.0 = 1; //~ ERROR - x.1 = 22; //~ ERROR - drop(x.0); //~ ERROR - drop(x.1); //~ ERROR + x.1 = 22; + drop(x.0); + drop(x.1); } fn assign_both_fields_the_use_var() { let x: (u32, u32); x.0 = 1; //~ ERROR - x.1 = 22; //~ ERROR - drop(x); //~ ERROR + x.1 = 22; + drop(x); } fn main() { } diff --git a/src/test/ui/borrowck/reassignment_immutable_fields.stderr b/src/test/ui/borrowck/reassignment_immutable_fields.stderr index 6aa58313834..d455a8f0787 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields.stderr +++ b/src/test/ui/borrowck/reassignment_immutable_fields.stderr @@ -1,55 +1,15 @@ -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields.rs:7:5 | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` LL | x.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ use of possibly uninitialized `x` -error[E0594]: cannot assign to field `x.1` of immutable binding - --> $DIR/reassignment_immutable_fields.rs:8:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -LL | x.0 = 1; -LL | x.1 = 22; - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0381]: use of possibly uninitialized variable: `x.0` - --> $DIR/reassignment_immutable_fields.rs:9:10 - | -LL | drop(x.0); - | ^^^ use of possibly uninitialized `x.0` - -error[E0381]: use of possibly uninitialized variable: `x.1` - --> $DIR/reassignment_immutable_fields.rs:10:10 - | -LL | drop(x.1); - | ^^^ use of possibly uninitialized `x.1` - -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields.rs:15:5 | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -LL | x.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `x.1` of immutable binding - --> $DIR/reassignment_immutable_fields.rs:16:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` LL | x.0 = 1; -LL | x.1 = 22; - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields.rs:17:10 - | -LL | drop(x); - | ^ use of possibly uninitialized `x` + | ^^^^^^^ use of possibly uninitialized `x` -error: aborting due to 7 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr deleted file mode 100644 index 649c127dcc9..00000000000 --- a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields_overlapping.rs:12:5 - | -LL | x.a = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields_overlapping.rs:13:5 - | -LL | let x: Foo; - | - help: consider changing this to be mutable: `mut x` -LL | x.a = 1; -LL | x.b = 22; - | ^^^^^^^^ cannot assign - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr index ea16ce45b42..649c127dcc9 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr +++ b/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.stderr @@ -1,19 +1,18 @@ -error[E0594]: cannot assign to field `x.a` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields_overlapping.rs:12:5 | -LL | let x: Foo; - | - help: make this binding mutable: `mut x` LL | x.a = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ use of possibly uninitialized `x` -error[E0594]: cannot assign to field `x.b` of immutable binding +error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable --> $DIR/reassignment_immutable_fields_overlapping.rs:13:5 | LL | let x: Foo; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.a = 1; LL | x.b = 22; - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot assign error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr deleted file mode 100644 index 9a2824ccb3c..00000000000 --- a/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields_twice.rs:7:5 - | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` -LL | x = (22, 44); -LL | x.0 = 1; - | ^^^^^^^ cannot assign - -error[E0381]: assign to part of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields_twice.rs:12:5 - | -LL | x.0 = 1; - | ^^^^^^^ use of possibly uninitialized `x` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs b/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs index a10baf627f3..2775a54c830 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs +++ b/src/test/ui/borrowck/reassignment_immutable_fields_twice.rs @@ -10,8 +10,8 @@ fn var_then_field() { fn same_field_twice() { let x: (u32, u32); x.0 = 1; //~ ERROR - x.0 = 22; //~ ERROR - x.1 = 44; //~ ERROR + x.0 = 22; + x.1 = 44; } fn main() { } diff --git a/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr b/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr index 1704360b49f..9a2824ccb3c 100644 --- a/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr +++ b/src/test/ui/borrowck/reassignment_immutable_fields_twice.stderr @@ -1,37 +1,18 @@ -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable --> $DIR/reassignment_immutable_fields_twice.rs:7:5 | LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x = (22, 44); LL | x.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ cannot assign -error[E0594]: cannot assign to field `x.0` of immutable binding +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields_twice.rs:12:5 | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -LL | x.0 = 1; - | ^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `x.0` of immutable binding - --> $DIR/reassignment_immutable_fields_twice.rs:13:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` LL | x.0 = 1; -LL | x.0 = 22; - | ^^^^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to field `x.1` of immutable binding - --> $DIR/reassignment_immutable_fields_twice.rs:14:5 - | -LL | let x: (u32, u32); - | - help: make this binding mutable: `mut x` -... -LL | x.1 = 44; - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^ use of possibly uninitialized `x` -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs index 5754220e824..55a8ae7a49e 100644 --- a/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs +++ b/src/test/ui/borrowck/two-phase-activation-sharing-interference.rs @@ -3,9 +3,9 @@ // revisions: nll_target // The following revisions are disabled due to missing support from two-phase beyond autorefs -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll_target] compile-flags: -Z borrowck=mir // This is an important corner case pointed out by Niko: one is // allowed to initiate a shared borrow during a reservation, but it diff --git a/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs b/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs index e428964939a..07169afefc9 100644 --- a/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs +++ b/src/test/ui/borrowck/two-phase-allow-access-during-reservation.rs @@ -3,9 +3,9 @@ // revisions: nll_target // The following revisions are disabled due to missing support for two_phase_beyond_autoref -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two_phase_beyond_autoref -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll_target] compile-flags: -Z borrowck=mir // This is the second counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ diff --git a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs index fd1b8841b4e..f2097fdf823 100644 --- a/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs +++ b/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z borrowck=mir -Z two-phase-borrows +// compile-flags: -Z borrowck=mir // This is the third counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ diff --git a/src/test/ui/borrowck/two-phase-method-receivers.rs b/src/test/ui/borrowck/two-phase-method-receivers.rs index f1df1a6a2c8..6838f6c7efd 100644 --- a/src/test/ui/borrowck/two-phase-method-receivers.rs +++ b/src/test/ui/borrowck/two-phase-method-receivers.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z borrowck=mir -Z two-phase-borrows +// compile-flags: -Z borrowck=mir // run-pass diff --git a/src/test/ui/borrowck/two-phase-multiple-activations.rs b/src/test/ui/borrowck/two-phase-multiple-activations.rs index 38ba0948640..a7fa7fac13e 100644 --- a/src/test/ui/borrowck/two-phase-multiple-activations.rs +++ b/src/test/ui/borrowck/two-phase-multiple-activations.rs @@ -1,4 +1,4 @@ -// compile-flags: -Z borrowck=mir -Z two-phase-borrows +// compile-flags: -Z borrowck=mir // run-pass diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr deleted file mode 100644 index 62ab00fd5e1..00000000000 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr +++ /dev/null @@ -1,71 +0,0 @@ -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:60:11 - | -LL | f(f(10)); - | - ^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:69:11 - | -LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) { - | - move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:76:11 - | -LL | f(f(10)); - | - ^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 - | -LL | fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) { - | - move occurs because `f` has type `std::boxed::Box<dyn std::ops::FnOnce(i32) -> i32>`, which does not implement the `Copy` trait -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - -error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:125:27 - | -LL | double_access(&mut a, &a); - | ------------- ------ ^^ immutable borrow occurs here - | | | - | | mutable borrow occurs here - | mutable borrow later used by call - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:153:7 - | -LL | i[i[3]] = 4; - | --^---- - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - | mutable borrow later used here - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:159:7 - | -LL | i[i[3]] = i[4]; - | --^---- - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - | mutable borrow later used here - -error: aborting due to 7 previous errors - -Some errors have detailed explanations: E0382, E0499, E0502. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr deleted file mode 100644 index 1d2824617ae..00000000000 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.stderr +++ /dev/null @@ -1,113 +0,0 @@ -error[E0503]: cannot use `*x` because it was mutably borrowed - --> $DIR/two-phase-nonrecv-autoref.rs:31:12 - | -LL | foo(x, *x); - | - ^^ use of borrowed `*x` - | | - | borrow of `*x` occurs here - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:60:11 - | -LL | f(f(10)); - | - ^ - first borrow ends here - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here - -error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:69:11 - | -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait - -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:76:11 - | -LL | f(f(10)); - | - ^ - first borrow ends here - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here - -error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 - | -LL | f(f(10)); - | - ^ value used here after move - | | - | value moved here - | - = note: move occurs because `f` has type `std::boxed::Box<(dyn std::ops::FnOnce(i32) -> i32 + 'static)>`, which does not implement the `Copy` trait - -error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:125:28 - | -LL | double_access(&mut a, &a); - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:131:9 - | -LL | a.m(a.i(10)); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:153:7 - | -LL | i[i[3]] = 4; - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:159:7 - | -LL | i[i[3]] = i[4]; - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:168:12 - | -LL | v.push(v.len()); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:179:9 - | -LL | s.m(s.i(10)); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `t` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:184:9 - | -LL | t.m(t.i(10)); - | - ^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error: aborting due to 12 previous errors - -Some errors have detailed explanations: E0382, E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr index 62ab00fd5e1..fca425da34d 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:60:11 + --> $DIR/two-phase-nonrecv-autoref.rs:58:11 | LL | f(f(10)); | - ^ second mutable borrow occurs here @@ -8,7 +8,7 @@ LL | f(f(10)); | first borrow later used by call error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:69:11 + --> $DIR/two-phase-nonrecv-autoref.rs:66:11 | LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) { | - move occurs because `f` has type `std::boxed::Box<F>`, which does not implement the `Copy` trait @@ -18,7 +18,7 @@ LL | f(f(10)); | value moved here error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/two-phase-nonrecv-autoref.rs:76:11 + --> $DIR/two-phase-nonrecv-autoref.rs:72:11 | LL | f(f(10)); | - ^ second mutable borrow occurs here @@ -27,7 +27,7 @@ LL | f(f(10)); | first borrow later used by call error[E0382]: use of moved value: `f` - --> $DIR/two-phase-nonrecv-autoref.rs:85:11 + --> $DIR/two-phase-nonrecv-autoref.rs:80:11 | LL | fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) { | - move occurs because `f` has type `std::boxed::Box<dyn std::ops::FnOnce(i32) -> i32>`, which does not implement the `Copy` trait @@ -37,7 +37,7 @@ LL | f(f(10)); | value moved here error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:125:27 + --> $DIR/two-phase-nonrecv-autoref.rs:119:27 | LL | double_access(&mut a, &a); | ------------- ------ ^^ immutable borrow occurs here @@ -46,7 +46,7 @@ LL | double_access(&mut a, &a); | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:153:7 + --> $DIR/two-phase-nonrecv-autoref.rs:145:7 | LL | i[i[3]] = 4; | --^---- @@ -56,7 +56,7 @@ LL | i[i[3]] = 4; | mutable borrow later used here error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-nonrecv-autoref.rs:159:7 + --> $DIR/two-phase-nonrecv-autoref.rs:150:7 | LL | i[i[3]] = i[4]; | --^---- diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs index 1005da05297..c0a117d6766 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs @@ -1,8 +1,7 @@ -// revisions: ast nll -//[ast]compile-flags: -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows +// revisions: nll +//[nll]compile-flags: -Z borrowck=mir -//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref // the above revision is disabled until two-phase-beyond-autoref support is better // This is a test checking that when we limit two-phase borrows to @@ -29,7 +28,6 @@ fn foo(x: &mut u32, y: u32) { fn deref_coercion(x: &mut u32) { foo(x, *x); - //[ast]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503] // Above error is a known limitation of AST borrowck } @@ -60,7 +58,6 @@ fn overloaded_call_traits() { f(f(10)); //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_si<F: Fn(i32) -> i32>(f: &mut F) { f(f(10)); @@ -69,14 +66,12 @@ fn overloaded_call_traits() { f(f(10)); //[nll]~^ ERROR use of moved value: `f` //[g2p]~^^ ERROR use of moved value: `f` - //[ast]~^^^ ERROR use of moved value: `f` } fn twice_ten_om(f: &mut FnMut(i32) -> i32) { f(f(10)); //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[ast]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time } fn twice_ten_oi(f: &mut Fn(i32) -> i32) { f(f(10)); @@ -85,7 +80,6 @@ fn overloaded_call_traits() { f(f(10)); //[nll]~^ ERROR use of moved value: `f` //[g2p]~^^ ERROR use of moved value: `f` - //[ast]~^^^ ERROR use of moved value: `f` } twice_ten_sm(&mut |x| x + 1); @@ -125,11 +119,9 @@ fn coerce_unsized() { double_access(&mut a, &a); //[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] //[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] // But this is okay. a.m(a.i(10)); - //[ast]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] // Above error is an expected limitation of AST borrowck } @@ -152,13 +144,11 @@ fn coerce_index_op() { let mut i = I(10); i[i[3]] = 4; //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] i[3] = i[4]; i[i[3]] = i[4]; //[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[ast]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] } fn main() { @@ -166,7 +156,6 @@ fn main() { // As a reminder, this is the basic case we want to ensure we handle. let mut v = vec![1, 2, 3]; v.push(v.len()); - //[ast]~^ ERROR cannot borrow `v` as immutable because it is also borrowed as mutable [E0502] // Error above is an expected limitation of AST borrowck // (as a rule, pnkfelix does not like to write tests with dead code.) @@ -177,12 +166,10 @@ fn main() { let mut s = S; s.m(s.i(10)); - //[ast]~^ ERROR cannot borrow `s` as immutable because it is also borrowed as mutable [E0502] // Error above is an expected limitation of AST borrowck let mut t = T; t.m(t.i(10)); - //[ast]~^ ERROR cannot borrow `t` as immutable because it is also borrowed as mutable [E0502] // Error above is an expected limitation of AST borrowck coerce_unsized(); diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.ast.stderr b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.ast.stderr deleted file mode 100644 index 28c997efc8a..00000000000 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.ast.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:19:5 - | -LL | let shared = &v; - | - immutable borrow occurs here -LL | -LL | v.extend(shared); - | ^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:30:15 - | -LL | v.extend(&v); - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:42:5 - | -LL | let shared = &v; - | - immutable borrow occurs here -LL | -LL | v.push(shared.len()); - | ^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2015.stderr b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2015.stderr index bb11b2e4f0f..8eb468892f2 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2015.stderr +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2015.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:19:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:18:5 | LL | let shared = &v; | -- immutable borrow occurs here @@ -11,7 +11,7 @@ LL | v.extend(shared); | mutable borrow occurs here error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:30:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:28:5 | LL | v.extend(&v); | ^^------^--^ @@ -21,7 +21,7 @@ LL | v.extend(&v); | mutable borrow occurs here warning: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:42:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:39:5 | LL | let shared = &v; | -- immutable borrow occurs here diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2018.stderr b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2018.stderr index bb11b2e4f0f..8eb468892f2 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2018.stderr +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.migrate2018.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:19:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:18:5 | LL | let shared = &v; | -- immutable borrow occurs here @@ -11,7 +11,7 @@ LL | v.extend(shared); | mutable borrow occurs here error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:30:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:28:5 | LL | v.extend(&v); | ^^------^--^ @@ -21,7 +21,7 @@ LL | v.extend(&v); | mutable borrow occurs here warning: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:42:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:39:5 | LL | let shared = &v; | -- immutable borrow occurs here diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2015.stderr b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2015.stderr index fb3a1fda631..730741c7a9a 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2015.stderr +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2015.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:19:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:18:5 | LL | let shared = &v; | -- immutable borrow occurs here @@ -10,7 +10,7 @@ LL | v.extend(shared); | mutable borrow occurs here error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:30:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:28:5 | LL | v.extend(&v); | ^^------^--^ @@ -20,7 +20,7 @@ LL | v.extend(&v); | mutable borrow occurs here error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:42:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:39:5 | LL | let shared = &v; | -- immutable borrow occurs here diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2018.stderr b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2018.stderr index fb3a1fda631..730741c7a9a 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2018.stderr +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.nll2018.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:19:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:18:5 | LL | let shared = &v; | -- immutable borrow occurs here @@ -10,7 +10,7 @@ LL | v.extend(shared); | mutable borrow occurs here error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:30:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:28:5 | LL | v.extend(&v); | ^^------^--^ @@ -20,7 +20,7 @@ LL | v.extend(&v); | mutable borrow occurs here error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-reservation-sharing-interference-2.rs:42:5 + --> $DIR/two-phase-reservation-sharing-interference-2.rs:39:5 | LL | let shared = &v; | -- immutable borrow occurs here diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs index 54fad9f66b8..de1af3aaa05 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference-2.rs @@ -1,12 +1,11 @@ // Test for #56254, we previously allowed the last example on the 2018 -// editiion. Make sure that we now emit a warning in that case and an error for +// edition. Make sure that we now emit a warning in that case and an error for // everyone else. //ignore-compare-mode-nll -//revisions: ast migrate2015 migrate2018 nll2015 nll2018 +//revisions: migrate2015 migrate2018 nll2015 nll2018 -//[migrate2015] compile-flags: -Zborrowck=migrate -Ztwo-phase-borrows //[migrate2018] edition:2018 //[nll2018] edition:2018 @@ -21,7 +20,6 @@ fn double_conflicts() { //[nll2015]~^^ ERROR cannot borrow `v` as mutable //[migrate2018]~^^^ ERROR cannot borrow `v` as mutable //[nll2018]~^^^^ ERROR cannot borrow `v` as mutable - //[ast]~^^^^^ ERROR cannot borrow `v` as mutable } fn activation_conflict() { @@ -32,7 +30,6 @@ fn activation_conflict() { //[nll2015]~^^ ERROR cannot borrow `v` as mutable //[migrate2018]~^^^ ERROR cannot borrow `v` as mutable //[nll2018]~^^^^ ERROR cannot borrow `v` as mutable - //[ast]~^^^^^ ERROR cannot borrow `v` as immutable } fn reservation_conflict() { @@ -47,8 +44,6 @@ fn reservation_conflict() { //[migrate2018]~^^^^^^ WARNING cannot borrow `v` as mutable //[migrate2018]~| WARNING may become a hard error in the future - - //[ast]~^^^^^^^^^ ERROR cannot borrow `v` as mutable } fn main() {} diff --git a/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs b/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs index f5fa8218edc..d8e60c5859e 100644 --- a/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs +++ b/src/test/ui/borrowck/two-phase-reservation-sharing-interference.rs @@ -3,10 +3,10 @@ // revisions: nll_target // The following revisions are disabled due to missing support from two-phase beyond autorefs -//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref //[nll_beyond] should-fail -//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll_target]compile-flags: -Z borrowck=mir // This is a corner case that the current implementation is (probably) // treating more conservatively than is necessary. But it also does diff --git a/src/test/ui/borrowck/two-phase-sneaky.nll.stderr b/src/test/ui/borrowck/two-phase-sneaky.nll.stderr deleted file mode 100644 index c66f3cbed91..00000000000 --- a/src/test/ui/borrowck/two-phase-sneaky.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/two-phase-sneaky.rs:12:9 - | -LL | v[0].push_str({ - | - -------- first borrow later used by call - | | - | first mutable borrow occurs here -LL | -LL | v.push(format!("foo")); - | ^ second mutable borrow occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/two-phase-sneaky.rs b/src/test/ui/borrowck/two-phase-sneaky.rs index abfa13da6af..b6e33d5d1b8 100644 --- a/src/test/ui/borrowck/two-phase-sneaky.rs +++ b/src/test/ui/borrowck/two-phase-sneaky.rs @@ -1,4 +1,4 @@ -// cmpile-flags: -Z borrowck=mir -Z two-phase-borrows +// cmpile-flags: -Z borrowck=mir // This is the first counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ diff --git a/src/test/ui/borrowck/two-phase-sneaky.stderr b/src/test/ui/borrowck/two-phase-sneaky.stderr index 38f24ccd606..c66f3cbed91 100644 --- a/src/test/ui/borrowck/two-phase-sneaky.stderr +++ b/src/test/ui/borrowck/two-phase-sneaky.stderr @@ -2,13 +2,12 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/two-phase-sneaky.rs:12:9 | LL | v[0].push_str({ - | - first mutable borrow occurs here + | - -------- first borrow later used by call + | | + | first mutable borrow occurs here LL | LL | v.push(format!("foo")); | ^ second mutable borrow occurs here -... -LL | }); - | - first borrow ends here error: aborting due to previous error diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.ast.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.ast.stderr deleted file mode 100644 index 81503380b79..00000000000 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.ast.stderr +++ /dev/null @@ -1,133 +0,0 @@ -error[E0503]: cannot use `self.cx` because it was mutably borrowed - --> $DIR/two-phase-surprise-no-conflict.rs:30:13 - | -LL | let _mut_borrow = &mut *self; - | ----- borrow of `*self` occurs here -LL | let _access = self.cx; - | ^^^^^^^ use of borrowed `*self` - -error[E0502]: cannot borrow `*self.cx_mut` as immutable because `*self` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:69:33 - | -LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ---- ^^^^^^^^^^^ - mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:121:52 - | -LL | reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:125:51 - | -LL | reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:129:50 - | -LL | reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:133:41 - | -LL | reg.register_ref(&TrivialPass::new(®.sess_mut)); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:141:56 - | -LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:146:59 - | -LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:151:58 - | -LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:156:49 - | -LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:168:51 - | -LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:173:50 - | -LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because `*reg` is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:178:41 - | -LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | --- ^^^^^^^^^^^^ - mutable borrow ends here - | | | - | mutable borrow occurs here immutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:59 - | -LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:58 - | -LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:49 - | -LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | --- ^^^^^^^^^^^^ - first borrow ends here - | | | - | first mutable borrow occurs here second mutable borrow occurs here - -error: aborting due to 16 previous errors - -Some errors have detailed explanations: E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr deleted file mode 100644 index 37df02ac493..00000000000 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr +++ /dev/null @@ -1,159 +0,0 @@ -error[E0503]: cannot use `self.cx` because it was mutably borrowed - --> $DIR/two-phase-surprise-no-conflict.rs:30:23 - | -LL | let _mut_borrow = &mut *self; - | ---------- borrow of `*self` occurs here -LL | let _access = self.cx; - | ^^^^^^^ use of borrowed `*self` -... -LL | _mut_borrow; - | ----------- borrow later used here - -error[E0502]: cannot borrow `*self.cx` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:54:33 - | -LL | self.hash_expr(&self.cx.body(eid).value); - | ---- --------- ^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `*self.cx_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:69:33 - | -LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ---- --------- ^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:121:51 - | -LL | reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - | --- --------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:125:50 - | -LL | reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:129:49 - | -LL | reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:133:40 - | -LL | reg.register_ref(&TrivialPass::new(®.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:141:51 - | -LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:146:54 - | -LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:151:53 - | -LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:156:44 - | -LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:168:50 - | -LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:173:49 - | -LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable - --> $DIR/two-phase-surprise-no-conflict.rs:178:40 - | -LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:54 - | -LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:53 - | -LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:44 - | -LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first mutable borrow occurs here - -error: aborting due to 17 previous errors - -Some errors have detailed explanations: E0499, E0502, E0503. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs b/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs index f097defa224..3fd24bbf290 100644 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs +++ b/src/test/ui/borrowck/two-phase-surprise-no-conflict.rs @@ -5,15 +5,6 @@ // that we decided it warranted its own unit test, and pnkfelix // decided to use that test as an opportunity to illustrate the cases. -// revisions: ast no2pb nll -//[ast]compile-flags: -Z borrowck=ast -//[no2pb]compile-flags: -Z borrowck=mir -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// (Since we are manually toggling NLL variations on and off, don't -// bother with compare-mode=nll) -// ignore-compare-mode-nll - #[derive(Copy, Clone)] struct BodyId; enum Expr { Closure(BodyId), Others } @@ -28,9 +19,7 @@ impl <'a> SpanlessHash<'a> { fn demo(&mut self) { let _mut_borrow = &mut *self; let _access = self.cx; - //[ast]~^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] - //[no2pb]~^^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] - //[nll]~^^^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] + //~^ ERROR cannot use `self.cx` because it was mutably borrowed [E0503] _mut_borrow; } @@ -52,7 +41,6 @@ impl <'a> SpanlessHash<'a> { // nothing in the activation for `self.hash_expr(..)` // can interfere with that immutable borrow. self.hash_expr(&self.cx.body(eid).value); - //[no2pb]~^ ERROR cannot borrow `*self.cx` }, _ => {} } @@ -67,9 +55,7 @@ impl <'a> SpanlessHash<'a> { // eventual activation of the `self` mutable borrow // for `self.hash_expr(..)` self.hash_expr(&self.cx_mut.body(eid).value); - //[ast]~^ ERROR cannot borrow `*self.cx_mut` - //[no2pb]~^^ ERROR cannot borrow `*self.cx_mut` - //[nll]~^^^ ERROR cannot borrow `*self` + //~^ ERROR cannot borrow `*self` }, _ => {} } @@ -119,44 +105,28 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { // cannot (according to its type) keep them alive. let reg = mk_reg(); reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_ref(&TrivialPass::new(®.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` // These are not okay: the inner mutable borrows immediately // conflict with the outer borrow/reservation, even with support // for two-phase borrows. let reg = mk_reg(); reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` let reg = mk_reg(); reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` + //~^ ERROR cannot borrow `reg.sess_mut` // These are not okay: the inner borrows may reach the actual // method invocation, because `CapturePass::new` might (according @@ -166,19 +136,13 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { // that will fail to get past lifetime inference.) let reg = mk_reg(); reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `*reg` as mutable + //~^ ERROR cannot borrow `*reg` as mutable let reg = mk_reg(); reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `*reg` as mutable + //~^ ERROR cannot borrow `*reg` as mutable let reg = mk_reg(); reg.register_ref(&CapturePass::new(®.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `*reg` as mutable + //~^ ERROR cannot borrow `*reg` as mutable // These are not okay: the inner mutable borrows immediately // conflict with the outer borrow/reservation, even with support @@ -188,22 +152,16 @@ fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { // that will fail to get past lifetime inference.) let reg = mk_reg(); reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time - //[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time + //~^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time + //~^^ ERROR cannot borrow `*reg` as mutable more than once at a time let reg = mk_reg(); reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time - //[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time + //~^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time + //~^^ ERROR cannot borrow `*reg` as mutable more than once at a time let reg = mk_reg(); reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - //[ast]~^ ERROR cannot borrow `reg.sess_mut` - //[no2pb]~^^ ERROR cannot borrow `reg.sess_mut` - //[nll]~^^^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time - //[nll]~^^^^ ERROR cannot borrow `*reg` as mutable more than once at a time + //~^ ERROR cannot borrow `reg.sess_mut` as mutable more than once at a time + //~^^ ERROR cannot borrow `*reg` as mutable more than once at a time } fn main() { } diff --git a/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr b/src/test/ui/borrowck/two-phase-surprise-no-conflict.stderr index 09a20720301..7d0e1566750 100644 --- a/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr +++ b/src/test/ui/borrowck/two-phase-surprise-no-conflict.stderr @@ -1,16 +1,16 @@ error[E0503]: cannot use `self.cx` because it was mutably borrowed - --> $DIR/two-phase-surprise-no-conflict.rs:30:23 + --> $DIR/two-phase-surprise-no-conflict.rs:21:23 | LL | let _mut_borrow = &mut *self; | ---------- borrow of `*self` occurs here LL | let _access = self.cx; | ^^^^^^^ use of borrowed `*self` -... +LL | LL | _mut_borrow; | ----------- borrow later used here error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:69:17 + --> $DIR/two-phase-surprise-no-conflict.rs:57:17 | LL | self.hash_expr(&self.cx_mut.body(eid).value); | ^^^^^---------^^-----------^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | self.hash_expr(&self.cx_mut.body(eid).value); | mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:141:51 + --> $DIR/two-phase-surprise-no-conflict.rs:119:51 | LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -29,7 +29,7 @@ LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:146:54 + --> $DIR/two-phase-surprise-no-conflict.rs:122:54 | LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -38,7 +38,7 @@ LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:151:53 + --> $DIR/two-phase-surprise-no-conflict.rs:125:53 | LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -47,7 +47,7 @@ LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:156:44 + --> $DIR/two-phase-surprise-no-conflict.rs:128:44 | LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -56,7 +56,7 @@ LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); | first mutable borrow occurs here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:168:5 + --> $DIR/two-phase-surprise-no-conflict.rs:138:5 | LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^ @@ -66,7 +66,7 @@ LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); | mutable borrow occurs here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:173:5 + --> $DIR/two-phase-surprise-no-conflict.rs:141:5 | LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { | -- lifetime `'a` defined here @@ -79,7 +79,7 @@ LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); | mutable borrow occurs here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable - --> $DIR/two-phase-surprise-no-conflict.rs:178:5 + --> $DIR/two-phase-surprise-no-conflict.rs:144:5 | LL | reg.register_ref(&CapturePass::new(®.sess_mut)); | ^^^^------------^^^^^^^^^^^^^^^^^^^-------------^^ @@ -89,7 +89,7 @@ LL | reg.register_ref(&CapturePass::new(®.sess_mut)); | mutable borrow occurs here error[E0499]: cannot borrow `*reg` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:5 + --> $DIR/two-phase-surprise-no-conflict.rs:154:5 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^ @@ -99,7 +99,7 @@ LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | second mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:190:54 + --> $DIR/two-phase-surprise-no-conflict.rs:154:54 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -108,7 +108,7 @@ LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `*reg` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:5 + --> $DIR/two-phase-surprise-no-conflict.rs:158:5 | LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { | -- lifetime `'a` defined here @@ -121,7 +121,7 @@ LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | second mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:196:53 + --> $DIR/two-phase-surprise-no-conflict.rs:158:53 | LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here @@ -130,7 +130,7 @@ LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); | first mutable borrow occurs here error[E0499]: cannot borrow `*reg` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:5 + --> $DIR/two-phase-surprise-no-conflict.rs:162:5 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); | ^^^^------------^^^^^^^^^^^^^^^^^^^^^^^-----------------^^ @@ -140,7 +140,7 @@ LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); | second mutable borrow occurs here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time - --> $DIR/two-phase-surprise-no-conflict.rs:202:44 + --> $DIR/two-phase-surprise-no-conflict.rs:162:44 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr deleted file mode 100644 index d6125cfd721..00000000000 --- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:11:9 - | -LL | let y = vec![format!("World")]; - | - captured outer variable -LL | call(|| { -LL | y.into_iter(); - | ^ cannot move out of captured variable in an `Fn` closure - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs index 4c6a05338a1..f45aa90b607 100644 --- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs +++ b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.rs @@ -9,6 +9,6 @@ fn main() { let y = vec![format!("World")]; call(|| { y.into_iter(); - //~^ ERROR cannot move out of captured outer variable in an `Fn` closure + //~^ ERROR cannot move out of captured variable in an `Fn` closure }); } diff --git a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr index bdfd6fb7e55..d6125cfd721 100644 --- a/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr +++ b/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of captured outer variable in an `Fn` closure +error[E0507]: cannot move out of captured variable in an `Fn` closure --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:11:9 | LL | let y = vec![format!("World")]; | - captured outer variable LL | call(|| { LL | y.into_iter(); - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure error: aborting due to previous error |
