diff --git a/src/test/incremental/feature_gate.rs b/src/test/incremental/feature_gate.rs index d36044ec92b..5317a9962f4 100644 --- a/src/test/incremental/feature_gate.rs +++ b/src/test/incremental/feature_gate.rs @@ -4,10 +4,10 @@ // compile-flags: -Z query-dep-graph #![feature(rustc_attrs)] -#![cfg_attr(rpass1, feature(nll))] +#![cfg_attr(rpass1, feature(abi_unadjusted))] fn main() { - let mut v = vec![1]; - v.push(v[0]); - //[cfail2]~^ ERROR cannot borrow } + +extern "unadjusted" fn foo() {} +//[cfail2]~^ ERROR: unadjusted ABI is an implementation detail and perma-unstable diff --git a/src/test/mir-opt/match_test.rs b/src/test/mir-opt/match_test.rs index 3f248f3d41a..a5317f98ef1 100644 --- a/src/test/mir-opt/match_test.rs +++ b/src/test/mir-opt/match_test.rs @@ -60,9 +60,11 @@ fn main() { // goto -> bb16; // } // bb12: { -// StorageLive(_8); -// _8 = _2; -// switchInt(move _8) -> [false: bb6, otherwise: bb11]; +// _8 = &shallow _1; +// StorageLive(_9); +// _9 = _2; +// FakeRead(ForMatchGuard, _8); +// switchInt(move _9) -> [false: bb6, otherwise: bb11]; // } // bb13: { // _3 = const 1i32; @@ -77,7 +79,7 @@ fn main() { // goto -> bb16; // } // bb16: { -// StorageDead(_8); +// StorageDead(_9); // _0 = (); // StorageDead(_2); // StorageDead(_1); diff --git a/src/test/run-fail/borrowck-local-borrow.rs b/src/test/run-fail/borrowck-local-borrow.rs index cb17a630562..d07f76b6252 100644 --- a/src/test/run-fail/borrowck-local-borrow.rs +++ b/src/test/run-fail/borrowck-local-borrow.rs @@ -1,6 +1,6 @@ // error-pattern:panic 1 -// revisions: ast mir +// revisions: migrate mir //[mir]compile-flags: -Z borrowck=mir fn main() { diff --git a/src/test/run-pass/asm-in-moved.rs b/src/test/run-pass/asm-in-moved.rs index dc73f83a940..8726db35555 100644 --- a/src/test/run-pass/asm-in-moved.rs +++ b/src/test/run-pass/asm-in-moved.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] #![allow(dead_code)] diff --git a/src/test/run-pass/asm-out-assign.rs b/src/test/run-pass/asm-out-assign.rs index d0978cc8342..5c46cb92c6b 100644 --- a/src/test/run-pass/asm-out-assign.rs +++ b/src/test/run-pass/asm-out-assign.rs @@ -1,6 +1,3 @@ -// revisions ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] diff --git a/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs b/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs index 25ef48d0d5c..72bf43da95e 100644 --- a/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs +++ b/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs @@ -2,9 +2,6 @@ #![allow(dead_code)] // Test taken from #45641 (https://github.com/rust-lang/rust/issues/45641) -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static mut Y: u32 = 0; unsafe fn should_ok() { diff --git a/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs b/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs index 0487c179e36..adc7dfd541f 100644 --- a/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs +++ b/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs @@ -1,6 +1,4 @@ // run-pass -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir // Test file taken from issue 45129 (https://github.com/rust-lang/rust/issues/45129) diff --git a/src/test/run-pass/borrowck/two-phase-baseline.rs b/src/test/run-pass/borrowck/two-phase-baseline.rs index aa8d1831294..994dc823dfc 100644 --- a/src/test/run-pass/borrowck/two-phase-baseline.rs +++ b/src/test/run-pass/borrowck/two-phase-baseline.rs @@ -1,5 +1,4 @@ // run-pass -// compile-flags: -Z borrowck=mir -Z two-phase-borrows // This is the "goto example" for why we want two phase borrows. diff --git a/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs b/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs index 9759223a1ba..0b20e1945e6 100644 --- a/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs +++ b/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs @@ -1,8 +1,4 @@ // run-pass -// revisions: lxl nll -//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows - -#![cfg_attr(nll, feature(nll))] fn main() { let mut a = 0; diff --git a/src/test/run-pass/drop/dynamic-drop.rs b/src/test/run-pass/drop/dynamic-drop.rs index 97e4cded80b..399b577dccb 100644 --- a/src/test/run-pass/drop/dynamic-drop.rs +++ b/src/test/run-pass/drop/dynamic-drop.rs @@ -1,8 +1,6 @@ // run-pass #![allow(unused_assignments)] #![allow(unused_variables)] -// revisions:lexical nll -#![cfg_attr(nll, feature(nll))] // ignore-wasm32-bare compiled with panic=abort by default diff --git a/src/test/run-pass/generator/yield-subtype.rs b/src/test/run-pass/generator/yield-subtype.rs index c38524857b4..fe88d424dd1 100644 --- a/src/test/run-pass/generator/yield-subtype.rs +++ b/src/test/run-pass/generator/yield-subtype.rs @@ -2,9 +2,6 @@ #![allow(dead_code)] #![allow(dead_code)] -// revisions:lexical nll -#![cfg_attr(nll, feature(nll))] - #![feature(generators)] fn bar<'a>() { diff --git a/src/test/run-pass/impl-trait/example-calendar.rs b/src/test/run-pass/impl-trait/example-calendar.rs index cd3d48f1a03..968e9b7d34a 100644 --- a/src/test/run-pass/impl-trait/example-calendar.rs +++ b/src/test/run-pass/impl-trait/example-calendar.rs @@ -1,8 +1,5 @@ // run-pass -// revisions: normal nll -//[nll] compile-flags:-Zborrowck=mir - #![feature(fn_traits, step_trait, unboxed_closures, diff --git a/src/test/run-pass/issues/issue-26996.rs b/src/test/run-pass/issues/issue-26996.rs index 8c5d2441780..04382be27d7 100644 --- a/src/test/run-pass/issues/issue-26996.rs +++ b/src/test/run-pass/issues/issue-26996.rs @@ -2,9 +2,9 @@ // This test is bogus (i.e., should be compile-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For -// now: just ignore it under nll +// now: just ignore it // -// ignore-compare-mode-nll +// ignore-test // This test is checking that the write to `c.0` (which has been moved out of) // won't overwrite the state in `c2`. diff --git a/src/test/run-pass/issues/issue-27021.rs b/src/test/run-pass/issues/issue-27021.rs index ecb065b1964..30551375450 100644 --- a/src/test/run-pass/issues/issue-27021.rs +++ b/src/test/run-pass/issues/issue-27021.rs @@ -2,9 +2,9 @@ // This test is bogus (i.e., should be compile-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For -// now: just ignore it under nll +// now: just ignore it // -// ignore-compare-mode-nll +// ignore-test // These are variants of issue-26996.rs. In all cases we are writing // into a record field that has been moved out of, and ensuring that diff --git a/src/test/run-pass/issues/issue-49298.rs b/src/test/run-pass/issues/issue-49298.rs index 56443f41020..697a160b4ec 100644 --- a/src/test/run-pass/issues/issue-49298.rs +++ b/src/test/run-pass/issues/issue-49298.rs @@ -4,9 +4,9 @@ // This test is bogus (i.e., should be compile-fail) during the period // where #54986 is implemented and #54987 is *not* implemented. For -// now: just ignore it under nll +// now: just ignore it // -// ignore-compare-mode-nll +// ignore-test // This test is checking that the space allocated for `x.1` does not // overlap with `y`. (The reason why such a thing happened at one diff --git a/src/test/ui-fulldeps/dropck-tarena-cycle-checked.stderr b/src/test/ui-fulldeps/dropck-tarena-cycle-checked.stderr index b6d5ee0cafe..7009c0bba69 100644 --- a/src/test/ui-fulldeps/dropck-tarena-cycle-checked.stderr +++ b/src/test/ui-fulldeps/dropck-tarena-cycle-checked.stderr @@ -1,12 +1,13 @@ error[E0597]: `arena` does not live long enough - --> $DIR/dropck-tarena-cycle-checked.rs:116:8 + --> $DIR/dropck-tarena-cycle-checked.rs:116:7 | LL | f(&arena); - | ^^^^^ borrowed value does not live long enough + | ^^^^^^ borrowed value does not live long enough LL | } - | - `arena` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `arena` dropped here while still borrowed + | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `arena::TypedArena` error: aborting due to previous error diff --git a/src/test/ui-fulldeps/dropck-tarena-unsound-drop.stderr b/src/test/ui-fulldeps/dropck-tarena-unsound-drop.stderr index 1e612f04983..319848b9896 100644 --- a/src/test/ui-fulldeps/dropck-tarena-unsound-drop.stderr +++ b/src/test/ui-fulldeps/dropck-tarena-unsound-drop.stderr @@ -1,12 +1,13 @@ error[E0597]: `arena` does not live long enough - --> $DIR/dropck-tarena-unsound-drop.rs:41:8 + --> $DIR/dropck-tarena-unsound-drop.rs:41:7 | LL | f(&arena); - | ^^^^^ borrowed value does not live long enough + | ^^^^^^ borrowed value does not live long enough LL | } - | - `arena` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `arena` dropped here while still borrowed + | borrow might be used here, when `arena` is dropped and runs the `Drop` code for type `arena::TypedArena` error: aborting due to previous error diff --git a/src/test/ui/E0501.ast.stderr b/src/test/ui/E0501.ast.stderr deleted file mode 100644 index e2f54c6553f..00000000000 --- a/src/test/ui/E0501.ast.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access - --> $DIR/E0501.rs:18:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - previous borrow occurs due to use of `a` in closure -LL | }; -LL | outside_closure_1(a); - | ^ borrow occurs here -... -LL | } - | - borrow from closure ends here - -error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access - --> $DIR/E0501.rs:21:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - previous borrow occurs due to use of `a` in closure -... -LL | outside_closure_2(a); - | ^ borrow occurs here -... -LL | } - | - borrow from closure ends here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/E0501.mir.stderr b/src/test/ui/E0501.mir.stderr deleted file mode 100644 index 74f14bebcc9..00000000000 --- a/src/test/ui/E0501.mir.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access - --> $DIR/E0501.rs:18:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - first borrow occurs due to use of `a` in closure -LL | }; -LL | outside_closure_1(a); - | ^ second borrow occurs here -... -LL | drop(bar); - | --- first borrow later used here - -error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access - --> $DIR/E0501.rs:21:23 - | -LL | let bar = || { - | -- closure construction occurs here -LL | inside_closure(a) - | - first borrow occurs due to use of `a` in closure -... -LL | outside_closure_2(a); - | ^ second borrow occurs here -... -LL | drop(bar); - | --- first borrow later used here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/E0501.rs b/src/test/ui/E0501.rs index a710e23a670..3e39d9a63c5 100644 --- a/src/test/ui/E0501.rs +++ b/src/test/ui/E0501.rs @@ -1,7 +1,3 @@ -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn inside_closure(x: &mut i32) { } @@ -15,11 +11,11 @@ fn foo(a: &mut i32) { let bar = || { inside_closure(a) }; - outside_closure_1(a); //[ast]~ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - //[mir]~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access + outside_closure_1(a); + //~^ ERROR cannot borrow `*a` as mutable because previous closure requires unique access - outside_closure_2(a); //[ast]~ ERROR cannot borrow `*a` as immutable because previous closure requires unique access - //[mir]~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access + outside_closure_2(a); + //~^ ERROR cannot borrow `*a` as immutable because previous closure requires unique access drop(bar); } diff --git a/src/test/ui/E0501.ast.nll.stderr b/src/test/ui/E0501.stderr similarity index 95% rename from src/test/ui/E0501.ast.nll.stderr rename to src/test/ui/E0501.stderr index 74f14bebcc9..53d98d7e13f 100644 --- a/src/test/ui/E0501.ast.nll.stderr +++ b/src/test/ui/E0501.stderr @@ -1,5 +1,5 @@ error[E0501]: cannot borrow `*a` as mutable because previous closure requires unique access - --> $DIR/E0501.rs:18:23 + --> $DIR/E0501.rs:14:23 | LL | let bar = || { | -- closure construction occurs here @@ -13,7 +13,7 @@ LL | drop(bar); | --- first borrow later used here error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access - --> $DIR/E0501.rs:21:23 + --> $DIR/E0501.rs:17:23 | LL | let bar = || { | -- closure construction occurs here diff --git a/src/test/ui/E0506.ast.nll.stderr b/src/test/ui/E0506.ast.nll.stderr deleted file mode 100644 index 6e2d63441e2..00000000000 --- a/src/test/ui/E0506.ast.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `fancy_num` because it is borrowed - --> $DIR/E0506.rs:11:5 - | -LL | let fancy_ref = &fancy_num; - | ---------- borrow of `fancy_num` occurs here -LL | fancy_num = FancyNum { num: 6 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here -... -LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); - | ------------- 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/E0506.ast.stderr b/src/test/ui/E0506.ast.stderr deleted file mode 100644 index 3e3001f232c..00000000000 --- a/src/test/ui/E0506.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `fancy_num` because it is borrowed - --> $DIR/E0506.rs:11:5 - | -LL | let fancy_ref = &fancy_num; - | --------- borrow of `fancy_num` occurs here -LL | fancy_num = FancyNum { num: 6 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/E0506.rs b/src/test/ui/E0506.rs index 04aaa008b5a..062a44a52bb 100644 --- a/src/test/ui/E0506.rs +++ b/src/test/ui/E0506.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct FancyNum { num: u8, } @@ -8,8 +5,7 @@ struct FancyNum { fn main() { let mut fancy_num = FancyNum { num: 5 }; let fancy_ref = &fancy_num; - fancy_num = FancyNum { num: 6 }; //[ast]~ ERROR E0506 - //[mir]~^ ERROR [E0506] + fancy_num = FancyNum { num: 6 }; //~ ERROR [E0506] println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); } diff --git a/src/test/ui/E0506.mir.stderr b/src/test/ui/E0506.stderr similarity index 95% rename from src/test/ui/E0506.mir.stderr rename to src/test/ui/E0506.stderr index 6e2d63441e2..17f883f84b8 100644 --- a/src/test/ui/E0506.mir.stderr +++ b/src/test/ui/E0506.stderr @@ -1,11 +1,11 @@ error[E0506]: cannot assign to `fancy_num` because it is borrowed - --> $DIR/E0506.rs:11:5 + --> $DIR/E0506.rs:8:5 | LL | let fancy_ref = &fancy_num; | ---------- borrow of `fancy_num` occurs here LL | fancy_num = FancyNum { num: 6 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `fancy_num` occurs here -... +LL | LL | println!("Num: {}, Ref: {}", fancy_num.num, fancy_ref.num); | ------------- borrow later used here diff --git a/src/test/ui/E0508-fail.ast.nll.stderr b/src/test/ui/E0508-fail.ast.nll.stderr deleted file mode 100644 index 972b84e37be..00000000000 --- a/src/test/ui/E0508-fail.ast.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508-fail.rs:8:18 - | -LL | let _value = array[0]; - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508-fail.ast.stderr b/src/test/ui/E0508-fail.ast.stderr deleted file mode 100644 index 8b249839f01..00000000000 --- a/src/test/ui/E0508-fail.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508-fail.rs:8:18 - | -LL | let _value = array[0]; - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider using a reference instead: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508-fail.mir.stderr b/src/test/ui/E0508-fail.mir.stderr deleted file mode 100644 index 972b84e37be..00000000000 --- a/src/test/ui/E0508-fail.mir.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508-fail.rs:8:18 - | -LL | let _value = array[0]; - | ^^^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&array[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/E0508-fail.rs b/src/test/ui/E0508-fail.rs index 20eac6cd351..072c3d66183 100644 --- a/src/test/ui/E0508-fail.rs +++ b/src/test/ui/E0508-fail.rs @@ -1,10 +1,6 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct NonCopy; fn main() { let array = [NonCopy; 1]; - let _value = array[0]; //[ast]~ ERROR [E0508] - //[mir]~^ ERROR [E0508] + let _value = array[0]; //~ ERROR [E0508] } diff --git a/src/test/ui/E0508.nll.stderr b/src/test/ui/E0508-fail.stderr similarity index 92% rename from src/test/ui/E0508.nll.stderr rename to src/test/ui/E0508-fail.stderr index 983062e450e..63590bec32e 100644 --- a/src/test/ui/E0508.nll.stderr +++ b/src/test/ui/E0508-fail.stderr @@ -1,5 +1,5 @@ error[E0508]: cannot move out of type `[NonCopy; 1]`, a non-copy array - --> $DIR/E0508.rs:5:18 + --> $DIR/E0508-fail.rs:5:18 | LL | let _value = array[0]; | ^^^^^^^^ diff --git a/src/test/ui/E0508.stderr b/src/test/ui/E0508.stderr index ba6cff80416..983062e450e 100644 --- a/src/test/ui/E0508.stderr +++ b/src/test/ui/E0508.stderr @@ -5,7 +5,7 @@ LL | let _value = array[0]; | ^^^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&array[0]` + | help: consider borrowing here: `&array[0]` error: aborting due to previous error diff --git a/src/test/ui/E0594.ast.stderr b/src/test/ui/E0594.ast.stderr deleted file mode 100644 index 06171f1a9c1..00000000000 --- a/src/test/ui/E0594.ast.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0594]: cannot assign to immutable static item - --> $DIR/E0594.rs:7:5 - | -LL | NUM = 20; - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/E0594.mir.stderr b/src/test/ui/E0594.mir.stderr deleted file mode 100644 index 4bc7fcf5c0f..00000000000 --- a/src/test/ui/E0594.mir.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0594]: cannot assign to immutable static item `NUM` - --> $DIR/E0594.rs:7:5 - | -LL | NUM = 20; - | ^^^^^^^^ cannot assign - -error: aborting due to previous error - diff --git a/src/test/ui/E0594.rs b/src/test/ui/E0594.rs index a8ca2fe6161..8b0cae7e17b 100644 --- a/src/test/ui/E0594.rs +++ b/src/test/ui/E0594.rs @@ -1,9 +1,5 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - static NUM: i32 = 18; fn main() { - NUM = 20; //[ast]~ ERROR E0594 - //[mir]~^ ERROR cannot assign to immutable static item `NUM` + NUM = 20; //~ ERROR cannot assign to immutable static item `NUM` } diff --git a/src/test/ui/E0594.ast.nll.stderr b/src/test/ui/E0594.stderr similarity index 86% rename from src/test/ui/E0594.ast.nll.stderr rename to src/test/ui/E0594.stderr index 4bc7fcf5c0f..c00ec4250a7 100644 --- a/src/test/ui/E0594.ast.nll.stderr +++ b/src/test/ui/E0594.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to immutable static item `NUM` - --> $DIR/E0594.rs:7:5 + --> $DIR/E0594.rs:4:5 | LL | NUM = 20; | ^^^^^^^^ cannot assign diff --git a/src/test/ui/E0596.ast.nll.stderr b/src/test/ui/E0596.ast.nll.stderr deleted file mode 100644 index c89a915cfbd..00000000000 --- a/src/test/ui/E0596.ast.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/E0596.rs:6:13 - | -LL | let x = 1; - | - help: consider changing this to be mutable: `mut x` -LL | let y = &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/E0596.ast.stderr b/src/test/ui/E0596.ast.stderr deleted file mode 100644 index 4b66e49ba85..00000000000 --- a/src/test/ui/E0596.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/E0596.rs:6:18 - | -LL | let x = 1; - | - help: make this binding mutable: `mut x` -LL | let y = &mut x; - | ^ cannot borrow mutably - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/E0596.rs b/src/test/ui/E0596.rs index 3ea2d64a404..9e2f5ee7636 100644 --- a/src/test/ui/E0596.rs +++ b/src/test/ui/E0596.rs @@ -1,8 +1,4 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let x = 1; - let y = &mut x; //[ast]~ ERROR [E0596] - //[mir]~^ ERROR [E0596] + let y = &mut x; //~ ERROR [E0596] } diff --git a/src/test/ui/E0596.mir.stderr b/src/test/ui/E0596.stderr similarity index 93% rename from src/test/ui/E0596.mir.stderr rename to src/test/ui/E0596.stderr index c89a915cfbd..79bc258f1fa 100644 --- a/src/test/ui/E0596.mir.stderr +++ b/src/test/ui/E0596.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/E0596.rs:6:13 + --> $DIR/E0596.rs:3:13 | LL | let x = 1; | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/access-mode-in-closures.nll.stderr b/src/test/ui/access-mode-in-closures.nll.stderr deleted file mode 100644 index 713eeba5459..00000000000 --- a/src/test/ui/access-mode-in-closures.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/access-mode-in-closures.rs:8:15 - | -LL | match *s { S(v) => v } - | ^^ - data moved here - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `s` - | -note: move occurs because `v` has type `std::vec::Vec`, which does not implement the `Copy` trait - --> $DIR/access-mode-in-closures.rs:8:22 - | -LL | match *s { S(v) => v } - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/access-mode-in-closures.stderr b/src/test/ui/access-mode-in-closures.stderr index 9976dfe946f..713eeba5459 100644 --- a/src/test/ui/access-mode-in-closures.stderr +++ b/src/test/ui/access-mode-in-closures.stderr @@ -2,9 +2,16 @@ error[E0507]: cannot move out of borrowed content --> $DIR/access-mode-in-closures.rs:8:15 | LL | match *s { S(v) => v } - | ^^ - hint: to prevent move, use `ref v` or `ref mut v` + | ^^ - data moved here | | | cannot move out of borrowed content + | help: consider removing the `*`: `s` + | +note: move occurs because `v` has type `std::vec::Vec`, which does not implement the `Copy` trait + --> $DIR/access-mode-in-closures.rs:8:22 + | +LL | match *s { S(v) => v } + | ^ error: aborting due to previous error diff --git a/src/test/ui/asm/asm-out-assign-imm.nll.stderr b/src/test/ui/asm/asm-out-assign-imm.nll.stderr deleted file mode 100644 index ac38218b849..00000000000 --- a/src/test/ui/asm/asm-out-assign-imm.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/asm-out-assign-imm.rs:24:34 - | -LL | let x: isize; - | - help: make this binding mutable: `mut x` -LL | x = 1; - | ----- first assignment to `x` -... -LL | asm!("mov $1, $0" : "=r"(x) : "r"(5)); - | ^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/asm/asm-out-assign-imm.stderr b/src/test/ui/asm/asm-out-assign-imm.stderr index 98f2f68a8f3..ac38218b849 100644 --- a/src/test/ui/asm/asm-out-assign-imm.stderr +++ b/src/test/ui/asm/asm-out-assign-imm.stderr @@ -1,6 +1,8 @@ error[E0384]: cannot assign twice to immutable variable `x` --> $DIR/asm-out-assign-imm.rs:24:34 | +LL | let x: isize; + | - help: make this binding mutable: `mut x` LL | x = 1; | ----- first assignment to `x` ... diff --git a/src/test/ui/asm/asm-out-read-uninit.mir.stderr b/src/test/ui/asm/asm-out-read-uninit.mir.stderr deleted file mode 100644 index cf74298be4a..00000000000 --- a/src/test/ui/asm/asm-out-read-uninit.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/asm-out-read-uninit.rs:25:43 - | -LL | asm!("mov $1, $0" : "=r"(x) : "r"(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/asm/asm-out-read-uninit.rs b/src/test/ui/asm/asm-out-read-uninit.rs index 44dd0503c3b..003f1fc5bb6 100644 --- a/src/test/ui/asm/asm-out-read-uninit.rs +++ b/src/test/ui/asm/asm-out-read-uninit.rs @@ -8,9 +8,6 @@ // ignore-mips // ignore-mips64 -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(asm)] fn foo(x: isize) { println!("{}", x); } @@ -23,8 +20,7 @@ pub fn main() { let x: isize; unsafe { asm!("mov $1, $0" : "=r"(x) : "r"(x)); - //[ast]~^ ERROR use of possibly uninitialized variable: `x` - //[mir]~^^ ERROR use of possibly uninitialized variable: `x` + //~^ ERROR use of possibly uninitialized variable: `x` } foo(x); } diff --git a/src/test/ui/asm/asm-out-read-uninit.ast.stderr b/src/test/ui/asm/asm-out-read-uninit.stderr similarity index 88% rename from src/test/ui/asm/asm-out-read-uninit.ast.stderr rename to src/test/ui/asm/asm-out-read-uninit.stderr index cf74298be4a..6d0445d4b7a 100644 --- a/src/test/ui/asm/asm-out-read-uninit.ast.stderr +++ b/src/test/ui/asm/asm-out-read-uninit.stderr @@ -1,5 +1,5 @@ error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/asm-out-read-uninit.rs:25:43 + --> $DIR/asm-out-read-uninit.rs:22:43 | LL | asm!("mov $1, $0" : "=r"(x) : "r"(x)); | ^ use of possibly uninitialized `x` diff --git a/src/test/ui/assign-imm-local-twice.ast.nll.stderr b/src/test/ui/assign-imm-local-twice.ast.nll.stderr deleted file mode 100644 index 2995a139ae4..00000000000 --- a/src/test/ui/assign-imm-local-twice.ast.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/assign-imm-local-twice.rs:11:5 - | -LL | let v: isize; - | - help: make this binding mutable: `mut v` -... -LL | v = 1; - | ----- first assignment to `v` -... -LL | v = 2; - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/assign-imm-local-twice.ast.stderr b/src/test/ui/assign-imm-local-twice.ast.stderr deleted file mode 100644 index f16b8e2ebd7..00000000000 --- a/src/test/ui/assign-imm-local-twice.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/assign-imm-local-twice.rs:11:5 - | -LL | v = 1; - | ----- first assignment to `v` -... -LL | v = 2; - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/assign-imm-local-twice.rs b/src/test/ui/assign-imm-local-twice.rs index de966a17857..c1c9bf62819 100644 --- a/src/test/ui/assign-imm-local-twice.rs +++ b/src/test/ui/assign-imm-local-twice.rs @@ -1,17 +1,11 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { let v: isize; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut v - v = 1; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment + //~^ HELP make this binding mutable + //~| SUGGESTION mut v + v = 1; //~ NOTE first assignment println!("v={}", v); - v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + v = 2; //~ ERROR cannot assign twice to immutable variable + //~| NOTE cannot assign twice to immutable println!("v={}", v); } diff --git a/src/test/ui/assign-imm-local-twice.mir.stderr b/src/test/ui/assign-imm-local-twice.stderr similarity index 84% rename from src/test/ui/assign-imm-local-twice.mir.stderr rename to src/test/ui/assign-imm-local-twice.stderr index 2995a139ae4..df0f4c4d806 100644 --- a/src/test/ui/assign-imm-local-twice.mir.stderr +++ b/src/test/ui/assign-imm-local-twice.stderr @@ -1,12 +1,12 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/assign-imm-local-twice.rs:11:5 + --> $DIR/assign-imm-local-twice.rs:7:5 | LL | let v: isize; | - help: make this binding mutable: `mut v` ... LL | v = 1; | ----- first assignment to `v` -... +LL | println!("v={}", v); LL | v = 2; | ^^^^^ cannot assign twice to immutable variable diff --git a/src/test/ui/associated-types/associated-types-outlives.nll.stderr b/src/test/ui/associated-types/associated-types-outlives.nll.stderr deleted file mode 100644 index 840e33b4b8a..00000000000 --- a/src/test/ui/associated-types/associated-types-outlives.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/associated-types-outlives.rs:22:14 - | -LL | 's: loop { y = denormalise(&x); break } - | -- borrow of `x` occurs here -LL | drop(x); - | ^ move out of `x` occurs here -LL | return f(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/associated-types/associated-types-outlives.stderr b/src/test/ui/associated-types/associated-types-outlives.stderr index e35862d718f..840e33b4b8a 100644 --- a/src/test/ui/associated-types/associated-types-outlives.stderr +++ b/src/test/ui/associated-types/associated-types-outlives.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/associated-types-outlives.rs:22:14 | LL | 's: loop { y = denormalise(&x); break } - | - borrow of `x` occurs here + | -- borrow of `x` occurs here LL | drop(x); | ^ move out of `x` occurs here +LL | return f(y); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/augmented-assignments.nll.stderr b/src/test/ui/augmented-assignments.nll.stderr deleted file mode 100644 index 1b3c2fccf95..00000000000 --- a/src/test/ui/augmented-assignments.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/augmented-assignments.rs:16:5 - | -LL | x - | - borrow of `x` occurs here -... -LL | x; - | ^ move out of `x` occurs here - -error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/augmented-assignments.rs:21:5 - | -LL | let y = Int(2); - | - help: consider changing this to be mutable: `mut y` -... -LL | y - | ^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0505, E0596. -For more information about an error, try `rustc --explain E0505`. diff --git a/src/test/ui/augmented-assignments.rs b/src/test/ui/augmented-assignments.rs index eea15eae879..1b4ac6edcb0 100644 --- a/src/test/ui/augmented-assignments.rs +++ b/src/test/ui/augmented-assignments.rs @@ -10,16 +10,18 @@ impl AddAssign for Int { fn main() { let mut x = Int(1); - x //~ error: use of moved value: `x` - //~^ value used here after move + x + //~^ NOTE borrow of `x` occurs here += - x; //~ value moved here + x; + //~^ ERROR cannot move out of `x` because it is borrowed + //~| move out of `x` occurs here let y = Int(2); - //~^ HELP make this binding mutable + //~^ HELP consider changing this to be mutable //~| SUGGESTION mut y - y //~ error: cannot borrow immutable local variable `y` as mutable - //~| cannot borrow + y //~ ERROR cannot borrow `y` as mutable, as it is not declared as mutable + //~| cannot borrow as mutable += Int(1); } diff --git a/src/test/ui/augmented-assignments.stderr b/src/test/ui/augmented-assignments.stderr index c0eddb40cf2..ce555da8975 100644 --- a/src/test/ui/augmented-assignments.stderr +++ b/src/test/ui/augmented-assignments.stderr @@ -1,24 +1,22 @@ -error[E0596]: cannot borrow immutable local variable `y` as mutable - --> $DIR/augmented-assignments.rs:21:5 - | -LL | let y = Int(2); - | - help: make this binding mutable: `mut y` -... -LL | y - | ^ cannot borrow mutably - -error[E0382]: use of moved value: `x` - --> $DIR/augmented-assignments.rs:13:5 +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/augmented-assignments.rs:16:5 | LL | x - | ^ value used here after move + | - borrow of `x` occurs here ... LL | x; - | - value moved here + | ^ move out of `x` occurs here + +error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable + --> $DIR/augmented-assignments.rs:23:5 | - = note: move occurs because `x` has type `Int`, which does not implement the `Copy` trait +LL | let y = Int(2); + | - help: consider changing this to be mutable: `mut y` +... +LL | y + | ^ cannot borrow as mutable error: aborting due to 2 previous errors -Some errors have detailed explanations: E0382, E0596. -For more information about an error, try `rustc --explain E0382`. +Some errors have detailed explanations: E0505, E0596. +For more information about an error, try `rustc --explain E0505`. diff --git a/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr b/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr deleted file mode 100644 index 5f8b7007f30..00000000000 --- a/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/bind-by-move-no-guards.rs:8:14 - | -LL | Some(z) if z.recv().unwrap() => { panic!() }, - | ^ moves value into pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr b/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr index 2af2b0d660e..5f8b7007f30 100644 --- a/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr +++ b/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr @@ -3,6 +3,8 @@ error[E0008]: cannot bind by-move into a pattern guard | LL | Some(z) if z.recv().unwrap() => { panic!() }, | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/binop/binop-consume-args.nll.stderr b/src/test/ui/binop/binop-consume-args.nll.stderr deleted file mode 100644 index 5751af27fcb..00000000000 --- a/src/test/ui/binop/binop-consume-args.nll.stderr +++ /dev/null @@ -1,253 +0,0 @@ -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:7:10 - | -LL | fn add, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs + rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:8:10 - | -LL | fn add, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs + rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:13:10 - | -LL | fn sub, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs - rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:14:10 - | -LL | fn sub, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs - rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:19:10 - | -LL | fn mul, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs * rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:20:10 - | -LL | fn mul, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs * rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:25:10 - | -LL | fn div, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs / rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:26:10 - | -LL | fn div, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs / rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:31:10 - | -LL | fn rem, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs % rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:32:10 - | -LL | fn rem, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs % rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:37:10 - | -LL | fn bitand, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs & rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:38:10 - | -LL | fn bitand, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs & rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:43:10 - | -LL | fn bitor, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs | rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:44:10 - | -LL | fn bitor, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs | rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:49:10 - | -LL | fn bitxor, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs ^ rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:50:10 - | -LL | fn bitxor, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs ^ rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:55:10 - | -LL | fn shl, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs << rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:56:10 - | -LL | fn shl, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs << rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `lhs` - --> $DIR/binop-consume-args.rs:61:10 - | -LL | fn shr, B>(lhs: A, rhs: B) { - | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs >> rhs; - | --- value moved here -LL | drop(lhs); - | ^^^ value used here after move - -error[E0382]: use of moved value: `rhs` - --> $DIR/binop-consume-args.rs:62:10 - | -LL | fn shr, B>(lhs: A, rhs: B) { - | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | lhs >> rhs; - | --- value moved here -LL | drop(lhs); -LL | drop(rhs); - | ^^^ value used here after move - -error: aborting due to 20 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/binop/binop-consume-args.stderr b/src/test/ui/binop/binop-consume-args.stderr index 9246c116709..5751af27fcb 100644 --- a/src/test/ui/binop/binop-consume-args.stderr +++ b/src/test/ui/binop/binop-consume-args.stderr @@ -1,212 +1,252 @@ error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:7:10 | +LL | fn add, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs + rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:8:10 | +LL | fn add, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs + rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:13:10 | +LL | fn sub, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs - rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:14:10 | +LL | fn sub, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs - rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:19:10 | +LL | fn mul, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs * rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:20:10 | +LL | fn mul, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs * rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:25:10 | +LL | fn div, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs / rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:26:10 | +LL | fn div, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs / rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:31:10 | +LL | fn rem, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs % rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:32:10 | +LL | fn rem, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs % rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:37:10 | +LL | fn bitand, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs & rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:38:10 | +LL | fn bitand, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs & rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:43:10 | +LL | fn bitor, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs | rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:44:10 | +LL | fn bitor, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs | rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:49:10 | +LL | fn bitxor, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs ^ rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:50:10 | +LL | fn bitxor, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs ^ rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:55:10 | +LL | fn shl, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs << rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:56:10 | +LL | fn shl, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs << rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error[E0382]: use of moved value: `lhs` --> $DIR/binop-consume-args.rs:61:10 | +LL | fn shr, B>(lhs: A, rhs: B) { + | - --- move occurs because `lhs` has type `A`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs >> rhs; | --- value moved here LL | drop(lhs); | ^^^ value used here after move - | - = note: move occurs because `lhs` has type `A`, which does not implement the `Copy` trait error[E0382]: use of moved value: `rhs` --> $DIR/binop-consume-args.rs:62:10 | +LL | fn shr, B>(lhs: A, rhs: B) { + | - --- move occurs because `rhs` has type `B`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | lhs >> rhs; | --- value moved here LL | drop(lhs); LL | drop(rhs); | ^^^ value used here after move - | - = note: move occurs because `rhs` has type `B`, which does not implement the `Copy` trait error: aborting due to 20 previous errors diff --git a/src/test/ui/binop/binop-move-semantics.nll.stderr b/src/test/ui/binop/binop-move-semantics.nll.stderr deleted file mode 100644 index 146e3781463..00000000000 --- a/src/test/ui/binop/binop-move-semantics.nll.stderr +++ /dev/null @@ -1,95 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/binop-move-semantics.rs:8:5 - | -LL | fn double_move>(x: T) { - | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | x - | - value moved here -LL | + -LL | x; - | ^ value used here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/binop-move-semantics.rs:14:5 - | -LL | fn move_then_borrow + Clone>(x: T) { - | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | x - | - value moved here -LL | + -LL | x.clone(); - | ^ value borrowed here after move - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/binop-move-semantics.rs:21:5 - | -LL | let m = &x; - | -- borrow of `x` occurs here -... -LL | x - | ^ move out of `x` occurs here -... -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/binop-move-semantics.rs:23:5 - | -LL | let n = &mut y; - | ------ borrow of `y` occurs here -... -LL | y; - | ^ move out of `y` occurs here -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0507]: cannot move out of borrowed content - --> $DIR/binop-move-semantics.rs:30:5 - | -LL | *m - | ^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/binop-move-semantics.rs:32:5 - | -LL | *n; - | ^^ cannot move out of borrowed content - -error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable - --> $DIR/binop-move-semantics.rs:54:5 - | -LL | &mut f - | ------ - | | - | _____mutable borrow occurs here - | | -LL | | + -LL | | &f; - | | ^- - | |_____|| - | |mutable borrow later used here - | immutable borrow occurs here - -error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable - --> $DIR/binop-move-semantics.rs:62:5 - | -LL | &f - | -- - | | - | _____immutable borrow occurs here - | | -LL | | + -LL | | &mut f; - | | ^^^^^- - | |_____|____| - | | immutable borrow later used here - | mutable borrow occurs here - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0382, E0502, E0505, E0507. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/binop/binop-move-semantics.rs b/src/test/ui/binop/binop-move-semantics.rs index 2bcf16f8ba8..17dec594042 100644 --- a/src/test/ui/binop/binop-move-semantics.rs +++ b/src/test/ui/binop/binop-move-semantics.rs @@ -11,7 +11,7 @@ fn double_move>(x: T) { fn move_then_borrow + Clone>(x: T) { x + - x.clone(); //~ ERROR: use of moved value + x.clone(); //~ ERROR: borrow of moved value } fn move_borrowed>(x: T, mut y: T) { diff --git a/src/test/ui/binop/binop-move-semantics.stderr b/src/test/ui/binop/binop-move-semantics.stderr index 1e48ad22d87..146e3781463 100644 --- a/src/test/ui/binop/binop-move-semantics.stderr +++ b/src/test/ui/binop/binop-move-semantics.stderr @@ -1,42 +1,51 @@ error[E0382]: use of moved value: `x` --> $DIR/binop-move-semantics.rs:8:5 | +LL | fn double_move>(x: T) { + | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | x | - value moved here LL | + LL | x; | ^ value used here after move - | - = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/binop-move-semantics.rs:14:5 | +LL | fn move_then_borrow + Clone>(x: T) { + | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | x | - value moved here LL | + LL | x.clone(); - | ^ value used here after move - | - = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + | ^ value borrowed here after move error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/binop-move-semantics.rs:21:5 | LL | let m = &x; - | - borrow of `x` occurs here + | -- borrow of `x` occurs here ... LL | x | ^ move out of `x` occurs here +... +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/binop-move-semantics.rs:23:5 | LL | let n = &mut y; - | - borrow of `y` occurs here + | ------ borrow of `y` occurs here ... LL | y; | ^ move out of `y` occurs here +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0507]: cannot move out of borrowed content --> $DIR/binop-move-semantics.rs:30:5 @@ -51,28 +60,34 @@ LL | *n; | ^^ cannot move out of borrowed content error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable - --> $DIR/binop-move-semantics.rs:54:6 + --> $DIR/binop-move-semantics.rs:54:5 | -LL | &mut f - | - mutable borrow occurs here -LL | + -LL | &f; - | ^ - | | - | immutable borrow occurs here - | mutable borrow ends here +LL | &mut f + | ------ + | | + | _____mutable borrow occurs here + | | +LL | | + +LL | | &f; + | | ^- + | |_____|| + | |mutable borrow later used here + | immutable borrow occurs here error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable - --> $DIR/binop-move-semantics.rs:62:10 + --> $DIR/binop-move-semantics.rs:62:5 | -LL | &f - | - immutable borrow occurs here -LL | + -LL | &mut f; - | ^ - | | - | mutable borrow occurs here - | immutable borrow ends here +LL | &f + | -- + | | + | _____immutable borrow occurs here + | | +LL | | + +LL | | &mut f; + | | ^^^^^- + | |_____|____| + | | immutable borrow later used here + | mutable borrow occurs here error: aborting due to 8 previous errors 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 similarity index 87% rename from src/test/ui/borrowck/borrowck-access-permissions.mir.stderr rename to 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.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.mir.stderr b/src/test/ui/borrowck/borrowck-asm.mir.stderr deleted file mode 100644 index 3fb1c9b22cf..00000000000 --- a/src/test/ui/borrowck/borrowck-asm.mir.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.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.ast.nll.stderr b/src/test/ui/borrowck/borrowck-asm.stderr similarity index 90% rename from src/test/ui/borrowck/borrowck-asm.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-asm.stderr index 3fb1c9b22cf..c771373022a 100644 --- a/src/test/ui/borrowck/borrowck-asm.ast.nll.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 similarity index 86% rename from src/test/ui/borrowck/borrowck-assign-comp.ast.nll.stderr rename to 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.nll.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.ast.nll.stderr deleted file mode 100644 index 703a9222c5f..00000000000 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.ast.nll.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.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-assign-to-constants.stderr similarity index 76% rename from src/test/ui/borrowck/borrowck-assign-to-constants.mir.stderr rename to src/test/ui/borrowck/borrowck-assign-to-constants.stderr index 703a9222c5f..800003caa0f 100644 --- a/src/test/ui/borrowck/borrowck-assign-to-constants.mir.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) 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 + | ^^^^^^^^^ mutable borrow occurs here LL | *bar1; -LL | } - | - immutable borrow ends here + | ----- immutable borrow later used 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 -LL | *bar1; -LL | } - | - mutable borrow ends 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 + | ^^^^^^^^^^^^^ cannot borrow as mutable -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 - -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(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 = 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`, 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`, 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`, 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`, 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`, 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`, 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 similarity index 54% rename from src/test/ui/borrowck/borrowck-box-insensitivity.rs rename to 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` should not -// be treated specially by the AST-borrowck. -// -// NLL goes back to treating `Box` specially (namely, knowing that -// it uniquely owns the data it holds). See rust-lang/rfcs#130. +// Test that `Box` is treated specially by borrow checking. This is the case +// because NLL reverted the deicision in 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)] +// run-pass + +#![feature(box_syntax)] struct A { x: Box, @@ -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` - //[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` - //[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` - //[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.nll.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr deleted file mode 100644 index a41738f6ca8..00000000000 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.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.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-closures-mut-and-imm.stderr similarity index 90% rename from src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr rename to src/test/ui/borrowck/borrowck-closures-mut-and-imm.stderr index a41738f6ca8..edeb21c16d3 100644 --- a/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.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 - | ^ + | ^^^^^ cannot assign -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 - | ^ +error: aborting due to 4 previous errors -error: aborting due to 5 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) { - | - move occurs because `b` has type `std::boxed::Box`, 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) { + | - move occurs because `b` has type `std::boxed::Box`, 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`, 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`, 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) { 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 similarity index 88% rename from src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr rename to 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`, 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`, 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`, 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`, 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`, 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`, 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`, 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`, 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 } 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`, 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`, 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`, 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`, 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`, 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`, 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`, 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.ast.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.stderr deleted file mode 100644 index 16c62fc1c7e..00000000000 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.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.mir.stderr b/src/test/ui/borrowck/borrowck-fn-in-const-a.stderr similarity index 85% rename from src/test/ui/borrowck/borrowck-fn-in-const-a.mir.stderr rename to src/test/ui/borrowck/borrowck-fn-in-const-a.stderr index 16c62fc1c7e..fff28359c14 100644 --- a/src/test/ui/borrowck/borrowck-fn-in-const-a.mir.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`, 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`, 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`, 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`, 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 similarity index 86% rename from src/test/ui/borrowck/borrowck-imm-ref-to-mut-rec-field-issue-3162-c.ast.nll.stderr rename to 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() -> (BoxBox>) + 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.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.mir.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr deleted file mode 100644 index 35649b1bb2a..00000000000 --- a/src/test/ui/borrowck/borrowck-init-in-fru.mir.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.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.ast.nll.stderr b/src/test/ui/borrowck/borrowck-init-in-fru.stderr similarity index 88% rename from src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-init-in-fru.stderr index 35649b1bb2a..fe55bc2fd95 100644 --- a/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.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.nll.stderr b/src/test/ui/borrowck/borrowck-issue-14498.ast.nll.stderr deleted file mode 100644 index 59576a2837e..00000000000 --- a/src/test/ui/borrowck/borrowck-issue-14498.ast.nll.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.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-issue-14498.stderr similarity index 88% rename from src/test/ui/borrowck/borrowck-issue-14498.mir.stderr rename to src/test/ui/borrowck/borrowck-issue-14498.stderr index 59576a2837e..fec4c27520c 100644 --- a/src/test/ui/borrowck/borrowck-issue-14498.mir.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,74 +7,79 @@ 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 | drop(p); + | - borrow later used here + +error[E0506]: cannot assign to `**y.a` because it is borrowed + --> $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 @@ -86,19 +91,6 @@ LL | let p = &y.a; 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 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) { } 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 similarity index 82% rename from src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr rename to 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.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.mir.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.mir.stderr deleted file mode 100644 index 734f965195c..00000000000 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.mir.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.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.ast.nll.stderr b/src/test/ui/borrowck/borrowck-lend-flow-match.stderr similarity index 89% rename from src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-lend-flow-match.stderr index 734f965195c..66f1cd9bd56 100644 --- a/src/test/ui/borrowck/borrowck-lend-flow-match.ast.nll.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 similarity index 83% rename from src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr rename to 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.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.mir.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr deleted file mode 100644 index ac9e73fadec..00000000000 --- a/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.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.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.ast.nll.stderr b/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.stderr similarity index 86% rename from src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr rename to 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.ast.nll.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 similarity index 84% rename from src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr rename to 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.nll.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.nll.stderr deleted file mode 100644 index 2ac05393e02..00000000000 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.ast.nll.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.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr similarity index 88% rename from src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.stderr rename to src/test/ui/borrowck/borrowck-match-binding-is-assignment.stderr index 2ac05393e02..5661ca52cba 100644 --- a/src/test/ui/borrowck/borrowck-match-binding-is-assignment.mir.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`, 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 + --> $DIR/borrowck-move-error-with-note.rs:29:11 | -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 +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`, 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) 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 similarity index 82% rename from src/test/ui/borrowck/borrowck-move-in-irrefut-pat.mir.stderr rename to 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.nll.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.nll.stderr deleted file mode 100644 index 874c38cb789..00000000000 --- a/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.ast.nll.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`, 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.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`, 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.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 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.mir.stderr b/src/test/ui/borrowck/borrowck-move-moved-value-into-closure.stderr similarity index 91% rename from src/test/ui/borrowck/borrowck-move-moved-value-into-closure.mir.stderr rename to 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.mir.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`, 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`, 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`, 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 similarity index 87% rename from src/test/ui/borrowck/borrowck-move-out-from-array.ast.stderr rename to 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`, 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.nll.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr deleted file mode 100644 index 81afb104c9d..00000000000 --- a/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.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.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.stderr similarity index 81% rename from src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr rename to 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.mir.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 similarity index 81% rename from src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.stderr rename to 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 similarity index 80% rename from src/test/ui/borrowck/borrowck-move-out-of-struct-with-dtor.mir.stderr rename to 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) => {} + | -- 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) => {} - | ^^--^ - | | | - | | 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-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`, 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`, 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`, 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`, 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`, 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`, 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`, 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`, 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`, 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,28 +64,44 @@ LL | drop(x); | = note: move occurs because `x` has type `std::boxed::Box`, 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 | let p = &x; + | -- borrow of `x` occurs here +LL | thread::spawn(move|| { + | ^^^^^^ move out of `x` occurs here +LL | +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:52: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`, 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`, 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); - | ^ value captured here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - -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`, which does not implement the `Copy` trait + | - 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 similarity index 84% rename from src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr rename to 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 { 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 similarity index 86% rename from src/test/ui/borrowck/borrowck-overloaded-index-and-overloaded-deref.mir.stderr rename to 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::> { 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.nll.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr deleted file mode 100644 index d09ce5d1805..00000000000 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.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.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.stderr similarity index 83% rename from src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr rename to src/test/ui/borrowck/borrowck-overloaded-index-ref-index.stderr index d09ce5d1805..fcbfe72a34b 100644 --- a/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.mir.stderr deleted file mode 100644 index f0e16838c8a..00000000000 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.mir.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.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 = 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.ast.nll.stderr b/src/test/ui/borrowck/borrowck-pat-reassign-binding.stderr similarity index 89% rename from src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.stderr rename to src/test/ui/borrowck/borrowck-pat-reassign-binding.stderr index f0e16838c8a..9e65ccf5a19 100644 --- a/src/test/ui/borrowck/borrowck-pat-reassign-binding.ast.nll.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 { - | - 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 { - | - 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.nll.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.nll.stderr deleted file mode 100644 index dbc9ece0c8f..00000000000 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.ast.nll.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.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.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.mir.stderr b/src/test/ui/borrowck/borrowck-struct-update-with-dtor.stderr similarity index 81% rename from src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.stderr rename to src/test/ui/borrowck/borrowck-struct-update-with-dtor.stderr index dbc9ece0c8f..ea16502ebe5 100644 --- a/src/test/ui/borrowck/borrowck-struct-update-with-dtor.mir.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 similarity index 83% rename from src/test/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.mir.stderr rename to 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.nll.stderr b/src/test/ui/borrowck/borrowck-unary-move.ast.nll.stderr deleted file mode 100644 index c29ff538304..00000000000 --- a/src/test/ui/borrowck/borrowck-unary-move.ast.nll.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.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.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 { 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.mir.stderr b/src/test/ui/borrowck/borrowck-unary-move.stderr similarity index 88% rename from src/test/ui/borrowck/borrowck-unary-move.mir.stderr rename to src/test/ui/borrowck/borrowck-unary-move.stderr index c29ff538304..aab225ed4a4 100644 --- a/src/test/ui/borrowck/borrowck-unary-move.mir.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 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 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 isize>(mut f: F) { use_mut(g); } fn b 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 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 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 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 similarity index 87% rename from src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr rename to 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: X, y: Y, @@ -8,36 +5,29 @@ struct S { fn main() { let x: &&Box; - let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] - //[mir]~^ [E0381] + let _y = &**x; //~ [E0381] let x: &&S; - 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; - 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; - 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 similarity index 81% rename from src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr rename to 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,3 +1,9 @@ +error[E0381]: borrow of possibly uninitialized variable: `x` + --> $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:11:14 | @@ -5,37 +11,31 @@ 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 + --> $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 similarity index 89% rename from src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr rename to 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 similarity index 81% rename from src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr rename to 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 similarity index 82% rename from src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr rename to 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 similarity index 89% rename from src/test/ui/borrowck/borrowck-vec-pattern-move-tail.ast.nll.stderr rename to 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]`, 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`, 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]`, 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]`, 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`, 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]`, 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]`, 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]`, 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] = &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] = &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] = &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] = &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]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:34:14 + --> $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`, 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 | ] => { | -LL | &mut [_a, - | ^-- hint: to prevent move, use `ref _a` or `ref mut _a` - | ______________| - | | -LL | | -LL | | -LL | | .. -LL | | ] => { - | |_________^ cannot move out of here error[E0508]: cannot move out of type `[std::boxed::Box]`, 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]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:55:14 + --> $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`, 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] => {} | -LL | &mut [ - | ______________^ -LL | | -LL | | _b] => {} - | |__________--^ cannot move out of here - | | - | hint: to prevent move, use `ref _b` or `ref mut _b` error[E0508]: cannot move out of type `[std::boxed::Box]`, 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]`, 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]`, 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 FnOnce(&'r ())>(f: F) { f(&()); @@ -24,8 +17,7 @@ fn give_any 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 similarity index 75% rename from src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr rename to 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 similarity index 94% rename from src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr rename to 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 similarity index 87% rename from src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr rename to 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 similarity index 76% rename from src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr rename to 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 similarity index 78% rename from src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr rename to 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 - -error[E0596]: cannot borrow field of immutable binding as mutable - --> $DIR/mutability-errors.rs:19:10 - | -LL | &mut f().0; - | ^^^^^ cannot mutably borrow field of immutable binding - -error[E0594]: cannot assign to immutable dereference of raw pointer `*x` - --> $DIR/mutability-errors.rs:23:5 - | -LL | *x = (1,); | ^^^^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to field `x.0` of immutable binding +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; - | ^^^^^^^^^^ 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,13 @@ 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 - -error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable - --> $DIR/mutability-errors.rs:48:14 + | ^^^^^^^ cannot assign | -LL | &mut x; - | ^ - | -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 +224,155 @@ 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` 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 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 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:5 | -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... +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 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 | -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... +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 + | ^^^^^^^ use of possibly uninitialized `x` -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` - -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 + | ^^^^^^^ use of possibly uninitialized `x` -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 - -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 i32>(f: Box) { - | - move occurs because `f` has type `std::boxed::Box`, 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 i32>) { - | - move occurs because `f` has type `std::boxed::Box 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`, 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 i32>(f: Box) { | - move occurs because `f` has type `std::boxed::Box`, 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 i32>) { | - move occurs because `f` has type `std::boxed::Box 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 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 similarity index 89% rename from src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr rename to 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 diff --git a/src/test/ui/by-move-pattern-binding.nll.stderr b/src/test/ui/by-move-pattern-binding.nll.stderr deleted file mode 100644 index 8b531474553..00000000000 --- a/src/test/ui/by-move-pattern-binding.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/by-move-pattern-binding.rs:14:11 - | -LL | match &s.x { - | ^^^^ cannot move out of borrowed content -LL | &E::Foo => {} -LL | &E::Bar(identifier) => f(identifier.clone()) - | ------------------- - | | | - | | data moved here - | help: consider removing the `&`: `E::Bar(identifier)` - | -note: move occurs because `identifier` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/by-move-pattern-binding.rs:16:17 - | -LL | &E::Bar(identifier) => f(identifier.clone()) - | ^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/by-move-pattern-binding.rs b/src/test/ui/by-move-pattern-binding.rs index 455b206e53f..d4c9f23164f 100644 --- a/src/test/ui/by-move-pattern-binding.rs +++ b/src/test/ui/by-move-pattern-binding.rs @@ -11,9 +11,9 @@ fn f(x: String) {} fn main() { let s = S { x: E::Bar("hello".to_string()) }; - match &s.x { + match &s.x { //~ ERROR cannot move &E::Foo => {} - &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move + &E::Bar(identifier) => f(identifier.clone()) }; match &s.x { &E::Foo => {} diff --git a/src/test/ui/by-move-pattern-binding.stderr b/src/test/ui/by-move-pattern-binding.stderr index 5135e0dadaf..8b531474553 100644 --- a/src/test/ui/by-move-pattern-binding.stderr +++ b/src/test/ui/by-move-pattern-binding.stderr @@ -1,11 +1,20 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/by-move-pattern-binding.rs:16:9 + --> $DIR/by-move-pattern-binding.rs:14:11 + | +LL | match &s.x { + | ^^^^ cannot move out of borrowed content +LL | &E::Foo => {} +LL | &E::Bar(identifier) => f(identifier.clone()) + | ------------------- + | | | + | | data moved here + | help: consider removing the `&`: `E::Bar(identifier)` + | +note: move occurs because `identifier` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/by-move-pattern-binding.rs:16:17 | LL | &E::Bar(identifier) => f(identifier.clone()) - | ^^^^^^^^----------^ - | | | - | | hint: to prevent move, use `ref identifier` or `ref mut identifier` - | cannot move out of borrowed content + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.stderr b/src/test/ui/cannot-mutate-captured-non-mut-var.ast.stderr deleted file mode 100644 index 4cdd1605c78..00000000000 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0594]: cannot assign to immutable captured outer variable in an `FnOnce` closure `x` - --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 - | -LL | to_fn_once(move|| { x = 2; }); - | ^^^^^ - -error[E0596]: cannot borrow immutable captured outer variable in an `FnOnce` closure `s` as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:18:25 - | -LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - | ^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.mir.stderr b/src/test/ui/cannot-mutate-captured-non-mut-var.mir.stderr deleted file mode 100644 index 9b444badeb3..00000000000 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.mir.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 - | -LL | let x = 1; - | - help: consider changing this to be mutable: `mut x` -LL | to_fn_once(move|| { x = 2; }); - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:18:25 - | -LL | let s = std::io::stdin(); - | - help: consider changing this to be mutable: `mut s` -LL | to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - | ^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.rs b/src/test/ui/cannot-mutate-captured-non-mut-var.rs index 18257d09fa0..a83884acb1d 100644 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.rs +++ b/src/test/ui/cannot-mutate-captured-non-mut-var.rs @@ -1,7 +1,3 @@ -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - #![feature(unboxed_closures)] use std::io::Read; @@ -11,11 +7,9 @@ fn to_fn_once>(f: F) -> F { f } fn main() { let x = 1; to_fn_once(move|| { x = 2; }); - //[ast]~^ ERROR: cannot assign to immutable captured outer variable - //[mir]~^^ ERROR: cannot assign to `x`, as it is not declared as mutable + //~^ ERROR: cannot assign to `x`, as it is not declared as mutable let s = std::io::stdin(); to_fn_once(move|| { s.read_to_end(&mut Vec::new()); }); - //[ast]~^ ERROR: cannot borrow immutable captured outer variable - //[mir]~^^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable + //~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.nll.stderr b/src/test/ui/cannot-mutate-captured-non-mut-var.stderr similarity index 92% rename from src/test/ui/cannot-mutate-captured-non-mut-var.ast.nll.stderr rename to src/test/ui/cannot-mutate-captured-non-mut-var.stderr index 9b444badeb3..2961497ef9f 100644 --- a/src/test/ui/cannot-mutate-captured-non-mut-var.ast.nll.stderr +++ b/src/test/ui/cannot-mutate-captured-non-mut-var.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 + --> $DIR/cannot-mutate-captured-non-mut-var.rs:9:25 | LL | let x = 1; | - help: consider changing this to be mutable: `mut x` @@ -7,7 +7,7 @@ LL | to_fn_once(move|| { x = 2; }); | ^^^^^ cannot assign error[E0596]: cannot borrow `s` as mutable, as it is not declared as mutable - --> $DIR/cannot-mutate-captured-non-mut-var.rs:18:25 + --> $DIR/cannot-mutate-captured-non-mut-var.rs:13:25 | LL | let s = std::io::stdin(); | - help: consider changing this to be mutable: `mut s` diff --git a/src/test/ui/check-static-values-constraints.nll.stderr b/src/test/ui/check-static-values-constraints.nll.stderr deleted file mode 100644 index f35703a306d..00000000000 --- a/src/test/ui/check-static-values-constraints.nll.stderr +++ /dev/null @@ -1,112 +0,0 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/check-static-values-constraints.rs:65:43 - | -LL | ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), - | ___________________________________________^ -LL | | -LL | | field2: SafeEnum::Variant1}}; - | |________________________________________________________________________________^ statics cannot evaluate destructors - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:79:33 - | -LL | static STATIC11: Box = box MyOwned; - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:79:37 - | -LL | static STATIC11: Box = box MyOwned; - | ^^^^^^^ - -error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/check-static-values-constraints.rs:90:32 - | -LL | field2: SafeEnum::Variant4("str".to_string()) - | ^^^^^^^^^^^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:95:5 - | -LL | box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:95:9 - | -LL | box MyOwned, - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:97:5 - | -LL | box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:97:9 - | -LL | box MyOwned, - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:102:6 - | -LL | &box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:102:10 - | -LL | &box MyOwned, - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:104:6 - | -LL | &box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:104:10 - | -LL | &box MyOwned, - | ^^^^^^^ - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:111:5 - | -LL | box 3; - | ^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:111:9 - | -LL | box 3; - | ^ - -error[E0507]: cannot move out of static item - --> $DIR/check-static-values-constraints.rs:116:45 - | -LL | let y = { static x: Box = box 3; x }; - | ^ - | | - | cannot move out of static item - | help: consider borrowing here: `&x` - -error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:116:38 - | -LL | let y = { static x: Box = box 3; x }; - | ^^^^^ allocation not allowed in statics - -error[E0019]: static contains unimplemented expression type - --> $DIR/check-static-values-constraints.rs:116:42 - | -LL | let y = { static x: Box = box 3; x }; - | ^ - -error: aborting due to 17 previous errors - -Some errors have detailed explanations: E0010, E0015, E0019, E0507. -For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/check-static-values-constraints.stderr b/src/test/ui/check-static-values-constraints.stderr index 9648704f735..f35703a306d 100644 --- a/src/test/ui/check-static-values-constraints.stderr +++ b/src/test/ui/check-static-values-constraints.stderr @@ -89,7 +89,10 @@ error[E0507]: cannot move out of static item --> $DIR/check-static-values-constraints.rs:116:45 | LL | let y = { static x: Box = box 3; x }; - | ^ cannot move out of static item + | ^ + | | + | cannot move out of static item + | help: consider borrowing here: `&x` error[E0010]: allocations are not allowed in statics --> $DIR/check-static-values-constraints.rs:116:38 diff --git a/src/test/ui/cleanup-rvalue-scopes-cf.rs b/src/test/ui/cleanup-rvalue-scopes-cf.rs index 106dbd324ff..e3cecb1bffe 100644 --- a/src/test/ui/cleanup-rvalue-scopes-cf.rs +++ b/src/test/ui/cleanup-rvalue-scopes-cf.rs @@ -1,5 +1,3 @@ -// ignore-compare-mode-nll - // Test that the borrow checker prevents pointers to temporaries // with statement lifetimes from escaping. @@ -7,7 +5,7 @@ use std::ops::Drop; static mut FLAGS: u64 = 0; -struct Box { f: T } +struct StackBox { f: T } struct AddFlags { bits: u64 } fn AddFlags(bits: u64) -> AddFlags { @@ -25,11 +23,13 @@ impl AddFlags { } pub fn main() { - let _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - let _x = &*arg(&AddFlags(1)); //~ ERROR value does not live long enough - let ref _x = *arg(&AddFlags(1)); //~ ERROR value does not live long enough - let &ref _x = arg(&AddFlags(1)); //~ ERROR value does not live long enough - let _x = AddFlags(1).get(); //~ ERROR value does not live long enough - let Box { f: _x } = Box { f: AddFlags(1).get() }; //~ ERROR value does not live long enough + let x1 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let x2 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed + let x3 = &*arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let ref x4 = *arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let &ref x5 = arg(&AddFlags(1)); //~ ERROR temporary value dropped while borrowed + let x6 = AddFlags(1).get(); //~ ERROR temporary value dropped while borrowed + let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; + //~^ ERROR temporary value dropped while borrowed + (x1, x2, x3, x4, x5, x6, x7); } diff --git a/src/test/ui/cleanup-rvalue-scopes-cf.stderr b/src/test/ui/cleanup-rvalue-scopes-cf.stderr index e35e71ce6e2..04e599755fb 100644 --- a/src/test/ui/cleanup-rvalue-scopes-cf.stderr +++ b/src/test/ui/cleanup-rvalue-scopes-cf.stderr @@ -1,93 +1,94 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:28:19 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:26:19 | -LL | let _x = arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x1 = arg(&AddFlags(1)); + | ^^^^^^^^^^^ - 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 | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- 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[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:29:14 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:27:14 | -LL | let _x = AddFlags(1).get(); - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x2 = AddFlags(1).get(); + | ^^^^^^^^^^^ - 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 | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- 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[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:30:21 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:28:21 | -LL | let _x = &*arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x3 = &*arg(&AddFlags(1)); + | ^^^^^^^^^^^ - 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 | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- 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[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:31:24 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:29:24 | -LL | let ref _x = *arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let ref x4 = *arg(&AddFlags(1)); + | ^^^^^^^^^^^ - 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 | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- 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[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:32:24 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:30:24 | -LL | let &ref _x = arg(&AddFlags(1)); - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let &ref x5 = arg(&AddFlags(1)); + | ^^^^^^^^^^^ - 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 | } - | - temporary value needs to live until here +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- 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[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:33:14 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:31:14 | -LL | let _x = AddFlags(1).get(); - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed +LL | let x6 = AddFlags(1).get(); + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough -LL | let Box { f: _x } = Box { f: AddFlags(1).get() }; -LL | } - | - temporary value needs to live until here + | creates a temporary which is freed while still in use +... +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- 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[E0597]: borrowed value does not live long enough - --> $DIR/cleanup-rvalue-scopes-cf.rs:34:34 +error[E0716]: temporary value dropped while borrowed + --> $DIR/cleanup-rvalue-scopes-cf.rs:32:44 | -LL | let Box { f: _x } = Box { f: AddFlags(1).get() }; - | ^^^^^^^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -LL | } - | - temporary value needs to live until here +LL | let StackBox { f: x7 } = StackBox { f: AddFlags(1).get() }; + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | + | creates a temporary which is freed while still in use +LL | +LL | (x1, x2, x3, x4, x5, x6, x7); + | -- 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 7 previous errors -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/closure_promotion.rs b/src/test/ui/closure_promotion.rs index a80745e8bcc..db9c0a6ef3b 100644 --- a/src/test/ui/closure_promotion.rs +++ b/src/test/ui/closure_promotion.rs @@ -1,8 +1,7 @@ -// ignore-compare-mode-nll +// compile-pass #![allow(const_err)] -// nll successfully compiles this. fn main() { - let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough + let x: &'static _ = &|| { let z = 3; z }; } diff --git a/src/test/ui/closure_promotion.stderr b/src/test/ui/closure_promotion.stderr deleted file mode 100644 index 475e28309cf..00000000000 --- a/src/test/ui/closure_promotion.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/closure_promotion.rs:7:26 - | -LL | let x: &'static _ = &|| { let z = 3; z }; - | ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | } - | - temporary 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/closures/closure-immutable-outer-variable.fixed b/src/test/ui/closures/closure-immutable-outer-variable.fixed index 22164a24d8b..03240d4857c 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.fixed +++ b/src/test/ui/closures/closure-immutable-outer-variable.fixed @@ -8,5 +8,6 @@ fn foo(mut f: Box) { fn main() { let mut y = true; - foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable + foo(Box::new(move || y = false) as Box<_>); + //~^ ERROR cannot assign to `y`, as it is not declared as mutable } diff --git a/src/test/ui/closures/closure-immutable-outer-variable.nll.stderr b/src/test/ui/closures/closure-immutable-outer-variable.nll.stderr deleted file mode 100644 index 558c9caeff3..00000000000 --- a/src/test/ui/closures/closure-immutable-outer-variable.nll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0594]: cannot assign to `y`, as it is not declared as mutable - --> $DIR/closure-immutable-outer-variable.rs:11:26 - | -LL | let y = true; - | - help: consider changing this to be mutable: `mut y` -LL | foo(Box::new(move || y = false) as Box<_>); - | ^^^^^^^^^ cannot assign - -error: aborting due to previous error - diff --git a/src/test/ui/closures/closure-immutable-outer-variable.rs b/src/test/ui/closures/closure-immutable-outer-variable.rs index fc4e3857268..8fa9e44845d 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.rs +++ b/src/test/ui/closures/closure-immutable-outer-variable.rs @@ -8,5 +8,6 @@ fn foo(mut f: Box) { fn main() { let y = true; - foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable + foo(Box::new(move || y = false) as Box<_>); + //~^ ERROR cannot assign to `y`, as it is not declared as mutable } diff --git a/src/test/ui/closures/closure-immutable-outer-variable.stderr b/src/test/ui/closures/closure-immutable-outer-variable.stderr index e675a08169e..558c9caeff3 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.stderr +++ b/src/test/ui/closures/closure-immutable-outer-variable.stderr @@ -1,10 +1,10 @@ -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `y`, as it is not declared as mutable --> $DIR/closure-immutable-outer-variable.rs:11:26 | LL | let y = true; - | - help: consider making `y` mutable: `mut y` + | - help: consider changing this to be mutable: `mut y` LL | foo(Box::new(move || y = false) as Box<_>); - | ^^^^^^^^^ + | ^^^^^^^^^ cannot assign error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr b/src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr deleted file mode 100644 index a60f1c77a58..00000000000 --- a/src/test/ui/codemap_tests/huge_multispan_highlight.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/huge_multispan_highlight.rs:90:13 - | -LL | let x = "foo"; - | - help: consider changing this to be mutable: `mut x` -... -LL | let y = &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/codemap_tests/huge_multispan_highlight.stderr b/src/test/ui/codemap_tests/huge_multispan_highlight.stderr index 13bd666a507..a60f1c77a58 100644 --- a/src/test/ui/codemap_tests/huge_multispan_highlight.stderr +++ b/src/test/ui/codemap_tests/huge_multispan_highlight.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/huge_multispan_highlight.rs:90:18 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/huge_multispan_highlight.rs:90:13 | LL | let x = "foo"; - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... LL | let y = &mut x; - | ^ cannot borrow mutably + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/issue-11715.nll.stderr b/src/test/ui/codemap_tests/issue-11715.nll.stderr deleted file mode 100644 index d0c29c768eb..00000000000 --- a/src/test/ui/codemap_tests/issue-11715.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/issue-11715.rs:5:13 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | let z = &mut x; - | ^^^^^^ second mutable borrow occurs here -LL | z.use_mut(); -LL | y.use_mut(); - | - 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/codemap_tests/issue-11715.stderr b/src/test/ui/codemap_tests/issue-11715.stderr index c37e6b34727..d0c29c768eb 100644 --- a/src/test/ui/codemap_tests/issue-11715.stderr +++ b/src/test/ui/codemap_tests/issue-11715.stderr @@ -1,13 +1,13 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/issue-11715.rs:5:18 + --> $DIR/issue-11715.rs:5:13 | LL | let y = &mut x; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | let z = &mut x; - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^ second mutable borrow occurs here +LL | z.use_mut(); +LL | y.use_mut(); + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/one_line.nll.stderr b/src/test/ui/codemap_tests/one_line.nll.stderr deleted file mode 100644 index eddbd29c0ef..00000000000 --- a/src/test/ui/codemap_tests/one_line.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `v` as mutable more than once at a time - --> $DIR/one_line.rs:3:12 - | -LL | v.push(v.pop().unwrap()); - | - ---- ^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first 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/codemap_tests/one_line.stderr b/src/test/ui/codemap_tests/one_line.stderr index 9dcaba8748e..eddbd29c0ef 100644 --- a/src/test/ui/codemap_tests/one_line.stderr +++ b/src/test/ui/codemap_tests/one_line.stderr @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/one_line.rs:3:12 | LL | v.push(v.pop().unwrap()); - | - ^ - first borrow ends here - | | | - | | second mutable borrow occurs here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/tab_3.nll.stderr b/src/test/ui/codemap_tests/tab_3.nll.stderr deleted file mode 100644 index 97816a76004..00000000000 --- a/src/test/ui/codemap_tests/tab_3.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `some_vec` - --> $DIR/tab_3.rs:7:20 - | -LL | let some_vec = vec!["hi"]; - | -------- move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait -LL | some_vec.into_iter(); - | -------- value moved here -LL | { -LL | println!("{:?}", some_vec); - | ^^^^^^^^ value borrowed 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/codemap_tests/tab_3.rs b/src/test/ui/codemap_tests/tab_3.rs index 4fd5b70f7ae..58b034d0fcf 100644 --- a/src/test/ui/codemap_tests/tab_3.rs +++ b/src/test/ui/codemap_tests/tab_3.rs @@ -4,6 +4,6 @@ fn main() { let some_vec = vec!["hi"]; some_vec.into_iter(); { - println!("{:?}", some_vec); //~ ERROR use of moved + println!("{:?}", some_vec); //~ ERROR borrow of moved } } diff --git a/src/test/ui/codemap_tests/tab_3.stderr b/src/test/ui/codemap_tests/tab_3.stderr index 4b550dbf9ee..97816a76004 100644 --- a/src/test/ui/codemap_tests/tab_3.stderr +++ b/src/test/ui/codemap_tests/tab_3.stderr @@ -1,13 +1,13 @@ -error[E0382]: use of moved value: `some_vec` +error[E0382]: borrow of moved value: `some_vec` --> $DIR/tab_3.rs:7:20 | +LL | let some_vec = vec!["hi"]; + | -------- move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait LL | some_vec.into_iter(); | -------- value moved here LL | { LL | println!("{:?}", some_vec); - | ^^^^^^^^ value used here after move - | - = note: move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait + | ^^^^^^^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr deleted file mode 100644 index 71f7d8721b0..00000000000 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 - | -LL | let y = borrow_mut(x); - | - first mutable borrow occurs here -LL | let z = borrow_mut(x); - | ^ second mutable borrow occurs here -... -LL | drop((y, z)); - | - first borrow later used here - -error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 - | -LL | let y = borrow(x); - | - borrow of `**x` occurs here -LL | let z = borrow(x); -LL | **x += 1; - | ^^^^^^^^ assignment to borrowed `**x` occurs here -... -LL | drop((y, z)); - | - borrow later used here - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 - | -LL | borrow_mut2(x, x); - | ----------- - ^ second mutable borrow occurs here - | | | - | | first mutable borrow occurs here - | first borrow later used by call - -error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable - --> $DIR/coerce-overloaded-autoderef.rs:34:5 - | -LL | borrow2(x, x); - | -------^^^^-^ - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - | immutable borrow later used by call - -error: aborting due to 4 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/coercion/coerce-overloaded-autoderef.ast.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.ast.stderr deleted file mode 100644 index 0e5a4a6c000..00000000000 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.ast.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 - | -LL | let y = borrow_mut(x); - | - first mutable borrow occurs here -LL | let z = borrow_mut(x); - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here - -error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 - | -LL | let y = borrow(x); - | - borrow of `**x` occurs here -LL | let z = borrow(x); -LL | **x += 1; - | ^^^^^^^^ assignment to borrowed `**x` occurs here - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 - | -LL | borrow_mut2(x, x); - | - ^- first borrow ends here - | | | - | | second mutable borrow occurs here - | first mutable borrow occurs here - -error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable - --> $DIR/coerce-overloaded-autoderef.rs:34:16 - | -LL | borrow2(x, x); - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here - | mutable borrow occurs here - -error: aborting due to 4 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/coercion/coerce-overloaded-autoderef.mir.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr deleted file mode 100644 index 39a2847c8d6..00000000000 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 - | -LL | let y = borrow_mut(x); - | - first mutable borrow occurs here -LL | let z = borrow_mut(x); - | ^ second mutable borrow occurs here -... -LL | drop((y, z)); - | - first borrow later used here - -error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 - | -LL | let y = borrow(x); - | - borrow of `**x` occurs here -LL | let z = borrow(x); -LL | **x += 1; - | ^^^^^^^^ assignment to borrowed `**x` occurs here -... -LL | drop((y, z)); - | - borrow later used here - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 - | -LL | borrow_mut2(x, x); - | ----------- - ^ second mutable borrow occurs here - | | | - | | first mutable borrow occurs here - | first borrow later used by call - -error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable - --> $DIR/coerce-overloaded-autoderef.rs:34:16 - | -LL | borrow2(x, x); - | ------- - ^ immutable borrow occurs here - | | | - | | mutable borrow occurs here - | mutable borrow later used by call - -error: aborting due to 4 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/coercion/coerce-overloaded-autoderef.rs b/src/test/ui/coercion/coerce-overloaded-autoderef.rs index ec72745cd71..01d9c1e486a 100644 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.rs +++ b/src/test/ui/coercion/coerce-overloaded-autoderef.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn borrow_mut(x: &mut T) -> &mut T { x } fn borrow(x: &T) -> &T { x } @@ -10,8 +7,7 @@ fn borrow2(_: &mut T, _: &T) {} fn double_mut_borrow(x: &mut Box) { let y = borrow_mut(x); let z = borrow_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 + //~^ ERROR cannot borrow `*x` as mutable more than once at a time drop((y, z)); } @@ -19,21 +15,18 @@ fn double_imm_borrow(x: &mut Box) { let y = borrow(x); let z = borrow(x); **x += 1; - //[ast]~^ ERROR cannot assign to `**x` because it is borrowed - //[mir]~^^ ERROR cannot assign to `**x` because it is borrowed + //~^ ERROR cannot assign to `**x` because it is borrowed drop((y, z)); } fn double_mut_borrow2(x: &mut Box) { borrow_mut2(x, 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 + //~^ ERROR cannot borrow `*x` as mutable more than once at a time } fn double_borrow2(x: &mut Box) { borrow2(x, x); - //[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable - //[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable + //~^ ERROR cannot borrow `*x` as mutable because it is also borrowed as immutable } pub fn main() {} diff --git a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr b/src/test/ui/coercion/coerce-overloaded-autoderef.stderr similarity index 87% rename from src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr rename to src/test/ui/coercion/coerce-overloaded-autoderef.stderr index 71f7d8721b0..7cdfcb5f4fc 100644 --- a/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr +++ b/src/test/ui/coercion/coerce-overloaded-autoderef.stderr @@ -1,28 +1,28 @@ error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:12:24 + --> $DIR/coerce-overloaded-autoderef.rs:9:24 | LL | let y = borrow_mut(x); | - first mutable borrow occurs here LL | let z = borrow_mut(x); | ^ second mutable borrow occurs here -... +LL | LL | drop((y, z)); | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed - --> $DIR/coerce-overloaded-autoderef.rs:21:5 + --> $DIR/coerce-overloaded-autoderef.rs:17:5 | LL | let y = borrow(x); | - borrow of `**x` occurs here LL | let z = borrow(x); LL | **x += 1; | ^^^^^^^^ assignment to borrowed `**x` occurs here -... +LL | LL | drop((y, z)); | - borrow later used here error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/coerce-overloaded-autoderef.rs:28:20 + --> $DIR/coerce-overloaded-autoderef.rs:23:20 | LL | borrow_mut2(x, x); | ----------- - ^ second mutable borrow occurs here @@ -31,7 +31,7 @@ LL | borrow_mut2(x, x); | first borrow later used by call error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable - --> $DIR/coerce-overloaded-autoderef.rs:34:5 + --> $DIR/coerce-overloaded-autoderef.rs:28:5 | LL | borrow2(x, x); | -------^^^^-^ diff --git a/src/test/ui/command-line-diagnostics.nll.stderr b/src/test/ui/command-line-diagnostics.nll.stderr deleted file mode 100644 index b3f8d8a643f..00000000000 --- a/src/test/ui/command-line-diagnostics.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/command-line-diagnostics.rs:6:5 - | -LL | let x = 42; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x = 43; - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/command-line-diagnostics.stderr b/src/test/ui/command-line-diagnostics.stderr index 6f1156e0d36..b3f8d8a643f 100644 --- a/src/test/ui/command-line-diagnostics.stderr +++ b/src/test/ui/command-line-diagnostics.stderr @@ -2,7 +2,10 @@ error[E0384]: cannot assign twice to immutable variable `x` --> $DIR/command-line-diagnostics.rs:6:5 | LL | let x = 42; - | - first assignment to `x` + | - + | | + | first assignment to `x` + | help: make this binding mutable: `mut x` LL | x = 43; | ^^^^^^ cannot assign twice to immutable variable diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr deleted file mode 100644 index ca80a9ab391..00000000000 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error: `foo` is not yet stable as a const fn - --> $DIR/dont_promote_unstable_const_fn.rs:15:25 - | -LL | const fn bar() -> u32 { foo() } - | ^^^^^ - | - = help: add `#![feature(foo)]` to the crate attributes to enable - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn.rs:18:28 - | -LL | let _: &'static u32 = &foo(); - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn.rs:22:28 - | -LL | let _: &'static u32 = &meh(); - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn.rs:23:26 - | -LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs index 7170be1b88b..90028690990 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs @@ -15,11 +15,11 @@ fn meh() -> u32 { 42 } const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn fn a() { - let _: &'static u32 = &foo(); //~ ERROR does not live long enough + let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed } fn main() { - let _: &'static u32 = &meh(); //~ ERROR does not live long enough + let _: &'static u32 = &meh(); //~ ERROR temporary value dropped while borrowed let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr index d79666688fa..ca80a9ab391 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr @@ -6,38 +6,38 @@ LL | const fn bar() -> u32 { foo() } | = help: add `#![feature(foo)]` to the crate attributes to enable -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:18:28 | LL | let _: &'static u32 = &foo(); - | ^^^^^ temporary value does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:22:28 | LL | let _: &'static u32 = &meh(); - | ^^^^^ temporary value does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn.rs:23:26 | LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 4 previous errors -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/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr deleted file mode 100644 index 129f0615107..00000000000 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:8:28 - | -LL | let _: &'static u32 = &foo(); - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let _x: &'static u32 = &foo(); -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:9:29 - | -LL | let _x: &'static u32 = &foo(); - | ------------ ^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs index 6dcfcfe6780..ea35f46807a 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.rs @@ -5,6 +5,6 @@ extern crate stability; use stability::foo; fn main() { - let _: &'static u32 = &foo(); //~ ERROR does not live long enough - let _x: &'static u32 = &foo(); //~ ERROR does not live long enough + let _: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed + let _x: &'static u32 = &foo(); //~ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr index 516c008e720..129f0615107 100644 --- a/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr +++ b/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.stderr @@ -1,24 +1,24 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:8:28 | LL | let _: &'static u32 = &foo(); - | ^^^^^ temporary value does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | let _x: &'static u32 = &foo(); LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:9:29 | LL | let _x: &'static u32 = &foo(); - | ^^^^^ temporary value does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -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/consts/const-eval/promoted_const_fn_fail.nll.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr deleted file mode 100644 index 519ba7d84b0..00000000000 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail.rs:20:27 - | -LL | let x: &'static u8 = &(bar() + 1); - | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs index 80562b0ee83..88181cb8610 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs @@ -17,7 +17,7 @@ const fn bar() -> u8 { } fn main() { - let x: &'static u8 = &(bar() + 1); //~ ERROR does not live long enough + let x: &'static u8 = &(bar() + 1); //~ ERROR temporary value dropped while borrowed let y = *x; unreachable!(); } diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr index c9a357d0f1b..519ba7d84b0 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_fn_fail.rs:20:27 | LL | let x: &'static u8 = &(bar() + 1); - | ^^^^^^^^^^^ temporary value does not live long enough + | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement 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/consts/const-eval/promoted_const_fn_fail_deny_const_err.nll.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.nll.stderr deleted file mode 100644 index 987d2304ae8..00000000000 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_fn_fail_deny_const_err.rs:21:27 - | -LL | let x: &'static u8 = &(bar() + 1); - | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs index f331e44de17..061ab7eeb02 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.rs @@ -19,7 +19,7 @@ fn main() { // This will compile, but then hard-abort at runtime. // FIXME(oli-obk): this should instead panic (not hard-abort) at runtime. let x: &'static u8 = &(bar() + 1); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let y = *x; unreachable!(); } diff --git a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr index 9c786b0864c..987d2304ae8 100644 --- a/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr +++ b/src/test/ui/consts/const-eval/promoted_const_fn_fail_deny_const_err.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_const_fn_fail_deny_const_err.rs:21:27 | LL | let x: &'static u8 = &(bar() + 1); - | ^^^^^^^^^^^ temporary value does not live long enough + | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement 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/consts/const-eval/promoted_raw_ptr_ops.nll.stderr b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr deleted file mode 100644 index a8bb6976da7..00000000000 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr +++ /dev/null @@ -1,46 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:4:29 - | -LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:6:30 - | -LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); - | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:7:28 - | -LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let a: &'static bool = &(main as fn() == main as fn()); -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_raw_ptr_ops.rs:8:29 - | -LL | let a: &'static bool = &(main as fn() == main as fn()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs index ef7e5506f22..c6fb5eeab5a 100644 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs +++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs @@ -2,8 +2,11 @@ fn main() { let x: &'static bool = &(42 as *const i32 == 43 as *const i32); - //~^ ERROR does not live long enough - let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough - let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough - let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed + let y: &'static usize = &(&1 as *const i32 as usize + 1); + //~^ ERROR temporary value dropped while borrowed + let z: &'static i32 = &(unsafe { *(42 as *const i32) }); + //~^ ERROR temporary value dropped while borrowed + let a: &'static bool = &(main as fn() == main as fn()); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr index 5a0654cc0c1..7f2e4899184 100644 --- a/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr @@ -1,46 +1,47 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:4:29 | LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promoted_raw_ptr_ops.rs:6:30 | LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/promoted_raw_ptr_ops.rs:7:28 +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:8:28 | LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let a: &'static bool = &(main as fn() == main as fn()); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/promoted_raw_ptr_ops.rs:8:29 +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:10:29 | LL | let a: &'static bool = &(main as fn() == main as fn()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 4 previous errors -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/consts/const-eval/transmute-const-promotion.nll.stderr b/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr deleted file mode 100644 index 5aae8c12d16..00000000000 --- a/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/transmute-const-promotion.rs:6:37 - | -LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/transmute-const-promotion.rs b/src/test/ui/consts/const-eval/transmute-const-promotion.rs index a1da3503973..8bd1b341e6e 100644 --- a/src/test/ui/consts/const-eval/transmute-const-promotion.rs +++ b/src/test/ui/consts/const-eval/transmute-const-promotion.rs @@ -4,5 +4,5 @@ use std::mem; fn main() { let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; - //~^ ERROR value does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-eval/transmute-const-promotion.stderr b/src/test/ui/consts/const-eval/transmute-const-promotion.stderr index 5829a1772d6..5aae8c12d16 100644 --- a/src/test/ui/consts/const-eval/transmute-const-promotion.stderr +++ b/src/test/ui/consts/const-eval/transmute-const-promotion.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/transmute-const-promotion.rs:6:37 | LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; - | ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement 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/consts/const-eval/union_promotion.nll.stderr b/src/test/ui/consts/const-eval/union_promotion.nll.stderr deleted file mode 100644 index b530c02f2fb..00000000000 --- a/src/test/ui/consts/const-eval/union_promotion.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/union_promotion.rs:9:29 - | -LL | let x: &'static bool = &unsafe { - | ____________-------------____^ - | | | - | | type annotation requires that borrow lasts for `'static` -LL | | Foo { a: &1 }.b == Foo { a: &2 }.b -LL | | }; - | |_____^ creates a temporary which is freed while still in use -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-eval/union_promotion.rs b/src/test/ui/consts/const-eval/union_promotion.rs index c308c81cf64..d3566511ef8 100644 --- a/src/test/ui/consts/const-eval/union_promotion.rs +++ b/src/test/ui/consts/const-eval/union_promotion.rs @@ -6,7 +6,7 @@ union Foo { } fn main() { - let x: &'static bool = &unsafe { //~ borrowed value does not live long enough + let x: &'static bool = &unsafe { //~ temporary value dropped while borrowed Foo { a: &1 }.b == Foo { a: &2 }.b }; } diff --git a/src/test/ui/consts/const-eval/union_promotion.stderr b/src/test/ui/consts/const-eval/union_promotion.stderr index c60f6718183..b530c02f2fb 100644 --- a/src/test/ui/consts/const-eval/union_promotion.stderr +++ b/src/test/ui/consts/const-eval/union_promotion.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/union_promotion.rs:9:29 | LL | let x: &'static bool = &unsafe { - | _____________________________^ + | ____________-------------____^ + | | | + | | type annotation requires that borrow lasts for `'static` LL | | Foo { a: &1 }.b == Foo { a: &2 }.b LL | | }; - | |_____^ temporary value does not live long enough + | |_____^ creates a temporary which is freed while still in use LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement 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/consts/const-int-conversion.nll.stderr b/src/test/ui/consts/const-int-conversion.nll.stderr deleted file mode 100644 index 65330e282c9..00000000000 --- a/src/test/ui/consts/const-int-conversion.nll.stderr +++ /dev/null @@ -1,80 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:4:28 - | -LL | let x: &'static i32 = &(5_i32.reverse_bits()); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:6:28 - | -LL | let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:8:28 - | -LL | let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:10:28 - | -LL | let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:12:29 - | -LL | let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:14:29 - | -LL | let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-conversion.rs:16:29 - | -LL | let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-conversion.rs b/src/test/ui/consts/const-int-conversion.rs index 8f0aa141a9d..ea409439ed6 100644 --- a/src/test/ui/consts/const-int-conversion.rs +++ b/src/test/ui/consts/const-int-conversion.rs @@ -2,17 +2,17 @@ fn main() { let x: &'static i32 = &(5_i32.reverse_bits()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes()); - //~^ ERROR does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-conversion.stderr b/src/test/ui/consts/const-int-conversion.stderr index ddb1a75f1b7..65330e282c9 100644 --- a/src/test/ui/consts/const-int-conversion.stderr +++ b/src/test/ui/consts/const-int-conversion.stderr @@ -1,80 +1,80 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:4:28 | LL | let x: &'static i32 = &(5_i32.reverse_bits()); - | ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:6:28 | LL | let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:8:28 | LL | let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:10:28 | LL | let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:12:29 | LL | let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:14:29 | LL | let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-conversion.rs:16:29 | LL | let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 7 previous errors -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/consts/const-int-overflowing.nll.stderr b/src/test/ui/consts/const-int-overflowing.nll.stderr deleted file mode 100644 index bd061ab3331..00000000000 --- a/src/test/ui/consts/const-int-overflowing.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-overflowing.rs:2:36 - | -LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-overflowing.rs:3:36 - | -LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-overflowing.rs:4:36 - | -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); - | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-overflowing.rs b/src/test/ui/consts/const-int-overflowing.rs index 4e69e857806..cd74c999099 100644 --- a/src/test/ui/consts/const-int-overflowing.rs +++ b/src/test/ui/consts/const-int-overflowing.rs @@ -1,5 +1,8 @@ fn main() { - let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough - let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough - let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough + let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); + //~^ ERROR temporary value dropped while borrowed + let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); + //~^ ERROR temporary value dropped while borrowed + let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-overflowing.stderr b/src/test/ui/consts/const-int-overflowing.stderr index 7228b5dbd4b..56c7f7f092d 100644 --- a/src/test/ui/consts/const-int-overflowing.stderr +++ b/src/test/ui/consts/const-int-overflowing.stderr @@ -1,35 +1,36 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-overflowing.rs:2:36 | LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-overflowing.rs:3:36 - | -LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-overflowing.rs:4:36 | -LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-overflowing.rs:6:36 | - = note: borrowed value must be valid for the static lifetime... +LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | +LL | } + | - temporary value is freed at the end of this statement 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 E0716`. diff --git a/src/test/ui/consts/const-int-rotate.nll.stderr b/src/test/ui/consts/const-int-rotate.nll.stderr deleted file mode 100644 index 2b7cdf5746e..00000000000 --- a/src/test/ui/consts/const-int-rotate.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-rotate.rs:2:28 - | -LL | let x: &'static i32 = &(5_i32.rotate_left(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let y: &'static i32 = &(5_i32.rotate_right(3)); -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-rotate.rs:3:28 - | -LL | let y: &'static i32 = &(5_i32.rotate_right(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-rotate.rs b/src/test/ui/consts/const-int-rotate.rs index d07c00e0110..3aacf854db1 100644 --- a/src/test/ui/consts/const-int-rotate.rs +++ b/src/test/ui/consts/const-int-rotate.rs @@ -1,4 +1,6 @@ fn main() { - let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough - let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough + let x: &'static i32 = &(5_i32.rotate_left(3)); + //~^ ERROR temporary value dropped while borrowed + let y: &'static i32 = &(5_i32.rotate_right(3)); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-rotate.stderr b/src/test/ui/consts/const-int-rotate.stderr index ec08e0a3f57..ed265804bbc 100644 --- a/src/test/ui/consts/const-int-rotate.stderr +++ b/src/test/ui/consts/const-int-rotate.stderr @@ -1,24 +1,25 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-rotate.rs:2:28 | LL | let x: &'static i32 = &(5_i32.rotate_left(3)); - | ^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let y: &'static i32 = &(5_i32.rotate_right(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-rotate.rs:3:28 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-rotate.rs:4:28 | LL | let y: &'static i32 = &(5_i32.rotate_right(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -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/consts/const-int-sign.nll.stderr b/src/test/ui/consts/const-int-sign.nll.stderr deleted file mode 100644 index 0ad7a39d595..00000000000 --- a/src/test/ui/consts/const-int-sign.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-sign.rs:2:29 - | -LL | let x: &'static bool = &(5_i32.is_negative()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let y: &'static bool = &(5_i32.is_positive()); -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-sign.rs:3:29 - | -LL | let y: &'static bool = &(5_i32.is_positive()); - | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-sign.rs b/src/test/ui/consts/const-int-sign.rs index a21797c5ce4..c3111ddf56c 100644 --- a/src/test/ui/consts/const-int-sign.rs +++ b/src/test/ui/consts/const-int-sign.rs @@ -1,4 +1,6 @@ fn main() { - let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough - let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough + let x: &'static bool = &(5_i32.is_negative()); + //~^ ERROR temporary value dropped while borrowed + let y: &'static bool = &(5_i32.is_positive()); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-sign.stderr b/src/test/ui/consts/const-int-sign.stderr index ffe09a0cfec..5f8fd414180 100644 --- a/src/test/ui/consts/const-int-sign.stderr +++ b/src/test/ui/consts/const-int-sign.stderr @@ -1,24 +1,25 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-sign.rs:2:29 | LL | let x: &'static bool = &(5_i32.is_negative()); - | ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let y: &'static bool = &(5_i32.is_positive()); + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-sign.rs:3:29 +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-sign.rs:4:29 | LL | let y: &'static bool = &(5_i32.is_positive()); - | ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -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/consts/const-int-wrapping.nll.stderr b/src/test/ui/consts/const-int-wrapping.nll.stderr deleted file mode 100644 index a186854ce0c..00000000000 --- a/src/test/ui/consts/const-int-wrapping.nll.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:2:28 - | -LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:3:28 - | -LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:4:28 - | -LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:5:28 - | -LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-int-wrapping.rs:6:28 - | -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-int-wrapping.rs b/src/test/ui/consts/const-int-wrapping.rs index 720e40b6ebd..50d04f9641d 100644 --- a/src/test/ui/consts/const-int-wrapping.rs +++ b/src/test/ui/consts/const-int-wrapping.rs @@ -1,7 +1,12 @@ fn main() { - let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough - let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough - let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough - let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough - let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough + let x: &'static i32 = &(5_i32.wrapping_add(3)); + //~^ ERROR temporary value dropped while borrowed + let y: &'static i32 = &(5_i32.wrapping_sub(3)); + //~^ ERROR temporary value dropped while borrowed + let z: &'static i32 = &(5_i32.wrapping_mul(3)); + //~^ ERROR temporary value dropped while borrowed + let a: &'static i32 = &(5_i32.wrapping_shl(3)); + //~^ ERROR temporary value dropped while borrowed + let b: &'static i32 = &(5_i32.wrapping_shr(3)); + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-int-wrapping.stderr b/src/test/ui/consts/const-int-wrapping.stderr index 478a6d80838..5174b72659c 100644 --- a/src/test/ui/consts/const-int-wrapping.stderr +++ b/src/test/ui/consts/const-int-wrapping.stderr @@ -1,57 +1,58 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:2:28 | LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-wrapping.rs:3:28 - | -LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:4:28 | -LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough - --> $DIR/const-int-wrapping.rs:5:28 - | -LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-int-wrapping.rs:6:28 | -LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); - | ^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... LL | } - | - temporary value only lives until here + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:8:28 | - = note: borrowed value must be valid for the static lifetime... +LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:10:28 + | +LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | +LL | } + | - temporary value is freed at the end of this statement 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 E0716`. diff --git a/src/test/ui/consts/const-ptr-nonnull.nll.stderr b/src/test/ui/consts/const-ptr-nonnull.nll.stderr deleted file mode 100644 index 26946fb9902..00000000000 --- a/src/test/ui/consts/const-ptr-nonnull.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-ptr-nonnull.rs:4:37 - | -LL | let x: &'static NonNull = &(NonNull::dangling()); - | --------------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-ptr-nonnull.rs:9:37 - | -LL | let x: &'static NonNull = &(non_null.cast()); - | --------------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-ptr-nonnull.rs b/src/test/ui/consts/const-ptr-nonnull.rs index 54e743aa32e..25cf6cf4aaa 100644 --- a/src/test/ui/consts/const-ptr-nonnull.rs +++ b/src/test/ui/consts/const-ptr-nonnull.rs @@ -2,10 +2,10 @@ use std::ptr::NonNull; fn main() { let x: &'static NonNull = &(NonNull::dangling()); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed let mut i: i32 = 10; let non_null = NonNull::new(&mut i).unwrap(); let x: &'static NonNull = &(non_null.cast()); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-ptr-nonnull.stderr b/src/test/ui/consts/const-ptr-nonnull.stderr index a606bed1782..26946fb9902 100644 --- a/src/test/ui/consts/const-ptr-nonnull.stderr +++ b/src/test/ui/consts/const-ptr-nonnull.stderr @@ -1,25 +1,25 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-nonnull.rs:4:37 | LL | let x: &'static NonNull = &(NonNull::dangling()); - | ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | --------------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-nonnull.rs:9:37 | LL | let x: &'static NonNull = &(non_null.cast()); - | ^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | --------------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -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/consts/const-ptr-unique.nll.stderr b/src/test/ui/consts/const-ptr-unique.nll.stderr deleted file mode 100644 index 3644cf4cec7..00000000000 --- a/src/test/ui/consts/const-ptr-unique.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/const-ptr-unique.rs:8:33 - | -LL | let x: &'static *mut u32 = &(unique.as_ptr()); - | ----------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/const-ptr-unique.rs b/src/test/ui/consts/const-ptr-unique.rs index be44a241816..252c5d1a9cd 100644 --- a/src/test/ui/consts/const-ptr-unique.rs +++ b/src/test/ui/consts/const-ptr-unique.rs @@ -6,5 +6,5 @@ fn main() { let mut i: u32 = 10; let unique = Unique::new(&mut i).unwrap(); let x: &'static *mut u32 = &(unique.as_ptr()); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/const-ptr-unique.stderr b/src/test/ui/consts/const-ptr-unique.stderr index 482b78b2386..3644cf4cec7 100644 --- a/src/test/ui/consts/const-ptr-unique.stderr +++ b/src/test/ui/consts/const-ptr-unique.stderr @@ -1,14 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/const-ptr-unique.rs:8:33 | LL | let x: &'static *mut u32 = &(unique.as_ptr()); - | ^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ----------------- ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement 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/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr deleted file mode 100644 index 1ec93ce5c9e..00000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr +++ /dev/null @@ -1,298 +0,0 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:37:25 - | -LL | const fn into_inner(self) -> T { self.0 } - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:39:36 - | -LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:44:28 - | -LL | const fn into_inner_lt(self) -> T { self.0 } - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:46:42 - | -LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:51:27 - | -LL | const fn into_inner_s(self) -> T { self.0 } - | ^^^^ constant functions cannot evaluate destructors - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:53:38 - | -LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:58:39 - | -LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:76:16 - | -LL | const fn foo11(t: T) -> T { t } - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:78:18 - | -LL | const fn foo11_2(t: T) -> T { t } - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:80:33 - | -LL | const fn foo19(f: f32) -> f32 { f * 2.0 } - | ^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:82:35 - | -LL | const fn foo19_2(f: f32) -> f32 { 2.0 - f } - | ^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int and `bool` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:84:35 - | -LL | const fn foo19_3(f: f32) -> f32 { -f } - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: only int, `bool` and `char` operations are stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:86:43 - | -LL | const fn foo19_4(f: f32, g: f32) -> f32 { f / g } - | ^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: cannot access `static` items in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:90:27 - | -LL | const fn foo25() -> u32 { BAR } - | ^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: cannot access `static` items in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:91:36 - | -LL | const fn foo26() -> &'static u32 { &BAR } - | ^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:92:42 - | -LL | const fn foo30(x: *const u32) -> usize { x as usize } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:94:63 - | -LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:96:42 - | -LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: casting pointers to ints is unstable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:98:63 - | -LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } - | ^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:100:38 - | -LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } } - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:102:29 - | -LL | const fn foo30_5(b: bool) { while b { } } - | ^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:104:44 - | -LL | const fn foo36(a: bool, b: bool) -> bool { a && b } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn (see issue #57563) - --> $DIR/min_const_fn.rs:106:44 - | -LL | const fn foo37(a: bool, b: bool) -> bool { a || b } - | ^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: mutable references in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:108:14 - | -LL | const fn inc(x: &mut i32) { *x += 1 } - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:113:6 - | -LL | impl Foo { - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:118:6 - | -LL | impl Foo { - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:123:6 - | -LL | impl Foo { - | ^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `impl Trait` in const fn is unstable (see issue #57563) - --> $DIR/min_const_fn.rs:129:24 - | -LL | const fn no_rpit2() -> AlanTuring { AlanTuring(0) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:131:34 - | -LL | const fn no_apit2(_x: AlanTuring) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:133:22 - | -LL | const fn no_apit(_x: impl std::fmt::Debug) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: `impl Trait` in const fn is unstable (see issue #57563) - --> $DIR/min_const_fn.rs:134:23 - | -LL | const fn no_rpit() -> impl std::fmt::Debug {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:135:23 - | -LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:136:32 - | -LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -warning[E0515]: cannot return reference to temporary value - --> $DIR/min_const_fn.rs:136:63 - | -LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^-- - | || - | |temporary value created here - | returns a reference to data owned by the current function - | - = 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[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:141:41 - | -LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:144:21 - | -LL | const fn no_fn_ptrs(_x: fn()) {} - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:146:27 - | -LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } - | ^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error: aborting due to 36 previous errors - -Some errors have detailed explanations: E0515, E0723. -For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index ee3ffcd4026..881cbb14b53 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -135,6 +135,9 @@ const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } //~^ ERROR trait bounds other than `Sized` +//~| WARNING cannot return reference to temporary value +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future const fn no_unsafe() { unsafe {} } diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index b5f224c6400..e4b0d4ee9da 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -256,8 +256,20 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } | = help: add #![feature(const_fn)] to the crate attributes to enable +warning[E0515]: cannot return reference to temporary value + --> $DIR/min_const_fn.rs:136:63 + | +LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } + | ^-- + | || + | |temporary value created here + | returns a reference to data owned by the current function + | + = 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[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:141:41 + --> $DIR/min_const_fn.rs:144:41 | LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -265,7 +277,7 @@ LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } = help: add #![feature(const_fn)] to the crate attributes to enable error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:144:21 + --> $DIR/min_const_fn.rs:147:21 | LL | const fn no_fn_ptrs(_x: fn()) {} | ^^ @@ -273,7 +285,7 @@ LL | const fn no_fn_ptrs(_x: fn()) {} = help: add #![feature(const_fn)] to the crate attributes to enable error[E0723]: function pointers in const fn are unstable (see issue #57563) - --> $DIR/min_const_fn.rs:146:27 + --> $DIR/min_const_fn.rs:149:27 | LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } | ^^^^ @@ -282,4 +294,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } error: aborting due to 36 previous errors -For more information about this error, try `rustc --explain E0723`. +Some errors have detailed explanations: E0515, E0723. +For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr deleted file mode 100644 index dc7e92ad404..00000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn_dyn.rs:9:5 - | -LL | x.0.field; - | ^^^^^^^^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable (see issue #57563) - --> $DIR/min_const_fn_dyn.rs:12:66 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | ^^ - | - = help: add #![feature(const_fn)] to the crate attributes to enable - -warning[E0716]: temporary value dropped while borrowed - --> $DIR/min_const_fn_dyn.rs:12:67 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | -^ - temporary value is freed at the end of this statement - | || - | |creates a temporary which is freed while still in use - | cast requires that borrow lasts for `'static` - | - = 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: aborting due to 2 previous errors - -Some errors have detailed explanations: E0716, E0723. -For more information about an error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs index 6ca1e59b3af..75b67192f00 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs @@ -11,5 +11,8 @@ const fn no_inner_dyn_trait2(x: Hide) { } const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } //~^ ERROR trait bounds other than `Sized` +//~| WARNING temporary value dropped while borrowed +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future fn main() {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr index 8ff963722cf..dc7e92ad404 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr @@ -14,6 +14,19 @@ LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } | = help: add #![feature(const_fn)] to the crate attributes to enable +warning[E0716]: temporary value dropped while borrowed + --> $DIR/min_const_fn_dyn.rs:12:67 + | +LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } + | -^ - temporary value is freed at the end of this statement + | || + | |creates a temporary which is freed while still in use + | cast requires that borrow lasts for `'static` + | + = 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: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0723`. +Some errors have detailed explanations: E0716, E0723. +For more information about an error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/promotion.nll.stderr b/src/test/ui/consts/min_const_fn/promotion.nll.stderr deleted file mode 100644 index 550423c2d93..00000000000 --- a/src/test/ui/consts/min_const_fn/promotion.nll.stderr +++ /dev/null @@ -1,68 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:11:27 - | -LL | let x: &'static () = &foo1(); - | ----------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:12:28 - | -LL | let y: &'static i32 = &foo2(42); - | ------------ ^^^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:13:28 - | -LL | let z: &'static i32 = &foo3(); - | ------------ ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:14:34 - | -LL | let a: &'static Cell = &foo4(); - | ------------------ ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:15:42 - | -LL | let a: &'static Option> = &foo5(); - | -------------------------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | let a: &'static Option> = &foo6(); -LL | } - | - temporary value is freed at the end of this statement - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promotion.rs:16:42 - | -LL | let a: &'static Option> = &foo6(); - | -------------------------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/consts/min_const_fn/promotion.rs b/src/test/ui/consts/min_const_fn/promotion.rs index 969bf40a93b..fbe535c714b 100644 --- a/src/test/ui/consts/min_const_fn/promotion.rs +++ b/src/test/ui/consts/min_const_fn/promotion.rs @@ -8,10 +8,10 @@ const fn foo5() -> Option> { Some(Cell::new(42)) } const fn foo6() -> Option> { None } fn main() { - let x: &'static () = &foo1(); //~ ERROR does not live long enough - let y: &'static i32 = &foo2(42); //~ ERROR does not live long enough - let z: &'static i32 = &foo3(); //~ ERROR does not live long enough - let a: &'static Cell = &foo4(); //~ ERROR does not live long enough - let a: &'static Option> = &foo5(); //~ ERROR does not live long enough - let a: &'static Option> = &foo6(); //~ ERROR does not live long enough + let x: &'static () = &foo1(); //~ ERROR temporary value dropped while borrowed + let y: &'static i32 = &foo2(42); //~ ERROR temporary value dropped while borrowed + let z: &'static i32 = &foo3(); //~ ERROR temporary value dropped while borrowed + let a: &'static Cell = &foo4(); //~ ERROR temporary value dropped while borrowed + let a: &'static Option> = &foo5(); //~ ERROR temporary value dropped while borrowed + let a: &'static Option> = &foo6(); //~ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/consts/min_const_fn/promotion.stderr b/src/test/ui/consts/min_const_fn/promotion.stderr index 92d60f0c585..550423c2d93 100644 --- a/src/test/ui/consts/min_const_fn/promotion.stderr +++ b/src/test/ui/consts/min_const_fn/promotion.stderr @@ -1,68 +1,68 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:11:27 | LL | let x: &'static () = &foo1(); - | ^^^^^^ temporary value does not live long enough + | ----------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:12:28 | LL | let y: &'static i32 = &foo2(42); - | ^^^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:13:28 | LL | let z: &'static i32 = &foo3(); - | ^^^^^^ temporary value does not live long enough + | ------------ ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:14:34 | LL | let a: &'static Cell = &foo4(); - | ^^^^^^ temporary value does not live long enough + | ------------------ ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` ... LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:15:42 | LL | let a: &'static Option> = &foo5(); - | ^^^^^^ temporary value does not live long enough + | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | let a: &'static Option> = &foo6(); LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promotion.rs:16:42 | LL | let a: &'static Option> = &foo6(); - | ^^^^^^ temporary value does not live long enough + | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 6 previous errors -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/consts/promote_const_let.nll.stderr b/src/test/ui/consts/promote_const_let.nll.stderr deleted file mode 100644 index c47d297c904..00000000000 --- a/src/test/ui/consts/promote_const_let.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/promote_const_let.rs:4:9 - | -LL | let x: &'static u32 = { - | ------------ type annotation requires that `y` is borrowed for `'static` -LL | let y = 42; -LL | &y - | ^^ borrowed value does not live long enough -LL | }; - | - `y` dropped here while still borrowed - -error[E0716]: temporary value dropped while borrowed - --> $DIR/promote_const_let.rs:6:28 - | -LL | let x: &'static u32 = &{ - | ____________------------____^ - | | | - | | type annotation requires that borrow lasts for `'static` -LL | | let y = 42; -LL | | y -LL | | }; - | |_____^ creates a temporary which is freed while still in use -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0597, E0716. -For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/consts/promote_const_let.rs b/src/test/ui/consts/promote_const_let.rs index a8a6d4d99c6..51a0fec2e7b 100644 --- a/src/test/ui/consts/promote_const_let.rs +++ b/src/test/ui/consts/promote_const_let.rs @@ -3,7 +3,7 @@ fn main() { let y = 42; &y //~ ERROR does not live long enough }; - let x: &'static u32 = &{ //~ ERROR does not live long enough + let x: &'static u32 = &{ //~ ERROR temporary value dropped while borrowed let y = 42; y }; diff --git a/src/test/ui/consts/promote_const_let.stderr b/src/test/ui/consts/promote_const_let.stderr index c4295776d0a..c47d297c904 100644 --- a/src/test/ui/consts/promote_const_let.stderr +++ b/src/test/ui/consts/promote_const_let.stderr @@ -1,27 +1,29 @@ error[E0597]: `y` does not live long enough - --> $DIR/promote_const_let.rs:4:10 + --> $DIR/promote_const_let.rs:4:9 | +LL | let x: &'static u32 = { + | ------------ type annotation requires that `y` is borrowed for `'static` +LL | let y = 42; LL | &y - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `y` dropped here while still borrowed -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/promote_const_let.rs:6:28 | LL | let x: &'static u32 = &{ - | ____________________________^ + | ____________------------____^ + | | | + | | type annotation requires that borrow lasts for `'static` LL | | let y = 42; LL | | y LL | | }; - | |_____^ temporary value does not live long enough + | |_____^ creates a temporary which is freed while still in use LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors have detailed explanations: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/did_you_mean/issue-31424.nll.stderr b/src/test/ui/did_you_mean/issue-31424.nll.stderr deleted file mode 100644 index 147225f1be5..00000000000 --- a/src/test/ui/did_you_mean/issue-31424.nll.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable - --> $DIR/issue-31424.rs:7:9 - | -LL | (&mut self).bar(); - | ^^^^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -warning: function cannot return without recursing - --> $DIR/issue-31424.rs:12:5 - | -LL | fn bar(self: &mut Self) { - | ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -LL | -LL | (&mut self).bar(); - | ----------------- recursive call site - | - = note: #[warn(unconditional_recursion)] on by default - = help: a `loop` may express intention better if this is on purpose - -error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable - --> $DIR/issue-31424.rs:14:9 - | -LL | (&mut self).bar(); - | ^^^^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-31424.stderr b/src/test/ui/did_you_mean/issue-31424.stderr index 7c351ea9bfe..147225f1be5 100644 --- a/src/test/ui/did_you_mean/issue-31424.stderr +++ b/src/test/ui/did_you_mean/issue-31424.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable argument `self` as mutable - --> $DIR/issue-31424.rs:7:15 +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-31424.rs:7:9 | LL | (&mut self).bar(); - | ^^^^ - | | - | cannot reborrow mutably - | try removing `&mut` here + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here warning: function cannot return without recursing --> $DIR/issue-31424.rs:12:5 @@ -19,15 +19,14 @@ LL | (&mut self).bar(); = note: #[warn(unconditional_recursion)] on by default = help: a `loop` may express intention better if this is on purpose -error[E0596]: cannot borrow immutable argument `self` as mutable - --> $DIR/issue-31424.rs:14:15 +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-31424.rs:14:9 | LL | (&mut self).bar(); - | ^^^^ cannot borrow mutably -help: consider removing the `&mut`, as it is an immutable binding to a mutable reference - | -LL | self.bar(); - | ^^^^ + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to 2 previous errors diff --git a/src/test/ui/did_you_mean/issue-34126.nll.stderr b/src/test/ui/did_you_mean/issue-34126.nll.stderr deleted file mode 100644 index 0843df29b5c..00000000000 --- a/src/test/ui/did_you_mean/issue-34126.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable - --> $DIR/issue-34126.rs:6:18 - | -LL | self.run(&mut self); - | ^^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable - --> $DIR/issue-34126.rs:6:18 - | -LL | self.run(&mut self); - | ---- --- ^^^^^^^^^ mutable borrow occurs here - | | | - | | immutable borrow later used by call - | immutable borrow occurs here - -error: aborting due to 2 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/did_you_mean/issue-34126.rs b/src/test/ui/did_you_mean/issue-34126.rs index 15bef1ef815..4989577dbb6 100644 --- a/src/test/ui/did_you_mean/issue-34126.rs +++ b/src/test/ui/did_you_mean/issue-34126.rs @@ -4,6 +4,7 @@ impl Z { fn run(&self, z: &mut Z) { } fn start(&mut self) { self.run(&mut self); //~ ERROR cannot borrow + //~| ERROR cannot borrow } } diff --git a/src/test/ui/did_you_mean/issue-34126.stderr b/src/test/ui/did_you_mean/issue-34126.stderr index 536e295181a..0843df29b5c 100644 --- a/src/test/ui/did_you_mean/issue-34126.stderr +++ b/src/test/ui/did_you_mean/issue-34126.stderr @@ -1,12 +1,22 @@ -error[E0596]: cannot borrow immutable argument `self` as mutable - --> $DIR/issue-34126.rs:6:23 +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-34126.rs:6:18 | LL | self.run(&mut self); - | ^^^^ - | | - | cannot reborrow mutably - | try removing `&mut` here + | ^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here -error: aborting due to previous error +error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable + --> $DIR/issue-34126.rs:6:18 + | +LL | self.run(&mut self); + | ---- --- ^^^^^^^^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call + | immutable borrow occurs here -For more information about this error, try `rustc --explain E0596`. +error: aborting due to 2 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/did_you_mean/issue-34337.nll.stderr b/src/test/ui/did_you_mean/issue-34337.nll.stderr deleted file mode 100644 index 81f7b6dbf1b..00000000000 --- a/src/test/ui/did_you_mean/issue-34337.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `key` as mutable, as it is not declared as mutable - --> $DIR/issue-34337.rs:6:9 - | -LL | get(&mut key); - | ^^^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-34337.stderr b/src/test/ui/did_you_mean/issue-34337.stderr index 353f409b074..81f7b6dbf1b 100644 --- a/src/test/ui/did_you_mean/issue-34337.stderr +++ b/src/test/ui/did_you_mean/issue-34337.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `key` as mutable - --> $DIR/issue-34337.rs:6:14 +error[E0596]: cannot borrow `key` as mutable, as it is not declared as mutable + --> $DIR/issue-34337.rs:6:9 | LL | get(&mut key); - | ^^^ - | | - | cannot reborrow mutably - | try removing `&mut` here + | ^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/issue-35937.nll.stderr b/src/test/ui/did_you_mean/issue-35937.nll.stderr deleted file mode 100644 index 4f9b6a6134d..00000000000 --- a/src/test/ui/did_you_mean/issue-35937.nll.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0596]: cannot borrow `f.v` as mutable, as `f` is not declared as mutable - --> $DIR/issue-35937.rs:7:5 - | -LL | let f = Foo { v: Vec::new() }; - | - help: consider changing this to be mutable: `mut f` -LL | f.v.push("cat".to_string()); - | ^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable - --> $DIR/issue-35937.rs:16:5 - | -LL | let s = S { x: 42 }; - | - help: consider changing this to be mutable: `mut s` -LL | s.x += 1; - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable - --> $DIR/issue-35937.rs:20:5 - | -LL | fn bar(s: S) { - | - help: consider changing this to be mutable: `mut s` -LL | s.x += 1; - | ^^^^^^^^ cannot assign - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-35937.stderr b/src/test/ui/did_you_mean/issue-35937.stderr index ea0f5583a2b..4f9b6a6134d 100644 --- a/src/test/ui/did_you_mean/issue-35937.stderr +++ b/src/test/ui/did_you_mean/issue-35937.stderr @@ -1,26 +1,26 @@ -error[E0596]: cannot borrow field `f.v` of immutable binding as mutable +error[E0596]: cannot borrow `f.v` as mutable, as `f` is not declared as mutable --> $DIR/issue-35937.rs:7:5 | LL | let f = Foo { v: Vec::new() }; - | - help: make this binding mutable: `mut f` + | - help: consider changing this to be mutable: `mut f` LL | f.v.push("cat".to_string()); - | ^^^ cannot mutably borrow field of immutable binding + | ^^^ cannot borrow as mutable -error[E0594]: cannot assign to field `s.x` of immutable binding +error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable --> $DIR/issue-35937.rs:16:5 | LL | let s = S { x: 42 }; - | - help: make this binding mutable: `mut s` + | - help: consider changing this to be mutable: `mut s` LL | s.x += 1; - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot assign -error[E0594]: cannot assign to field `s.x` of immutable binding +error[E0594]: cannot assign to `s.x`, as `s` is not declared as mutable --> $DIR/issue-35937.rs:20:5 | LL | fn bar(s: S) { - | - help: make this binding mutable: `mut s` + | - help: consider changing this to be mutable: `mut s` LL | s.x += 1; - | ^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot assign error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/issue-37139.nll.stderr b/src/test/ui/did_you_mean/issue-37139.nll.stderr deleted file mode 100644 index 163817dd9bf..00000000000 --- a/src/test/ui/did_you_mean/issue-37139.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/issue-37139.rs:12:18 - | -LL | test(&mut x); - | ^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-37139.rs b/src/test/ui/did_you_mean/issue-37139.rs index b7f419ae4a6..07d855d0969 100644 --- a/src/test/ui/did_you_mean/issue-37139.rs +++ b/src/test/ui/did_you_mean/issue-37139.rs @@ -9,7 +9,7 @@ fn main() { let mut x = TestEnum::Item(10); match x { TestEnum::Item(ref mut x) => { - test(&mut x); //~ ERROR cannot borrow immutable + test(&mut x); //~ ERROR cannot borrow `x` as mutable, as it is not declared as mutable } } } diff --git a/src/test/ui/did_you_mean/issue-37139.stderr b/src/test/ui/did_you_mean/issue-37139.stderr index cd42ee8001a..163817dd9bf 100644 --- a/src/test/ui/did_you_mean/issue-37139.stderr +++ b/src/test/ui/did_you_mean/issue-37139.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> $DIR/issue-37139.rs:12:23 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/issue-37139.rs:12:18 | LL | test(&mut x); - | ^ - | | - | cannot reborrow mutably - | try removing `&mut` here + | ^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/issue-38147-1.nll.stderr b/src/test/ui/did_you_mean/issue-38147-1.nll.stderr deleted file mode 100644 index 6efac371c02..00000000000 --- a/src/test/ui/did_you_mean/issue-38147-1.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-1.rs:17:9 - | -LL | fn f(&self) { - | ----- help: consider changing this to be a mutable reference: `&mut self` -LL | self.s.push('x'); - | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-1.rs b/src/test/ui/did_you_mean/issue-38147-1.rs index b67239619d9..c068a1834f3 100644 --- a/src/test/ui/did_you_mean/issue-38147-1.rs +++ b/src/test/ui/did_you_mean/issue-38147-1.rs @@ -14,7 +14,7 @@ struct Foo<'a> { impl<'a> Foo<'a> { fn f(&self) { - self.s.push('x'); //~ ERROR cannot borrow data mutably + self.s.push('x'); //~ cannot borrow `*self.s` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/did_you_mean/issue-38147-1.stderr b/src/test/ui/did_you_mean/issue-38147-1.stderr index 4311836be34..6efac371c02 100644 --- a/src/test/ui/did_you_mean/issue-38147-1.stderr +++ b/src/test/ui/did_you_mean/issue-38147-1.stderr @@ -1,11 +1,11 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-1.rs:17:9 | LL | fn f(&self) { - | ----- use `&mut self` here to make mutable + | ----- help: consider changing this to be a mutable reference: `&mut self` LL | self.s.push('x'); - | ^^^^^^ assignment into an immutable reference + | ^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-2.nll.stderr b/src/test/ui/did_you_mean/issue-38147-2.nll.stderr deleted file mode 100644 index cb498108931..00000000000 --- a/src/test/ui/did_you_mean/issue-38147-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-2.rs:7:9 - | -LL | s: &'a String - | ---------- help: consider changing this to be mutable: `&'a mut String` -... -LL | self.s.push('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/did_you_mean/issue-38147-2.rs b/src/test/ui/did_you_mean/issue-38147-2.rs index e43ebf9d261..fe2634d88ab 100644 --- a/src/test/ui/did_you_mean/issue-38147-2.rs +++ b/src/test/ui/did_you_mean/issue-38147-2.rs @@ -5,7 +5,7 @@ struct Bar<'a> { impl<'a> Bar<'a> { fn f(&mut self) { self.s.push('x'); - //~^ ERROR cannot borrow borrowed content `*self.s` of immutable binding as mutable + //~^ ERROR cannot borrow `*self.s` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/did_you_mean/issue-38147-2.stderr b/src/test/ui/did_you_mean/issue-38147-2.stderr index fa4fccb8d27..cb498108931 100644 --- a/src/test/ui/did_you_mean/issue-38147-2.stderr +++ b/src/test/ui/did_you_mean/issue-38147-2.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow borrowed content `*self.s` of immutable binding as mutable +error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-2.rs:7:9 | LL | s: &'a String - | ---------- use `&'a mut String` here to make mutable + | ---------- help: consider changing this to be mutable: `&'a mut String` ... LL | self.s.push('x'); | ^^^^^^ cannot borrow as mutable diff --git a/src/test/ui/did_you_mean/issue-38147-3.nll.stderr b/src/test/ui/did_you_mean/issue-38147-3.nll.stderr deleted file mode 100644 index 67782578a2c..00000000000 --- a/src/test/ui/did_you_mean/issue-38147-3.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-3.rs:7:9 - | -LL | s: &'a String - | ---------- help: consider changing this to be mutable: `&'a mut String` -... -LL | self.s.push('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/did_you_mean/issue-38147-3.rs b/src/test/ui/did_you_mean/issue-38147-3.rs index 4cd703f2f61..40b8e0dba26 100644 --- a/src/test/ui/did_you_mean/issue-38147-3.rs +++ b/src/test/ui/did_you_mean/issue-38147-3.rs @@ -5,7 +5,7 @@ struct Qux<'a> { impl<'a> Qux<'a> { fn f(&self) { self.s.push('x'); - //~^ ERROR cannot borrow borrowed content `*self.s` of immutable binding as mutable + //~^ ERROR cannot borrow `*self.s` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/did_you_mean/issue-38147-3.stderr b/src/test/ui/did_you_mean/issue-38147-3.stderr index 2cb9835278d..67782578a2c 100644 --- a/src/test/ui/did_you_mean/issue-38147-3.stderr +++ b/src/test/ui/did_you_mean/issue-38147-3.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow borrowed content `*self.s` of immutable binding as mutable +error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-3.rs:7:9 | LL | s: &'a String - | ---------- use `&'a mut String` here to make mutable + | ---------- help: consider changing this to be mutable: `&'a mut String` ... LL | self.s.push('x'); | ^^^^^^ cannot borrow as mutable diff --git a/src/test/ui/did_you_mean/issue-38147-4.nll.stderr b/src/test/ui/did_you_mean/issue-38147-4.nll.stderr deleted file mode 100644 index db3e6b89426..00000000000 --- a/src/test/ui/did_you_mean/issue-38147-4.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference - --> $DIR/issue-38147-4.rs:6:5 - | -LL | fn f(x: usize, f: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut Foo<'_>` -LL | f.s.push('x'); - | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-38147-4.rs b/src/test/ui/did_you_mean/issue-38147-4.rs index 26573d4fdde..e2028a9e67b 100644 --- a/src/test/ui/did_you_mean/issue-38147-4.rs +++ b/src/test/ui/did_you_mean/issue-38147-4.rs @@ -3,7 +3,7 @@ struct Foo<'a> { } fn f(x: usize, f: &Foo) { - f.s.push('x'); //~ ERROR cannot borrow data mutably + f.s.push('x'); //~ ERROR cannot borrow `*f.s` as mutable, as it is behind a `&` reference } fn main() {} diff --git a/src/test/ui/did_you_mean/issue-38147-4.stderr b/src/test/ui/did_you_mean/issue-38147-4.stderr index 71d44f9abad..db3e6b89426 100644 --- a/src/test/ui/did_you_mean/issue-38147-4.stderr +++ b/src/test/ui/did_you_mean/issue-38147-4.stderr @@ -1,11 +1,11 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `*f.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-4.rs:6:5 | LL | fn f(x: usize, f: &Foo) { - | ---- use `&mut Foo` here to make mutable + | ---- help: consider changing this to be a mutable reference: `&mut Foo<'_>` LL | f.s.push('x'); - | ^^^ assignment into an immutable reference + | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-39544.nll.stderr b/src/test/ui/did_you_mean/issue-39544.nll.stderr deleted file mode 100644 index dfaaf6b17dc..00000000000 --- a/src/test/ui/did_you_mean/issue-39544.nll.stderr +++ /dev/null @@ -1,101 +0,0 @@ -error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable - --> $DIR/issue-39544.rs:11:13 - | -LL | let z = Z { x: X::Y }; - | - help: consider changing this to be mutable: `mut z` -LL | let _ = &mut z.x; - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:16:17 - | -LL | fn foo<'z>(&'z self) { - | -------- help: consider changing this to be a mutable reference: `&'z mut self` -LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:20:17 - | -LL | fn foo1(&self, other: &Z) { - | ----- help: consider changing this to be a mutable reference: `&mut self` -LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:21:17 - | -LL | fn foo1(&self, other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut self.x; -LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:25:17 - | -LL | fn foo2<'a>(&'a self, other: &Z) { - | -------- help: consider changing this to be a mutable reference: `&'a mut self` -LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:26:17 - | -LL | fn foo2<'a>(&'a self, other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut self.x; -LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:30:17 - | -LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -------- help: consider changing this to be a mutable reference: `&'a mut Self` -LL | let _ = &mut self.x; - | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:31:17 - | -LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut self.x; -LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:35:17 - | -LL | fn foo4(other: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut other.x; - | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable - --> $DIR/issue-39544.rs:41:13 - | -LL | pub fn with_arg(z: Z, w: &Z) { - | - help: consider changing this to be mutable: `mut z` -LL | let _ = &mut z.x; - | ^^^^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference - --> $DIR/issue-39544.rs:42:13 - | -LL | pub fn with_arg(z: Z, w: &Z) { - | -- help: consider changing this to be a mutable reference: `&mut Z` -LL | let _ = &mut z.x; -LL | let _ = &mut w.x; - | ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0594]: cannot assign to `*x.0` which is behind a `&` reference - --> $DIR/issue-39544.rs:48:5 - | -LL | *x.0 = 1; - | ^^^^^^^^ cannot assign - -error: aborting due to 12 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-39544.rs b/src/test/ui/did_you_mean/issue-39544.rs index 89696a06aaa..3c86f29a89c 100644 --- a/src/test/ui/did_you_mean/issue-39544.rs +++ b/src/test/ui/did_you_mean/issue-39544.rs @@ -46,5 +46,5 @@ pub fn with_tuple() { let mut y = 0; let x = (&y,); *x.0 = 1; - //~^ ERROR cannot assign to borrowed content `*x.0` of immutable binding + //~^ ERROR cannot assign to `*x.0` which is behind a `&` reference } diff --git a/src/test/ui/did_you_mean/issue-39544.stderr b/src/test/ui/did_you_mean/issue-39544.stderr index 2e2a665f092..dfaaf6b17dc 100644 --- a/src/test/ui/did_you_mean/issue-39544.stderr +++ b/src/test/ui/did_you_mean/issue-39544.stderr @@ -1,100 +1,100 @@ -error[E0596]: cannot borrow field `z.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:11:18 +error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable + --> $DIR/issue-39544.rs:11:13 | LL | let z = Z { x: X::Y }; - | - help: make this binding mutable: `mut z` + | - help: consider changing this to be mutable: `mut z` LL | let _ = &mut z.x; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:16:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:16:17 | LL | fn foo<'z>(&'z self) { - | -------- use `&'z mut self` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&'z mut self` LL | let _ = &mut self.x; - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:20:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:20:17 | LL | fn foo1(&self, other: &Z) { - | ----- use `&mut self` here to make mutable + | ----- help: consider changing this to be a mutable reference: `&mut self` LL | let _ = &mut self.x; - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:21:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:21:17 | LL | fn foo1(&self, other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut self.x; LL | let _ = &mut other.x; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:25:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:25:17 | LL | fn foo2<'a>(&'a self, other: &Z) { - | -------- use `&'a mut self` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&'a mut self` LL | let _ = &mut self.x; - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:26:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:26:17 | LL | fn foo2<'a>(&'a self, other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut self.x; LL | let _ = &mut other.x; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `self.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:30:22 +error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:30:17 | LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -------- use `&'a mut Self` here to make mutable + | -------- help: consider changing this to be a mutable reference: `&'a mut Self` LL | let _ = &mut self.x; - | ^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:31:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:31:17 | LL | fn foo3<'a>(self: &'a Self, other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut self.x; LL | let _ = &mut other.x; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `other.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:35:22 +error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:35:17 | LL | fn foo4(other: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut other.x; - | ^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `z.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:41:18 +error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable + --> $DIR/issue-39544.rs:41:13 | LL | pub fn with_arg(z: Z, w: &Z) { - | - help: make this binding mutable: `mut z` + | - help: consider changing this to be mutable: `mut z` LL | let _ = &mut z.x; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow field `w.x` of immutable binding as mutable - --> $DIR/issue-39544.rs:42:18 +error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference + --> $DIR/issue-39544.rs:42:13 | LL | pub fn with_arg(z: Z, w: &Z) { - | -- use `&mut Z` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut Z` LL | let _ = &mut z.x; LL | let _ = &mut w.x; - | ^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0594]: cannot assign to borrowed content `*x.0` of immutable binding +error[E0594]: cannot assign to `*x.0` which is behind a `&` reference --> $DIR/issue-39544.rs:48:5 | LL | *x.0 = 1; - | ^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^ cannot assign error: aborting due to 12 previous errors diff --git a/src/test/ui/did_you_mean/issue-40823.nll.stderr b/src/test/ui/did_you_mean/issue-40823.nll.stderr deleted file mode 100644 index 73473406a9a..00000000000 --- a/src/test/ui/did_you_mean/issue-40823.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference - --> $DIR/issue-40823.rs:3:5 - | -LL | let mut buf = &[1, 2, 3, 4]; - | ------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4]` -LL | buf.iter_mut(); - | ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/did_you_mean/issue-40823.rs b/src/test/ui/did_you_mean/issue-40823.rs index 7e456a354b3..0f8c7455467 100644 --- a/src/test/ui/did_you_mean/issue-40823.rs +++ b/src/test/ui/did_you_mean/issue-40823.rs @@ -1,4 +1,4 @@ fn main() { let mut buf = &[1, 2, 3, 4]; - buf.iter_mut(); //~ ERROR cannot borrow immutable borrowed content + buf.iter_mut(); //~ ERROR cannot borrow `*buf` as mutable, as it is behind a `&` reference } diff --git a/src/test/ui/did_you_mean/issue-40823.stderr b/src/test/ui/did_you_mean/issue-40823.stderr index fa2150a8d7f..73473406a9a 100644 --- a/src/test/ui/did_you_mean/issue-40823.stderr +++ b/src/test/ui/did_you_mean/issue-40823.stderr @@ -1,8 +1,10 @@ -error[E0596]: cannot borrow immutable borrowed content `*buf` as mutable +error[E0596]: cannot borrow `*buf` as mutable, as it is behind a `&` reference --> $DIR/issue-40823.rs:3:5 | +LL | let mut buf = &[1, 2, 3, 4]; + | ------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4]` LL | buf.iter_mut(); - | ^^^ cannot borrow as mutable + | ^^^ `buf` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.nll.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.nll.stderr deleted file mode 100644 index fff3a64ff29..00000000000 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:22 - | -LL | let X { x: y } = x; - | - ^ cannot move out of here - | | - | data moved here - | -note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:16 - | -LL | let X { x: y } = x; - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr index 9984cac7a4a..fff3a64ff29 100644 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr +++ b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-let.stderr @@ -1,11 +1,16 @@ error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:9 + --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:22 | LL | let X { x: y } = x; - | ^^^^^^^-^^ - | | | - | | hint: to prevent move, use `ref y` or `ref mut y` - | cannot move out of here + | - ^ cannot move out of here + | | + | data moved here + | +note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/disallowed-deconstructing-destructing-struct-let.rs:12:16 + | +LL | let X { x: y } = x; + | ^ error: aborting due to previous error diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.nll.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.nll.stderr deleted file mode 100644 index 2143c2f9b22..00000000000 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:14:11 - | -LL | match x { - | ^ cannot move out of here -LL | X { x: y } => println!("contents: {}", y) - | - data moved here - | -note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait - --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:15:16 - | -LL | X { x: y } => println!("contents: {}", y) - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs index 3a5ed6e3b3e..9c996a93b95 100644 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs +++ b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.rs @@ -12,7 +12,7 @@ fn main() { let x = X { x: "hello".to_string() }; match x { + //~^ ERROR cannot move out of type `X`, which implements the `Drop` trait X { x: y } => println!("contents: {}", y) - //~^ ERROR cannot move out of type `X`, which implements the `Drop` trait } } diff --git a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr index 8be1b385afe..762f64b8b2a 100644 --- a/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr +++ b/src/test/ui/disallowed-deconstructing/disallowed-deconstructing-destructing-struct-match.stderr @@ -1,11 +1,17 @@ error[E0509]: cannot move out of type `X`, which implements the `Drop` trait - --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:15:9 + --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:14:11 + | +LL | match x { + | ^ cannot move out of here +LL | +LL | X { x: y } => println!("contents: {}", y) + | - data moved here + | +note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + --> $DIR/disallowed-deconstructing-destructing-struct-match.rs:16:16 | LL | X { x: y } => println!("contents: {}", y) - | ^^^^^^^-^^ - | | | - | | hint: to prevent move, use `ref y` or `ref mut y` - | cannot move out of here + | ^ error: aborting due to previous error diff --git a/src/test/ui/dropck/drop-with-active-borrows-1.nll.stderr b/src/test/ui/dropck/drop-with-active-borrows-1.nll.stderr deleted file mode 100644 index 7fed27adaff..00000000000 --- a/src/test/ui/dropck/drop-with-active-borrows-1.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/drop-with-active-borrows-1.rs:4:10 - | -LL | let b: Vec<&str> = a.lines().collect(); - | - borrow of `a` occurs here -LL | drop(a); - | ^ move out of `a` occurs here -LL | for s in &b { - | -- 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/dropck/drop-with-active-borrows-1.stderr b/src/test/ui/dropck/drop-with-active-borrows-1.stderr index 71960fcecb5..7fed27adaff 100644 --- a/src/test/ui/dropck/drop-with-active-borrows-1.stderr +++ b/src/test/ui/dropck/drop-with-active-borrows-1.stderr @@ -5,6 +5,8 @@ LL | let b: Vec<&str> = a.lines().collect(); | - borrow of `a` occurs here LL | drop(a); | ^ move out of `a` occurs here +LL | for s in &b { + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr b/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr deleted file mode 100644 index ffec9306b77..00000000000 --- a/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local variable `raw_lines` - --> $DIR/drop-with-active-borrows-2.rs:3:5 - | -LL | raw_lines.iter().map(|l| l.trim()).collect() - | ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | returns a value referencing data owned by the current function - | `raw_lines` 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/dropck/drop-with-active-borrows-2.rs b/src/test/ui/dropck/drop-with-active-borrows-2.rs index 4e45633a281..cf4cb3dbe7a 100644 --- a/src/test/ui/dropck/drop-with-active-borrows-2.rs +++ b/src/test/ui/dropck/drop-with-active-borrows-2.rs @@ -1,7 +1,7 @@ fn read_lines_borrowed<'a>() -> Vec<&'a str> { let raw_lines: Vec = vec!["foo ".to_string(), " bar".to_string()]; raw_lines.iter().map(|l| l.trim()).collect() - //~^ ERROR `raw_lines` does not live long enough + //~^ ERROR cannot return value referencing local variable `raw_lines` } fn main() { diff --git a/src/test/ui/dropck/drop-with-active-borrows-2.stderr b/src/test/ui/dropck/drop-with-active-borrows-2.stderr index ef46c9276be..ffec9306b77 100644 --- a/src/test/ui/dropck/drop-with-active-borrows-2.stderr +++ b/src/test/ui/dropck/drop-with-active-borrows-2.stderr @@ -1,18 +1,12 @@ -error[E0597]: `raw_lines` does not live long enough +error[E0515]: cannot return value referencing local variable `raw_lines` --> $DIR/drop-with-active-borrows-2.rs:3:5 | LL | raw_lines.iter().map(|l| l.trim()).collect() - | ^^^^^^^^^ borrowed value does not live long enough -LL | -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 1:24... - --> $DIR/drop-with-active-borrows-2.rs:1:24 - | -LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { - | ^^ + | ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `raw_lines` 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/dropck/dropck-eyepatch-extern-crate.ast.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr deleted file mode 100644 index 31adb2f3f14..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:41:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:43:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:47:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:50:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:57:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:59:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr deleted file mode 100644 index e0b7fc4eb90..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-extern-crate.rs:47:19 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c_shortest` dropped here while still borrowed - | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `other::Dt` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs index 68065639398..b8f30355413 100644 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs +++ b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs @@ -1,13 +1,3 @@ -// The behavior of AST-borrowck and NLL explcitly differ here due to -// NLL's increased precision; so we use revisions and do not worry -// about the --compare-mode=nll on this test. - -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// ignore-compare-mode-nll - // aux-build:dropck_eyepatch_extern_crate.rs // The point of this test is to illustrate that the `#[may_dangle]` @@ -19,52 +9,74 @@ // // See also dropck-eyepatch.rs for more information about the general // structure of the test. -#![feature(rustc_attrs)] extern crate dropck_eyepatch_extern_crate as other; use other::{Dt,Dr,Pt,Pr,St,Sr}; -fn main() { #![rustc_error] // rust-lang/rust#49855 +fn main() { use std::cell::Cell; - let c_long; - let (c, mut dt, mut dr, mut pt, mut pr, st, sr, c_shortest) - : (Cell<_>, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>, Cell<_>); - c_long = Cell::new(1); - c = Cell::new(1); - c_shortest = Cell::new(1); - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long); - dr = Dr("dr", &c_long); + // We use separate blocks with separate variable to prevent the error + // messages from being deduplicated. - // Error: destructor order imprecisely modelled - dt = Dt("dt", &c); - //[ast]~^ ERROR `c` does not live long enough - dr = Dr("dr", &c); - //[ast]~^ ERROR `c` does not live long enough + { + let c_long; + let (mut dt, mut dr): (Dt<_>, Dr<_>); + c_long = Cell::new(1); - // Error: `c_shortest` dies too soon for the references in dtors to be valid. - dt = Dt("dt", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - //[nll]~^^ ERROR `c_shortest` does not live long enough - dr = Dr("dr", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c_shortest, &c_long); - pr = Pr("pr", &c_shortest, &c_long); + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long); + dr = Dr("dr", &c_long); + } - // Error: Drop impl's assertion does not apply to `B` nor `&'b _` - pt = Pt("pt", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - pr = Pr("pr", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough + { + let (c, mut dt, mut dr): (Cell<_>, Dt<_>, Dr<_>); + c = Cell::new(1); - // No error: St and Sr have no destructor. - st = St("st", &c_shortest); - sr = Sr("sr", &c_shortest); + // No Error: destructor order precisely modelled + dt = Dt("dt", &c); + dr = Dr("dr", &c); + } - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); + { + let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + c_shortest = Cell::new(1); + + // Error: `c_shortest` dies too soon for the references in dtors to be valid. + dt = Dt("dt", &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + dr = Dr("dr", &c_shortest); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c_shortest, &c_long); + pr = Pr("pr", &c_shortest, &c_long); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + // Error: Drop impl's assertion does not apply to `B` nor `&'b _` + pt = Pt("pt", &c_long, &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + pr = Pr("pr", &c_long, &c_shortest); + } + + { + let (st, sr, c_shortest): (St<_>, Sr<_>, Cell<_>); + c_shortest = Cell::new(1); + // No error: St and Sr have no destructor. + st = St("st", &c_shortest); + sr = Sr("sr", &c_shortest); + } } fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr b/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr new file mode 100644 index 00000000000..c10232107e8 --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr @@ -0,0 +1,31 @@ +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:46:23 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `other::Dt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-extern-crate.rs:68:32 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `pt` is dropped and runs the `Drop` code for type `other::Pt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr deleted file mode 100644 index ddd47e97434..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:58:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:60:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:64:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:67:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:74:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:76:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr deleted file mode 100644 index 97c1caa87f5..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch-reorder.rs:64:19 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c_shortest` dropped here while still borrowed - | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.rs b/src/test/ui/dropck/dropck-eyepatch-reorder.rs index 16aaa261257..44552b3fc1d 100644 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.rs +++ b/src/test/ui/dropck/dropck-eyepatch-reorder.rs @@ -1,14 +1,4 @@ -// The behavior of AST-borrowck and NLL explcitly differ here due to -// NLL's increased precision; so we use revisions and do not worry -// about the --compare-mode=nll on this test. - -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// ignore-compare-mode-nll - -#![feature(dropck_eyepatch, rustc_attrs)] +#![feature(dropck_eyepatch)] // The point of this test is to test uses of `#[may_dangle]` attribute // where the formal declaration order (in the impl generics) does not @@ -41,47 +31,70 @@ unsafe impl<'b, #[may_dangle] 'a, B: fmt::Debug> Drop for Pr<'a, 'b, B> { fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } } -fn main() { #![rustc_error] // rust-lang/rust#49855 +fn main() { use std::cell::Cell; - let c_long; - let (c, mut dt, mut dr, mut pt, mut pr, st, sr, c_shortest) - : (Cell<_>, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>, Cell<_>); - c_long = Cell::new(1); - c = Cell::new(1); - c_shortest = Cell::new(1); - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long); - dr = Dr("dr", &c_long); + // We use separate blocks with separate variable to prevent the error + // messages from being deduplicated. - // Error: destructor order imprecisely modelled - dt = Dt("dt", &c); - //[ast]~^ ERROR `c` does not live long enough - dr = Dr("dr", &c); - //[ast]~^ ERROR `c` does not live long enough + { + let c_long; + let (mut dt, mut dr): (Dt<_>, Dr<_>); + c_long = Cell::new(1); - // Error: `c_shortest` dies too soon for the references in dtors to be valid. - dt = Dt("dt", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - //[nll]~^^ ERROR `c_shortest` does not live long enough - dr = Dr("dr", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c_shortest, &c_long); - pr = Pr("pr", &c_shortest, &c_long); + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long); + dr = Dr("dr", &c_long); + } - // Error: Drop impl's assertion does not apply to `B` nor `&'b _` - pt = Pt("pt", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - pr = Pr("pr", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough + { + let (c, mut dt, mut dr): (Cell<_>, Dt<_>, Dr<_>); + c = Cell::new(1); - // No error: St and Sr have no destructor. - st = St("st", &c_shortest); - sr = Sr("sr", &c_shortest); + // No Error: destructor order precisely modelled + dt = Dt("dt", &c); + dr = Dr("dr", &c); + } - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); + { + let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + c_shortest = Cell::new(1); + + // Error: `c_shortest` dies too soon for the references in dtors to be valid. + dt = Dt("dt", &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + dr = Dr("dr", &c_shortest); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c_shortest, &c_long); + pr = Pr("pr", &c_shortest, &c_long); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + // Error: Drop impl's assertion does not apply to `B` nor `&'b _` + pt = Pt("pt", &c_long, &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + pr = Pr("pr", &c_long, &c_shortest); + } + + { + let (st, sr, c_shortest): (St<_>, Sr<_>, Cell<_>); + c_shortest = Cell::new(1); + // No error: St and Sr have no destructor. + st = St("st", &c_shortest); + sr = Sr("sr", &c_shortest); + } } fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.stderr b/src/test/ui/dropck/dropck-eyepatch-reorder.stderr new file mode 100644 index 00000000000..5055cdd8b2b --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch-reorder.stderr @@ -0,0 +1,31 @@ +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:64:23 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch-reorder.rs:86:32 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `pt` is dropped and runs the `Drop` code for type `Pt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.ast.stderr b/src/test/ui/dropck/dropck-eyepatch.ast.stderr deleted file mode 100644 index 0952ed0d6b7..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch.ast.stderr +++ /dev/null @@ -1,69 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch.rs:81:20 - | -LL | dt = Dt("dt", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c` does not live long enough - --> $DIR/dropck-eyepatch.rs:83:20 - | -LL | dr = Dr("dr", &c); - | ^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:87:20 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:90:20 - | -LL | dr = Dr("dr", &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:98:29 - | -LL | pt = Pt("pt", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:100:29 - | -LL | pr = Pr("pr", &c_long, &c_shortest); - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `c_shortest` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.nll.stderr b/src/test/ui/dropck/dropck-eyepatch.nll.stderr deleted file mode 100644 index 4a6e42ef94a..00000000000 --- a/src/test/ui/dropck/dropck-eyepatch.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `c_shortest` does not live long enough - --> $DIR/dropck-eyepatch.rs:87:19 - | -LL | dt = Dt("dt", &c_shortest); - | ^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c_shortest` dropped here while still borrowed - | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-eyepatch.rs b/src/test/ui/dropck/dropck-eyepatch.rs index fb1c03b6786..ec1c6856138 100644 --- a/src/test/ui/dropck/dropck-eyepatch.rs +++ b/src/test/ui/dropck/dropck-eyepatch.rs @@ -1,14 +1,4 @@ -// The behavior of AST-borrowck and NLL explcitly differ here due to -// NLL's increased precision; so we use revisions and do not worry -// about the --compare-mode=nll on this test. - -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// ignore-compare-mode-nll - -#![feature(dropck_eyepatch, rustc_attrs)] +#![feature(dropck_eyepatch)] // The point of this test is to illustrate that the `#[may_dangle]` // attribute specifically allows, in the context of a type @@ -64,48 +54,70 @@ unsafe impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> { fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } } -fn main() { #![rustc_error] // rust-lang/rust#49855 + +fn main() { use std::cell::Cell; - let c_long; - let (c, mut dt, mut dr, mut pt, mut pr, st, sr, c_shortest) - : (Cell<_>, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>, Cell<_>); - c_long = Cell::new(1); - c = Cell::new(1); - c_shortest = Cell::new(1); - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long); - dr = Dr("dr", &c_long); + // We use separate blocks with separate variable to prevent the error + // messages from being deduplicated. - // Error: destructor order imprecisely modelled - dt = Dt("dt", &c); - //[ast]~^ ERROR `c` does not live long enough - dr = Dr("dr", &c); - //[ast]~^ ERROR `c` does not live long enough + { + let c_long; + let (mut dt, mut dr): (Dt<_>, Dr<_>); + c_long = Cell::new(1); - // Error: `c_shortest` dies too soon for the references in dtors to be valid. - dt = Dt("dt", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - //[nll]~^^ ERROR `c_shortest` does not live long enough - dr = Dr("dr", &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long); + dr = Dr("dr", &c_long); + } - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c_shortest, &c_long); - pr = Pr("pr", &c_shortest, &c_long); + { + let (c, mut dt, mut dr): (Cell<_>, Dt<_>, Dr<_>); + c = Cell::new(1); - // Error: Drop impl's assertion does not apply to `B` nor `&'b _` - pt = Pt("pt", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough - pr = Pr("pr", &c_long, &c_shortest); - //[ast]~^ ERROR `c_shortest` does not live long enough + // No Error: destructor order precisely modelled + dt = Dt("dt", &c); + dr = Dr("dr", &c); + } - // No error: St and Sr have no destructor. - st = St("st", &c_shortest); - sr = Sr("sr", &c_shortest); + { + let (mut dt, mut dr, c_shortest): (Dt<_>, Dr<_>, Cell<_>); + c_shortest = Cell::new(1); - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - use_imm(sr.1); use_imm(st.1); use_imm(pr.1); use_imm(pt.1); use_imm(dr.1); use_imm(dt.1); + // Error: `c_shortest` dies too soon for the references in dtors to be valid. + dt = Dt("dt", &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + dr = Dr("dr", &c_shortest); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c_shortest, &c_long); + pr = Pr("pr", &c_shortest, &c_long); + } + + { + let c_long; + let (mut pt, mut pr, c_shortest): (Pt<_, _>, Pr<_>, Cell<_>); + c_long = Cell::new(1); + c_shortest = Cell::new(1); + // Error: Drop impl's assertion does not apply to `B` nor `&'b _` + pt = Pt("pt", &c_long, &c_shortest); + //~^ ERROR `c_shortest` does not live long enough + pr = Pr("pr", &c_long, &c_shortest); + } + + { + let (st, sr, c_shortest): (St<_>, Sr<_>, Cell<_>); + c_shortest = Cell::new(1); + // No error: St and Sr have no destructor. + st = St("st", &c_shortest); + sr = Sr("sr", &c_shortest); + } } - fn use_imm(_: &T) { } diff --git a/src/test/ui/dropck/dropck-eyepatch.stderr b/src/test/ui/dropck/dropck-eyepatch.stderr new file mode 100644 index 00000000000..21295e6c601 --- /dev/null +++ b/src/test/ui/dropck/dropck-eyepatch.stderr @@ -0,0 +1,31 @@ +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:88:23 + | +LL | dt = Dt("dt", &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error[E0597]: `c_shortest` does not live long enough + --> $DIR/dropck-eyepatch.rs:110:32 + | +LL | pt = Pt("pt", &c_long, &c_shortest); + | ^^^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - + | | + | `c_shortest` dropped here while still borrowed + | borrow might be used here, when `pt` is dropped and runs the `Drop` code for type `Pt` + | + = note: values in a scope are dropped in the opposite order they are defined + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-union.nll.stderr b/src/test/ui/dropck/dropck-union.nll.stderr deleted file mode 100644 index 228744326f9..00000000000 --- a/src/test/ui/dropck/dropck-union.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `v` does not live long enough - --> $DIR/dropck-union.rs:39:18 - | -LL | v.0.set(Some(&v)); - | ^^ borrowed value does not live long enough -LL | } - | - - | | - | `v` dropped here while still borrowed - | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Wrap` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck-union.stderr b/src/test/ui/dropck/dropck-union.stderr index 4f6cd872449..228744326f9 100644 --- a/src/test/ui/dropck/dropck-union.stderr +++ b/src/test/ui/dropck/dropck-union.stderr @@ -1,12 +1,13 @@ error[E0597]: `v` does not live long enough - --> $DIR/dropck-union.rs:39:19 + --> $DIR/dropck-union.rs:39:18 | LL | v.0.set(Some(&v)); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } - | - `v` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `v` dropped here while still borrowed + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Wrap` error: aborting due to previous error diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr b/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr deleted file mode 100644 index 8c669b597c3..00000000000 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr +++ /dev/null @@ -1,73 +0,0 @@ -error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:111:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` -LL | o1.set0(&o2); - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o2` dropped here while still borrowed - -error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:112:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` -LL | o1.set0(&o2); -LL | o1.set1(&o3); - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o3` dropped here while still borrowed - -error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:113:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` -... -LL | o2.set0(&o2); - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o2` dropped here while still borrowed - -error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:114:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` -... -LL | o2.set1(&o3); - | ^^^ borrowed value does not live long enough -... -LL | } - | - `o3` dropped here while still borrowed - -error[E0597]: `o1` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:115:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o1` is borrowed for `'static` -... -LL | o3.set0(&o1); - | ^^^ borrowed value does not live long enough -LL | o3.set1(&o2); -LL | } - | - `o1` dropped here while still borrowed - -error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:116:13 - | -LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` -... -LL | o3.set1(&o2); - | ^^^ borrowed value does not live long enough -LL | } - | - `o2` dropped here while still borrowed - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr index 792ef46f244..8c669b597c3 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr @@ -1,67 +1,72 @@ error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:111:14 + --> $DIR/dropck_trait_cycle_checked.rs:111:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` LL | o1.set0(&o2); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o2` dropped here while still borrowed error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:112:14 + --> $DIR/dropck_trait_cycle_checked.rs:112:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` +LL | o1.set0(&o2); LL | o1.set1(&o3); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o3` dropped here while still borrowed error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:113:14 + --> $DIR/dropck_trait_cycle_checked.rs:113:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` +... LL | o2.set0(&o2); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o2` dropped here while still borrowed error[E0597]: `o3` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:114:14 + --> $DIR/dropck_trait_cycle_checked.rs:114:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` +... LL | o2.set1(&o3); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o3` dropped here while still borrowed error[E0597]: `o1` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:115:14 + --> $DIR/dropck_trait_cycle_checked.rs:115:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o1` is borrowed for `'static` +... LL | o3.set0(&o1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | o3.set1(&o2); LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o1` dropped here while still borrowed error[E0597]: `o2` does not live long enough - --> $DIR/dropck_trait_cycle_checked.rs:116:14 + --> $DIR/dropck_trait_cycle_checked.rs:116:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` +... LL | o3.set1(&o2); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `o2` dropped here while still borrowed error: aborting due to 6 previous errors diff --git a/src/test/ui/dst/dst-bad-coerce3.nll.stderr b/src/test/ui/dst/dst-bad-coerce3.nll.stderr deleted file mode 100644 index 289d451f02a..00000000000 --- a/src/test/ui/dst/dst-bad-coerce3.nll.stderr +++ /dev/null @@ -1,58 +0,0 @@ -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:16:32 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &Fat<[isize; 3]> = &f1; - | ^^^ borrowed value does not live long enough -LL | let f3: &'a Fat<[isize]> = f2; - | ---------------- type annotation requires that `f1` is borrowed for `'a` -... -LL | } - | - `f1` dropped here while still borrowed - -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:21:25 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &Fat = &f1; - | ^^^ borrowed value does not live long enough -LL | let f3: &'a Fat = f2; - | ------------ type annotation requires that `f1` is borrowed for `'a` -... -LL | } - | - `f1` dropped here while still borrowed - -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:26:30 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &([isize; 3],) = &f1; - | ^^^ borrowed value does not live long enough -LL | let f3: &'a ([isize],) = f2; - | -------------- type annotation requires that `f1` is borrowed for `'a` -... -LL | } - | - `f1` dropped here while still borrowed - -error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:31:23 - | -LL | fn baz<'a>() { - | -- lifetime `'a` defined here -... -LL | let f2: &(Foo,) = &f1; - | ^^^ borrowed value does not live long enough -LL | let f3: &'a (Bar,) = f2; - | ---------- type annotation requires that `f1` is borrowed for `'a` -LL | } - | - `f1` dropped here while still borrowed - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/dst/dst-bad-coerce3.stderr b/src/test/ui/dst/dst-bad-coerce3.stderr index 61473269e50..289d451f02a 100644 --- a/src/test/ui/dst/dst-bad-coerce3.stderr +++ b/src/test/ui/dst/dst-bad-coerce3.stderr @@ -1,62 +1,57 @@ error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:16:33 + --> $DIR/dst-bad-coerce3.rs:16:32 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &Fat<[isize; 3]> = &f1; - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough +LL | let f3: &'a Fat<[isize]> = f2; + | ---------------- type annotation requires that `f1` is borrowed for `'a` ... 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:8... - --> $DIR/dst-bad-coerce3.rs:13:8 - | -LL | fn baz<'a>() { - | ^^ + | - `f1` dropped here while still borrowed error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:21:26 + --> $DIR/dst-bad-coerce3.rs:21:25 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &Fat = &f1; - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough +LL | let f3: &'a Fat = f2; + | ------------ type annotation requires that `f1` is borrowed for `'a` ... 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:8... - --> $DIR/dst-bad-coerce3.rs:13:8 - | -LL | fn baz<'a>() { - | ^^ + | - `f1` dropped here while still borrowed error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:26:31 + --> $DIR/dst-bad-coerce3.rs:26:30 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &([isize; 3],) = &f1; - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough +LL | let f3: &'a ([isize],) = f2; + | -------------- type annotation requires that `f1` is borrowed for `'a` ... 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:8... - --> $DIR/dst-bad-coerce3.rs:13:8 - | -LL | fn baz<'a>() { - | ^^ + | - `f1` dropped here while still borrowed error[E0597]: `f1` does not live long enough - --> $DIR/dst-bad-coerce3.rs:31:24 - | -LL | let f2: &(Foo,) = &f1; - | ^^ borrowed value does not live long enough -LL | let f3: &'a (Bar,) = f2; -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:8... - --> $DIR/dst-bad-coerce3.rs:13:8 + --> $DIR/dst-bad-coerce3.rs:31:23 | LL | fn baz<'a>() { - | ^^ + | -- lifetime `'a` defined here +... +LL | let f2: &(Foo,) = &f1; + | ^^^ borrowed value does not live long enough +LL | let f3: &'a (Bar,) = f2; + | ---------- type annotation requires that `f1` is borrowed for `'a` +LL | } + | - `f1` dropped here while still borrowed error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-index.nll.stderr b/src/test/ui/dst/dst-index.nll.stderr deleted file mode 100644 index ec09a93a4aa..00000000000 --- a/src/test/ui/dst/dst-index.nll.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0161]: cannot move a value of type str: the size of str cannot be statically determined - --> $DIR/dst-index.rs:31:5 - | -LL | S[0]; - | ^^^^ - -error[E0161]: cannot move a value of type dyn std::fmt::Debug: the size of dyn std::fmt::Debug cannot be statically determined - --> $DIR/dst-index.rs:34:5 - | -LL | T[0]; - | ^^^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/dst-index.rs:31:5 - | -LL | S[0]; - | ^^^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/dst-index.rs:34:5 - | -LL | T[0]; - | ^^^^ cannot move out of borrowed content - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0161, E0507. -For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/dst/dst-index.rs b/src/test/ui/dst/dst-index.rs index 663c704ff39..71ff067bbd9 100644 --- a/src/test/ui/dst/dst-index.rs +++ b/src/test/ui/dst/dst-index.rs @@ -29,9 +29,9 @@ impl Index for T { fn main() { S[0]; - //~^ ERROR cannot move out of indexed content + //~^ ERROR cannot move out of borrowed content //~^^ ERROR E0161 T[0]; - //~^ ERROR cannot move out of indexed content + //~^ ERROR cannot move out of borrowed content //~^^ ERROR E0161 } diff --git a/src/test/ui/dst/dst-index.stderr b/src/test/ui/dst/dst-index.stderr index 863a5c1177c..ec09a93a4aa 100644 --- a/src/test/ui/dst/dst-index.stderr +++ b/src/test/ui/dst/dst-index.stderr @@ -4,23 +4,23 @@ error[E0161]: cannot move a value of type str: the size of str cannot be statica LL | S[0]; | ^^^^ -error[E0161]: cannot move a value of type (dyn std::fmt::Debug + 'static): the size of (dyn std::fmt::Debug + 'static) cannot be statically determined +error[E0161]: cannot move a value of type dyn std::fmt::Debug: the size of dyn std::fmt::Debug cannot be statically determined --> $DIR/dst-index.rs:34:5 | LL | T[0]; | ^^^^ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/dst-index.rs:31:5 | LL | S[0]; - | ^^^^ cannot move out of indexed content + | ^^^^ cannot move out of borrowed content -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/dst-index.rs:34:5 | LL | T[0]; - | ^^^^ cannot move out of indexed content + | ^^^^ cannot move out of borrowed content error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-rvalue.nll.stderr b/src/test/ui/dst/dst-rvalue.nll.stderr deleted file mode 100644 index 7ef8e4dc72e..00000000000 --- a/src/test/ui/dst/dst-rvalue.nll.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0161]: cannot move a value of type str: the size of str cannot be statically determined - --> $DIR/dst-rvalue.rs:6:28 - | -LL | let _x: Box = box *"hello world"; - | ^^^^^^^^^^^^^^ - -error[E0161]: cannot move a value of type [isize]: the size of [isize] cannot be statically determined - --> $DIR/dst-rvalue.rs:11:32 - | -LL | let _x: Box<[isize]> = box *array; - | ^^^^^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/dst-rvalue.rs:6:28 - | -LL | let _x: Box = box *"hello world"; - | ^^^^^^^^^^^^^^ cannot move out of borrowed content - -error[E0508]: cannot move out of type `[isize]`, a non-copy slice - --> $DIR/dst-rvalue.rs:11:32 - | -LL | let _x: Box<[isize]> = box *array; - | ^^^^^^ cannot move out of here - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0161, E0507, E0508. -For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/dst/dst-rvalue.rs b/src/test/ui/dst/dst-rvalue.rs index 86747dad00d..5115bee836b 100644 --- a/src/test/ui/dst/dst-rvalue.rs +++ b/src/test/ui/dst/dst-rvalue.rs @@ -10,5 +10,5 @@ pub fn main() { let array: &[isize] = &[1, 2, 3]; let _x: Box<[isize]> = box *array; //~^ ERROR E0161 - //~^^ ERROR cannot move out of borrowed content + //~^^ ERROR cannot move out of type `[isize]`, a non-copy slice } diff --git a/src/test/ui/dst/dst-rvalue.stderr b/src/test/ui/dst/dst-rvalue.stderr index 1ad597152fb..7ef8e4dc72e 100644 --- a/src/test/ui/dst/dst-rvalue.stderr +++ b/src/test/ui/dst/dst-rvalue.stderr @@ -16,13 +16,13 @@ error[E0507]: cannot move out of borrowed content LL | let _x: Box = box *"hello world"; | ^^^^^^^^^^^^^^ cannot move out of borrowed content -error[E0507]: cannot move out of borrowed content +error[E0508]: cannot move out of type `[isize]`, a non-copy slice --> $DIR/dst-rvalue.rs:11:32 | LL | let _x: Box<[isize]> = box *array; - | ^^^^^^ cannot move out of borrowed content + | ^^^^^^ cannot move out of here error: aborting due to 4 previous errors -Some errors have detailed explanations: E0161, E0507. +Some errors have detailed explanations: E0161, E0507, E0508. For more information about an error, try `rustc --explain E0161`. diff --git a/src/test/ui/error-codes/E0008.nll.stderr b/src/test/ui/error-codes/E0008.nll.stderr deleted file mode 100644 index 2505c03a148..00000000000 --- a/src/test/ui/error-codes/E0008.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/E0008.rs:3:14 - | -LL | Some(s) if s.len() == 0 => {}, - | ^ moves value into pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/error-codes/E0008.stderr b/src/test/ui/error-codes/E0008.stderr index d5c44efd667..2505c03a148 100644 --- a/src/test/ui/error-codes/E0008.stderr +++ b/src/test/ui/error-codes/E0008.stderr @@ -3,6 +3,8 @@ error[E0008]: cannot bind by-move into a pattern guard | LL | Some(s) if s.len() == 0 => {}, | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0017.nll.stderr b/src/test/ui/error-codes/E0017.nll.stderr deleted file mode 100644 index 67ff7da611b..00000000000 --- a/src/test/ui/error-codes/E0017.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0017]: references in constants may only refer to immutable values - --> $DIR/E0017.rs:4:30 - | -LL | const CR: &'static mut i32 = &mut C; - | ^^^^^^ constants require immutable values - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ statics require immutable values - -error: cannot mutate statics in the initializer of another static - --> $DIR/E0017.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ - -error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/E0017.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ cannot borrow as mutable - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:8:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; - | ^^^^^^ statics require immutable values - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0017, E0596. -For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr index 07fe9076715..67ff7da611b 100644 --- a/src/test/ui/error-codes/E0017.stderr +++ b/src/test/ui/error-codes/E0017.stderr @@ -16,11 +16,11 @@ error: cannot mutate statics in the initializer of another static LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/E0017.rs:5:44 +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/E0017.rs:5:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^ + | ^^^^^^ cannot borrow as mutable error[E0017]: references in statics may only refer to immutable values --> $DIR/E0017.rs:8:38 diff --git a/src/test/ui/error-codes/E0161.ast.stderr b/src/test/ui/error-codes/E0161.migrate.stderr similarity index 100% rename from src/test/ui/error-codes/E0161.ast.stderr rename to src/test/ui/error-codes/E0161.migrate.stderr diff --git a/src/test/ui/error-codes/E0161.astul.stderr b/src/test/ui/error-codes/E0161.migrateul.stderr similarity index 100% rename from src/test/ui/error-codes/E0161.astul.stderr rename to src/test/ui/error-codes/E0161.migrateul.stderr diff --git a/src/test/ui/error-codes/E0161.rs b/src/test/ui/error-codes/E0161.rs index a6d2b245eb1..2ca17050ae2 100644 --- a/src/test/ui/error-codes/E0161.rs +++ b/src/test/ui/error-codes/E0161.rs @@ -3,15 +3,15 @@ // Check that E0161 is a hard error in all possible configurations that might // affect it. -// revisions: ast nll zflags edition astul nllul zflagsul editionul -//[zflags]compile-flags: -Z borrowck=migrate -Z two-phase-borrows +// revisions: migrate nll zflags edition migrateul nllul zflagsul editionul +//[zflags]compile-flags: -Z borrowck=migrate //[edition]edition:2018 -//[zflagsul]compile-flags: -Z borrowck=migrate -Z two-phase-borrows +//[zflagsul]compile-flags: -Z borrowck=migrate //[editionul]edition:2018 #![cfg_attr(nll, feature(nll))] #![cfg_attr(nllul, feature(nll))] -#![cfg_attr(astul, feature(unsized_locals))] +#![cfg_attr(migrateul, feature(unsized_locals))] #![cfg_attr(zflagsul, feature(unsized_locals))] #![cfg_attr(nllul, feature(unsized_locals))] #![cfg_attr(editionul, feature(unsized_locals))] @@ -20,11 +20,11 @@ fn foo(x: Box<[i32]>) { box *x; - //[ast]~^ ERROR E0161 + //[migrate]~^ ERROR E0161 //[nll]~^^ ERROR E0161 //[zflags]~^^^ ERROR E0161 //[edition]~^^^^ ERROR E0161 - //[astul]~^^^^^ ERROR E0161 + //[migrateul]~^^^^^ ERROR E0161 //[nllul]~^^^^^^ ERROR E0161 //[zflagsul]~^^^^^^^ ERROR E0161 //[editionul]~^^^^^^^^ ERROR E0161 diff --git a/src/test/ui/error-codes/E0301.nll.stderr b/src/test/ui/error-codes/E0301.nll.stderr deleted file mode 100644 index 24234c9929e..00000000000 --- a/src/test/ui/error-codes/E0301.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0301]: cannot mutably borrow in a pattern guard - --> $DIR/E0301.rs:4:19 - | -LL | option if option.take().is_none() => {}, - | ^^^^^^ borrowed mutably in pattern guard - | - = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0301`. diff --git a/src/test/ui/error-codes/E0301.stderr b/src/test/ui/error-codes/E0301.stderr index 80ee681a517..24234c9929e 100644 --- a/src/test/ui/error-codes/E0301.stderr +++ b/src/test/ui/error-codes/E0301.stderr @@ -3,6 +3,8 @@ error[E0301]: cannot mutably borrow in a pattern guard | LL | option if option.take().is_none() => {}, | ^^^^^^ borrowed mutably in pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0388.nll.stderr b/src/test/ui/error-codes/E0388.nll.stderr deleted file mode 100644 index e0ca4316732..00000000000 --- a/src/test/ui/error-codes/E0388.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0017]: references in constants may only refer to immutable values - --> $DIR/E0388.rs:4:30 - | -LL | const CR: &'static mut i32 = &mut C; - | ^^^^^^ constants require immutable values - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ statics require immutable values - -error: cannot mutate statics in the initializer of another static - --> $DIR/E0388.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ - -error[E0596]: cannot borrow immutable static item `X` as mutable - --> $DIR/E0388.rs:5:39 - | -LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^^^^^^ cannot borrow as mutable - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:8:38 - | -LL | static CONST_REF: &'static mut i32 = &mut C; - | ^^^^^^ statics require immutable values - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0017, E0596. -For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr index fae43ff4647..e0ca4316732 100644 --- a/src/test/ui/error-codes/E0388.stderr +++ b/src/test/ui/error-codes/E0388.stderr @@ -16,11 +16,11 @@ error: cannot mutate statics in the initializer of another static LL | static STATIC_REF: &'static mut i32 = &mut X; | ^^^^^^ -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/E0388.rs:5:44 +error[E0596]: cannot borrow immutable static item `X` as mutable + --> $DIR/E0388.rs:5:39 | LL | static STATIC_REF: &'static mut i32 = &mut X; - | ^ + | ^^^^^^ cannot borrow as mutable error[E0017]: references in statics may only refer to immutable values --> $DIR/E0388.rs:8:38 diff --git a/src/test/ui/error-codes/E0389.nll.stderr b/src/test/ui/error-codes/E0389.nll.stderr deleted file mode 100644 index 5310367d51a..00000000000 --- a/src/test/ui/error-codes/E0389.nll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference - --> $DIR/E0389.rs:8:5 - | -LL | let fancy_ref = &(&mut fancy); - | ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)` -LL | fancy_ref.num = 6; - | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0389.rs b/src/test/ui/error-codes/E0389.rs index 8b821330ebe..9dab2c30924 100644 --- a/src/test/ui/error-codes/E0389.rs +++ b/src/test/ui/error-codes/E0389.rs @@ -5,6 +5,6 @@ struct FancyNum { fn main() { let mut fancy = FancyNum{ num: 5 }; let fancy_ref = &(&mut fancy); - fancy_ref.num = 6; //~ ERROR E0389 + fancy_ref.num = 6; //~ ERROR cannot assign to `fancy_ref.num` which is behind a `&` reference println!("{}", fancy_ref.num); } diff --git a/src/test/ui/error-codes/E0389.stderr b/src/test/ui/error-codes/E0389.stderr index 927eace727e..5310367d51a 100644 --- a/src/test/ui/error-codes/E0389.stderr +++ b/src/test/ui/error-codes/E0389.stderr @@ -1,9 +1,10 @@ -error[E0389]: cannot assign to data in a `&` reference +error[E0594]: cannot assign to `fancy_ref.num` which is behind a `&` reference --> $DIR/E0389.rs:8:5 | +LL | let fancy_ref = &(&mut fancy); + | ------------- help: consider changing this to be a mutable reference: `&mut (&mut fancy)` LL | fancy_ref.num = 6; - | ^^^^^^^^^^^^^^^^^ assignment into an immutable reference + | ^^^^^^^^^^^^^^^^^ `fancy_ref` is a `&` reference, so the data it refers to cannot be written error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. diff --git a/src/test/ui/error-codes/E0499.nll.stderr b/src/test/ui/error-codes/E0499.nll.stderr deleted file mode 100644 index d56baf72272..00000000000 --- a/src/test/ui/error-codes/E0499.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `i` as mutable more than once at a time - --> $DIR/E0499.rs:4:17 - | -LL | let mut x = &mut i; - | ------ first mutable borrow occurs here -LL | let mut a = &mut i; - | ^^^^^^ second mutable borrow occurs here -LL | a.use_mut(); -LL | x.use_mut(); - | - 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/error-codes/E0499.stderr b/src/test/ui/error-codes/E0499.stderr index 82270162b38..d56baf72272 100644 --- a/src/test/ui/error-codes/E0499.stderr +++ b/src/test/ui/error-codes/E0499.stderr @@ -1,13 +1,13 @@ error[E0499]: cannot borrow `i` as mutable more than once at a time - --> $DIR/E0499.rs:4:22 + --> $DIR/E0499.rs:4:17 | LL | let mut x = &mut i; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | let mut a = &mut i; - | ^ second mutable borrow occurs here -... -LL | } - | - first borrow ends here + | ^^^^^^ second mutable borrow occurs here +LL | a.use_mut(); +LL | x.use_mut(); + | - first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0502.nll.stderr b/src/test/ui/error-codes/E0502.nll.stderr deleted file mode 100644 index cade6d71852..00000000000 --- a/src/test/ui/error-codes/E0502.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `*a` as mutable because it is also borrowed as immutable - --> $DIR/E0502.rs:4:5 - | -LL | let ref y = a; - | ----- immutable borrow occurs here -LL | bar(a); - | ^^^^^^ mutable borrow occurs here -LL | y.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/error-codes/E0502.stderr b/src/test/ui/error-codes/E0502.stderr index 26a2c3bf353..cade6d71852 100644 --- a/src/test/ui/error-codes/E0502.stderr +++ b/src/test/ui/error-codes/E0502.stderr @@ -1,13 +1,12 @@ -error[E0502]: cannot borrow `*a` as mutable because `a` is also borrowed as immutable - --> $DIR/E0502.rs:4:9 +error[E0502]: cannot borrow `*a` as mutable because it is also borrowed as immutable + --> $DIR/E0502.rs:4:5 | LL | let ref y = a; | ----- immutable borrow occurs here LL | bar(a); - | ^ 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 previous error diff --git a/src/test/ui/error-codes/E0503.nll.stderr b/src/test/ui/error-codes/E0503.nll.stderr deleted file mode 100644 index 106dda2bc22..00000000000 --- a/src/test/ui/error-codes/E0503.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0503]: cannot use `value` because it was mutably borrowed - --> $DIR/E0503.rs:4:16 - | -LL | let _borrow = &mut value; - | ---------- borrow of `value` occurs here -LL | let _sum = value + 1; - | ^^^^^ use of borrowed `value` -LL | _borrow.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/error-codes/E0503.stderr b/src/test/ui/error-codes/E0503.stderr index 62cb3afca78..106dda2bc22 100644 --- a/src/test/ui/error-codes/E0503.stderr +++ b/src/test/ui/error-codes/E0503.stderr @@ -2,9 +2,11 @@ error[E0503]: cannot use `value` because it was mutably borrowed --> $DIR/E0503.rs:4:16 | LL | let _borrow = &mut value; - | ----- borrow of `value` occurs here + | ---------- borrow of `value` occurs here LL | let _sum = value + 1; | ^^^^^ use of borrowed `value` +LL | _borrow.use_mut(); + | ------- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0504.nll.stderr b/src/test/ui/error-codes/E0504.nll.stderr deleted file mode 100644 index 1f2a0407a39..00000000000 --- a/src/test/ui/error-codes/E0504.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0505]: cannot move out of `fancy_num` because it is borrowed - --> $DIR/E0504.rs:9:13 - | -LL | let fancy_ref = &fancy_num; - | ---------- borrow of `fancy_num` occurs here -LL | -LL | let x = move || { - | ^^^^^^^ move out of `fancy_num` occurs here -LL | println!("child function: {}", fancy_num.num); - | --------- move occurs due to use in closure -... -LL | println!("main function: {}", fancy_ref.num); - | ------------- 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/error-codes/E0504.rs b/src/test/ui/error-codes/E0504.rs index 06ae0848b7c..c2658bef619 100644 --- a/src/test/ui/error-codes/E0504.rs +++ b/src/test/ui/error-codes/E0504.rs @@ -6,8 +6,8 @@ fn main() { let fancy_num = FancyNum { num: 5 }; let fancy_ref = &fancy_num; - let x = move || { - println!("child function: {}", fancy_num.num); //~ ERROR E0504 + let x = move || { //~ ERROR E0505 + println!("child function: {}", fancy_num.num); }; x(); diff --git a/src/test/ui/error-codes/E0504.stderr b/src/test/ui/error-codes/E0504.stderr index a987713a11d..1f2a0407a39 100644 --- a/src/test/ui/error-codes/E0504.stderr +++ b/src/test/ui/error-codes/E0504.stderr @@ -1,12 +1,17 @@ -error[E0504]: cannot move `fancy_num` into closure because it is borrowed - --> $DIR/E0504.rs:10:40 +error[E0505]: cannot move out of `fancy_num` because it is borrowed + --> $DIR/E0504.rs:9:13 | LL | let fancy_ref = &fancy_num; - | --------- borrow of `fancy_num` occurs here -... + | ---------- borrow of `fancy_num` occurs here +LL | +LL | let x = move || { + | ^^^^^^^ move out of `fancy_num` occurs here LL | println!("child function: {}", fancy_num.num); - | ^^^^^^^^^ move into closure occurs here + | --------- move occurs due to use in closure +... +LL | println!("main function: {}", fancy_ref.num); + | ------------- borrow later used here error: aborting due to previous error -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/error-codes/E0505.nll.stderr b/src/test/ui/error-codes/E0505.nll.stderr deleted file mode 100644 index 4d9d1ef121c..00000000000 --- a/src/test/ui/error-codes/E0505.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/E0505.rs:9:13 - | -LL | let _ref_to_val: &Value = &x; - | -- borrow of `x` occurs here -LL | eat(x); - | ^ move out of `x` occurs here -LL | _ref_to_val.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/error-codes/E0505.stderr b/src/test/ui/error-codes/E0505.stderr index 28dfb25986f..4d9d1ef121c 100644 --- a/src/test/ui/error-codes/E0505.stderr +++ b/src/test/ui/error-codes/E0505.stderr @@ -2,9 +2,11 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/E0505.rs:9:13 | LL | let _ref_to_val: &Value = &x; - | - borrow of `x` occurs here + | -- borrow of `x` occurs here LL | eat(x); | ^ move out of `x` occurs here +LL | _ref_to_val.use_ref(); + | ----------- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0509.nll.stderr b/src/test/ui/error-codes/E0509.nll.stderr deleted file mode 100644 index e5c0cf6e24e..00000000000 --- a/src/test/ui/error-codes/E0509.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0509]: cannot move out of type `DropStruct`, which implements the `Drop` trait - --> $DIR/E0509.rs:16:23 - | -LL | let fancy_field = drop_struct.fancy; - | ^^^^^^^^^^^^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&drop_struct.fancy` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/error-codes/E0509.stderr b/src/test/ui/error-codes/E0509.stderr index 25b6d8a47d2..e5c0cf6e24e 100644 --- a/src/test/ui/error-codes/E0509.stderr +++ b/src/test/ui/error-codes/E0509.stderr @@ -5,7 +5,7 @@ LL | let fancy_field = drop_struct.fancy; | ^^^^^^^^^^^^^^^^^ | | | cannot move out of here - | help: consider using a reference instead: `&drop_struct.fancy` + | help: consider borrowing here: `&drop_struct.fancy` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0597.nll.stderr b/src/test/ui/error-codes/E0597.nll.stderr deleted file mode 100644 index b4a1180ad54..00000000000 --- a/src/test/ui/error-codes/E0597.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/E0597.rs:8:16 - | -LL | x.x = Some(&y); - | ^^ borrowed value does not live long enough -LL | -LL | } - | - - | | - | `y` dropped here while still borrowed - | borrow might be used here, when `x` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/error-codes/E0597.stderr b/src/test/ui/error-codes/E0597.stderr index cab97858531..b4a1180ad54 100644 --- a/src/test/ui/error-codes/E0597.stderr +++ b/src/test/ui/error-codes/E0597.stderr @@ -1,13 +1,16 @@ error[E0597]: `y` does not live long enough - --> $DIR/E0597.rs:8:17 + --> $DIR/E0597.rs:8:16 | LL | x.x = Some(&y); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | LL | } - | - `y` dropped here while still borrowed + | - + | | + | `y` dropped here while still borrowed + | borrow might be used here, when `x` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/feature-gates/feature-gate-nll.rs b/src/test/ui/feature-gates/feature-gate-nll.rs index 14c48fb48a0..2cf6e4d5209 100644 --- a/src/test/ui/feature-gates/feature-gate-nll.rs +++ b/src/test/ui/feature-gates/feature-gate-nll.rs @@ -1,18 +1,20 @@ -// This is a test checking that if you do not opt into NLL then you -// should not get the effects of NLL applied to the test. - -// Don't use 2018 edition, since that turns on NLL (migration mode). -// edition:2015 +// There isn't a great way to test feature(nll), since it just disables migrate +// mode and changes some error messages. We just test for migrate mode. // Don't use compare-mode=nll, since that turns on NLL. // ignore-compare-mode-nll +#![feature(rustc_attrs)] -#![allow(dead_code)] +#[rustc_error] +fn main() { //~ ERROR compilation successful + let mut x = (33, &0); -fn main() { - let mut x = 33; - - let p = &x; - x = 22; //~ ERROR cannot assign to `x` because it is borrowed [E0506] + let m = &mut x; + let p = &*x.1; + //~^ WARNING cannot borrow + //~| WARNING this error has been downgraded to a warning + //~| WARNING this warning will become a hard error in the future + m; } + diff --git a/src/test/ui/feature-gates/feature-gate-nll.stderr b/src/test/ui/feature-gates/feature-gate-nll.stderr index cc004e3a1da..ac21241b303 100644 --- a/src/test/ui/feature-gates/feature-gate-nll.stderr +++ b/src/test/ui/feature-gates/feature-gate-nll.stderr @@ -1,11 +1,29 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/feature-gate-nll.rs:17:5 +warning[E0502]: cannot borrow `*x.1` as immutable because it is also borrowed as mutable + --> $DIR/feature-gate-nll.rs:14:13 | -LL | let p = &x; - | - borrow of `x` occurs here -LL | x = 22; - | ^^^^^^ assignment to borrowed `x` occurs here +LL | let m = &mut x; + | ------ mutable borrow occurs here +LL | let p = &*x.1; + | ^^^^^ immutable borrow occurs here +... +LL | m; + | - mutable 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: compilation successful + --> $DIR/feature-gate-nll.rs:10:1 + | +LL | / fn main() { +LL | | let mut x = (33, &0); +LL | | +LL | | let m = &mut x; +... | +LL | | m; +LL | | } + | |_^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0506`. +For more information about this error, try `rustc --explain E0502`. diff --git a/src/test/ui/fn/fn-closure-mutable-capture.nll.stderr b/src/test/ui/fn/fn-closure-mutable-capture.nll.stderr deleted file mode 100644 index 8dfae0cbdf2..00000000000 --- a/src/test/ui/fn/fn-closure-mutable-capture.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure - --> $DIR/fn-closure-mutable-capture.rs:5:17 - | -LL | bar(move || x = 1); - | ^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/fn-closure-mutable-capture.rs:5:9 - | -LL | bar(move || x = 1); - | ^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/fn/fn-closure-mutable-capture.rs b/src/test/ui/fn/fn-closure-mutable-capture.rs index a37eceffb9d..81376af091b 100644 --- a/src/test/ui/fn/fn-closure-mutable-capture.rs +++ b/src/test/ui/fn/fn-closure-mutable-capture.rs @@ -3,8 +3,9 @@ pub fn bar(_f: F) {} pub fn foo() { let mut x = 0; bar(move || x = 1); - //~^ ERROR cannot assign to captured outer variable in an `Fn` closure - //~| NOTE `Fn` closures cannot capture their enclosing environment for modifications + //~^ ERROR cannot assign to `x`, as it is a captured variable in a `Fn` closure + //~| NOTE cannot assign + //~| HELP consider changing this to accept closures that implement `FnMut` } fn main() {} diff --git a/src/test/ui/fn/fn-closure-mutable-capture.stderr b/src/test/ui/fn/fn-closure-mutable-capture.stderr index 2414bcd5e2e..8dfae0cbdf2 100644 --- a/src/test/ui/fn/fn-closure-mutable-capture.stderr +++ b/src/test/ui/fn/fn-closure-mutable-capture.stderr @@ -1,11 +1,10 @@ -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/fn-closure-mutable-capture.rs:5:17 | LL | bar(move || 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/fn-closure-mutable-capture.rs:5:9 | LL | bar(move || x = 1); diff --git a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.nll.stderr b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.nll.stderr deleted file mode 100644 index e7b45753421..00000000000 --- a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0509]: cannot move out of type `A`, which implements the `Drop` trait - --> $DIR/functional-struct-update-noncopyable.rs:12:14 - | -LL | let _b = A { y: Arc::new(3), ..a }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0509`. diff --git a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr index 5549adc8d0e..e7b45753421 100644 --- a/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr +++ b/src/test/ui/functional-struct-update/functional-struct-update-noncopyable.stderr @@ -1,8 +1,8 @@ error[E0509]: cannot move out of type `A`, which implements the `Drop` trait - --> $DIR/functional-struct-update-noncopyable.rs:12:36 + --> $DIR/functional-struct-update-noncopyable.rs:12:14 | LL | let _b = A { y: Arc::new(3), ..a }; - | ^ cannot move out of here + | ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of here error: aborting due to previous error diff --git a/src/test/ui/generator/borrowing.nll.stderr b/src/test/ui/generator/borrowing.nll.stderr deleted file mode 100644 index 3d58873f826..00000000000 --- a/src/test/ui/generator/borrowing.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:9:33 - | -LL | Pin::new(&mut || yield &a).resume() - | ----------^ - | | | - | | borrowed value does not live long enough - | value captured here by generator - | a temporary with access to the borrow is created here ... -LL | -LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator - | | - | `a` dropped here while still borrowed - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:16:20 - | -LL | let _b = { - | -- borrow later stored here -LL | let a = 3; -LL | || { - | -- value captured here by generator -LL | yield &a - | ^ borrowed value does not live long enough -... -LL | }; - | - `a` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generator/borrowing.stderr b/src/test/ui/generator/borrowing.stderr index 38502aa8e0b..3d58873f826 100644 --- a/src/test/ui/generator/borrowing.stderr +++ b/src/test/ui/generator/borrowing.stderr @@ -2,28 +2,32 @@ error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:9:33 | LL | Pin::new(&mut || yield &a).resume() - | -- ^ borrowed value does not live long enough - | | - | capture occurs here + | ----------^ + | | | + | | borrowed value does not live long enough + | value captured here by generator + | a temporary with access to the borrow is created here ... LL | LL | }; - | - borrowed value only lives until here -... -LL | } - | - borrowed value needs to live until here + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator + | | + | `a` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `a` does not live long enough --> $DIR/borrowing.rs:16:20 | +LL | let _b = { + | -- borrow later stored here +LL | let a = 3; LL | || { - | -- capture occurs here + | -- value captured here by generator LL | yield &a | ^ borrowed value does not live long enough ... LL | }; - | - borrowed value only lives until here -LL | } - | - borrowed value needs to live until here + | - `a` dropped here while still borrowed error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/dropck.nll.stderr b/src/test/ui/generator/dropck.nll.stderr deleted file mode 100644 index 8bb860f288f..00000000000 --- a/src/test/ui/generator/dropck.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0597]: `*cell` does not live long enough - --> $DIR/dropck.rs:10:40 - | -LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); - | ^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `*cell` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `ref_` does not live long enough - --> $DIR/dropck.rs:15:18 - | -LL | gen = || { - | -- value captured here by generator -LL | // but the generator can use it to drop a `Ref<'a, i32>`. -LL | let _d = ref_.take(); - | ^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `ref_` dropped here while still borrowed - | borrow might be used here, when `gen` is dropped and runs the destructor for generator - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generator/dropck.stderr b/src/test/ui/generator/dropck.stderr index 977f388a626..8bb860f288f 100644 --- a/src/test/ui/generator/dropck.stderr +++ b/src/test/ui/generator/dropck.stderr @@ -5,23 +5,29 @@ LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); | ^^^^ borrowed value does not live long enough ... LL | } - | - `*cell` dropped here while still borrowed + | - + | | + | `*cell` dropped here while still borrowed + | borrow might be used here, when `gen` is dropped and runs the destructor for generator | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `ref_` does not live long enough --> $DIR/dropck.rs:15:18 | LL | gen = || { - | -- capture occurs here + | -- value captured here by generator LL | // but the generator can use it to drop a `Ref<'a, i32>`. LL | let _d = ref_.take(); | ^^^^ borrowed value does not live long enough ... LL | } - | - borrowed value dropped before borrower + | - + | | + | `ref_` dropped here while still borrowed + | borrow might be used here, when `gen` is dropped and runs the destructor for generator | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/generator-region-requirements.ast.stderr b/src/test/ui/generator/generator-region-requirements.migrate.stderr similarity index 100% rename from src/test/ui/generator/generator-region-requirements.ast.stderr rename to src/test/ui/generator/generator-region-requirements.migrate.stderr diff --git a/src/test/ui/generator/generator-region-requirements.rs b/src/test/ui/generator/generator-region-requirements.rs index 9738f6c3932..cd9abaae056 100644 --- a/src/test/ui/generator/generator-region-requirements.rs +++ b/src/test/ui/generator/generator-region-requirements.rs @@ -1,4 +1,4 @@ -// revisions: ast nll +// revisions: migrate nll // ignore-compare-mode-nll #![feature(generators, generator_trait)] @@ -15,7 +15,7 @@ fn dangle(x: &mut i32) -> &'static mut i32 { match Pin::new(&mut g).resume() { GeneratorState::Complete(c) => return c, //[nll]~^ ERROR explicit lifetime required -//[ast]~^^ ERROR explicit lifetime required +//[migrate]~^^ ERROR explicit lifetime required GeneratorState::Yielded(_) => (), } } diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr b/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr deleted file mode 100644 index de533e4d5ff..00000000000 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0521]: borrowed data escapes outside of generator - --> $DIR/ref-escapes-but-not-over-yield.rs:11:9 - | -LL | let mut a = &3; - | ----- `a` is declared here, outside of the generator body -... -LL | a = &b; - | ^^^^-- - | | | - | | borrow is only valid in the generator body - | reference to `b` escapes the generator body here - -error: aborting due to previous error - diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.rs b/src/test/ui/generator/ref-escapes-but-not-over-yield.rs index 8c576581ad8..3856d8233bc 100644 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.rs +++ b/src/test/ui/generator/ref-escapes-but-not-over-yield.rs @@ -9,7 +9,7 @@ fn foo(x: &i32) { yield(); let b = 5; a = &b; - //~^ ERROR `b` does not live long enough + //~^ ERROR borrowed data escapes outside of generator }; } diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr b/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr index 20a06abebd6..de533e4d5ff 100644 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr +++ b/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr @@ -1,14 +1,14 @@ -error[E0597]: `b` does not live long enough - --> $DIR/ref-escapes-but-not-over-yield.rs:11:14 +error[E0521]: borrowed data escapes outside of generator + --> $DIR/ref-escapes-but-not-over-yield.rs:11:9 | +LL | let mut a = &3; + | ----- `a` is declared here, outside of the generator body +... LL | a = &b; - | ^ borrowed value does not live long enough -LL | -LL | }; - | - `b` dropped here while still borrowed -LL | } - | - borrowed value needs to live until here + | ^^^^-- + | | | + | | borrow is only valid in the generator body + | reference to `b` escapes the generator body here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generator/yield-in-args.nll.stderr b/src/test/ui/generator/yield-in-args.nll.stderr deleted file mode 100644 index ee6d22c27cd..00000000000 --- a/src/test/ui/generator/yield-in-args.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-in-args.rs:8:13 - | -LL | foo(&b, yield); - | ^^ ----- possible yield occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0626`. diff --git a/src/test/ui/generator/yield-in-args.stderr b/src/test/ui/generator/yield-in-args.stderr index 2f22dea4e91..ee6d22c27cd 100644 --- a/src/test/ui/generator/yield-in-args.stderr +++ b/src/test/ui/generator/yield-in-args.stderr @@ -1,8 +1,8 @@ error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-in-args.rs:8:14 + --> $DIR/yield-in-args.rs:8:13 | LL | foo(&b, yield); - | ^ ----- possible yield occurs here + | ^^ ----- possible yield occurs here error: aborting due to previous error diff --git a/src/test/ui/generator/yield-while-iterating.nll.stderr b/src/test/ui/generator/yield-while-iterating.nll.stderr deleted file mode 100644 index 6a96b25b19f..00000000000 --- a/src/test/ui/generator/yield-while-iterating.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-iterating.rs:13:18 - | -LL | for p in &x { - | ^^ -LL | yield(); - | ------- possible yield occurs here - -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/yield-while-iterating.rs:58:20 - | -LL | let mut b = || { - | -- mutable borrow occurs here -LL | for p in &mut x { - | - first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x[0]); - | ^ immutable borrow occurs here -LL | Pin::new(&mut b).resume(); - | ------ mutable borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0502, E0626. -For more information about an error, try `rustc --explain E0502`. diff --git a/src/test/ui/generator/yield-while-iterating.stderr b/src/test/ui/generator/yield-while-iterating.stderr index 91f28e1c4d0..6a96b25b19f 100644 --- a/src/test/ui/generator/yield-while-iterating.stderr +++ b/src/test/ui/generator/yield-while-iterating.stderr @@ -1,8 +1,8 @@ error[E0626]: borrow may still be in use when generator yields - --> $DIR/yield-while-iterating.rs:13:19 + --> $DIR/yield-while-iterating.rs:13:18 | LL | for p in &x { - | ^ + | ^^ LL | yield(); | ------- possible yield occurs here @@ -12,13 +12,12 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as muta LL | let mut b = || { | -- mutable borrow occurs here LL | for p in &mut x { - | - previous borrow occurs due to use of `x` in closure + | - first borrow occurs due to use of `x` in generator ... LL | println!("{}", x[0]); | ^ immutable borrow occurs here LL | Pin::new(&mut b).resume(); -LL | } - | - mutable borrow ends here + | ------ mutable borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr b/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr deleted file mode 100644 index 4c37cd35173..00000000000 --- a/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access - --> $DIR/yield-while-ref-reborrowed.rs:36:20 - | -LL | let mut b = || { - | -- generator construction occurs here -LL | let a = &mut *x; - | - first borrow occurs due to use of `x` in generator -... -LL | println!("{}", x); - | ^ second borrow occurs here -LL | Pin::new(&mut b).resume(); - | ------ first borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0501`. diff --git a/src/test/ui/generator/yield-while-ref-reborrowed.stderr b/src/test/ui/generator/yield-while-ref-reborrowed.stderr index 155f2770d3d..4c37cd35173 100644 --- a/src/test/ui/generator/yield-while-ref-reborrowed.stderr +++ b/src/test/ui/generator/yield-while-ref-reborrowed.stderr @@ -2,15 +2,14 @@ error[E0501]: cannot borrow `x` as immutable because previous closure requires u --> $DIR/yield-while-ref-reborrowed.rs:36:20 | LL | let mut b = || { - | -- closure construction occurs here + | -- generator construction occurs here LL | let a = &mut *x; - | - previous borrow occurs due to use of `x` in closure + | - first borrow occurs due to use of `x` in generator ... LL | println!("{}", x); - | ^ borrow occurs here + | ^ second borrow occurs here LL | Pin::new(&mut b).resume(); -LL | } - | - borrow from closure ends here + | ------ first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr b/src/test/ui/hashmap-iter-value-lifetime.nll.stderr deleted file mode 100644 index f7626b13bad..00000000000 --- a/src/test/ui/hashmap-iter-value-lifetime.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-iter-value-lifetime.rs:7:5 - | -LL | let (_, thing) = my_stuff.iter().next().unwrap(); - | -------- immutable borrow occurs here -LL | -LL | my_stuff.clear(); - | ^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | -LL | println!("{}", *thing); - | ------ 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/hashmap-iter-value-lifetime.stderr b/src/test/ui/hashmap-iter-value-lifetime.stderr index 0f7e04dae0c..f7626b13bad 100644 --- a/src/test/ui/hashmap-iter-value-lifetime.stderr +++ b/src/test/ui/hashmap-iter-value-lifetime.stderr @@ -5,10 +5,10 @@ LL | let (_, thing) = my_stuff.iter().next().unwrap(); | -------- immutable borrow occurs here LL | LL | my_stuff.clear(); - | ^^^^^^^^ mutable borrow occurs here -... -LL | } - | - immutable borrow ends here + | ^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | println!("{}", *thing); + | ------ immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hashmap-lifetimes.nll.stderr b/src/test/ui/hashmap-lifetimes.nll.stderr deleted file mode 100644 index 497c7d1216c..00000000000 --- a/src/test/ui/hashmap-lifetimes.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as immutable - --> $DIR/hashmap-lifetimes.rs:6:5 - | -LL | let mut it = my_stuff.iter(); - | -------- immutable borrow occurs here -LL | my_stuff.insert(1, 43); - | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here -LL | it; - | -- 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/hashmap-lifetimes.stderr b/src/test/ui/hashmap-lifetimes.stderr index 728946ca13a..497c7d1216c 100644 --- a/src/test/ui/hashmap-lifetimes.stderr +++ b/src/test/ui/hashmap-lifetimes.stderr @@ -4,10 +4,9 @@ error[E0502]: cannot borrow `my_stuff` as mutable because it is also borrowed as LL | let mut it = my_stuff.iter(); | -------- immutable borrow occurs here LL | my_stuff.insert(1, 43); - | ^^^^^^^^ mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | it; -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr deleted file mode 100644 index 70d5b3c2ec5..00000000000 --- a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `foo` as mutable more than once at a time - --> $DIR/hrtb-debruijn-in-receiver.rs:17:5 - | -LL | foo.insert(); - | --- first mutable borrow occurs here -LL | foo.insert(); - | ^^^ - | | - | second mutable borrow occurs here - | 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/hrtb/hrtb-debruijn-in-receiver.stderr b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr index e498a9ad022..70d5b3c2ec5 100644 --- a/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr +++ b/src/test/ui/hrtb/hrtb-debruijn-in-receiver.stderr @@ -4,9 +4,10 @@ error[E0499]: cannot borrow `foo` as mutable more than once at a time LL | foo.insert(); | --- first mutable borrow occurs here LL | foo.insert(); - | ^^^ second mutable borrow occurs here -LL | } - | - first borrow ends here + | ^^^ + | | + | second mutable borrow occurs here + | first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.stderr b/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.stderr deleted file mode 100644 index 6f055aaf5ae..00000000000 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/hrtb-identity-fn-borrows.rs:17:5 - | -LL | let y = f.call(&x); - | - borrow of `x` occurs here -LL | x = 5; - | ^^^^^ 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/hrtb/hrtb-identity-fn-borrows.mir.stderr b/src/test/ui/hrtb/hrtb-identity-fn-borrows.mir.stderr deleted file mode 100644 index 2b69b3f6228..00000000000 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/hrtb-identity-fn-borrows.rs:17:5 - | -LL | let y = f.call(&x); - | -- borrow of `x` occurs here -LL | x = 5; - | ^^^^^ assignment to borrowed `x` occurs here -... -LL | drop(y); - | - 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/hrtb/hrtb-identity-fn-borrows.rs b/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs index 35b39a9a69d..89fc4705a78 100644 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs +++ b/src/test/ui/hrtb/hrtb-identity-fn-borrows.rs @@ -1,9 +1,6 @@ // Test that the `'a` in the where clause correctly links the region // of the output to the region of the input. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - trait FnLike { fn call(&self, arg: A) -> R; } @@ -14,8 +11,7 @@ fn call_repeatedly(f: F) // Result is stored: cannot re-assign `x` let mut x = 3; let y = f.call(&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 // Result is not stored: can re-assign `x` let mut x = 3; diff --git a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.nll.stderr b/src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr similarity index 89% rename from src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.nll.stderr rename to src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr index 2b69b3f6228..4886a3c8bad 100644 --- a/src/test/ui/hrtb/hrtb-identity-fn-borrows.ast.nll.stderr +++ b/src/test/ui/hrtb/hrtb-identity-fn-borrows.stderr @@ -1,5 +1,5 @@ error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/hrtb-identity-fn-borrows.rs:17:5 + --> $DIR/hrtb-identity-fn-borrows.rs:14:5 | LL | let y = f.call(&x); | -- borrow of `x` occurs here diff --git a/src/test/ui/hygiene/fields-move.nll.stderr b/src/test/ui/hygiene/fields-move.nll.stderr deleted file mode 100644 index 562f60e31b5..00000000000 --- a/src/test/ui/hygiene/fields-move.nll.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:18:9 - | -LL | $foo.x - | ^^^^^^ value used here after move -... -LL | assert_two_copies(copy_modern!(foo), foo.x); - | ----- value moved here -LL | assert_two_copies(copy_legacy!(foo), foo.x); - | ----------------- in this macro invocation - | - = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:28:42 - | -LL | $foo.x - | ------ value moved here -... -LL | assert_two_copies(copy_modern!(foo), foo.x); - | ^^^^^ value used here after move - | - = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:29:42 - | -LL | $foo.x - | ------ value moved here -... -LL | assert_two_copies(copy_legacy!(foo), foo.x); - | ^^^^^ value used here after move - | - = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/hygiene/fields-move.stderr b/src/test/ui/hygiene/fields-move.stderr index 43d55fdc68f..562f60e31b5 100644 --- a/src/test/ui/hygiene/fields-move.stderr +++ b/src/test/ui/hygiene/fields-move.stderr @@ -1,3 +1,16 @@ +error[E0382]: use of moved value: `foo.x` + --> $DIR/fields-move.rs:18:9 + | +LL | $foo.x + | ^^^^^^ value used here after move +... +LL | assert_two_copies(copy_modern!(foo), foo.x); + | ----- value moved here +LL | assert_two_copies(copy_legacy!(foo), foo.x); + | ----------------- in this macro invocation + | + = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait + error[E0382]: use of moved value: `foo.x` --> $DIR/fields-move.rs:28:42 | @@ -9,25 +22,11 @@ LL | assert_two_copies(copy_modern!(foo), foo.x); | = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `foo.x` - --> $DIR/fields-move.rs:18:9 - | -LL | $foo.x - | ------ value moved here -... -LL | $foo.x - | ^^^^^^ value used here after move -... -LL | assert_two_copies(copy_legacy!(foo), foo.x); - | ----------------- in this macro invocation - | - = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait - error[E0382]: use of moved value: `foo.x` --> $DIR/fields-move.rs:29:42 | -LL | $foo.x - | ------ value moved here +LL | $foo.x + | ------ value moved here ... LL | assert_two_copies(copy_legacy!(foo), foo.x); | ^^^^^ value used here after move diff --git a/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr b/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr deleted file mode 100644 index fb90825c0d9..00000000000 --- a/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `s.0` as mutable more than once at a time - --> $DIR/fields-numeric-borrowck.rs:6:16 - | -LL | let borrow1 = &mut s.0; - | -------- first mutable borrow occurs here -LL | let S { 0: ref mut borrow2 } = s; - | ^^^^^^^^^^^^^^^ second mutable borrow occurs here -... -LL | borrow1.use_mut(); - | ------- 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/hygiene/fields-numeric-borrowck.stderr b/src/test/ui/hygiene/fields-numeric-borrowck.stderr index 11b5fd70aff..fb90825c0d9 100644 --- a/src/test/ui/hygiene/fields-numeric-borrowck.stderr +++ b/src/test/ui/hygiene/fields-numeric-borrowck.stderr @@ -2,12 +2,12 @@ error[E0499]: cannot borrow `s.0` as mutable more than once at a time --> $DIR/fields-numeric-borrowck.rs:6:16 | LL | let borrow1 = &mut s.0; - | --- first mutable borrow occurs here + | -------- first mutable borrow occurs here LL | let S { 0: ref mut borrow2 } = s; | ^^^^^^^^^^^^^^^ second mutable borrow occurs here ... -LL | } - | - first borrow ends here +LL | borrow1.use_mut(); + | ------- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/immut-function-arguments.ast.stderr b/src/test/ui/immut-function-arguments.ast.stderr deleted file mode 100644 index 1b5615a4cca..00000000000 --- a/src/test/ui/immut-function-arguments.ast.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0594]: cannot assign to immutable `Box` content `*y` - --> $DIR/immut-function-arguments.rs:5:5 - | -LL | fn f(y: Box) { - | - help: make this binding mutable: `mut y` -LL | *y = 5; - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to immutable `Box` content `*q` - --> $DIR/immut-function-arguments.rs:10:35 - | -LL | let _frob = |q: Box| { *q = 2; }; - | - ^^^^^^ cannot borrow as mutable - | | - | help: make this binding mutable: `mut q` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/immut-function-arguments.mir.stderr b/src/test/ui/immut-function-arguments.mir.stderr deleted file mode 100644 index 48471372342..00000000000 --- a/src/test/ui/immut-function-arguments.mir.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0594]: cannot assign to `*y`, as `y` is not declared as mutable - --> $DIR/immut-function-arguments.rs:5:5 - | -LL | fn f(y: Box) { - | - help: consider changing this to be mutable: `mut y` -LL | *y = 5; - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `*q`, as `q` is not declared as mutable - --> $DIR/immut-function-arguments.rs:10:35 - | -LL | let _frob = |q: Box| { *q = 2; }; - | - ^^^^^^ cannot assign - | | - | help: consider changing this to be mutable: `mut q` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/immut-function-arguments.rs b/src/test/ui/immut-function-arguments.rs index 2cc9c694ef1..242a33e8216 100644 --- a/src/test/ui/immut-function-arguments.rs +++ b/src/test/ui/immut-function-arguments.rs @@ -1,14 +1,9 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn f(y: Box) { - *y = 5; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign + *y = 5; //~ ERROR cannot assign } fn g() { - let _frob = |q: Box| { *q = 2; }; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign + let _frob = |q: Box| { *q = 2; }; //~ ERROR cannot assign } fn main() {} diff --git a/src/test/ui/immut-function-arguments.ast.nll.stderr b/src/test/ui/immut-function-arguments.stderr similarity index 86% rename from src/test/ui/immut-function-arguments.ast.nll.stderr rename to src/test/ui/immut-function-arguments.stderr index 48471372342..7871ba52db9 100644 --- a/src/test/ui/immut-function-arguments.ast.nll.stderr +++ b/src/test/ui/immut-function-arguments.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `*y`, as `y` is not declared as mutable - --> $DIR/immut-function-arguments.rs:5:5 + --> $DIR/immut-function-arguments.rs:2:5 | LL | fn f(y: Box) { | - help: consider changing this to be mutable: `mut y` @@ -7,7 +7,7 @@ LL | *y = 5; | ^^^^^^ cannot assign error[E0594]: cannot assign to `*q`, as `q` is not declared as mutable - --> $DIR/immut-function-arguments.rs:10:35 + --> $DIR/immut-function-arguments.rs:6:35 | LL | let _frob = |q: Box| { *q = 2; }; | - ^^^^^^ cannot assign diff --git a/src/test/ui/in-band-lifetimes/mut_while_borrow.nll.stderr b/src/test/ui/in-band-lifetimes/mut_while_borrow.nll.stderr deleted file mode 100644 index f96ff9dd4e6..00000000000 --- a/src/test/ui/in-band-lifetimes/mut_while_borrow.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0506]: cannot assign to `p` because it is borrowed - --> $DIR/mut_while_borrow.rs:9:5 - | -LL | let r = foo(&p); - | -- borrow of `p` occurs here -LL | p += 1; - | ^^^^^^ assignment to borrowed `p` occurs here -LL | println!("{}", 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/in-band-lifetimes/mut_while_borrow.stderr b/src/test/ui/in-band-lifetimes/mut_while_borrow.stderr index 556c15d0edb..f96ff9dd4e6 100644 --- a/src/test/ui/in-band-lifetimes/mut_while_borrow.stderr +++ b/src/test/ui/in-band-lifetimes/mut_while_borrow.stderr @@ -2,9 +2,11 @@ error[E0506]: cannot assign to `p` because it is borrowed --> $DIR/mut_while_borrow.rs:9:5 | LL | let r = foo(&p); - | - borrow of `p` occurs here + | -- borrow of `p` occurs here LL | p += 1; | ^^^^^^ assignment to borrowed `p` occurs here +LL | println!("{}", r); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-10398.nll.stderr b/src/test/ui/issues/issue-10398.nll.stderr deleted file mode 100644 index f5f4974265b..00000000000 --- a/src/test/ui/issues/issue-10398.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/issue-10398.rs:7:14 - | -LL | let _a = x; - | - value moved here -LL | drop(x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, 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/issues/issue-10398.stderr b/src/test/ui/issues/issue-10398.stderr index ceb2cfe2b75..f5f4974265b 100644 --- a/src/test/ui/issues/issue-10398.stderr +++ b/src/test/ui/issues/issue-10398.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/issue-10398.rs:7:14 | LL | let _a = x; - | -- value moved here + | - value moved here LL | drop(x); | ^ value used here after move | diff --git a/src/test/ui/issues/issue-11192.nll.stderr b/src/test/ui/issues/issue-11192.nll.stderr deleted file mode 100644 index 2a9d913171c..00000000000 --- a/src/test/ui/issues/issue-11192.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable - --> $DIR/issue-11192.rs:20:10 - | -LL | let mut test = |foo: &Foo| { - | ----------- mutable borrow occurs here -LL | println!("access {}", foo.x); -LL | ptr = box Foo { x: ptr.x + 1 }; - | --- first borrow occurs due to use of `ptr` in closure -... -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/issues/issue-11192.stderr b/src/test/ui/issues/issue-11192.stderr index ce90b16207f..2a9d913171c 100644 --- a/src/test/ui/issues/issue-11192.stderr +++ b/src/test/ui/issues/issue-11192.stderr @@ -1,17 +1,16 @@ -error[E0502]: cannot borrow `*ptr` as immutable because `ptr` is also borrowed as mutable - --> $DIR/issue-11192.rs:20:11 +error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as mutable + --> $DIR/issue-11192.rs:20:10 | LL | let mut test = |foo: &Foo| { | ----------- mutable borrow occurs here LL | println!("access {}", foo.x); 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 | test(&*ptr); - | ^^^^ immutable borrow occurs here -LL | -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/issues/issue-11493.ast.stderr b/src/test/ui/issues/issue-11493.ast.stderr deleted file mode 100644 index a5f8aefd194..00000000000 --- a/src/test/ui/issues/issue-11493.ast.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: borrowed value does not live long enough (Ast) - --> $DIR/issue-11493.rs:10:35 - | -LL | let y = x.as_ref().unwrap_or(&id(5)); - | ^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here - | - = note: consider using a `let` binding to increase its lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-11493.mir.stderr b/src/test/ui/issues/issue-11493.mir.stderr deleted file mode 100644 index a5f8aefd194..00000000000 --- a/src/test/ui/issues/issue-11493.mir.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: borrowed value does not live long enough (Ast) - --> $DIR/issue-11493.rs:10:35 - | -LL | let y = x.as_ref().unwrap_or(&id(5)); - | ^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here - | - = note: consider using a `let` binding to increase its lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-11493.rs b/src/test/ui/issues/issue-11493.rs index 4fdc32b42c2..b28c173b19b 100644 --- a/src/test/ui/issues/issue-11493.rs +++ b/src/test/ui/issues/issue-11493.rs @@ -1,14 +1,7 @@ -// This file must never have a trailing newline -// -// revisions: ast mir -// compile-flags: -Z borrowck=compare - fn id(x: T) -> T { x } fn main() { let x = Some(3); - let y = x.as_ref().unwrap_or(&id(5)); - //[ast]~^ ERROR borrowed value does not live long enough (Ast) - //[mir]~^^ ERROR borrowed value does not live long enough (Ast) - // This actually passes in mir + let y = x.as_ref().unwrap_or(&id(5)); //~ ERROR + &y; } diff --git a/src/test/ui/issues/issue-11493.stderr b/src/test/ui/issues/issue-11493.stderr new file mode 100644 index 00000000000..f954d64ac5b --- /dev/null +++ b/src/test/ui/issues/issue-11493.stderr @@ -0,0 +1,15 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/issue-11493.rs:5:35 + | +LL | let y = x.as_ref().unwrap_or(&id(5)); + | ^^^^^ - temporary value is freed at the end of this statement + | | + | creates a temporary which is freed while still in use +LL | &y; + | -- 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/issues/issue-11681.nll.stderr b/src/test/ui/issues/issue-11681.nll.stderr deleted file mode 100644 index f2f93076671..00000000000 --- a/src/test/ui/issues/issue-11681.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-11681.rs:13:10 - | -LL | let testValue = &Test; - | ---- temporary value created here -LL | return testValue; - | ^^^^^^^^^ 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/issues/issue-11681.rs b/src/test/ui/issues/issue-11681.rs index 8294ca6b22e..6d8810d8052 100644 --- a/src/test/ui/issues/issue-11681.rs +++ b/src/test/ui/issues/issue-11681.rs @@ -9,8 +9,8 @@ impl Drop for Test { } fn createTest<'a>() -> &'a Test { - let testValue = &Test; //~ ERROR borrowed value does not live long enough - return testValue; + let testValue = &Test; + return testValue; //~ ERROR cannot return value referencing temporary value } diff --git a/src/test/ui/issues/issue-11681.stderr b/src/test/ui/issues/issue-11681.stderr index f59ddb07642..f2f93076671 100644 --- a/src/test/ui/issues/issue-11681.stderr +++ b/src/test/ui/issues/issue-11681.stderr @@ -1,18 +1,11 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-11681.rs:12:20 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-11681.rs:13:10 | LL | let testValue = &Test; - | ^^^^ temporary value does not live long enough + | ---- temporary value created here LL | return testValue; -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 11:15... - --> $DIR/issue-11681.rs:11:15 - | -LL | fn createTest<'a>() -> &'a Test { - | ^^ + | ^^^^^^^^^ 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/issues/issue-11873.nll.stderr b/src/test/ui/issues/issue-11873.nll.stderr deleted file mode 100644 index 4475bdf1474..00000000000 --- a/src/test/ui/issues/issue-11873.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/issue-11873.rs:4:14 - | -LL | let mut f = || v.push(2); - | -- - borrow occurs due to use in closure - | | - | borrow of `v` occurs here -LL | let _w = v; - | ^ move out of `v` occurs here -LL | -LL | f(); - | - 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/issues/issue-11873.stderr b/src/test/ui/issues/issue-11873.stderr index 63bb4e7bd04..4475bdf1474 100644 --- a/src/test/ui/issues/issue-11873.stderr +++ b/src/test/ui/issues/issue-11873.stderr @@ -1,10 +1,15 @@ error[E0505]: cannot move out of `v` because it is borrowed - --> $DIR/issue-11873.rs:4:9 + --> $DIR/issue-11873.rs:4:14 | LL | let mut f = || v.push(2); - | -- borrow of `v` occurs here + | -- - borrow occurs due to use in closure + | | + | borrow of `v` occurs here LL | let _w = v; - | ^^ move out of `v` occurs here + | ^ move out of `v` occurs here +LL | +LL | f(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-12041.nll.stderr b/src/test/ui/issues/issue-12041.nll.stderr deleted file mode 100644 index d95cc89ce99..00000000000 --- a/src/test/ui/issues/issue-12041.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0382]: use of moved value: `tx` - --> $DIR/issue-12041.rs:8:22 - | -LL | let tx = tx; - | ^^ value moved here, in previous iteration of loop - | - = note: move occurs because `tx` has type `std::sync::mpsc::Sender`, 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/issues/issue-12041.stderr b/src/test/ui/issues/issue-12041.stderr index 48544c073ef..d95cc89ce99 100644 --- a/src/test/ui/issues/issue-12041.stderr +++ b/src/test/ui/issues/issue-12041.stderr @@ -1,8 +1,8 @@ error[E0382]: use of moved value: `tx` - --> $DIR/issue-12041.rs:8:17 + --> $DIR/issue-12041.rs:8:22 | LL | let tx = tx; - | ^^ value moved here in previous iteration of loop + | ^^ value moved here, in previous iteration of loop | = note: move occurs because `tx` has type `std::sync::mpsc::Sender`, which does not implement the `Copy` trait diff --git a/src/test/ui/issues/issue-12470.nll.stderr b/src/test/ui/issues/issue-12470.nll.stderr deleted file mode 100644 index c97e59195ed..00000000000 --- a/src/test/ui/issues/issue-12470.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing local data `*b` - --> $DIR/issue-12470.rs:29:5 - | -LL | let bb: &B = &*b; - | --- `*b` is borrowed here -LL | make_a(bb) - | ^^^^^^^^^^ 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/issues/issue-12470.rs b/src/test/ui/issues/issue-12470.rs index acf1b764fd9..77b78c8a1f7 100644 --- a/src/test/ui/issues/issue-12470.rs +++ b/src/test/ui/issues/issue-12470.rs @@ -25,8 +25,8 @@ fn make_a<'a>(p: &'a X) -> A<'a> { fn make_make_a<'a>() -> A<'a> { let b: Box = box B {i:1}; - let bb: &B = &*b; //~ ERROR does not live long enough - make_a(bb) + let bb: &B = &*b; + make_a(bb) //~ ERROR cannot return value referencing local data `*b` } fn main() { diff --git a/src/test/ui/issues/issue-12470.stderr b/src/test/ui/issues/issue-12470.stderr index fadfb75cde6..c97e59195ed 100644 --- a/src/test/ui/issues/issue-12470.stderr +++ b/src/test/ui/issues/issue-12470.stderr @@ -1,18 +1,11 @@ -error[E0597]: `*b` does not live long enough - --> $DIR/issue-12470.rs:28:19 +error[E0515]: cannot return value referencing local data `*b` + --> $DIR/issue-12470.rs:29:5 | LL | let bb: &B = &*b; - | ^^ borrowed value does not live long enough + | --- `*b` is borrowed here LL | make_a(bb) -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 26:16... - --> $DIR/issue-12470.rs:26:16 - | -LL | fn make_make_a<'a>() -> A<'a> { - | ^^ + | ^^^^^^^^^^ 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/issues/issue-12567.nll.stderr b/src/test/ui/issues/issue-12567.nll.stderr deleted file mode 100644 index 17388df91d1..00000000000 --- a/src/test/ui/issues/issue-12567.nll.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:4:11 - | -LL | match (l1, l2) { - | ^^^^^^^^ cannot move out of here -LL | (&[], &[]) => println!("both empty"), -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | -- data moved here -... -LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/issue-12567.rs:6:17 - | -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^^ -... -LL | (&[hd1, ..], &[hd2, ..]) - | ^^^ - -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:4:11 - | -LL | match (l1, l2) { - | ^^^^^^^^ cannot move out of here -LL | (&[], &[]) => println!("both empty"), -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | -- data moved here -... -LL | (&[hd1, ..], &[hd2, ..]) - | --- ...and here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/issue-12567.rs:6:17 - | -LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^^ -... -LL | (&[hd1, ..], &[hd2, ..]) - | ^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/issues/issue-12567.rs b/src/test/ui/issues/issue-12567.rs index 1e1debe31ce..643d9a2fc69 100644 --- a/src/test/ui/issues/issue-12567.rs +++ b/src/test/ui/issues/issue-12567.rs @@ -2,15 +2,13 @@ fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) { match (l1, l2) { + //~^ ERROR: cannot move out of type `[T]`, a non-copy slice + //~| ERROR: cannot move out of type `[T]`, a non-copy slice (&[], &[]) => println!("both empty"), (&[], &[hd, ..]) | (&[hd, ..], &[]) => println!("one empty"), - //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice - //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice (&[hd1, ..], &[hd2, ..]) => println!("both nonempty"), - //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice - //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice } } diff --git a/src/test/ui/issues/issue-12567.stderr b/src/test/ui/issues/issue-12567.stderr index 15f723f1cee..1de29dc8c61 100644 --- a/src/test/ui/issues/issue-12567.stderr +++ b/src/test/ui/issues/issue-12567.stderr @@ -1,39 +1,45 @@ error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:6:16 + --> $DIR/issue-12567.rs:4:11 + | +LL | match (l1, l2) { + | ^^^^^^^^ cannot move out of here +... +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | -- data moved here +LL | => println!("one empty"), +LL | (&[hd1, ..], &[hd2, ..]) + | --- ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/issue-12567.rs:8:17 | LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^--^^^^^ - | || - | |hint: to prevent move, use `ref hd` or `ref mut hd` - | cannot move out of here + | ^^ +LL | => println!("one empty"), +LL | (&[hd1, ..], &[hd2, ..]) + | ^^^ error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:6:30 + --> $DIR/issue-12567.rs:4:11 + | +LL | match (l1, l2) { + | ^^^^^^^^ cannot move out of here +... +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | -- data moved here +LL | => println!("one empty"), +LL | (&[hd1, ..], &[hd2, ..]) + | --- ...and here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/issue-12567.rs:8:17 | LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) - | ^--^^^^^ - | || - | |hint: to prevent move, use `ref hd` or `ref mut hd` - | cannot move out of here - -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:10:11 - | + | ^^ +LL | => println!("one empty"), LL | (&[hd1, ..], &[hd2, ..]) - | ^---^^^^^ - | || - | |hint: to prevent move, use `ref hd1` or `ref mut hd1` - | cannot move out of here + | ^^^ -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:10:23 - | -LL | (&[hd1, ..], &[hd2, ..]) - | ^---^^^^^ - | || - | |hint: to prevent move, use `ref hd2` or `ref mut hd2` - | cannot move out of here - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/issues/issue-13497-2.nll.stderr b/src/test/ui/issues/issue-13497-2.nll.stderr deleted file mode 100644 index 8ad921027e2..00000000000 --- a/src/test/ui/issues/issue-13497-2.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0515]: cannot return value referencing local variable `rawLines` - --> $DIR/issue-13497-2.rs:3:5 - | -LL | rawLines - | ^------- - | | - | _____`rawLines` is borrowed here - | | -LL | | .iter().map(|l| l.trim()).collect() - | |___________________________________________^ 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/issues/issue-13497-2.rs b/src/test/ui/issues/issue-13497-2.rs index a39ae4f1cf3..c82da0f0096 100644 --- a/src/test/ui/issues/issue-13497-2.rs +++ b/src/test/ui/issues/issue-13497-2.rs @@ -1,6 +1,6 @@ fn read_lines_borrowed<'a>() -> Vec<&'a str> { let rawLines: Vec = vec!["foo ".to_string(), " bar".to_string()]; - rawLines //~ ERROR `rawLines` does not live long enough + rawLines //~ ERROR cannot return value referencing local variable `rawLines` .iter().map(|l| l.trim()).collect() } diff --git a/src/test/ui/issues/issue-13497-2.stderr b/src/test/ui/issues/issue-13497-2.stderr index 5fde55cce00..8ad921027e2 100644 --- a/src/test/ui/issues/issue-13497-2.stderr +++ b/src/test/ui/issues/issue-13497-2.stderr @@ -1,18 +1,14 @@ -error[E0597]: `rawLines` does not live long enough +error[E0515]: cannot return value referencing local variable `rawLines` --> $DIR/issue-13497-2.rs:3:5 | -LL | rawLines - | ^^^^^^^^ borrowed value does not live long enough -LL | .iter().map(|l| l.trim()).collect() -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 1:24... - --> $DIR/issue-13497-2.rs:1:24 - | -LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { - | ^^ +LL | rawLines + | ^------- + | | + | _____`rawLines` is borrowed here + | | +LL | | .iter().map(|l| l.trim()).collect() + | |___________________________________________^ 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/issues/issue-17263.ast.stderr b/src/test/ui/issues/issue-17263.ast.stderr deleted file mode 100644 index 09e33073a5b..00000000000 --- a/src/test/ui/issues/issue-17263.ast.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0499]: cannot borrow `x` (via `x.b`) as mutable more than once at a time - --> $DIR/issue-17263.rs:17:34 - | -LL | let (a, b) = (&mut x.a, &mut x.b); - | --- ^^^ second mutable borrow occurs here (via `x.b`) - | | - | first mutable borrow occurs here (via `x.a`) -... -LL | } - | - first borrow ends here - -error[E0502]: cannot borrow `foo` (via `foo.b`) as immutable because `foo` is also borrowed as mutable (via `foo.a`) - --> $DIR/issue-17263.rs:21:32 - | -LL | let (c, d) = (&mut foo.a, &foo.b); - | ----- ^^^^^ immutable borrow of `foo.b` -- which overlaps with `foo.a` -- occurs here - | | - | mutable borrow occurs here (via `foo.a`) -... -LL | } - | - mutable borrow ends 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/issues/issue-17263.nll.stderr b/src/test/ui/issues/issue-17263.nll.stderr deleted file mode 100644 index 5604037a38d..00000000000 --- a/src/test/ui/issues/issue-17263.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/issue-17263.rs:15:1 - | -LL | / fn main() { -LL | | let mut x: Box<_> = box Foo { a: 1, b: 2 }; -LL | | let (a, b) = (&mut x.a, &mut x.b); -LL | | -... | -LL | | use_mut(a); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-17263.rs b/src/test/ui/issues/issue-17263.rs index 754f3b90aac..dce30275ff3 100644 --- a/src/test/ui/issues/issue-17263.rs +++ b/src/test/ui/issues/issue-17263.rs @@ -1,28 +1,18 @@ -// This checks diagnostic quality for cases where AST-borrowck treated -// `Box` as other types (see rust-lang/rfcs#130). NLL again treats -// `Box` specially. We capture the differences via revisions. +// compile-pass -// revisions: ast nll -//[ast]compile-flags: -Z borrowck=ast -//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows - -// don't worry about the --compare-mode=nll on this test. -// ignore-compare-mode-nll -#![feature(box_syntax, rustc_attrs)] +#![feature(box_syntax)] struct Foo { a: isize, b: isize } -#[rustc_error] // rust-lang/rust#49855 -fn main() { //[nll]~ ERROR compilation successful + +fn main() { let mut x: Box<_> = box Foo { a: 1, b: 2 }; let (a, b) = (&mut x.a, &mut x.b); - //[ast]~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time let mut foo: Box<_> = box Foo { a: 1, b: 2 }; let (c, d) = (&mut foo.a, &foo.b); - //[ast]~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable - // We explicitly use the references created above to illustrate - // that NLL is accepting this code *not* because of artificially + // We explicitly use the references created above to illustrate that the + // borrow checker is accepting this code *not* because of artificially // short lifetimes, but rather because it understands that all the // references are of disjoint parts of memory. use_imm(d); diff --git a/src/test/ui/issues/issue-17385.nll.stderr b/src/test/ui/issues/issue-17385.nll.stderr deleted file mode 100644 index 28c22260c38..00000000000 --- a/src/test/ui/issues/issue-17385.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0382]: use of moved value: `foo` - --> $DIR/issue-17385.rs:19:11 - | -LL | let foo = X(1); - | --- move occurs because `foo` has type `X`, which does not implement the `Copy` trait -LL | drop(foo); - | --- value moved here -LL | match foo { -LL | X(1) => (), - | ^ value used here after move - -error[E0382]: use of moved value: `e` - --> $DIR/issue-17385.rs:25:11 - | -LL | let e = Enum::Variant2; - | - move occurs because `e` has type `Enum`, which does not implement the `Copy` trait -LL | drop(e); - | - value moved here -LL | match e { - | ^ value used 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/issues/issue-17385.rs b/src/test/ui/issues/issue-17385.rs index 7400aadb059..93364d2f625 100644 --- a/src/test/ui/issues/issue-17385.rs +++ b/src/test/ui/issues/issue-17385.rs @@ -15,8 +15,8 @@ impl Drop for Enum { fn main() { let foo = X(1); drop(foo); - match foo { //~ ERROR use of moved value - X(1) => (), + match foo { + X(1) => (), //~ ERROR use of moved value _ => unreachable!() } diff --git a/src/test/ui/issues/issue-17385.stderr b/src/test/ui/issues/issue-17385.stderr index ee55d862e13..28c22260c38 100644 --- a/src/test/ui/issues/issue-17385.stderr +++ b/src/test/ui/issues/issue-17385.stderr @@ -1,22 +1,23 @@ error[E0382]: use of moved value: `foo` - --> $DIR/issue-17385.rs:18:11 + --> $DIR/issue-17385.rs:19:11 | +LL | let foo = X(1); + | --- move occurs because `foo` has type `X`, which does not implement the `Copy` trait LL | drop(foo); | --- value moved here LL | match foo { - | ^^^ value used here after move - | - = note: move occurs because `foo` has type `X`, which does not implement the `Copy` trait +LL | X(1) => (), + | ^ value used here after move error[E0382]: use of moved value: `e` --> $DIR/issue-17385.rs:25:11 | +LL | let e = Enum::Variant2; + | - move occurs because `e` has type `Enum`, which does not implement the `Copy` trait LL | drop(e); | - value moved here LL | match e { | ^ value used here after move - | - = note: move occurs because `e` has type `Enum`, which does not implement the `Copy` trait error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-17545.nll.stderr b/src/test/ui/issues/issue-17545.nll.stderr deleted file mode 100644 index 79a1e09bd7c..00000000000 --- a/src/test/ui/issues/issue-17545.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-17545.rs:7:10 - | -LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { - | -- lifetime `'a` defined here -LL | / bar.call(( -LL | | &id(()), - | | ^^^^^^ creates a temporary which is freed while still in use -LL | | )); - | | -- temporary value is freed at the end of this statement - | |______| - | argument requires that borrow lasts for `'a` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-17545.rs b/src/test/ui/issues/issue-17545.rs index d62c0b9f32c..ced6fff315f 100644 --- a/src/test/ui/issues/issue-17545.rs +++ b/src/test/ui/issues/issue-17545.rs @@ -4,7 +4,7 @@ fn id(x: T) -> T { x } pub fn foo<'a, F: Fn(&'a ())>(bar: F) { bar.call(( - &id(()), //~ ERROR borrowed value does not live long enough + &id(()), //~ ERROR temporary value dropped while borrowed )); } fn main() {} diff --git a/src/test/ui/issues/issue-17545.stderr b/src/test/ui/issues/issue-17545.stderr index c4acaf2278e..79a1e09bd7c 100644 --- a/src/test/ui/issues/issue-17545.stderr +++ b/src/test/ui/issues/issue-17545.stderr @@ -1,18 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-17545.rs:7:10 | -LL | &id(()), - | ^^^^^^ temporary value does not live long enough -LL | )); - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 5:12... - --> $DIR/issue-17545.rs:5:12 - | -LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { - | ^^ - = note: consider using a `let` binding to increase its lifetime +LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { + | -- lifetime `'a` defined here +LL | / bar.call(( +LL | | &id(()), + | | ^^^^^^ creates a temporary which is freed while still in use +LL | | )); + | | -- temporary value is freed at the end of this statement + | |______| + | argument requires that borrow lasts for `'a` 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/issues/issue-17718-constants-not-static.nll.stderr b/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr deleted file mode 100644 index 8f3acae7139..00000000000 --- a/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/issue-17718-constants-not-static.rs:5:30 - | -LL | fn foo() -> &'static usize { &id(FOO) } - | ^------- - | || - | |temporary value created here - | 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/issues/issue-17718-constants-not-static.rs b/src/test/ui/issues/issue-17718-constants-not-static.rs index e857b906efa..2e6aff1618b 100644 --- a/src/test/ui/issues/issue-17718-constants-not-static.rs +++ b/src/test/ui/issues/issue-17718-constants-not-static.rs @@ -3,7 +3,7 @@ fn id(x: T) -> T { x } const FOO: usize = 3; fn foo() -> &'static usize { &id(FOO) } -//~^ ERROR: borrowed value does not live long enough +//~^ ERROR: cannot return reference to temporary value fn main() { } diff --git a/src/test/ui/issues/issue-17718-constants-not-static.stderr b/src/test/ui/issues/issue-17718-constants-not-static.stderr index 2a5b9d72223..8f3acae7139 100644 --- a/src/test/ui/issues/issue-17718-constants-not-static.stderr +++ b/src/test/ui/issues/issue-17718-constants-not-static.stderr @@ -1,13 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-17718-constants-not-static.rs:5:31 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-17718-constants-not-static.rs:5:30 | LL | fn foo() -> &'static usize { &id(FOO) } - | ^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = 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 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/issues/issue-17718-static-move.nll.stderr b/src/test/ui/issues/issue-17718-static-move.nll.stderr deleted file mode 100644 index c3e6267d30f..00000000000 --- a/src/test/ui/issues/issue-17718-static-move.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of static item - --> $DIR/issue-17718-static-move.rs:6:14 - | -LL | let _a = FOO; - | ^^^ - | | - | cannot move out of static item - | help: consider borrowing here: `&FOO` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-17718-static-move.stderr b/src/test/ui/issues/issue-17718-static-move.stderr index 064a991e4a3..c3e6267d30f 100644 --- a/src/test/ui/issues/issue-17718-static-move.stderr +++ b/src/test/ui/issues/issue-17718-static-move.stderr @@ -5,7 +5,7 @@ LL | let _a = FOO; | ^^^ | | | cannot move out of static item - | help: consider using a reference instead: `&FOO` + | help: consider borrowing here: `&FOO` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-17954.nll.stderr b/src/test/ui/issues/issue-17954.nll.stderr deleted file mode 100644 index e08375fee1f..00000000000 --- a/src/test/ui/issues/issue-17954.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0712]: thread-local variable borrowed past end of function - --> $DIR/issue-17954.rs:7:13 - | -LL | let a = &FOO; - | ^^^^ thread-local variables cannot be borrowed beyond the end of the function -... -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/issues/issue-17954.rs b/src/test/ui/issues/issue-17954.rs index a8fbf2372b0..eb6a3d70f58 100644 --- a/src/test/ui/issues/issue-17954.rs +++ b/src/test/ui/issues/issue-17954.rs @@ -5,12 +5,11 @@ static FOO: u8 = 3; fn main() { let a = &FOO; - //~^ ERROR borrowed value does not live long enough - //~| does not live long enough - //~| NOTE borrowed value must be valid for the static lifetime + //~^ ERROR thread-local variable borrowed past end of function + //~| NOTE thread-local variables cannot be borrowed beyond the end of the function std::thread::spawn(move || { println!("{}", a); }); } -//~^ NOTE borrowed value only lives until here +//~^ NOTE end of enclosing function is here diff --git a/src/test/ui/issues/issue-17954.stderr b/src/test/ui/issues/issue-17954.stderr index 458bef54992..e08375fee1f 100644 --- a/src/test/ui/issues/issue-17954.stderr +++ b/src/test/ui/issues/issue-17954.stderr @@ -1,14 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-17954.rs:7:14 +error[E0712]: thread-local variable borrowed past end of function + --> $DIR/issue-17954.rs:7:13 | LL | let a = &FOO; - | ^^^ borrowed value does not live long enough + | ^^^^ thread-local variables cannot be borrowed beyond the end of the function ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - end of enclosing function is 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 E0712`. diff --git a/src/test/ui/issues/issue-18118.nll.stderr b/src/test/ui/issues/issue-18118.nll.stderr deleted file mode 100644 index 49798a148de..00000000000 --- a/src/test/ui/issues/issue-18118.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `p` does not live long enough - --> $DIR/issue-18118.rs:4:9 - | -LL | &p - | ^^ - | | - | borrowed value does not live long enough - | using this value as a constant requires that `p` is borrowed for `'static` -LL | }; - | - `p` 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/issues/issue-18118.stderr b/src/test/ui/issues/issue-18118.stderr index 07fa1f60e06..49798a148de 100644 --- a/src/test/ui/issues/issue-18118.stderr +++ b/src/test/ui/issues/issue-18118.stderr @@ -1,12 +1,13 @@ error[E0597]: `p` does not live long enough - --> $DIR/issue-18118.rs:4:10 + --> $DIR/issue-18118.rs:4:9 | LL | &p - | ^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | using this value as a constant requires that `p` is borrowed for `'static` LL | }; - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `p` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18566.nll.stderr b/src/test/ui/issues/issue-18566.nll.stderr deleted file mode 100644 index 8db78935f83..00000000000 --- a/src/test/ui/issues/issue-18566.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `*s` as mutable more than once at a time - --> $DIR/issue-18566.rs:23:19 - | -LL | MyPtr(s).poke(s); - | - ---- ^ second mutable borrow occurs here - | | | - | | first borrow later used by call - | first 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/issues/issue-18566.stderr b/src/test/ui/issues/issue-18566.stderr index 90c3af48eb4..8db78935f83 100644 --- a/src/test/ui/issues/issue-18566.stderr +++ b/src/test/ui/issues/issue-18566.stderr @@ -2,9 +2,9 @@ error[E0499]: cannot borrow `*s` as mutable more than once at a time --> $DIR/issue-18566.rs:23:19 | LL | MyPtr(s).poke(s); - | - ^- first borrow ends here - | | | - | | second mutable borrow occurs here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18783.nll.stderr b/src/test/ui/issues/issue-18783.nll.stderr deleted file mode 100644 index 047b42578a2..00000000000 --- a/src/test/ui/issues/issue-18783.nll.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0499]: cannot borrow `y` as mutable more than once at a time - --> $DIR/issue-18783.rs:7:21 - | -LL | c.push(Box::new(|| y = 0)); - | -- - first borrow occurs due to use of `y` in closure - | | - | first mutable borrow occurs here -LL | c.push(Box::new(|| y = 0)); - | ^^ - second borrow occurs due to use of `y` in closure - | | - | second mutable borrow occurs here -LL | -LL | } - | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` - -error[E0499]: cannot borrow `y` as mutable more than once at a time - --> $DIR/issue-18783.rs:16:29 - | -LL | Push::push(&c, Box::new(|| y = 0)); - | -- - first borrow occurs due to use of `y` in closure - | | - | first mutable borrow occurs here -LL | Push::push(&c, Box::new(|| y = 0)); - | ^^ - second borrow occurs due to use of `y` in closure - | | - | second mutable borrow occurs here -LL | -LL | } - | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/issues/issue-18783.stderr b/src/test/ui/issues/issue-18783.stderr index f88c42552e3..047b42578a2 100644 --- a/src/test/ui/issues/issue-18783.stderr +++ b/src/test/ui/issues/issue-18783.stderr @@ -2,31 +2,31 @@ error[E0499]: cannot borrow `y` as mutable more than once at a time --> $DIR/issue-18783.rs:7:21 | LL | c.push(Box::new(|| y = 0)); - | -- - previous borrow occurs due to use of `y` in closure + | -- - first borrow occurs due to use of `y` in closure | | | first mutable borrow occurs here LL | c.push(Box::new(|| y = 0)); - | ^^ - borrow occurs due to use of `y` in closure + | ^^ - second borrow occurs due to use of `y` in closure | | | second mutable borrow occurs here LL | LL | } - | - first borrow ends here + | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` error[E0499]: cannot borrow `y` as mutable more than once at a time --> $DIR/issue-18783.rs:16:29 | LL | Push::push(&c, Box::new(|| y = 0)); - | -- - previous borrow occurs due to use of `y` in closure + | -- - first borrow occurs due to use of `y` in closure | | | first mutable borrow occurs here LL | Push::push(&c, Box::new(|| y = 0)); - | ^^ - borrow occurs due to use of `y` in closure + | ^^ - second borrow occurs due to use of `y` in closure | | | second mutable borrow occurs here LL | LL | } - | - first borrow ends here + | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-19163.nll.stderr b/src/test/ui/issues/issue-19163.nll.stderr deleted file mode 100644 index af509aa59d4..00000000000 --- a/src/test/ui/issues/issue-19163.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/issue-19163.rs:9:14 - | -LL | mywrite!(&v, "Hello world"); - | ^^ 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/issues/issue-19163.rs b/src/test/ui/issues/issue-19163.rs index 20d3244027d..d98c5912af2 100644 --- a/src/test/ui/issues/issue-19163.rs +++ b/src/test/ui/issues/issue-19163.rs @@ -7,5 +7,5 @@ use std::io::Write; fn main() { let mut v = vec![]; mywrite!(&v, "Hello world"); - //~^ error: cannot borrow immutable borrowed content as mutable + //~^ ERROR cannot borrow data in a `&` reference as mutable } diff --git a/src/test/ui/issues/issue-19163.stderr b/src/test/ui/issues/issue-19163.stderr index 242ceaedcb0..af509aa59d4 100644 --- a/src/test/ui/issues/issue-19163.stderr +++ b/src/test/ui/issues/issue-19163.stderr @@ -1,4 +1,4 @@ -error[E0596]: cannot borrow immutable borrowed content as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/issue-19163.rs:9:14 | LL | mywrite!(&v, "Hello world"); diff --git a/src/test/ui/issues/issue-20801.nll.stderr b/src/test/ui/issues/issue-20801.nll.stderr deleted file mode 100644 index adcbe55aa32..00000000000 --- a/src/test/ui/issues/issue-20801.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-20801.rs:26:22 - | -LL | let a = unsafe { *mut_ref() }; - | ^^^^^^^^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `mut_ref()` - -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-20801.rs:29:22 - | -LL | let b = unsafe { *imm_ref() }; - | ^^^^^^^^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `imm_ref()` - -error[E0507]: cannot move out of dereference of raw pointer - --> $DIR/issue-20801.rs:32:22 - | -LL | let c = unsafe { *mut_ptr() }; - | ^^^^^^^^^^ - | | - | cannot move out of dereference of raw pointer - | help: consider removing the `*`: `mut_ptr()` - -error[E0507]: cannot move out of dereference of raw pointer - --> $DIR/issue-20801.rs:35:22 - | -LL | let d = unsafe { *const_ptr() }; - | ^^^^^^^^^^^^ - | | - | cannot move out of dereference of raw pointer - | help: consider removing the `*`: `const_ptr()` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-20801.stderr b/src/test/ui/issues/issue-20801.stderr index 3e273919bb9..adcbe55aa32 100644 --- a/src/test/ui/issues/issue-20801.stderr +++ b/src/test/ui/issues/issue-20801.stderr @@ -2,25 +2,37 @@ error[E0507]: cannot move out of borrowed content --> $DIR/issue-20801.rs:26:22 | LL | let a = unsafe { *mut_ref() }; - | ^^^^^^^^^^ cannot move out of borrowed content + | ^^^^^^^^^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `mut_ref()` error[E0507]: cannot move out of borrowed content --> $DIR/issue-20801.rs:29:22 | LL | let b = unsafe { *imm_ref() }; - | ^^^^^^^^^^ cannot move out of borrowed content + | ^^^^^^^^^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `imm_ref()` error[E0507]: cannot move out of dereference of raw pointer --> $DIR/issue-20801.rs:32:22 | LL | let c = unsafe { *mut_ptr() }; - | ^^^^^^^^^^ cannot move out of dereference of raw pointer + | ^^^^^^^^^^ + | | + | cannot move out of dereference of raw pointer + | help: consider removing the `*`: `mut_ptr()` error[E0507]: cannot move out of dereference of raw pointer --> $DIR/issue-20801.rs:35:22 | LL | let d = unsafe { *const_ptr() }; - | ^^^^^^^^^^^^ cannot move out of dereference of raw pointer + | ^^^^^^^^^^^^ + | | + | cannot move out of dereference of raw pointer + | help: consider removing the `*`: `const_ptr()` error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-21600.nll.stderr b/src/test/ui/issues/issue-21600.nll.stderr deleted file mode 100644 index 21f3774c056..00000000000 --- a/src/test/ui/issues/issue-21600.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/issue-21600.rs:14:20 - | -LL | call_it(|| x.gen_mut()); - | ^ cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/issue-21600.rs:14:17 - | -LL | call_it(|| x.gen_mut()); - | ^^^^^^^^^^^^^^ - -error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/issue-21600.rs:14:17 - | -LL | call_it(|| x.gen_mut()); - | ^^ - mutable borrow occurs due to use of `x` in closure - | | - | cannot borrow as mutable - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/issue-21600.rs:12:13 - | -LL | call_it(|| { - | _____________^ -LL | | call_it(|| x.gen()); -LL | | call_it(|| x.gen_mut()); -LL | | -LL | | }); - | |_____^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-21600.rs b/src/test/ui/issues/issue-21600.rs index 1efc873bee2..2e22e5e6fa2 100644 --- a/src/test/ui/issues/issue-21600.rs +++ b/src/test/ui/issues/issue-21600.rs @@ -11,7 +11,8 @@ fn main() { let mut x = A; call_it(|| { call_it(|| x.gen()); - call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer - //~^ ERROR cannot borrow data mutably in a captured outer + call_it(|| x.gen_mut()); + //~^ ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + //~| ERROR cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure }); } diff --git a/src/test/ui/issues/issue-21600.stderr b/src/test/ui/issues/issue-21600.stderr index a20838c6c9b..9c534809dbe 100644 --- a/src/test/ui/issues/issue-21600.stderr +++ b/src/test/ui/issues/issue-21600.stderr @@ -1,8 +1,22 @@ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/issue-21600.rs:14:20 + | +LL | call_it(|| x.gen_mut()); + | ^ cannot borrow as mutable + | +help: consider changing this to accept closures that implement `FnMut` --> $DIR/issue-21600.rs:14:17 | LL | call_it(|| x.gen_mut()); - | ^^ + | ^^^^^^^^^^^^^^ + +error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure + --> $DIR/issue-21600.rs:14:17 + | +LL | call_it(|| x.gen_mut()); + | ^^ - mutable borrow occurs due to use of `x` in closure + | | + | cannot borrow as mutable | help: consider changing this to accept closures that implement `FnMut` --> $DIR/issue-21600.rs:12:13 @@ -12,21 +26,10 @@ LL | call_it(|| { LL | | call_it(|| x.gen()); LL | | call_it(|| x.gen_mut()); LL | | +LL | | LL | | }); | |_____^ -error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure - --> $DIR/issue-21600.rs:14:20 - | -LL | call_it(|| x.gen_mut()); - | ^ - | -help: consider changing this closure to take self by mutable reference - --> $DIR/issue-21600.rs:14:17 - | -LL | call_it(|| x.gen_mut()); - | ^^^^^^^^^^^^^^ - error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0387`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-24267-flow-exit.nll.stderr b/src/test/ui/issues/issue-24267-flow-exit.nll.stderr deleted file mode 100644 index 3b4f27621f6..00000000000 --- a/src/test/ui/issues/issue-24267-flow-exit.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/issue-24267-flow-exit.rs:12:20 - | -LL | println!("{}", x); - | ^ use of possibly uninitialized `x` - -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/issue-24267-flow-exit.rs:18:20 - | -LL | println!("{}", x); - | ^ 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/issues/issue-24267-flow-exit.rs b/src/test/ui/issues/issue-24267-flow-exit.rs index ce3a799fb38..a1b4d75d404 100644 --- a/src/test/ui/issues/issue-24267-flow-exit.rs +++ b/src/test/ui/issues/issue-24267-flow-exit.rs @@ -9,11 +9,11 @@ pub fn main() { pub fn foo1() { let x: i32; loop { x = break; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` } pub fn foo2() { let x: i32; for _ in 0..10 { x = continue; } - println!("{}", x); //~ ERROR use of possibly uninitialized variable: `x` + println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x` } diff --git a/src/test/ui/issues/issue-24267-flow-exit.stderr b/src/test/ui/issues/issue-24267-flow-exit.stderr index 2b9e2ee9011..3b4f27621f6 100644 --- a/src/test/ui/issues/issue-24267-flow-exit.stderr +++ b/src/test/ui/issues/issue-24267-flow-exit.stderr @@ -1,10 +1,10 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/issue-24267-flow-exit.rs:12:20 | LL | println!("{}", x); | ^ use of possibly uninitialized `x` -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/issue-24267-flow-exit.rs:18:20 | LL | println!("{}", x); diff --git a/src/test/ui/issues/issue-24357.nll.stderr b/src/test/ui/issues/issue-24357.nll.stderr deleted file mode 100644 index a9c43a8f0d9..00000000000 --- a/src/test/ui/issues/issue-24357.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/issue-24357.rs:6:12 - | -LL | let x = NoCopy; - | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait -LL | let f = move || { let y = x; }; - | ------- - variable moved due to use in closure - | | - | value moved into closure here -LL | -LL | let z = x; - | ^ 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/issues/issue-24357.rs b/src/test/ui/issues/issue-24357.rs index 84f263ff649..152e69ebc87 100644 --- a/src/test/ui/issues/issue-24357.rs +++ b/src/test/ui/issues/issue-24357.rs @@ -1,10 +1,11 @@ struct NoCopy; fn main() { let x = NoCopy; + //~^ NOTE move occurs because `x` has type `NoCopy` let f = move || { let y = x; }; - //~^ NOTE value moved (into closure) here + //~^ NOTE value moved into closure here + //~| NOTE variable moved due to use in closure let z = x; //~^ ERROR use of moved value: `x` //~| NOTE value used here after move - //~| NOTE move occurs because `x` has type `NoCopy` } diff --git a/src/test/ui/issues/issue-24357.stderr b/src/test/ui/issues/issue-24357.stderr index ced24ffc5ed..b9e15f5e21b 100644 --- a/src/test/ui/issues/issue-24357.stderr +++ b/src/test/ui/issues/issue-24357.stderr @@ -1,13 +1,16 @@ error[E0382]: use of moved value: `x` - --> $DIR/issue-24357.rs:6:8 + --> $DIR/issue-24357.rs:8:12 | -LL | let f = move || { let y = x; }; - | ------- value moved (into closure) here +LL | let x = NoCopy; + | - move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait LL | +LL | let f = move || { let y = x; }; + | ------- - variable moved due to use in closure + | | + | value moved into closure here +... LL | let z = x; - | ^ value used here after move - | - = note: move occurs because `x` has type `NoCopy`, which does not implement the `Copy` trait + | ^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25579.ast.nll.stderr b/src/test/ui/issues/issue-25579.ast.nll.stderr deleted file mode 100644 index 107f88b413b..00000000000 --- a/src/test/ui/issues/issue-25579.ast.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error: compilation successful - --> $DIR/issue-25579.rs:21:1 - | -LL | / fn main() { -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-25579.ast.stderr b/src/test/ui/issues/issue-25579.ast.stderr deleted file mode 100644 index 31e74d1c1ed..00000000000 --- a/src/test/ui/issues/issue-25579.ast.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0499]: cannot borrow `l.0` as mutable more than once at a time - --> $DIR/issue-25579.rs:14:32 - | -LL | &mut Sexpression::Cons(ref mut expr) => { - | ^^^^^^^^^^^^ mutable borrow starts here in previous iteration of loop -... -LL | } - | - mutable borrow ends here - -error[E0506]: cannot assign to `l` because it is borrowed - --> $DIR/issue-25579.rs:15:13 - | -LL | &mut Sexpression::Cons(ref mut expr) => { - | ------------ borrow of `l` occurs here -LL | l = &mut **expr; - | ^^^^^^^^^^^^^^^ assignment to borrowed `l` occurs here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0499, E0506. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/issues/issue-25579.mir.stderr b/src/test/ui/issues/issue-25579.mir.stderr deleted file mode 100644 index 107f88b413b..00000000000 --- a/src/test/ui/issues/issue-25579.mir.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error: compilation successful - --> $DIR/issue-25579.rs:21:1 - | -LL | / fn main() { -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-25579.rs b/src/test/ui/issues/issue-25579.rs index 1813253332f..31ba102746b 100644 --- a/src/test/ui/issues/issue-25579.rs +++ b/src/test/ui/issues/issue-25579.rs @@ -1,7 +1,4 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -#![feature(rustc_attrs)] +// compile-pass enum Sexpression { Num(()), @@ -11,12 +8,13 @@ enum Sexpression { fn causes_error_in_ast(mut l: &mut Sexpression) { loop { match l { &mut Sexpression::Num(ref mut n) => {}, - &mut Sexpression::Cons(ref mut expr) => { //[ast]~ ERROR [E0499] - l = &mut **expr; //[ast]~ ERROR [E0506] + &mut Sexpression::Cons(ref mut expr) => { + l = &mut **expr; } }} } -#[rustc_error] -fn main() { //[mir]~ ERROR compilation successful + +fn main() { + causes_error_in_ast(&mut Sexpression::Num(())); } diff --git a/src/test/ui/issues/issue-25700.nll.stderr b/src/test/ui/issues/issue-25700.nll.stderr deleted file mode 100644 index fa309a55c3c..00000000000 --- a/src/test/ui/issues/issue-25700.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `t` - --> $DIR/issue-25700.rs:13:10 - | -LL | let t = S::<()>(None); - | - move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait -LL | drop(t); - | - value moved here -LL | drop(t); - | ^ 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/issues/issue-25700.stderr b/src/test/ui/issues/issue-25700.stderr index 4a203c7c257..fa309a55c3c 100644 --- a/src/test/ui/issues/issue-25700.stderr +++ b/src/test/ui/issues/issue-25700.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `t` --> $DIR/issue-25700.rs:13:10 | +LL | let t = S::<()>(None); + | - move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait LL | drop(t); | - value moved here LL | drop(t); | ^ value used here after move - | - = note: move occurs because `t` has type `S<()>`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25793.nll.stderr b/src/test/ui/issues/issue-25793.nll.stderr deleted file mode 100644 index daea9cd8cd7..00000000000 --- a/src/test/ui/issues/issue-25793.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0503]: cannot use `self.width` because it was mutably borrowed - --> $DIR/issue-25793.rs:4:9 - | -LL | $this.width.unwrap() - | ^^^^^^^^^^^ use of borrowed `*self` -... -LL | let r = &mut *self; - | ---------- borrow of `*self` occurs here -LL | r.get_size(width!(self)) - | -------- ------------ in this macro invocation - | | - | borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0503`. diff --git a/src/test/ui/issues/issue-25793.stderr b/src/test/ui/issues/issue-25793.stderr index e8d208c19aa..daea9cd8cd7 100644 --- a/src/test/ui/issues/issue-25793.stderr +++ b/src/test/ui/issues/issue-25793.stderr @@ -5,9 +5,11 @@ LL | $this.width.unwrap() | ^^^^^^^^^^^ use of borrowed `*self` ... LL | let r = &mut *self; - | ----- borrow of `*self` occurs here + | ---------- borrow of `*self` occurs here LL | r.get_size(width!(self)) - | ------------ in this macro invocation + | -------- ------------ in this macro invocation + | | + | borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/issues/issue-2590.nll.stderr b/src/test/ui/issues/issue-2590.nll.stderr deleted file mode 100644 index e19e83dc747..00000000000 --- a/src/test/ui/issues/issue-2590.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-2590.rs:11:9 - | -LL | self.tokens - | ^^^^^^^^^^^ 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/issues/issue-2590.stderr b/src/test/ui/issues/issue-2590.stderr index c50652d3284..e19e83dc747 100644 --- a/src/test/ui/issues/issue-2590.stderr +++ b/src/test/ui/issues/issue-2590.stderr @@ -2,7 +2,7 @@ error[E0507]: cannot move out of borrowed content --> $DIR/issue-2590.rs:11:9 | LL | self.tokens - | ^^^^ cannot move out of borrowed content + | ^^^^^^^^^^^ cannot move out of borrowed content error: aborting due to previous error diff --git a/src/test/ui/issues/issue-26619.nll.stderr b/src/test/ui/issues/issue-26619.nll.stderr deleted file mode 100644 index d1157cda92b..00000000000 --- a/src/test/ui/issues/issue-26619.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing function parameter - --> $DIR/issue-26619.rs:7:76 - | -LL | for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { - | -------- ^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function - | | - | function parameter borrowed here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-26619.rs b/src/test/ui/issues/issue-26619.rs index cd89c674e49..00e09f3f077 100644 --- a/src/test/ui/issues/issue-26619.rs +++ b/src/test/ui/issues/issue-26619.rs @@ -5,7 +5,7 @@ pub struct History<'a> { pub _s: &'a str } impl<'a> History<'a> { pub fn get_page(&self) { for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { - //~^ ERROR borrowed value does not live long enough + //~^ ERROR cannot return value referencing function parameter println!("{:?}", s); } } diff --git a/src/test/ui/issues/issue-26619.stderr b/src/test/ui/issues/issue-26619.stderr index 3ac6c4e308d..d1157cda92b 100644 --- a/src/test/ui/issues/issue-26619.stderr +++ b/src/test/ui/issues/issue-26619.stderr @@ -1,12 +1,11 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-26619.rs:7:66 +error[E0515]: cannot return value referencing function parameter + --> $DIR/issue-26619.rs:7:76 | LL | for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) { - | ^^^^^^^^ -- temporary value needs to live until here - | | | - | | temporary value dropped here while still borrowed - | temporary value does not live long enough + | -------- ^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function + | | + | function parameter 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/issues/issue-27592.nll.stderr b/src/test/ui/issues/issue-27592.nll.stderr deleted file mode 100644 index 9d3eaa9705d..00000000000 --- a/src/test/ui/issues/issue-27592.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-27592.rs:16:14 - | -LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^^^^^^^^^^^^^^^^---------------------------^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-27592.rs:16:14 - | -LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-27592.rs b/src/test/ui/issues/issue-27592.rs index 6006f9a7c51..b023ea18ac9 100644 --- a/src/test/ui/issues/issue-27592.rs +++ b/src/test/ui/issues/issue-27592.rs @@ -14,6 +14,6 @@ impl ::std::fmt::Write for Stream { fn main() { write(|| format_args!("{}", String::from("Hello world"))); - //~^ ERROR borrowed value does not live long enough - //~| ERROR borrowed value does not live long enough + //~^ ERROR cannot return value referencing temporary value + //~| ERROR cannot return value referencing temporary value } diff --git a/src/test/ui/issues/issue-27592.stderr b/src/test/ui/issues/issue-27592.stderr index 0f62abee1ca..9d3eaa9705d 100644 --- a/src/test/ui/issues/issue-27592.stderr +++ b/src/test/ui/issues/issue-27592.stderr @@ -1,21 +1,21 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-27592.rs:16:27 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-27592.rs:16:14 | LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^ -- temporary value needs to live until here - | | | - | | temporary value dropped here while still borrowed - | temporary value does not live long enough + | ^^^^^^^^^^^^^^^^^^^---------------------------^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-27592.rs:16:33 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-27592.rs:16:14 | LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^-- temporary value needs to live until here - | | | - | | temporary value dropped here while still borrowed - | temporary value does not live long enough + | ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function error: aborting due to 2 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/issues/issue-30438-a.nll.stderr b/src/test/ui/issues/issue-30438-a.nll.stderr deleted file mode 100644 index 53845af82fb..00000000000 --- a/src/test/ui/issues/issue-30438-a.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/issue-30438-a.rs:12:16 - | -LL | return &Test { s: &self.s}; - | ^------------------ - | || - | |temporary value created here - | 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/issues/issue-30438-a.rs b/src/test/ui/issues/issue-30438-a.rs index 8900821090b..0d4eb796ad9 100644 --- a/src/test/ui/issues/issue-30438-a.rs +++ b/src/test/ui/issues/issue-30438-a.rs @@ -10,7 +10,7 @@ impl <'a> Index for Test<'a> { type Output = Test<'a>; fn index(&self, _: usize) -> &Self::Output { return &Test { s: &self.s}; - //~^ ERROR: borrowed value does not live long enough + //~^ ERROR: cannot return reference to temporary value } } diff --git a/src/test/ui/issues/issue-30438-a.stderr b/src/test/ui/issues/issue-30438-a.stderr index 89f8e623dc4..53845af82fb 100644 --- a/src/test/ui/issues/issue-30438-a.stderr +++ b/src/test/ui/issues/issue-30438-a.stderr @@ -1,21 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-30438-a.rs:12:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-30438-a.rs:12:16 | LL | return &Test { s: &self.s}; - | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 11:5... - --> $DIR/issue-30438-a.rs:11:5 - | -LL | / fn index(&self, _: usize) -> &Self::Output { -LL | | return &Test { s: &self.s}; -LL | | -LL | | } - | |_____^ - = note: consider using a `let` binding to increase its lifetime + | ^------------------ + | || + | |temporary value created here + | 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 E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-b.nll.stderr b/src/test/ui/issues/issue-30438-b.nll.stderr deleted file mode 100644 index fd6bd25b1da..00000000000 --- a/src/test/ui/issues/issue-30438-b.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/issue-30438-b.rs:13:9 - | -LL | &Test { s: &self.s} - | ^------------------ - | || - | |temporary value created here - | 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/issues/issue-30438-b.rs b/src/test/ui/issues/issue-30438-b.rs index b84211bec67..79510cdb663 100644 --- a/src/test/ui/issues/issue-30438-b.rs +++ b/src/test/ui/issues/issue-30438-b.rs @@ -11,7 +11,7 @@ impl <'a> Index for Test<'a> { type Output = Test<'a>; fn index(&self, _: usize) -> &Self::Output { &Test { s: &self.s} - //~^ ERROR: borrowed value does not live long enough + //~^ ERROR: cannot return reference to temporary value } } diff --git a/src/test/ui/issues/issue-30438-b.stderr b/src/test/ui/issues/issue-30438-b.stderr index 49208ed696a..fd6bd25b1da 100644 --- a/src/test/ui/issues/issue-30438-b.stderr +++ b/src/test/ui/issues/issue-30438-b.stderr @@ -1,21 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-30438-b.rs:13:10 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-30438-b.rs:13:9 | LL | &Test { s: &self.s} - | ^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 12:5... - --> $DIR/issue-30438-b.rs:12:5 - | -LL | / fn index(&self, _: usize) -> &Self::Output { -LL | | &Test { s: &self.s} -LL | | -LL | | } - | |_____^ + | ^------------------ + | || + | |temporary value created here + | 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 E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-30438-c.nll.stderr b/src/test/ui/issues/issue-30438-c.nll.stderr deleted file mode 100644 index 7c001088097..00000000000 --- a/src/test/ui/issues/issue-30438-c.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0515]: cannot return reference to local variable `x` - --> $DIR/issue-30438-c.rs:9: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/issues/issue-30438-c.rs b/src/test/ui/issues/issue-30438-c.rs index 75caf0a75df..813c1d3e2cc 100644 --- a/src/test/ui/issues/issue-30438-c.rs +++ b/src/test/ui/issues/issue-30438-c.rs @@ -7,7 +7,7 @@ struct Test<'a> { s: &'a str } fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y as Trait>::Out where 'z: 'static { let x = Test { s: "this cannot last" }; &x - //~^ ERROR: `x` does not live long enough + //~^ ERROR: cannot return reference to local variable `x` } impl<'b> Trait for Test<'b> { type Out = Test<'b>; } diff --git a/src/test/ui/issues/issue-30438-c.stderr b/src/test/ui/issues/issue-30438-c.stderr index a003e27f055..7c001088097 100644 --- a/src/test/ui/issues/issue-30438-c.stderr +++ b/src/test/ui/issues/issue-30438-c.stderr @@ -1,18 +1,9 @@ -error[E0597]: `x` does not live long enough - --> $DIR/issue-30438-c.rs:9:6 +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-30438-c.rs:9:5 | LL | &x - | ^ borrowed value does not live long enough -LL | -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'y as defined on the function body at 7:10... - --> $DIR/issue-30438-c.rs:7:10 - | -LL | fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y as Trait>::Out where 'z: 'static { - | ^^ + | ^^ 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 E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/issues/issue-33819.nll.stderr b/src/test/ui/issues/issue-33819.nll.stderr deleted file mode 100644 index 8bc2d82cd3f..00000000000 --- a/src/test/ui/issues/issue-33819.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable - --> $DIR/issue-33819.rs:4:34 - | -LL | Some(ref v) => { let a = &mut v; }, - | ^^^^^^ - | | - | cannot borrow as mutable - | try removing `&mut` here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-33819.rs b/src/test/ui/issues/issue-33819.rs index 7f25ebd18ff..b73e85974a8 100644 --- a/src/test/ui/issues/issue-33819.rs +++ b/src/test/ui/issues/issue-33819.rs @@ -2,8 +2,7 @@ fn main() { let mut op = Some(2); match op { Some(ref v) => { let a = &mut v; }, - //~^ ERROR:cannot borrow immutable - //~| cannot borrow mutably + //~^ ERROR cannot borrow `v` as mutable, as it is not declared as mutable None => {}, } } diff --git a/src/test/ui/issues/issue-33819.stderr b/src/test/ui/issues/issue-33819.stderr index 09b8835a8a6..8bc2d82cd3f 100644 --- a/src/test/ui/issues/issue-33819.stderr +++ b/src/test/ui/issues/issue-33819.stderr @@ -1,8 +1,11 @@ -error[E0596]: cannot borrow immutable local variable `v` as mutable - --> $DIR/issue-33819.rs:4:39 +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable + --> $DIR/issue-33819.rs:4:34 | LL | Some(ref v) => { let a = &mut v; }, - | ^ cannot borrow mutably + | ^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-36082.ast.nll.stderr b/src/test/ui/issues/issue-36082.ast.nll.stderr deleted file mode 100644 index 6b3b13aa291..00000000000 --- a/src/test/ui/issues/issue-36082.ast.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-36082.rs:11:19 - | -LL | let val: &_ = x.borrow().0; - | ^^^^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | println!("{}", val); - | --- 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/issues/issue-36082.ast.stderr b/src/test/ui/issues/issue-36082.ast.stderr deleted file mode 100644 index 56e50e55ed3..00000000000 --- a/src/test/ui/issues/issue-36082.ast.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-36082.rs:11:19 - | -LL | let val: &_ = x.borrow().0; - | ^^^^^^^^^^ - temporary value dropped here while still borrowed - | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here - | - = note: consider using a `let` binding to increase its lifetime - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-36082.rs b/src/test/ui/issues/issue-36082.rs index 2658ef0ddaa..a2ff477eb81 100644 --- a/src/test/ui/issues/issue-36082.rs +++ b/src/test/ui/issues/issue-36082.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - use std::cell::RefCell; fn main() { @@ -9,15 +6,10 @@ fn main() { let x = RefCell::new((&mut r,s)); let val: &_ = x.borrow().0; - //[ast]~^ ERROR borrowed value does not live long enough [E0597] - //[ast]~| NOTE temporary value dropped here while still borrowed - //[ast]~| NOTE temporary value does not live long enough - //[ast]~| NOTE consider using a `let` binding to increase its lifetime - //[mir]~^^^^^ ERROR temporary value dropped while borrowed [E0716] - //[mir]~| NOTE temporary value is freed at the end of this statement - //[mir]~| NOTE creates a temporary which is freed while still in use - //[mir]~| NOTE consider using a `let` binding to create a longer lived value + //~^ ERROR temporary value dropped while borrowed [E0716] + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE consider using a `let` binding to create a longer lived value println!("{}", val); - //[mir]~^ borrow later used here + //~^ borrow later used here } -//[ast]~^ NOTE temporary value needs to live until here diff --git a/src/test/ui/issues/issue-36082.mir.stderr b/src/test/ui/issues/issue-36082.stderr similarity index 94% rename from src/test/ui/issues/issue-36082.mir.stderr rename to src/test/ui/issues/issue-36082.stderr index 6b3b13aa291..26bf4cb1be8 100644 --- a/src/test/ui/issues/issue-36082.mir.stderr +++ b/src/test/ui/issues/issue-36082.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-36082.rs:11:19 + --> $DIR/issue-36082.rs:8:19 | LL | let val: &_ = x.borrow().0; | ^^^^^^^^^^ - temporary value is freed at the end of this statement diff --git a/src/test/ui/issues/issue-36400.nll.stderr b/src/test/ui/issues/issue-36400.nll.stderr deleted file mode 100644 index 3b37578f3c4..00000000000 --- a/src/test/ui/issues/issue-36400.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable - --> $DIR/issue-36400.rs:5:7 - | -LL | let x = Box::new(3); - | - help: consider changing this to be mutable: `mut x` -LL | f(&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/issues/issue-36400.rs b/src/test/ui/issues/issue-36400.rs index 5ba9eb2333b..a405f9b1135 100644 --- a/src/test/ui/issues/issue-36400.rs +++ b/src/test/ui/issues/issue-36400.rs @@ -2,5 +2,5 @@ fn f(x: &mut u32) {} fn main() { let x = Box::new(3); - f(&mut *x); //~ ERROR cannot borrow immutable + f(&mut *x); //~ ERROR cannot borrow `*x` as mutable, as `x` is not declared as mutable } diff --git a/src/test/ui/issues/issue-36400.stderr b/src/test/ui/issues/issue-36400.stderr index 1494324eea3..3b37578f3c4 100644 --- a/src/test/ui/issues/issue-36400.stderr +++ b/src/test/ui/issues/issue-36400.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable `Box` content `*x` as mutable - --> $DIR/issue-36400.rs:5:12 +error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable + --> $DIR/issue-36400.rs:5:7 | LL | let x = Box::new(3); - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | f(&mut *x); - | ^^ cannot borrow as mutable + | ^^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40288.nll.stderr b/src/test/ui/issues/issue-40288.nll.stderr deleted file mode 100644 index fb4ecab362d..00000000000 --- a/src/test/ui/issues/issue-40288.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `*refr` because it is borrowed - --> $DIR/issue-40288.rs:16:5 - | -LL | save_ref(&*refr, &mut out); - | ------ borrow of `*refr` occurs here -... -LL | *refr = 3; - | ^^^^^^^^^ assignment to borrowed `*refr` occurs here -... -LL | println!("{:?}", out[0]); - | ------ 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/issues/issue-40288.stderr b/src/test/ui/issues/issue-40288.stderr index 5e8ad323ccb..fb4ecab362d 100644 --- a/src/test/ui/issues/issue-40288.stderr +++ b/src/test/ui/issues/issue-40288.stderr @@ -2,10 +2,13 @@ error[E0506]: cannot assign to `*refr` because it is borrowed --> $DIR/issue-40288.rs:16:5 | LL | save_ref(&*refr, &mut out); - | ----- borrow of `*refr` occurs here + | ------ borrow of `*refr` occurs here ... LL | *refr = 3; | ^^^^^^^^^ assignment to borrowed `*refr` occurs here +... +LL | println!("{:?}", out[0]); + | ------ borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr deleted file mode 100644 index fbfbc0cb977..00000000000 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-40402-1.rs:9:13 - | -LL | let e = f.v[0]; - | ^^^^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&f.v[0]` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs index 6bb0b6f1cfb..786c37e5969 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.rs @@ -6,5 +6,5 @@ struct Foo { fn main() { let mut f = Foo { v: Vec::new() }; f.v.push("hello".to_string()); - let e = f.v[0]; //~ ERROR cannot move out of indexed content + let e = f.v[0]; //~ ERROR cannot move out of borrowed content } diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr index 5e7be1a3101..fbfbc0cb977 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.stderr @@ -1,11 +1,11 @@ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/issue-40402-1.rs:9:13 | LL | let e = f.v[0]; | ^^^^^^ | | - | cannot move out of indexed content - | help: consider using a reference instead: `&f.v[0]` + | cannot move out of borrowed content + | help: consider borrowing here: `&f.v[0]` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr deleted file mode 100644 index 0c4a85b5901..00000000000 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-40402-2.rs:5:18 - | -LL | let (a, b) = x[0]; - | - - ^^^^ - | | | | - | | | cannot move out of borrowed content - | | | help: consider borrowing here: `&x[0]` - | | ...and here - | data moved here - | -note: move occurs because these variables have types that don't implement the `Copy` trait - --> $DIR/issue-40402-2.rs:5:10 - | -LL | let (a, b) = x[0]; - | ^ ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs index 0b8f40c5eff..480a4df48a3 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.rs @@ -2,5 +2,5 @@ // are nested within a pattern fn main() { let x = vec![(String::new(), String::new())]; - let (a, b) = x[0]; //~ ERROR cannot move out of indexed content + let (a, b) = x[0]; //~ ERROR cannot move out of borrowed content } diff --git a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr index b672029f717..0c4a85b5901 100644 --- a/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr +++ b/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.stderr @@ -1,11 +1,19 @@ -error[E0507]: cannot move out of indexed content +error[E0507]: cannot move out of borrowed content --> $DIR/issue-40402-2.rs:5:18 | LL | let (a, b) = x[0]; - | - - ^^^^ cannot move out of indexed content - | | | - | | ...and here (use `ref b` or `ref mut b`) - | hint: to prevent move, use `ref a` or `ref mut a` + | - - ^^^^ + | | | | + | | | cannot move out of borrowed content + | | | help: consider borrowing here: `&x[0]` + | | ...and here + | data moved here + | +note: move occurs because these variables have types that don't implement the `Copy` trait + --> $DIR/issue-40402-2.rs:5:10 + | +LL | let (a, b) = x[0]; + | ^ ^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-40510-1.nll.stderr b/src/test/ui/issues/issue-40510-1.stderr similarity index 100% rename from src/test/ui/issues/issue-40510-1.nll.stderr rename to src/test/ui/issues/issue-40510-1.stderr diff --git a/src/test/ui/issues/issue-40510-3.nll.stderr b/src/test/ui/issues/issue-40510-3.stderr similarity index 100% rename from src/test/ui/issues/issue-40510-3.nll.stderr rename to src/test/ui/issues/issue-40510-3.stderr diff --git a/src/test/ui/issues/issue-41139.nll.stderr b/src/test/ui/issues/issue-41139.nll.stderr deleted file mode 100644 index 4dd017b0a91..00000000000 --- a/src/test/ui/issues/issue-41139.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0161]: cannot move a value of type dyn Trait: the size of dyn Trait cannot be statically determined - --> $DIR/issue-41139.rs:6:23 - | -LL | let t : &Trait = &get_function()(); - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0161`. diff --git a/src/test/ui/issues/issue-41139.rs b/src/test/ui/issues/issue-41139.rs index 0bfbea11b0e..f3e6c44ecb9 100644 --- a/src/test/ui/issues/issue-41139.rs +++ b/src/test/ui/issues/issue-41139.rs @@ -4,5 +4,5 @@ fn get_function<'a>() -> &'a Fn() -> Trait { panic!("") } fn main() { let t : &Trait = &get_function()(); - //~^ ERROR cannot move a value of type (dyn Trait + 'static) + //~^ ERROR cannot move a value of type dyn Trait } diff --git a/src/test/ui/issues/issue-41139.stderr b/src/test/ui/issues/issue-41139.stderr index 3e3de7b7cf1..4dd017b0a91 100644 --- a/src/test/ui/issues/issue-41139.stderr +++ b/src/test/ui/issues/issue-41139.stderr @@ -1,4 +1,4 @@ -error[E0161]: cannot move a value of type (dyn Trait + 'static): the size of (dyn Trait + 'static) cannot be statically determined +error[E0161]: cannot move a value of type dyn Trait: the size of dyn Trait cannot be statically determined --> $DIR/issue-41139.rs:6:23 | LL | let t : &Trait = &get_function()(); diff --git a/src/test/ui/issues/issue-41726.nll.stderr b/src/test/ui/issues/issue-41726.nll.stderr deleted file mode 100644 index c92753d6e3d..00000000000 --- a/src/test/ui/issues/issue-41726.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/issue-41726.rs:5:9 - | -LL | things[src.as_str()].sort(); - | ^^^^^^^^^^^^^^^^^^^^ cannot borrow as mutable - | - = help: trait `IndexMut` is required to modify indexed content, but it is not implemented for `std::collections::HashMap>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-41726.rs b/src/test/ui/issues/issue-41726.rs index 41dcaa8e280..ed056293890 100644 --- a/src/test/ui/issues/issue-41726.rs +++ b/src/test/ui/issues/issue-41726.rs @@ -2,6 +2,6 @@ use std::collections::HashMap; fn main() { let things: HashMap> = HashMap::new(); for src in things.keys() { - things[src.as_str()].sort(); //~ ERROR cannot borrow immutable + things[src.as_str()].sort(); //~ ERROR cannot borrow data in a `&` reference as mutable } } diff --git a/src/test/ui/issues/issue-41726.stderr b/src/test/ui/issues/issue-41726.stderr index e29c163b817..c92753d6e3d 100644 --- a/src/test/ui/issues/issue-41726.stderr +++ b/src/test/ui/issues/issue-41726.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/issue-41726.rs:5:9 | LL | things[src.as_str()].sort(); diff --git a/src/test/ui/issues/issue-42106.nll.stderr b/src/test/ui/issues/issue-42106.nll.stderr deleted file mode 100644 index d5a9d233bc9..00000000000 --- a/src/test/ui/issues/issue-42106.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0502]: cannot borrow `*collection` as mutable because it is also borrowed as immutable - --> $DIR/issue-42106.rs:3:5 - | -LL | let _a = &collection; - | ----------- immutable borrow occurs here -LL | collection.swap(1, 2); - | ^^^^^^^^^^ mutable borrow occurs here -LL | _a.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/issues/issue-42106.stderr b/src/test/ui/issues/issue-42106.stderr index 9e3ce9878c2..d5a9d233bc9 100644 --- a/src/test/ui/issues/issue-42106.stderr +++ b/src/test/ui/issues/issue-42106.stderr @@ -1,13 +1,12 @@ -error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable +error[E0502]: cannot borrow `*collection` as mutable because it is also borrowed as immutable --> $DIR/issue-42106.rs:3:5 | LL | let _a = &collection; - | ---------- immutable borrow occurs here + | ----------- immutable borrow occurs here LL | collection.swap(1, 2); | ^^^^^^^^^^ mutable borrow occurs here LL | _a.use_ref(); -LL | } - | - immutable borrow ends here + | -- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-42344.nll.stderr b/src/test/ui/issues/issue-42344.nll.stderr deleted file mode 100644 index 5cffa1b5121..00000000000 --- a/src/test/ui/issues/issue-42344.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item - --> $DIR/issue-42344.rs:4:5 - | -LL | TAB[0].iter_mut(); - | ^^^^^^ 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/issues/issue-42344.rs b/src/test/ui/issues/issue-42344.rs index 5f1bb4f91bb..a7636edf2f8 100644 --- a/src/test/ui/issues/issue-42344.rs +++ b/src/test/ui/issues/issue-42344.rs @@ -1,7 +1,8 @@ static TAB: [&mut [u8]; 0] = []; pub unsafe fn test() { - TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389] + TAB[0].iter_mut(); + //~^ ERROR cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item [E0596] } pub fn main() {} diff --git a/src/test/ui/issues/issue-42344.stderr b/src/test/ui/issues/issue-42344.stderr index 6bf26c2cf5c..5cffa1b5121 100644 --- a/src/test/ui/issues/issue-42344.stderr +++ b/src/test/ui/issues/issue-42344.stderr @@ -1,9 +1,9 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `*TAB[_]` as mutable, as `TAB` is an immutable static item --> $DIR/issue-42344.rs:4:5 | LL | TAB[0].iter_mut(); - | ^^^^^^ assignment into an immutable reference + | ^^^^^^ cannot borrow as mutable error: aborting due to previous error -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/issues/issue-42796.nll.stderr b/src/test/ui/issues/issue-42796.nll.stderr deleted file mode 100644 index d9dfbc999f3..00000000000 --- a/src/test/ui/issues/issue-42796.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `s` - --> $DIR/issue-42796.rs:18:20 - | -LL | let s = "Hello!".to_owned(); - | - move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait -LL | let mut s_copy = s; - | - value moved here -... -LL | println!("{}", s); - | ^ value borrowed 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/issues/issue-42796.rs b/src/test/ui/issues/issue-42796.rs index 98b91270b7d..5e83a1cd677 100644 --- a/src/test/ui/issues/issue-42796.rs +++ b/src/test/ui/issues/issue-42796.rs @@ -15,5 +15,5 @@ fn main() { let mut s_copy = s; s_copy.push_str("World!"); "0wned!".to_owned(); - println!("{}", s); //~ ERROR use of moved value + println!("{}", s); //~ ERROR borrow of moved value } diff --git a/src/test/ui/issues/issue-42796.stderr b/src/test/ui/issues/issue-42796.stderr index d180e6478ef..d9dfbc999f3 100644 --- a/src/test/ui/issues/issue-42796.stderr +++ b/src/test/ui/issues/issue-42796.stderr @@ -1,13 +1,13 @@ -error[E0382]: use of moved value: `s` +error[E0382]: borrow of moved value: `s` --> $DIR/issue-42796.rs:18:20 | +LL | let s = "Hello!".to_owned(); + | - move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait LL | let mut s_copy = s; - | ---------- value moved here + | - value moved here ... LL | println!("{}", s); - | ^ value used here after move - | - = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/issues/issue-4335.nll.stderr b/src/test/ui/issues/issue-4335.nll.stderr deleted file mode 100644 index 1b5cab24929..00000000000 --- a/src/test/ui/issues/issue-4335.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/issue-4335.rs:6:20 - | -LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { - | - captured outer variable -LL | id(Box::new(|| *v)) - | ^^ cannot move out of captured variable in an `FnMut` closure - -error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function - --> $DIR/issue-4335.rs:6:17 - | -LL | id(Box::new(|| *v)) - | ^^ - `v` is borrowed here - | | - | may outlive borrowed value `v` - | -note: closure is returned here - --> $DIR/issue-4335.rs:6:5 - | -LL | id(Box::new(|| *v)) - | ^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword - | -LL | id(Box::new(move || *v)) - | ^^^^^^^ - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0373, E0507. -For more information about an error, try `rustc --explain E0373`. diff --git a/src/test/ui/issues/issue-4335.stderr b/src/test/ui/issues/issue-4335.stderr index 3b04c26d49c..1b5cab24929 100644 --- a/src/test/ui/issues/issue-4335.stderr +++ b/src/test/ui/issues/issue-4335.stderr @@ -1,3 +1,11 @@ +error[E0507]: cannot move out of captured variable in an `FnMut` closure + --> $DIR/issue-4335.rs:6:20 + | +LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { + | - captured outer variable +LL | id(Box::new(|| *v)) + | ^^ cannot move out of captured variable in an `FnMut` closure + error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function --> $DIR/issue-4335.rs:6:17 | @@ -5,17 +13,17 @@ LL | id(Box::new(|| *v)) | ^^ - `v` is borrowed here | | | may outlive borrowed value `v` + | +note: closure is returned here + --> $DIR/issue-4335.rs:6:5 + | +LL | id(Box::new(|| *v)) + | ^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword | LL | id(Box::new(move || *v)) | ^^^^^^^ -error[E0507]: cannot move out of borrowed content - --> $DIR/issue-4335.rs:6:20 - | -LL | id(Box::new(|| *v)) - | ^^ cannot move out of borrowed content - error: aborting due to 2 previous errors Some errors have detailed explanations: E0373, E0507. diff --git a/src/test/ui/issues/issue-44373.nll.stderr b/src/test/ui/issues/issue-44373.nll.stderr deleted file mode 100644 index 6f92fbb1eb6..00000000000 --- a/src/test/ui/issues/issue-44373.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-44373.rs:4:42 - | -LL | let _val: &'static [&'static u32] = &[&FOO]; - | ----------------------- ^^^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-44373.rs b/src/test/ui/issues/issue-44373.rs index 13e9fa9ea67..0d011d096bd 100644 --- a/src/test/ui/issues/issue-44373.rs +++ b/src/test/ui/issues/issue-44373.rs @@ -1,5 +1,5 @@ static FOO: u32 = 50; fn main() { - let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR borrowed value does not live long enough + let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR temporary value dropped while borrowed } diff --git a/src/test/ui/issues/issue-44373.stderr b/src/test/ui/issues/issue-44373.stderr index c5295583390..6f92fbb1eb6 100644 --- a/src/test/ui/issues/issue-44373.stderr +++ b/src/test/ui/issues/issue-44373.stderr @@ -1,13 +1,13 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-44373.rs:4:42 | LL | let _val: &'static [&'static u32] = &[&FOO]; - | ^^^^^^ temporary value does not live long enough + | ----------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement 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/issues/issue-45199.ast.stderr b/src/test/ui/issues/issue-45199.ast.stderr deleted file mode 100644 index 9dfd8e82133..00000000000 --- a/src/test/ui/issues/issue-45199.ast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:10:5 - | -LL | b = Box::new(1); - | --------------- first assignment to `b` -LL | -LL | b = Box::new(2); - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:21:5 - | -LL | let b = Box::new(1); - | - first assignment to `b` -... -LL | b = Box::new(2); - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:30:5 - | -LL | fn test_args(b: Box) { - | - first assignment to `b` -... -LL | b = Box::new(2); - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/issues/issue-45199.mir.stderr b/src/test/ui/issues/issue-45199.mir.stderr deleted file mode 100644 index c6ae7c9514d..00000000000 --- a/src/test/ui/issues/issue-45199.mir.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:10:5 - | -LL | let b: Box; - | - help: make this binding mutable: `mut b` -... -LL | b = Box::new(1); - | - first assignment to `b` -LL | -LL | b = Box::new(2); - | ^ cannot assign twice to immutable variable - -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:21:5 - | -LL | let b = Box::new(1); - | - - | | - | first assignment to `b` - | help: make this binding mutable: `mut b` -... -LL | b = Box::new(2); - | ^ cannot assign twice to immutable variable - -error[E0384]: cannot assign to immutable argument `b` - --> $DIR/issue-45199.rs:30:5 - | -LL | fn test_args(b: Box) { - | - help: make this binding mutable: `mut b` -... -LL | b = Box::new(2); - | ^ cannot assign to immutable argument - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/issues/issue-45199.rs b/src/test/ui/issues/issue-45199.rs index bb55534c132..cbd45cbb619 100644 --- a/src/test/ui/issues/issue-45199.rs +++ b/src/test/ui/issues/issue-45199.rs @@ -1,36 +1,24 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test_drop_replace() { let b: Box; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut b - b = Box::new(1); //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + //~^ HELP make this binding mutable + //~| SUGGESTION mut b + b = Box::new(1); //~ NOTE first assignment + b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` + //~| NOTE cannot assign twice to immutable } fn test_call() { - let b = Box::new(1); //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| HELP make this binding mutable - //[mir]~| SUGGESTION mut b - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + let b = Box::new(1); //~ NOTE first assignment + //~| HELP make this binding mutable + //~| SUGGESTION mut b + b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` + //~| NOTE cannot assign twice to immutable } -fn test_args(b: Box) { //[ast]~ NOTE first assignment - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut b - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign to immutable argument `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign to immutable argument +fn test_args(b: Box) { //~ HELP make this binding mutable + //~| SUGGESTION mut b + b = Box::new(2); //~ ERROR cannot assign to immutable argument `b` + //~| NOTE cannot assign to immutable argument } fn main() {} diff --git a/src/test/ui/issues/issue-45199.ast.nll.stderr b/src/test/ui/issues/issue-45199.stderr similarity index 90% rename from src/test/ui/issues/issue-45199.ast.nll.stderr rename to src/test/ui/issues/issue-45199.stderr index c6ae7c9514d..83b634051bb 100644 --- a/src/test/ui/issues/issue-45199.ast.nll.stderr +++ b/src/test/ui/issues/issue-45199.stderr @@ -1,17 +1,16 @@ error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:10:5 + --> $DIR/issue-45199.rs:6:5 | LL | let b: Box; | - help: make this binding mutable: `mut b` ... LL | b = Box::new(1); | - first assignment to `b` -LL | LL | b = Box::new(2); | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:21:5 + --> $DIR/issue-45199.rs:14:5 | LL | let b = Box::new(1); | - @@ -23,11 +22,11 @@ LL | b = Box::new(2); | ^ cannot assign twice to immutable variable error[E0384]: cannot assign to immutable argument `b` - --> $DIR/issue-45199.rs:30:5 + --> $DIR/issue-45199.rs:20:5 | LL | fn test_args(b: Box) { | - help: make this binding mutable: `mut b` -... +LL | LL | b = Box::new(2); | ^ cannot assign to immutable argument diff --git a/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs b/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs index 9f86caeaea9..b3f655628ba 100644 --- a/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs +++ b/src/test/ui/issues/issue-45696-long-live-borrows-in-boxes.rs @@ -1,14 +1,5 @@ // rust-lang/rust#45696: This test is checking that we can return // mutable borrows owned by boxes even when the boxes are dropped. -// -// We will explicitly test AST-borrowck, NLL, and migration modes; -// thus we will also skip the automated compare-mode=nll. - -// revisions: ast nll migrate -// ignore-compare-mode-nll - -#![cfg_attr(nll, feature(nll))] -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows // run-pass diff --git a/src/test/ui/issues/issue-45696-no-variant-box-recur.rs b/src/test/ui/issues/issue-45696-no-variant-box-recur.rs index 867da22221a..b5d9036aba6 100644 --- a/src/test/ui/issues/issue-45696-no-variant-box-recur.rs +++ b/src/test/ui/issues/issue-45696-no-variant-box-recur.rs @@ -1,16 +1,15 @@ -// rust-lang/rust#45696: This test checks the compiler won't infinite -// loop when you declare a variable of type `struct A(Box, ...);` -// (which is impossible to construct but *is* possible to declare; see -// also issues #4287, #44933, and #52852). +// rust-lang/rust#45696: This test checks the compiler won't infinite loop when +// you declare a variable of type `struct A(Box, ...);` (which is impossible +// to construct but *is* possible to declare; see also issues #4287, #44933, +// and #52852). // -// We will explicitly test AST-borrowck, NLL, and migration modes; -// thus we will also skip the automated compare-mode=nll. +// We will explicitly test NLL, and migration modes; thus we will also skip the +// automated compare-mode=nll. -// revisions: ast nll migrate +// revisions: nll migrate // ignore-compare-mode-nll #![cfg_attr(nll, feature(nll))] -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows // run-pass diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.ast.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.ast.stderr deleted file mode 100644 index 0aaba52d29f..00000000000 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.ast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: compilation successful - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:1 - | -LL | / fn main() { -LL | | -LL | | let mut x = 1; -LL | | { -... | -LL | | *boxed_boxed_scribbled(Box::new(Box::new(Scribble(&mut x)))) += 10; -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr index f8aab239de4..8cc9f1eb2a6 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr @@ -1,5 +1,5 @@ warning[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:53:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:51:5 | LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -13,7 +13,7 @@ LL | } = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future warning[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:64:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:62:5 | LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -27,7 +27,7 @@ LL | } = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future warning[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:75:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5 | LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -41,12 +41,12 @@ LL | } = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future error: compilation successful - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:1 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:80:1 | LL | / fn main() { -LL | | LL | | let mut x = 1; LL | | { +LL | | let mut long_lived = Scribble(&mut x); ... | LL | | *boxed_boxed_scribbled(Box::new(Box::new(Scribble(&mut x)))) += 10; LL | | } diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr index bfb58325ece..1b9fb049926 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr @@ -1,5 +1,5 @@ error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:53:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:51:5 | LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -10,7 +10,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:64:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:62:5 | LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { | -- lifetime `'a` defined here @@ -21,7 +21,7 @@ LL | } | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:75:5 + --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5 | LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { | -- lifetime `'a` defined here diff --git a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs index fc56a2a8b70..f568efa487c 100644 --- a/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs +++ b/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs @@ -2,21 +2,19 @@ // mutable borrows that would be scribbled over by destructors before // the return occurs. // -// We will explicitly test AST-borrowck, NLL, and migration modes; +// We will explicitly test NLL, and migration modes; // thus we will also skip the automated compare-mode=nll. -// revisions: ast nll migrate +// revisions: nll migrate // ignore-compare-mode-nll -// This test is going to pass in the ast and migrate revisions, -// because the AST-borrowck accepted this code in the past (see notes -// below). So we use `#[rustc_error]` to keep the outcome as an error -// in all scenarios, and rely on the stderr files to show what the -// actual behavior is. (See rust-lang/rust#49855.) +// This test is going to pass in the migrate revision, because the AST-borrowck +// accepted this code in the past (see notes below). So we use `#[rustc_error]` +// to keep the outcome as an error in all scenarios, and rely on the stderr +// files to show what the actual behavior is. (See rust-lang/rust#49855.) #![feature(rustc_attrs)] #![cfg_attr(nll, feature(nll))] -//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows struct Scribble<'a>(&'a mut u32); @@ -79,8 +77,7 @@ fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { } #[rustc_error] -fn main() { //[ast]~ ERROR compilation successful - //[migrate]~^ ERROR compilation successful +fn main() { //[migrate]~ ERROR compilation successful let mut x = 1; { let mut long_lived = Scribble(&mut x); diff --git a/src/test/ui/issues/issue-46023.ast.nll.stderr b/src/test/ui/issues/issue-46023.ast.nll.stderr deleted file mode 100644 index 6ef44b416d0..00000000000 --- a/src/test/ui/issues/issue-46023.ast.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-46023.rs:8:9 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | x = 1; - | ^^^^^ cannot assign - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-46023.ast.stderr b/src/test/ui/issues/issue-46023.ast.stderr deleted file mode 100644 index 68f7741f4d1..00000000000 --- a/src/test/ui/issues/issue-46023.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure - --> $DIR/issue-46023.rs:8:9 - | -LL | let x = 0; - | - help: consider making `x` mutable: `mut x` -... -LL | x = 1; - | ^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-46023.rs b/src/test/ui/issues/issue-46023.rs index a9ecbbeea47..a923eb24421 100644 --- a/src/test/ui/issues/issue-46023.rs +++ b/src/test/ui/issues/issue-46023.rs @@ -1,12 +1,8 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let x = 0; (move || { x = 1; - //[mir]~^ ERROR cannot assign to `x`, as it is not declared as mutable [E0594] - //[ast]~^^ ERROR cannot assign to captured outer variable in an `FnMut` closure [E0594] + //~^ ERROR cannot assign to `x`, as it is not declared as mutable [E0594] })() } diff --git a/src/test/ui/issues/issue-46023.mir.stderr b/src/test/ui/issues/issue-46023.stderr similarity index 89% rename from src/test/ui/issues/issue-46023.mir.stderr rename to src/test/ui/issues/issue-46023.stderr index 6ef44b416d0..fac696c6fdc 100644 --- a/src/test/ui/issues/issue-46023.mir.stderr +++ b/src/test/ui/issues/issue-46023.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/issue-46023.rs:8:9 + --> $DIR/issue-46023.rs:5:9 | LL | let x = 0; | - help: consider changing this to be mutable: `mut x` diff --git a/src/test/ui/issues/issue-46604.ast.nll.stderr b/src/test/ui/issues/issue-46604.ast.nll.stderr deleted file mode 100644 index 497af09efab..00000000000 --- a/src/test/ui/issues/issue-46604.ast.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0017]: references in statics may only refer to immutable values - --> $DIR/issue-46604.rs:4:25 - | -LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; - | ^^^^^^^^^^^^^^^^^^^^ statics require immutable values - -error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item - --> $DIR/issue-46604.rs:10:5 - | -LL | buf[0]=2; - | ^^^^^^^^ cannot assign - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0017`. diff --git a/src/test/ui/issues/issue-46604.ast.stderr b/src/test/ui/issues/issue-46604.ast.stderr deleted file mode 100644 index 058ee151e37..00000000000 --- a/src/test/ui/issues/issue-46604.ast.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0017]: references in statics may only refer to immutable values - --> $DIR/issue-46604.rs:4:25 - | -LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; - | ^^^^^^^^^^^^^^^^^^^^ statics require immutable values - -error[E0389]: cannot assign to data in a `&` reference - --> $DIR/issue-46604.rs:10:5 - | -LL | buf[0]=2; - | ^^^^^^^^ assignment into an immutable reference - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0017, E0389. -For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/issues/issue-46604.rs b/src/test/ui/issues/issue-46604.rs index 34fe3af3ab6..4f1ad38dbdd 100644 --- a/src/test/ui/issues/issue-46604.rs +++ b/src/test/ui/issues/issue-46604.rs @@ -1,12 +1,7 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //[ast]~ ERROR E0017 - //[mir]~^ ERROR E0017 +static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR E0017 fn write>(buffer: T) { } fn main() { write(&buf); - buf[0]=2; //[ast]~ ERROR E0389 - //[mir]~^ ERROR E0594 + buf[0]=2; //~ ERROR E0594 } diff --git a/src/test/ui/issues/issue-46604.mir.stderr b/src/test/ui/issues/issue-46604.stderr similarity index 88% rename from src/test/ui/issues/issue-46604.mir.stderr rename to src/test/ui/issues/issue-46604.stderr index 497af09efab..961b249daeb 100644 --- a/src/test/ui/issues/issue-46604.mir.stderr +++ b/src/test/ui/issues/issue-46604.stderr @@ -1,11 +1,11 @@ error[E0017]: references in statics may only refer to immutable values - --> $DIR/issue-46604.rs:4:25 + --> $DIR/issue-46604.rs:1:25 | LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; | ^^^^^^^^^^^^^^^^^^^^ statics require immutable values error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item - --> $DIR/issue-46604.rs:10:5 + --> $DIR/issue-46604.rs:6:5 | LL | buf[0]=2; | ^^^^^^^^ cannot assign diff --git a/src/test/ui/issues/issue-49824.nll.stderr b/src/test/ui/issues/issue-49824.nll.stderr deleted file mode 100644 index bfa07059c68..00000000000 --- a/src/test/ui/issues/issue-49824.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: captured variable cannot escape `FnMut` closure body - --> $DIR/issue-49824.rs:12:9 - | -LL | || { - | - inferred to be a `FnMut` closure -LL | / || { -LL | | let _y = &mut x; -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 - = 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: compilation successful - --> $DIR/issue-49824.rs:8:1 - | -LL | / fn main() { -LL | | -LL | | let mut x = 0; -LL | | || { -... | -LL | | }; -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-49824.rs b/src/test/ui/issues/issue-49824.rs index 58cada5d31e..b0d01b3d98d 100644 --- a/src/test/ui/issues/issue-49824.rs +++ b/src/test/ui/issues/issue-49824.rs @@ -1,15 +1,16 @@ #![feature(rustc_attrs)] -// This test checks that a failure occurs with NLL but does not fail with the -// legacy AST output. Check issue-49824.nll.stderr for expected compilation error -// output under NLL and #49824 for more information. +// This test checks that a warning occurs with migrate mode. #[rustc_error] fn main() { - //~^ compilation successful + //~^ ERROR compilation successful let mut x = 0; || { || { + //~^ WARNING captured variable cannot escape `FnMut` closure body + //~| WARNING this error has been downgraded to a warning + //~| WARNING this warning will become a hard error in the future let _y = &mut x; } }; diff --git a/src/test/ui/issues/issue-49824.stderr b/src/test/ui/issues/issue-49824.stderr index 4ad537f3eb5..c66ee69cb2b 100644 --- a/src/test/ui/issues/issue-49824.stderr +++ b/src/test/ui/issues/issue-49824.stderr @@ -1,5 +1,23 @@ +warning: captured variable cannot escape `FnMut` closure body + --> $DIR/issue-49824.rs:10:9 + | +LL | || { + | - inferred to be a `FnMut` closure +LL | / || { +LL | | +LL | | +LL | | +LL | | let _y = &mut x; +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 + = 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: compilation successful - --> $DIR/issue-49824.rs:8:1 + --> $DIR/issue-49824.rs:6:1 | LL | / fn main() { LL | | diff --git a/src/test/ui/issues/issue-51244.nll.stderr b/src/test/ui/issues/issue-51244.nll.stderr deleted file mode 100644 index 8a7e71e0326..00000000000 --- a/src/test/ui/issues/issue-51244.nll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference - --> $DIR/issue-51244.rs:3:5 - | -LL | let ref my_ref @ _ = 0; - | -------------- help: consider changing this to be a mutable reference: `ref mut my_ref @ _` -LL | *my_ref = 0; - | ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-51244.rs b/src/test/ui/issues/issue-51244.rs index d3651810131..509060e1ad8 100644 --- a/src/test/ui/issues/issue-51244.rs +++ b/src/test/ui/issues/issue-51244.rs @@ -1,4 +1,4 @@ fn main() { let ref my_ref @ _ = 0; - *my_ref = 0; //~ ERROR cannot assign to immutable borrowed content `*my_ref` [E0594] + *my_ref = 0; //~ ERROR cannot assign to `*my_ref` which is behind a `&` reference [E0594] } diff --git a/src/test/ui/issues/issue-51244.stderr b/src/test/ui/issues/issue-51244.stderr index 4ab5e8db23a..8a7e71e0326 100644 --- a/src/test/ui/issues/issue-51244.stderr +++ b/src/test/ui/issues/issue-51244.stderr @@ -1,10 +1,10 @@ -error[E0594]: cannot assign to immutable borrowed content `*my_ref` +error[E0594]: cannot assign to `*my_ref` which is behind a `&` reference --> $DIR/issue-51244.rs:3:5 | LL | let ref my_ref @ _ = 0; - | -------------- help: use a mutable reference instead: `ref mut my_ref @ _` + | -------------- help: consider changing this to be a mutable reference: `ref mut my_ref @ _` LL | *my_ref = 0; - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ `my_ref` is a `&` reference, so the data it refers to cannot be written error: aborting due to previous error diff --git a/src/test/ui/issues/issue-52049.nll.stderr b/src/test/ui/issues/issue-52049.nll.stderr deleted file mode 100644 index 55929d85da4..00000000000 --- a/src/test/ui/issues/issue-52049.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-52049.rs:6:10 - | -LL | foo(&unpromotable(5u32)); - | -----^^^^^^^^^^^^^^^^^^- - | | | - | | creates a temporary which is freed while still in use - | argument requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/issues/issue-52049.rs b/src/test/ui/issues/issue-52049.rs index 23b21cf4e61..efdcc449305 100644 --- a/src/test/ui/issues/issue-52049.rs +++ b/src/test/ui/issues/issue-52049.rs @@ -5,4 +5,4 @@ fn unpromotable(t: T) -> T { t } fn main() { foo(&unpromotable(5u32)); } -//~^^ ERROR borrowed value does not live long enough +//~^^ ERROR temporary value dropped while borrowed diff --git a/src/test/ui/issues/issue-52049.stderr b/src/test/ui/issues/issue-52049.stderr index 45381765f8c..55929d85da4 100644 --- a/src/test/ui/issues/issue-52049.stderr +++ b/src/test/ui/issues/issue-52049.stderr @@ -1,13 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-52049.rs:6:10 | LL | foo(&unpromotable(5u32)); - | ^^^^^^^^^^^^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | -----^^^^^^^^^^^^^^^^^^- + | | | + | | creates a temporary which is freed while still in use + | argument requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement 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/issues/issue-52126-assign-op-invariance.nll.stderr b/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr deleted file mode 100644 index d231f621e59..00000000000 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `line` does not live long enough - --> $DIR/issue-52126-assign-op-invariance.rs:34:28 - | -LL | let v: Vec<&str> = line.split_whitespace().collect(); - | ^^^^ borrowed value does not live long enough -... -LL | acc += cnt2; - | --- borrow later used here -... -LL | } - | - `line` 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/issues/issue-52126-assign-op-invariance.stderr b/src/test/ui/issues/issue-52126-assign-op-invariance.stderr index b07b8d5281e..d231f621e59 100644 --- a/src/test/ui/issues/issue-52126-assign-op-invariance.stderr +++ b/src/test/ui/issues/issue-52126-assign-op-invariance.stderr @@ -4,10 +4,11 @@ error[E0597]: `line` does not live long enough LL | let v: Vec<&str> = line.split_whitespace().collect(); | ^^^^ borrowed value does not live long enough ... +LL | acc += cnt2; + | --- borrow later used here +... LL | } | - `line` dropped here while still borrowed -LL | } - | - borrowed value needs to live until here error: aborting due to previous error diff --git a/src/test/ui/issues/issue-52240.nll.stderr b/src/test/ui/issues/issue-52240.nll.stderr deleted file mode 100644 index 69b663b17d3..00000000000 --- a/src/test/ui/issues/issue-52240.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/issue-52240.rs:9:27 - | -LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { - | ^^^^^^^^^^^ 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/issues/issue-52240.rs b/src/test/ui/issues/issue-52240.rs index 9ac7e9905da..5def557789f 100644 --- a/src/test/ui/issues/issue-52240.rs +++ b/src/test/ui/issues/issue-52240.rs @@ -7,7 +7,7 @@ enum Foo { fn main() { let arr = vec!(Foo::Bar(0)); if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { - //~^ ERROR cannot borrow field of immutable binding as mutable + //~^ ERROR cannot borrow data in a `&` reference as mutable *val = 9001; } match arr[0] { diff --git a/src/test/ui/issues/issue-52240.stderr b/src/test/ui/issues/issue-52240.stderr index c2c2524816d..69b663b17d3 100644 --- a/src/test/ui/issues/issue-52240.stderr +++ b/src/test/ui/issues/issue-52240.stderr @@ -1,8 +1,8 @@ -error[E0596]: cannot borrow field of immutable binding as mutable +error[E0596]: cannot borrow data in a `&` reference as mutable --> $DIR/issue-52240.rs:9:27 | LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { - | ^^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/issues/issue-5500-1.ast.stderr b/src/test/ui/issues/issue-5500-1.ast.stderr deleted file mode 100644 index fb0f9782846..00000000000 --- a/src/test/ui/issues/issue-5500-1.ast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0594]: cannot assign to field `_iter.node` of immutable binding - --> $DIR/issue-5500-1.rs:12:5 - | -LL | let _iter = TrieMapIterator{node: &a}; - | ----- help: make this binding mutable: `mut _iter` -LL | / _iter.node = & -LL | | -LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK -LL | | // because the test is here to check that the compiler doesn't ICE (cf. #5500). -LL | | panic!() - | |____________^ cannot mutably borrow field of immutable binding - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-5500-1.mir.stderr b/src/test/ui/issues/issue-5500-1.mir.stderr deleted file mode 100644 index fbabfbd2b5c..00000000000 --- a/src/test/ui/issues/issue-5500-1.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0594]: cannot assign to field `_iter.node` of immutable binding (Ast) - --> $DIR/issue-5500-1.rs:12:5 - | -LL | let _iter = TrieMapIterator{node: &a}; - | ----- help: make this binding mutable: `mut _iter` -LL | / _iter.node = & -LL | | -LL | | // MIR doesn't generate an error because the code isn't reachable. This is OK -LL | | // because the test is here to check that the compiler doesn't ICE (cf. #5500). -LL | | panic!() - | |____________^ cannot mutably borrow field of immutable binding - -error: aborting due to previous error - diff --git a/src/test/ui/issues/issue-5500-1.rs b/src/test/ui/issues/issue-5500-1.rs index e8043563c73..56f5ce9901e 100644 --- a/src/test/ui/issues/issue-5500-1.rs +++ b/src/test/ui/issues/issue-5500-1.rs @@ -1,6 +1,8 @@ -// ignore-compare-mode-nll -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=compare +// MIR doesn't generate an error because the assignment isn't reachable. This +// is OK because the test is here to check that the compiler doesn't ICE (cf. +// #5500). + +// compile-pass struct TrieMapIterator<'a> { node: &'a usize @@ -9,9 +11,5 @@ struct TrieMapIterator<'a> { fn main() { let a = 5; let _iter = TrieMapIterator{node: &a}; - _iter.node = & //[ast]~ ERROR cannot assign to field `_iter.node` of immutable binding - //[mir]~^ ERROR cannot assign to field `_iter.node` of immutable binding (Ast) - // MIR doesn't generate an error because the code isn't reachable. This is OK - // because the test is here to check that the compiler doesn't ICE (cf. #5500). - panic!() + _iter.node = &panic!() } diff --git a/src/test/ui/issues/issue-55511.nll.stderr b/src/test/ui/issues/issue-55511.nll.stderr deleted file mode 100644 index bf3e58e8cdb..00000000000 --- a/src/test/ui/issues/issue-55511.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/issue-55511.rs:13:28 - | -LL | let b = Some(Cell::new(&a)); - | ^^ borrowed value does not live long enough -... -LL | <() as Foo<'static>>::C => { } - | ----------------------- type annotation requires that `a` is borrowed for `'static` -... -LL | } - | - `a` 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/issues/issue-55511.stderr b/src/test/ui/issues/issue-55511.stderr index 24668f04551..bf3e58e8cdb 100644 --- a/src/test/ui/issues/issue-55511.stderr +++ b/src/test/ui/issues/issue-55511.stderr @@ -1,13 +1,14 @@ error[E0597]: `a` does not live long enough - --> $DIR/issue-55511.rs:13:29 + --> $DIR/issue-55511.rs:13:28 | LL | let b = Some(Cell::new(&a)); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough +... +LL | <() as Foo<'static>>::C => { } + | ----------------------- type annotation requires that `a` is borrowed for `'static` ... LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `a` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/issues/issue-6801.nll.stderr b/src/test/ui/issues/issue-6801.nll.stderr deleted file mode 100644 index dbb8e6530c0..00000000000 --- a/src/test/ui/issues/issue-6801.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/issue-6801.rs:19:13 - | -LL | let sq = || { *x * *x }; - | -- - borrow occurs due to use in closure - | | - | borrow of `x` occurs here -LL | -LL | twice(x); - | ^ move out of `x` occurs here -LL | invoke(sq); - | -- 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/issues/issue-6801.stderr b/src/test/ui/issues/issue-6801.stderr index 482e4873f3a..dbb8e6530c0 100644 --- a/src/test/ui/issues/issue-6801.stderr +++ b/src/test/ui/issues/issue-6801.stderr @@ -2,10 +2,14 @@ error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/issue-6801.rs:19:13 | LL | let sq = || { *x * *x }; - | -- borrow of `x` occurs here + | -- - borrow occurs due to use in closure + | | + | borrow of `x` occurs here LL | LL | twice(x); | ^ move out of `x` occurs here +LL | invoke(sq); + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr deleted file mode 100644 index 0e2fc0a0fe9..00000000000 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion.rs:2:17 - | -LL | let mut x = vec![1].iter(); - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -LL | -LL | x.use_mut(); - | - 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/lifetimes/borrowck-let-suggestion.rs b/src/test/ui/lifetimes/borrowck-let-suggestion.rs index 1deb0457e95..3d591a506d5 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.rs +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.rs @@ -1,6 +1,6 @@ fn f() { let mut x = vec![1].iter(); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed x.use_mut(); } diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr index 7a95137ac92..0e2fc0a0fe9 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.stderr @@ -1,17 +1,17 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion.rs:2:17 | LL | let mut x = vec![1].iter(); - | ^^^^^^^ - temporary value dropped here while still borrowed + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here + | creates a temporary which is freed while still in use +LL | +LL | x.use_mut(); + | - 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/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.nll.stderr deleted file mode 100644 index 8376ee88d9a..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-loop.rs:9:9 - | -LL | let v: isize; - | - help: make this binding mutable: `mut v` -... -LL | v = 1; - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.stderr deleted file mode 100644 index db2a482be72..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.ast.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-loop.rs:9:9 - | -LL | v = 1; - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs index 59447ba3d75..c9e1851b9a9 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { let v: isize; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut v + //~^ HELP make this binding mutable + //~| SUGGESTION mut v loop { - v = 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable variable - //[mir]~| NOTE cannot assign twice to immutable variable - v.clone(); // just to prevent liveness warnings + v = 1; //~ ERROR cannot assign twice to immutable variable `v` + //~| NOTE cannot assign twice to immutable variable } } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr similarity index 86% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.mir.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr index 8376ee88d9a..69dff734ee4 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.mir.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-loop.stderr @@ -1,5 +1,5 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-loop.rs:9:9 + --> $DIR/liveness-assign-imm-local-in-loop.rs:6:9 | LL | let v: isize; | - help: make this binding mutable: `mut v` diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.stderr deleted file mode 100644 index b287edf2fda..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-op-eq.rs:10:5 - | -LL | v = 2; - | ----- first assignment to `v` -LL | -LL | v += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.mir.stderr deleted file mode 100644 index a6a1c73a786..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-op-eq.rs:10:5 - | -LL | let v: isize; - | - help: make this binding mutable: `mut v` -... -LL | v = 2; - | ----- first assignment to `v` -LL | -LL | v += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs index a2677f4e223..f24f7d2bcfc 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { let v: isize; - //[mir]~^ HELP make this binding mutable - //[mir]~| SUGGESTION mut v - v = 2; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - v += 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + //~^ HELP make this binding mutable + //~| SUGGESTION mut v + v = 2; //~ NOTE first assignment + v += 1; //~ ERROR cannot assign twice to immutable variable `v` + //~| NOTE cannot assign twice to immutable v.clone(); } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr similarity index 86% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.nll.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr index a6a1c73a786..182958dd492 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.ast.nll.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-in-op-eq.stderr @@ -1,12 +1,11 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-in-op-eq.rs:10:5 + --> $DIR/liveness-assign-imm-local-in-op-eq.rs:6:5 | LL | let v: isize; | - help: make this binding mutable: `mut v` ... LL | v = 2; | ----- first assignment to `v` -LL | LL | v += 1; | ^^^^^^ cannot assign twice to immutable variable diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.stderr deleted file mode 100644 index 108ca48f2fc..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/liveness-assign-imm-local-with-drop.rs:10:5 - | -LL | let b = Box::new(1); - | - first assignment to `b` -... -LL | b = Box::new(2); - | ^^^^^^^^^^^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.mir.stderr deleted file mode 100644 index 8316ffd7f51..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/liveness-assign-imm-local-with-drop.rs:10:5 - | -LL | let b = Box::new(1); - | - - | | - | first assignment to `b` - | help: make this binding mutable: `mut b` -... -LL | b = Box::new(2); - | ^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs index 4a81dcd3cfb..8963e32717e 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { - let b = Box::new(1); //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| HELP make this binding mutable - //[mir]~| SUGGESTION mut b + let b = Box::new(1); //~ NOTE first assignment + //~| HELP make this binding mutable + //~| SUGGESTION mut b drop(b); - b = Box::new(2); //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `b` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` + //~| NOTE cannot assign twice to immutable drop(b); } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr similarity index 88% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.nll.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr index 8316ffd7f51..7c4af624b27 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.ast.nll.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.stderr @@ -1,5 +1,5 @@ error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/liveness-assign-imm-local-with-drop.rs:10:5 + --> $DIR/liveness-assign-imm-local-with-drop.rs:6:5 | LL | let b = Box::new(1); | - diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.stderr deleted file mode 100644 index 34fb160bba6..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-with-init.rs:10:5 - | -LL | let v: isize = 1; - | - first assignment to `v` -... -LL | v = 2; - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.mir.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.mir.stderr deleted file mode 100644 index 5fa06f93c1c..00000000000 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-with-init.rs:10:5 - | -LL | let v: isize = 1; - | - - | | - | first assignment to `v` - | help: make this binding mutable: `mut v` -... -LL | v = 2; - | ^^^^^ cannot assign twice to immutable variable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0384`. diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs index 2c59aaf4f92..4ab222af8d0 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.rs @@ -1,16 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Zborrowck=mir - fn test() { - let v: isize = 1; //[ast]~ NOTE first assignment - //[mir]~^ NOTE first assignment - //[mir]~| HELP make this binding mutable - //[mir]~| SUGGESTION mut v + let v: isize = 1; //~ NOTE first assignment + //~| HELP make this binding mutable + //~| SUGGESTION mut v v.clone(); - v = 2; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `v` - //[ast]~| NOTE cannot assign twice to immutable - //[mir]~| NOTE cannot assign twice to immutable + v = 2; //~ ERROR cannot assign twice to immutable variable `v` + //~| NOTE cannot assign twice to immutable v.clone(); } diff --git a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.nll.stderr b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr similarity index 87% rename from src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.nll.stderr rename to src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr index 5fa06f93c1c..6f5d5574877 100644 --- a/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.ast.nll.stderr +++ b/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-init.stderr @@ -1,5 +1,5 @@ error[E0384]: cannot assign twice to immutable variable `v` - --> $DIR/liveness-assign-imm-local-with-init.rs:10:5 + --> $DIR/liveness-assign-imm-local-with-init.rs:6:5 | LL | let v: isize = 1; | - diff --git a/src/test/ui/liveness/liveness-move-call-arg.nll.stderr b/src/test/ui/liveness/liveness-move-call-arg.nll.stderr deleted file mode 100644 index ab4460a3268..00000000000 --- a/src/test/ui/liveness/liveness-move-call-arg.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/liveness-move-call-arg.rs:9:14 - | -LL | let x: Box = box 25; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | loop { -LL | take(x); - | ^ value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-move-call-arg.stderr b/src/test/ui/liveness/liveness-move-call-arg.stderr index c50c01e2a9e..ab4460a3268 100644 --- a/src/test/ui/liveness/liveness-move-call-arg.stderr +++ b/src/test/ui/liveness/liveness-move-call-arg.stderr @@ -1,10 +1,11 @@ error[E0382]: use of moved value: `x` --> $DIR/liveness-move-call-arg.rs:9:14 | +LL | let x: Box = box 25; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +LL | loop { LL | take(x); - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value moved here, in previous iteration of loop error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-move-in-loop.nll.stderr b/src/test/ui/liveness/liveness-move-in-loop.nll.stderr deleted file mode 100644 index 150c1ec82b8..00000000000 --- a/src/test/ui/liveness/liveness-move-in-loop.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0382]: use of moved value: `y` - --> $DIR/liveness-move-in-loop.rs:11:25 - | -LL | let y: Box = box 42; - | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | x = y; - | ^ value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-move-in-loop.stderr b/src/test/ui/liveness/liveness-move-in-loop.stderr index 52e83a6a68f..150c1ec82b8 100644 --- a/src/test/ui/liveness/liveness-move-in-loop.stderr +++ b/src/test/ui/liveness/liveness-move-in-loop.stderr @@ -1,10 +1,11 @@ error[E0382]: use of moved value: `y` --> $DIR/liveness-move-in-loop.rs:11:25 | +LL | let y: Box = box 42; + | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | x = y; - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value moved here, in previous iteration of loop error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-move-in-while.nll.stderr b/src/test/ui/liveness/liveness-move-in-while.nll.stderr deleted file mode 100644 index e1eed1b59f4..00000000000 --- a/src/test/ui/liveness/liveness-move-in-while.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `y` - --> $DIR/liveness-move-in-while.rs:7:24 - | -LL | let y: Box = box 42; - | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | println!("{}", y); - | ^ value borrowed here after move -LL | while true { while true { while true { x = y; x.clone(); } } } - | - value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-move-in-while.rs b/src/test/ui/liveness/liveness-move-in-while.rs index a43e75982a1..420d1311f8b 100644 --- a/src/test/ui/liveness/liveness-move-in-while.rs +++ b/src/test/ui/liveness/liveness-move-in-while.rs @@ -4,8 +4,7 @@ fn main() { let y: Box = box 42; let mut x: Box; loop { - println!("{}", y); //~ ERROR use of moved value: `y` + println!("{}", y); //~ ERROR borrow of moved value: `y` while true { while true { while true { x = y; x.clone(); } } } - //~^ ERROR use of moved value: `y` } } diff --git a/src/test/ui/liveness/liveness-move-in-while.stderr b/src/test/ui/liveness/liveness-move-in-while.stderr index 61b4cd8c630..e1eed1b59f4 100644 --- a/src/test/ui/liveness/liveness-move-in-while.stderr +++ b/src/test/ui/liveness/liveness-move-in-while.stderr @@ -1,21 +1,14 @@ -error[E0382]: use of moved value: `y` +error[E0382]: borrow of moved value: `y` --> $DIR/liveness-move-in-while.rs:7:24 | +LL | let y: Box = box 42; + | - move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | println!("{}", y); - | ^ value used here after move + | ^ value borrowed here after move LL | while true { while true { while true { x = y; x.clone(); } } } - | - value moved here - | - = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + | - value moved here, in previous iteration of loop -error[E0382]: use of moved value: `y` - --> $DIR/liveness-move-in-while.rs:8:52 - | -LL | while true { while true { while true { x = y; x.clone(); } } } - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/liveness/liveness-use-after-move.nll.stderr b/src/test/ui/liveness/liveness-use-after-move.nll.stderr deleted file mode 100644 index 383b89afaa7..00000000000 --- a/src/test/ui/liveness/liveness-use-after-move.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/liveness-use-after-move.rs:6:20 - | -LL | let x: Box<_> = box 5; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | let y = x; - | - value moved here -LL | println!("{}", *x); - | ^^ value borrowed 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/liveness/liveness-use-after-move.rs b/src/test/ui/liveness/liveness-use-after-move.rs index 157587c7a7b..5263e293603 100644 --- a/src/test/ui/liveness/liveness-use-after-move.rs +++ b/src/test/ui/liveness/liveness-use-after-move.rs @@ -3,6 +3,6 @@ fn main() { let x: Box<_> = box 5; let y = x; - println!("{}", *x); //~ ERROR use of moved value: `*x` + println!("{}", *x); //~ ERROR borrow of moved value: `x` y.clone(); } diff --git a/src/test/ui/liveness/liveness-use-after-move.stderr b/src/test/ui/liveness/liveness-use-after-move.stderr index ce192ae05f0..383b89afaa7 100644 --- a/src/test/ui/liveness/liveness-use-after-move.stderr +++ b/src/test/ui/liveness/liveness-use-after-move.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `*x` +error[E0382]: borrow of moved value: `x` --> $DIR/liveness-use-after-move.rs:6:20 | +LL | let x: Box<_> = box 5; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | let y = x; - | - value moved here + | - value moved here LL | println!("{}", *x); - | ^^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/liveness/liveness-use-after-send.nll.stderr b/src/test/ui/liveness/liveness-use-after-send.nll.stderr deleted file mode 100644 index ccf9499f644..00000000000 --- a/src/test/ui/liveness/liveness-use-after-send.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `message` - --> $DIR/liveness-use-after-send.rs:16:20 - | -LL | fn test00_start(ch: Chan>, message: Box, _count: Box) { - | ------- move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | send(ch, message); - | ------- value moved here -LL | println!("{}", message); - | ^^^^^^^ value borrowed 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/liveness/liveness-use-after-send.rs b/src/test/ui/liveness/liveness-use-after-send.rs index 7f2cc3c00f4..6fcd91a9d9b 100644 --- a/src/test/ui/liveness/liveness-use-after-send.rs +++ b/src/test/ui/liveness/liveness-use-after-send.rs @@ -13,7 +13,7 @@ struct Chan(isize, marker::PhantomData); // message after the send deinitializes it fn test00_start(ch: Chan>, message: Box, _count: Box) { send(ch, message); - println!("{}", message); //~ ERROR use of moved value: `message` + println!("{}", message); //~ ERROR borrow of moved value: `message` } fn main() { panic!(); } diff --git a/src/test/ui/liveness/liveness-use-after-send.stderr b/src/test/ui/liveness/liveness-use-after-send.stderr index 28173285fb4..ccf9499f644 100644 --- a/src/test/ui/liveness/liveness-use-after-send.stderr +++ b/src/test/ui/liveness/liveness-use-after-send.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `message` +error[E0382]: borrow of moved value: `message` --> $DIR/liveness-use-after-send.rs:16:20 | +LL | fn test00_start(ch: Chan>, message: Box, _count: Box) { + | ------- move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | send(ch, message); | ------- value moved here LL | println!("{}", message); - | ^^^^^^^ value used here after move - | - = note: move occurs because `message` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^^^^^^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/loops/loop-proper-liveness.nll.stderr b/src/test/ui/loops/loop-proper-liveness.nll.stderr deleted file mode 100644 index c87720659fd..00000000000 --- a/src/test/ui/loops/loop-proper-liveness.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: borrow of possibly uninitialized variable: `x` - --> $DIR/loop-proper-liveness.rs:9:22 - | -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/loops/loop-proper-liveness.rs b/src/test/ui/loops/loop-proper-liveness.rs index fd9d6612220..b8f76fbe57b 100644 --- a/src/test/ui/loops/loop-proper-liveness.rs +++ b/src/test/ui/loops/loop-proper-liveness.rs @@ -6,7 +6,7 @@ fn test1() { 'a: loop { x = loop { break 'a }; } - println!("{:?}", x); //~ ERROR use of possibly uninitialized variable + println!("{:?}", x); //~ ERROR borrow of possibly uninitialized variable } // test2 and test3 should not fail. diff --git a/src/test/ui/loops/loop-proper-liveness.stderr b/src/test/ui/loops/loop-proper-liveness.stderr index 392b961fa07..c87720659fd 100644 --- a/src/test/ui/loops/loop-proper-liveness.stderr +++ b/src/test/ui/loops/loop-proper-liveness.stderr @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/loop-proper-liveness.rs:9:22 | LL | println!("{:?}", x); diff --git a/src/test/ui/macros/span-covering-argument-1.nll.stderr b/src/test/ui/macros/span-covering-argument-1.nll.stderr deleted file mode 100644 index 2ac881107b9..00000000000 --- a/src/test/ui/macros/span-covering-argument-1.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable - --> $DIR/span-covering-argument-1.rs:5:14 - | -LL | let $s = 0; - | -- help: consider changing this to be mutable: `mut foo` -LL | *&mut $s = 0; - | ^^^^^^^ cannot borrow as mutable -... -LL | bad!(foo whatever); - | ------------------- in this macro invocation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/macros/span-covering-argument-1.rs b/src/test/ui/macros/span-covering-argument-1.rs index 0256aaf901e..9b9506c80b1 100644 --- a/src/test/ui/macros/span-covering-argument-1.rs +++ b/src/test/ui/macros/span-covering-argument-1.rs @@ -3,7 +3,7 @@ macro_rules! bad { { let $s = 0; *&mut $s = 0; - //~^ ERROR cannot borrow immutable local variable `foo` as mutable [E0596] + //~^ ERROR cannot borrow `foo` as mutable, as it is not declared as mutable [E0596] } } } diff --git a/src/test/ui/macros/span-covering-argument-1.stderr b/src/test/ui/macros/span-covering-argument-1.stderr index 345b880ccad..2ac881107b9 100644 --- a/src/test/ui/macros/span-covering-argument-1.stderr +++ b/src/test/ui/macros/span-covering-argument-1.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `foo` as mutable - --> $DIR/span-covering-argument-1.rs:5:19 +error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable + --> $DIR/span-covering-argument-1.rs:5:14 | LL | let $s = 0; - | -- help: make this binding mutable: `mut $s` + | -- help: consider changing this to be mutable: `mut foo` LL | *&mut $s = 0; - | ^^ cannot borrow mutably + | ^^^^^^^ cannot borrow as mutable ... LL | bad!(foo whatever); | ------------------- in this macro invocation diff --git a/src/test/ui/methods/method-self-arg-2.nll.stderr b/src/test/ui/methods/method-self-arg-2.nll.stderr deleted file mode 100644 index 946e71ee5b9..00000000000 --- a/src/test/ui/methods/method-self-arg-2.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/method-self-arg-2.rs:15:14 - | -LL | let y = &mut x; - | ------ mutable borrow occurs here -LL | Foo::bar(&x); - | ^^ immutable borrow occurs here -LL | y.use_mut(); - | - mutable borrow later used here - -error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/method-self-arg-2.rs:20:14 - | -LL | let y = &mut x; - | ------ first mutable borrow occurs here -LL | Foo::baz(&mut x); - | ^^^^^^ second mutable borrow occurs here -LL | y.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/methods/method-self-arg-2.stderr b/src/test/ui/methods/method-self-arg-2.stderr index c2f7032df41..946e71ee5b9 100644 --- a/src/test/ui/methods/method-self-arg-2.stderr +++ b/src/test/ui/methods/method-self-arg-2.stderr @@ -1,24 +1,22 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable - --> $DIR/method-self-arg-2.rs:15:15 + --> $DIR/method-self-arg-2.rs:15:14 | LL | let y = &mut x; - | - mutable borrow occurs here + | ------ mutable borrow occurs here LL | Foo::bar(&x); - | ^ immutable borrow occurs here -... -LL | } - | - mutable borrow ends here + | ^^ immutable borrow occurs here +LL | y.use_mut(); + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time - --> $DIR/method-self-arg-2.rs:20:19 + --> $DIR/method-self-arg-2.rs:20:14 | LL | let y = &mut x; - | - first mutable borrow occurs here + | ------ first mutable borrow occurs here LL | Foo::baz(&mut x); - | ^ second mutable borrow occurs here + | ^^^^^^ second mutable borrow occurs here LL | y.use_mut(); -LL | } - | - first borrow ends here + | - first borrow later used here error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/move-guard-same-consts.nll.stderr b/src/test/ui/moves/move-guard-same-consts.nll.stderr deleted file mode 100644 index 0945fbe68a0..00000000000 --- a/src/test/ui/moves/move-guard-same-consts.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/move-guard-same-consts.rs:20:24 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | (1, 2) if take(x) => (), - | - value moved here -LL | (1, 2) if take(x) => (), - | ^ 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/moves/move-guard-same-consts.stderr b/src/test/ui/moves/move-guard-same-consts.stderr index 65f6f1239fe..0945fbe68a0 100644 --- a/src/test/ui/moves/move-guard-same-consts.stderr +++ b/src/test/ui/moves/move-guard-same-consts.stderr @@ -1,12 +1,13 @@ error[E0382]: use of moved value: `x` --> $DIR/move-guard-same-consts.rs:20:24 | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | (1, 2) if take(x) => (), | - value moved here LL | (1, 2) if take(x) => (), | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/moves/move-in-guard-1.nll.stderr b/src/test/ui/moves/move-in-guard-1.nll.stderr deleted file mode 100644 index 542fd169863..00000000000 --- a/src/test/ui/moves/move-in-guard-1.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/move-in-guard-1.rs:10:24 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | (1, _) if take(x) => (), - | - value moved here -LL | (_, 2) if take(x) => (), - | ^ 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/moves/move-in-guard-1.stderr b/src/test/ui/moves/move-in-guard-1.stderr index af49fa82b0f..542fd169863 100644 --- a/src/test/ui/moves/move-in-guard-1.stderr +++ b/src/test/ui/moves/move-in-guard-1.stderr @@ -1,12 +1,13 @@ error[E0382]: use of moved value: `x` --> $DIR/move-in-guard-1.rs:10:24 | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | (1, _) if take(x) => (), | - value moved here LL | (_, 2) if take(x) => (), | ^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/moves/move-in-guard-2.nll.stderr b/src/test/ui/moves/move-in-guard-2.nll.stderr deleted file mode 100644 index 8bd405279c5..00000000000 --- a/src/test/ui/moves/move-in-guard-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/move-in-guard-2.rs:10:24 - | -LL | let x: Box<_> = box 1; - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -... -LL | (_, 2) if take(x) => (), - | ^ value moved here, in previous iteration of loop - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/move-in-guard-2.stderr b/src/test/ui/moves/move-in-guard-2.stderr index 5228abe86ef..8bd405279c5 100644 --- a/src/test/ui/moves/move-in-guard-2.stderr +++ b/src/test/ui/moves/move-in-guard-2.stderr @@ -1,10 +1,11 @@ error[E0382]: use of moved value: `x` --> $DIR/move-in-guard-2.rs:10:24 | +LL | let x: Box<_> = box 1; + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait +... LL | (_, 2) if take(x) => (), - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value moved here, in previous iteration of loop error: aborting due to previous error diff --git a/src/test/ui/moves/move-into-dead-array-1.nll.stderr b/src/test/ui/moves/move-into-dead-array-1.nll.stderr deleted file mode 100644 index 33da0e54a1e..00000000000 --- a/src/test/ui/moves/move-into-dead-array-1.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0381]: use of possibly uninitialized variable: `a` - --> $DIR/move-into-dead-array-1.rs:14:5 - | -LL | a[i] = d(); - | ^^^^ use of possibly uninitialized `a` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0381`. diff --git a/src/test/ui/moves/move-into-dead-array-1.stderr b/src/test/ui/moves/move-into-dead-array-1.stderr index 3a1bbe97d28..33da0e54a1e 100644 --- a/src/test/ui/moves/move-into-dead-array-1.stderr +++ b/src/test/ui/moves/move-into-dead-array-1.stderr @@ -2,7 +2,7 @@ error[E0381]: use of possibly uninitialized variable: `a` --> $DIR/move-into-dead-array-1.rs:14:5 | LL | a[i] = d(); - | ^^^^^^^^^^ use of possibly uninitialized `a` + | ^^^^ use of possibly uninitialized `a` error: aborting due to previous error diff --git a/src/test/ui/moves/move-into-dead-array-2.nll.stderr b/src/test/ui/moves/move-into-dead-array-2.nll.stderr deleted file mode 100644 index 19e476c04ea..00000000000 --- a/src/test/ui/moves/move-into-dead-array-2.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `a` - --> $DIR/move-into-dead-array-2.rs:14:5 - | -LL | fn foo(mut a: [D; 4], i: usize) { - | ----- move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait -LL | drop(a); - | - value moved here -LL | a[i] = d(); - | ^^^^ 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/moves/move-into-dead-array-2.stderr b/src/test/ui/moves/move-into-dead-array-2.stderr index 4521fa9bcb0..19e476c04ea 100644 --- a/src/test/ui/moves/move-into-dead-array-2.stderr +++ b/src/test/ui/moves/move-into-dead-array-2.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `a` --> $DIR/move-into-dead-array-2.rs:14:5 | +LL | fn foo(mut a: [D; 4], i: usize) { + | ----- move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait LL | drop(a); | - value moved here LL | a[i] = d(); - | ^^^^^^^^^^ value used here after move - | - = note: move occurs because `a` has type `[D; 4]`, which does not implement the `Copy` trait + | ^^^^ value used here after move error: aborting due to previous error diff --git a/src/test/ui/moves/move-out-of-slice-1.nll.stderr b/src/test/ui/moves/move-out-of-slice-1.nll.stderr deleted file mode 100644 index b4b1fe97ca9..00000000000 --- a/src/test/ui/moves/move-out-of-slice-1.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-1.rs:7:11 - | -LL | match a { - | ^ cannot move out of here -LL | box [a] => {}, - | - data moved here - | -note: move occurs because `a` has type `A`, which does not implement the `Copy` trait - --> $DIR/move-out-of-slice-1.rs:8:14 - | -LL | box [a] => {}, - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/moves/move-out-of-slice-1.rs b/src/test/ui/moves/move-out-of-slice-1.rs index 3e0906060e6..982648f5b23 100644 --- a/src/test/ui/moves/move-out-of-slice-1.rs +++ b/src/test/ui/moves/move-out-of-slice-1.rs @@ -4,8 +4,8 @@ struct A; fn main() { let a: Box<[A]> = Box::new([A]); - match a { - box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice + match a { //~ ERROR cannot move out of type `[A]`, a non-copy slice + box [a] => {}, _ => {} } } diff --git a/src/test/ui/moves/move-out-of-slice-1.stderr b/src/test/ui/moves/move-out-of-slice-1.stderr index f84e3a3f3e3..b4b1fe97ca9 100644 --- a/src/test/ui/moves/move-out-of-slice-1.stderr +++ b/src/test/ui/moves/move-out-of-slice-1.stderr @@ -1,11 +1,16 @@ error[E0508]: cannot move out of type `[A]`, a non-copy slice - --> $DIR/move-out-of-slice-1.rs:8:13 + --> $DIR/move-out-of-slice-1.rs:7:11 + | +LL | match a { + | ^ cannot move out of here +LL | box [a] => {}, + | - data moved here + | +note: move occurs because `a` has type `A`, which does not implement the `Copy` trait + --> $DIR/move-out-of-slice-1.rs:8:14 | LL | box [a] => {}, - | ^-^ - | || - | |hint: to prevent move, use `ref a` or `ref mut a` - | cannot move out of here + | ^ error: aborting due to previous error diff --git a/src/test/ui/moves/move-out-of-tuple-field.nll.stderr b/src/test/ui/moves/move-out-of-tuple-field.nll.stderr deleted file mode 100644 index 888ef3352e2..00000000000 --- a/src/test/ui/moves/move-out-of-tuple-field.nll.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:8:13 - | -LL | let y = x.0; - | --- value moved here -LL | let z = x.0; - | ^^^ value used here after move - | - = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:12:13 - | -LL | let y = x.0; - | --- value moved here -LL | let z = x.0; - | ^^^ value used here after move - | - = note: move occurs because `x.0` has type `std::boxed::Box`, 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/moves/move-out-of-tuple-field.stderr b/src/test/ui/moves/move-out-of-tuple-field.stderr index 89662c8303d..888ef3352e2 100644 --- a/src/test/ui/moves/move-out-of-tuple-field.stderr +++ b/src/test/ui/moves/move-out-of-tuple-field.stderr @@ -1,20 +1,20 @@ error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:8:9 + --> $DIR/move-out-of-tuple-field.rs:8:13 | LL | let y = x.0; - | - value moved here + | --- value moved here LL | let z = x.0; - | ^ value used here after move + | ^^^ value used here after move | = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x.0` - --> $DIR/move-out-of-tuple-field.rs:12:9 + --> $DIR/move-out-of-tuple-field.rs:12:13 | LL | let y = x.0; - | - value moved here + | --- value moved here LL | let z = x.0; - | ^ value used here after move + | ^^^ value used here after move | = note: move occurs because `x.0` has type `std::boxed::Box`, which does not implement the `Copy` trait diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.nll.stderr b/src/test/ui/moves/moves-based-on-type-access-to-field.nll.stderr deleted file mode 100644 index 71a3c4506ea..00000000000 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-access-to-field.rs:11:12 - | -LL | let x = vec!["hi".to_string()]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | consume(x.into_iter().next().unwrap()); - | - value moved here -LL | touch(&x[0]); - | ^ value borrowed 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/moves/moves-based-on-type-access-to-field.rs b/src/test/ui/moves/moves-based-on-type-access-to-field.rs index c7ea357a5d9..e2003ed6e47 100644 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.rs +++ b/src/test/ui/moves/moves-based-on-type-access-to-field.rs @@ -8,7 +8,7 @@ fn touch(_a: &A) {} fn f20() { let x = vec!["hi".to_string()]; consume(x.into_iter().next().unwrap()); - touch(&x[0]); //~ ERROR use of moved value: `x` + touch(&x[0]); //~ ERROR borrow of moved value: `x` } fn main() {} diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr index ed4d69f838e..71a3c4506ea 100644 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr +++ b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-access-to-field.rs:11:12 | +LL | let x = vec!["hi".to_string()]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | consume(x.into_iter().next().unwrap()); | - value moved here LL | touch(&x[0]); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr b/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr deleted file mode 100644 index b83a15c9d4d..00000000000 --- a/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/moves-based-on-type-block-bad.rs:24:19 - | -LL | match hellothere.x { - | ^^^^^^^^^^^^ - | | - | cannot move out of borrowed content - | help: consider borrowing here: `&hellothere.x` -... -LL | box E::Bar(x) => println!("{}", x.to_string()), - | - data moved here - | -note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait - --> $DIR/moves-based-on-type-block-bad.rs:27:28 - | -LL | box E::Bar(x) => println!("{}", x.to_string()), - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/moves/moves-based-on-type-block-bad.stderr b/src/test/ui/moves/moves-based-on-type-block-bad.stderr index f5328edfcc2..b83a15c9d4d 100644 --- a/src/test/ui/moves/moves-based-on-type-block-bad.stderr +++ b/src/test/ui/moves/moves-based-on-type-block-bad.stderr @@ -2,10 +2,19 @@ error[E0507]: cannot move out of borrowed content --> $DIR/moves-based-on-type-block-bad.rs:24:19 | LL | match hellothere.x { - | ^^^^^^^^^^ cannot move out of borrowed content + | ^^^^^^^^^^^^ + | | + | cannot move out of borrowed content + | help: consider borrowing here: `&hellothere.x` ... LL | box E::Bar(x) => println!("{}", x.to_string()), - | - hint: to prevent move, use `ref x` or `ref mut x` + | - data moved here + | +note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + --> $DIR/moves-based-on-type-block-bad.rs:27:28 + | +LL | box E::Bar(x) => println!("{}", x.to_string()), + | ^ error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.nll.stderr b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.nll.stderr deleted file mode 100644 index 3a05a1305be..00000000000 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-capture-clause-bad.rs:8:20 - | -LL | let x = "Hello world!".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | println!("{}", x); - | - variable moved due to use in closure -LL | }); -LL | println!("{}", x); - | ^ value borrowed 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/moves/moves-based-on-type-capture-clause-bad.rs b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs index d5f44a0b3f7..b2f68352f89 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs +++ b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.rs @@ -5,5 +5,5 @@ fn main() { thread::spawn(move|| { println!("{}", x); }); - println!("{}", x); //~ ERROR use of moved value + println!("{}", x); //~ ERROR borrow of moved value } diff --git a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr index 39119ff3aaa..3a05a1305be 100644 --- a/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr +++ b/src/test/ui/moves/moves-based-on-type-capture-clause-bad.stderr @@ -1,13 +1,15 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/moves-based-on-type-capture-clause-bad.rs:8:20 | +LL | let x = "Hello world!".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | thread::spawn(move|| { - | ------ value moved (into closure) here -... + | ------ value moved into closure here +LL | println!("{}", x); + | - variable moved due to use in closure +LL | }); LL | println!("{}", x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.nll.stderr b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.nll.stderr deleted file mode 100644 index fb8562d00ea..00000000000 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: use of moved value: `node` - --> $DIR/moves-based-on-type-cyclic-types-issue-4821.rs:13:13 - | -LL | Some(right) => consume(right), - | ----- value moved here -... -LL | consume(node) + r - | ^^^^ value used here after partial move - | - = note: move occurs because value has type `std::boxed::Box`, 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/moves/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs index 4417fb926d9..b070671cb25 100644 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs +++ b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.rs @@ -10,7 +10,7 @@ fn foo(node: Box) -> isize { Some(right) => consume(right), None => 0 }; - consume(node) + r //~ ERROR use of partially moved value: `node` + consume(node) + r //~ ERROR use of moved value: `node` } fn consume(v: Box) -> isize { diff --git a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr index 8b904c7169b..fb8562d00ea 100644 --- a/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr +++ b/src/test/ui/moves/moves-based-on-type-cyclic-types-issue-4821.stderr @@ -1,13 +1,13 @@ -error[E0382]: use of partially moved value: `node` +error[E0382]: use of moved value: `node` --> $DIR/moves-based-on-type-cyclic-types-issue-4821.rs:13:13 | LL | Some(right) => consume(right), | ----- value moved here ... LL | consume(node) + r - | ^^^^ value used here after move + | ^^^^ value used here after partial move | - = note: move occurs because the value has type `std::boxed::Box`, which does not implement the `Copy` trait + = note: move occurs because value has type `std::boxed::Box`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.nll.stderr b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.nll.stderr deleted file mode 100644 index 25f88fe157a..00000000000 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:11:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = Foo { f:x }; - | - value moved here -LL | -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:20:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = Foo { f:(((x))) }; - | ------- value moved here -LL | -LL | touch(&x); - | ^^ value borrowed 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/moves/moves-based-on-type-distribute-copy-over-paren.rs b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs index 7c7ca0044e2..0b44ca56ced 100644 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs +++ b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.rs @@ -6,20 +6,20 @@ fn touch(_a: &A) {} fn f00() { let x = "hi".to_string(); + //~^ NOTE move occurs because `x` has type `std::string::String` let _y = Foo { f:x }; //~^ NOTE value moved here - touch(&x); //~ ERROR use of moved value: `x` - //~^ NOTE value used here after move - //~| NOTE move occurs because `x` has type `std::string::String` + touch(&x); //~ ERROR borrow of moved value: `x` + //~^ NOTE value borrowed here after move } fn f05() { let x = "hi".to_string(); + //~^ NOTE move occurs because `x` has type `std::string::String` let _y = Foo { f:(((x))) }; //~^ NOTE value moved here - touch(&x); //~ ERROR use of moved value: `x` - //~^ NOTE value used here after move - //~| NOTE move occurs because `x` has type `std::string::String` + touch(&x); //~ ERROR borrow of moved value: `x` + //~^ NOTE value borrowed here after move } fn f10() { diff --git a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr index edf521a896f..d7a7ceabf85 100644 --- a/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr +++ b/src/test/ui/moves/moves-based-on-type-distribute-copy-over-paren.stderr @@ -1,24 +1,26 @@ -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:11:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:12:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | LL | let _y = Foo { f:x }; | - value moved here LL | LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:20:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-distribute-copy-over-paren.rs:21:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +LL | LL | let _y = Foo { f:(((x))) }; | ------- value moved here LL | LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-exprs.nll.stderr b/src/test/ui/moves/moves-based-on-type-exprs.nll.stderr deleted file mode 100644 index 67fae606c4e..00000000000 --- a/src/test/ui/moves/moves-based-on-type-exprs.nll.stderr +++ /dev/null @@ -1,123 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:12:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = Foo { f:x }; - | - value moved here -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:18:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = (x, 3); - | - value moved here -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:35:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | x - | - value moved here -... -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:36:11 - | -LL | let y = "ho".to_string(); - | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | y - | - value moved here -... -LL | touch(&y); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:46:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | true => x, - | - value moved here -... -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:47:11 - | -LL | let y = "ho".to_string(); - | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | false => y - | - value moved here -... -LL | touch(&y); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:58:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -... -LL | _ if guard(x) => 10, - | - value moved here -... -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:65:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = [x]; - | - value moved here -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:71:11 - | -LL | let x = "hi".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = vec![x]; - | - value moved here -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:77:11 - | -LL | let x = vec!["hi".to_string()]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let _y = x.into_iter().next().unwrap(); - | - value moved here -LL | touch(&x); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:83:11 - | -LL | let x = vec!["hi".to_string()]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let _y = [x.into_iter().next().unwrap(); 1]; - | - value moved here -LL | touch(&x); - | ^^ value borrowed here after move - -error: aborting due to 11 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-exprs.rs b/src/test/ui/moves/moves-based-on-type-exprs.rs index b058f83291b..4a52d8d3206 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.rs +++ b/src/test/ui/moves/moves-based-on-type-exprs.rs @@ -9,13 +9,13 @@ fn touch(_a: &A) {} fn f10() { let x = "hi".to_string(); let _y = Foo { f:x }; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f20() { let x = "hi".to_string(); let _y = (x, 3); - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f21() { @@ -32,8 +32,8 @@ fn f30(cond: bool) { } else { y }; - touch(&x); //~ ERROR use of moved value: `x` - touch(&y); //~ ERROR use of moved value: `y` + touch(&x); //~ ERROR borrow of moved value: `x` + touch(&y); //~ ERROR borrow of moved value: `y` } fn f40(cond: bool) { @@ -43,8 +43,8 @@ fn f40(cond: bool) { true => x, false => y }; - touch(&x); //~ ERROR use of moved value: `x` - touch(&y); //~ ERROR use of moved value: `y` + touch(&x); //~ ERROR borrow of moved value: `x` + touch(&y); //~ ERROR borrow of moved value: `y` } fn f50(cond: bool) { @@ -55,32 +55,32 @@ fn f50(cond: bool) { true => 10, false => 20, }; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` touch(&y); } fn f70() { let x = "hi".to_string(); let _y = [x]; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f80() { let x = "hi".to_string(); let _y = vec![x]; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f100() { let x = vec!["hi".to_string()]; let _y = x.into_iter().next().unwrap(); - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f110() { let x = vec!["hi".to_string()]; let _y = [x.into_iter().next().unwrap(); 1]; - touch(&x); //~ ERROR use of moved value: `x` + touch(&x); //~ ERROR borrow of moved value: `x` } fn f120() { diff --git a/src/test/ui/moves/moves-based-on-type-exprs.stderr b/src/test/ui/moves/moves-based-on-type-exprs.stderr index 6cb297cbd63..67fae606c4e 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.stderr +++ b/src/test/ui/moves/moves-based-on-type-exprs.stderr @@ -1,117 +1,122 @@ -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:12:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:12:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = Foo { f:x }; | - value moved here LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:18:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:18:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = (x, 3); | - value moved here LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:35:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:35:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +... LL | x | - value moved here ... LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:36:12 +error[E0382]: borrow of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:36:11 | +LL | let y = "ho".to_string(); + | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait +... LL | y | - value moved here ... LL | touch(&y); - | ^ value used here after move - | - = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:46:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:46:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +... LL | true => x, | - value moved here ... LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `y` - --> $DIR/moves-based-on-type-exprs.rs:47:12 +error[E0382]: borrow of moved value: `y` + --> $DIR/moves-based-on-type-exprs.rs:47:11 | +LL | let y = "ho".to_string(); + | - move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait +... LL | false => y | - value moved here ... LL | touch(&y); - | ^ value used here after move - | - = note: move occurs because `y` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:58:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:58:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait +... LL | _ if guard(x) => 10, | - value moved here ... LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:65:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:65:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = [x]; | - value moved here LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:71:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:71:11 | +LL | let x = "hi".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = vec![x]; | - value moved here LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:77:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:77:11 | +LL | let x = vec!["hi".to_string()]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let _y = x.into_iter().next().unwrap(); | - value moved here LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/moves-based-on-type-exprs.rs:83:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-exprs.rs:83:11 | +LL | let x = vec!["hi".to_string()]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let _y = [x.into_iter().next().unwrap(); 1]; | - value moved here LL | touch(&x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait + | ^^ value borrowed here after move error: aborting due to 11 previous errors diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.nll.stderr b/src/test/ui/moves/moves-based-on-type-match-bindings.nll.stderr deleted file mode 100644 index 322999a1f0f..00000000000 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-match-bindings.rs:16:11 - | -LL | Foo {f} => {} - | - value moved here -... -LL | touch(&x); - | ^^ value borrowed here after partial move - | - = note: move occurs because `x.f` has type `std::string::String`, 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/moves/moves-based-on-type-match-bindings.rs b/src/test/ui/moves/moves-based-on-type-match-bindings.rs index 59e5a8f684e..1290d4a25ab 100644 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.rs +++ b/src/test/ui/moves/moves-based-on-type-match-bindings.rs @@ -13,8 +13,8 @@ fn f10() { Foo {f} => {} }; - touch(&x); //~ ERROR use of partially moved value: `x` - //~^ value used here after move + touch(&x); //~ ERROR borrow of moved value: `x` + //~^ value borrowed here after partial move //~| move occurs because `x.f` has type `std::string::String` } diff --git a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr index 9174cfa122c..322999a1f0f 100644 --- a/src/test/ui/moves/moves-based-on-type-match-bindings.stderr +++ b/src/test/ui/moves/moves-based-on-type-match-bindings.stderr @@ -1,11 +1,11 @@ -error[E0382]: use of partially moved value: `x` - --> $DIR/moves-based-on-type-match-bindings.rs:16:12 +error[E0382]: borrow of moved value: `x` + --> $DIR/moves-based-on-type-match-bindings.rs:16:11 | LL | Foo {f} => {} | - value moved here ... LL | touch(&x); - | ^ value used here after move + | ^^ value borrowed here after partial move | = note: move occurs because `x.f` has type `std::string::String`, which does not implement the `Copy` trait diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr deleted file mode 100644 index 0568a2e94a7..00000000000 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:11:28 - | -LL | let i = box 3; - | - captured outer variable -LL | let _f = to_fn(|| test(i)); - | ^ 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/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr index 654881d25e6..0568a2e94a7 100644 --- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.stderr +++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.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/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:11:28 | LL | let i = box 3; | - captured outer variable LL | let _f = to_fn(|| test(i)); - | ^ 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/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr deleted file mode 100644 index 483c364752b..00000000000 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0499]: cannot borrow `*f` as mutable more than once at a time - --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:20:27 - | -LL | (f.c)(f, true); - | ----- ^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error[E0382]: borrow of moved value: `f` - --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:32:5 - | -LL | fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { - | - ----- move occurs because `f` has type `F`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | let mut r = R {c: Box::new(f)}; - | - value moved here -LL | f(&mut r, false) - | ^ value borrowed here after move - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0382, E0499. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs index 737a131c9bf..3fa11878629 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs @@ -29,7 +29,7 @@ fn innocent_looking_victim() { fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { let mut r = R {c: Box::new(f)}; - f(&mut r, false) //~ ERROR use of moved value + f(&mut r, false) //~ ERROR borrow of moved value } fn main() { innocent_looking_victim() } diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr index bdc736576c9..483c364752b 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.stderr @@ -2,20 +2,22 @@ error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:20:27 | LL | (f.c)(f, true); - | ----- ^ - first borrow ends here - | | | - | | second mutable borrow occurs here + | ----- ^ second mutable borrow occurs here + | | | first mutable borrow occurs here + | first borrow later used by call -error[E0382]: use of moved value: `f` +error[E0382]: borrow of moved value: `f` --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:32:5 | +LL | fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { + | - ----- move occurs because `f` has type `F`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | let mut r = R {c: Box::new(f)}; | - value moved here LL | f(&mut r, false) - | ^ value used here after move - | - = note: move occurs because `f` has type `F`, which does not implement the `Copy` trait + | ^ value borrowed here after move error: aborting due to 2 previous errors diff --git a/src/test/ui/moves/moves-sru-moved-field.nll.stderr b/src/test/ui/moves/moves-sru-moved-field.nll.stderr deleted file mode 100644 index a012c2d9b7b..00000000000 --- a/src/test/ui/moves/moves-sru-moved-field.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `f.moved` - --> $DIR/moves-sru-moved-field.rs:20:14 - | -LL | let _b = Foo {noncopyable: g, ..f}; - | ------------------------- value moved here -LL | let _c = Foo {noncopyable: h, ..f}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `f.moved` has type `std::boxed::Box`, 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/moves/moves-sru-moved-field.stderr b/src/test/ui/moves/moves-sru-moved-field.stderr index aac399ea4a1..a012c2d9b7b 100644 --- a/src/test/ui/moves/moves-sru-moved-field.stderr +++ b/src/test/ui/moves/moves-sru-moved-field.stderr @@ -1,10 +1,10 @@ error[E0382]: use of moved value: `f.moved` - --> $DIR/moves-sru-moved-field.rs:20:37 + --> $DIR/moves-sru-moved-field.rs:20:14 | LL | let _b = Foo {noncopyable: g, ..f}; - | - value moved here + | ------------------------- value moved here LL | let _c = Foo {noncopyable: h, ..f}; - | ^ value used here after move + | ^^^^^^^^^^^^^^^^^^^^^^^^^ value used here after move | = note: move occurs because `f.moved` has type `std::boxed::Box`, which does not implement the `Copy` trait diff --git a/src/test/ui/mut/mut-cant-alias.nll.stderr b/src/test/ui/mut/mut-cant-alias.nll.stderr deleted file mode 100644 index d56e45db13d..00000000000 --- a/src/test/ui/mut/mut-cant-alias.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0499]: cannot borrow `b` as mutable more than once at a time - --> $DIR/mut-cant-alias.rs:9:20 - | -LL | let b1 = &mut *b; - | - first mutable borrow occurs here -LL | let b2 = &mut *b; - | ^ second mutable borrow occurs here -LL | b1.use_mut(); - | -- 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/mut/mut-cant-alias.stderr b/src/test/ui/mut/mut-cant-alias.stderr index 5fc194bc3db..d56e45db13d 100644 --- a/src/test/ui/mut/mut-cant-alias.stderr +++ b/src/test/ui/mut/mut-cant-alias.stderr @@ -6,8 +6,7 @@ LL | let b1 = &mut *b; LL | let b2 = &mut *b; | ^ second mutable borrow occurs here LL | b1.use_mut(); -LL | } - | - first borrow ends here + | -- first borrow later used here error: aborting due to previous error diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.ast.stderr b/src/test/ui/mut/mut-pattern-internal-mutability.ast.stderr deleted file mode 100644 index 737e9f38c74..00000000000 --- a/src/test/ui/mut/mut-pattern-internal-mutability.ast.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/mut-pattern-internal-mutability.rs:8:5 - | -LL | let &mut x = foo; - | - first assignment to `x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0506]: cannot assign to `*foo` because it is borrowed - --> $DIR/mut-pattern-internal-mutability.rs:17:5 - | -LL | let &mut ref x = foo; - | ----- borrow of `*foo` occurs here -LL | *foo += 1; - | ^^^^^^^^^ assignment to borrowed `*foo` occurs here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0384, E0506. -For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.mir.stderr b/src/test/ui/mut/mut-pattern-internal-mutability.mir.stderr deleted file mode 100644 index 0b67a6d5b20..00000000000 --- a/src/test/ui/mut/mut-pattern-internal-mutability.mir.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/mut-pattern-internal-mutability.rs:8:5 - | -LL | let &mut x = foo; - | - - | | - | first assignment to `x` - | help: make this binding mutable: `mut x` -LL | x += 1; - | ^^^^^^ cannot assign twice to immutable variable - -error[E0506]: cannot assign to `*foo` because it is borrowed - --> $DIR/mut-pattern-internal-mutability.rs:17:5 - | -LL | let &mut ref x = foo; - | ----- borrow of `*foo` occurs here -LL | *foo += 1; - | ^^^^^^^^^ assignment to borrowed `*foo` occurs here -LL | -LL | drop(x); - | - borrow later used here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0384, E0506. -For more information about an error, try `rustc --explain E0384`. diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.rs b/src/test/ui/mut/mut-pattern-internal-mutability.rs index ffad623e572..bcee878e389 100644 --- a/src/test/ui/mut/mut-pattern-internal-mutability.rs +++ b/src/test/ui/mut/mut-pattern-internal-mutability.rs @@ -1,12 +1,8 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let foo = &mut 1; let &mut x = foo; - x += 1; //[ast]~ ERROR cannot assign twice to immutable variable - //[mir]~^ ERROR cannot assign twice to immutable variable `x` + x += 1; //~ ERROR cannot assign twice to immutable variable `x` // explicitly mut-ify internals let &mut mut x = foo; @@ -14,7 +10,6 @@ fn main() { // check borrowing is detected successfully let &mut ref x = foo; - *foo += 1; //[ast]~ ERROR cannot assign to `*foo` because it is borrowed - //[mir]~^ ERROR cannot assign to `*foo` because it is borrowed + *foo += 1; //~ ERROR cannot assign to `*foo` because it is borrowed drop(x); } diff --git a/src/test/ui/mut/mut-pattern-internal-mutability.ast.nll.stderr b/src/test/ui/mut/mut-pattern-internal-mutability.stderr similarity index 87% rename from src/test/ui/mut/mut-pattern-internal-mutability.ast.nll.stderr rename to src/test/ui/mut/mut-pattern-internal-mutability.stderr index 0b67a6d5b20..eaa33453a75 100644 --- a/src/test/ui/mut/mut-pattern-internal-mutability.ast.nll.stderr +++ b/src/test/ui/mut/mut-pattern-internal-mutability.stderr @@ -1,5 +1,5 @@ error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/mut-pattern-internal-mutability.rs:8:5 + --> $DIR/mut-pattern-internal-mutability.rs:5:5 | LL | let &mut x = foo; | - @@ -10,13 +10,12 @@ LL | x += 1; | ^^^^^^ cannot assign twice to immutable variable error[E0506]: cannot assign to `*foo` because it is borrowed - --> $DIR/mut-pattern-internal-mutability.rs:17:5 + --> $DIR/mut-pattern-internal-mutability.rs:13:5 | LL | let &mut ref x = foo; | ----- borrow of `*foo` occurs here LL | *foo += 1; | ^^^^^^^^^ assignment to borrowed `*foo` occurs here -LL | LL | drop(x); | - borrow later used here diff --git a/src/test/ui/mut/mut-suggestion.nll.stderr b/src/test/ui/mut/mut-suggestion.nll.stderr deleted file mode 100644 index 61656db5ec2..00000000000 --- a/src/test/ui/mut/mut-suggestion.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable - --> $DIR/mut-suggestion.rs:12: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 `local` as mutable, as it is not declared as mutable - --> $DIR/mut-suggestion.rs:21:5 - | -LL | let local = S; - | ----- help: consider changing this to be mutable: `mut local` -... -LL | local.mutate(); - | ^^^^^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/mut/mut-suggestion.rs b/src/test/ui/mut/mut-suggestion.rs index 0d95a8bc12a..3104b20aca4 100644 --- a/src/test/ui/mut/mut-suggestion.rs +++ b/src/test/ui/mut/mut-suggestion.rs @@ -7,18 +7,16 @@ impl S { } fn func(arg: S) { - //~^ HELP make this binding mutable + //~^ HELP consider changing this to be mutable //~| SUGGESTION mut arg arg.mutate(); - //~^ ERROR cannot borrow immutable argument - //~| cannot borrow mutably + //~^ ERROR cannot borrow `arg` as mutable, as it is not declared as mutable } fn main() { let local = S; - //~^ HELP make this binding mutable + //~^ HELP consider changing this to be mutable //~| SUGGESTION mut local local.mutate(); - //~^ ERROR cannot borrow immutable local variable - //~| cannot borrow mutably + //~^ ERROR cannot borrow `local` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/mut/mut-suggestion.stderr b/src/test/ui/mut/mut-suggestion.stderr index 1998ec1eca9..245eaff4bb4 100644 --- a/src/test/ui/mut/mut-suggestion.stderr +++ b/src/test/ui/mut/mut-suggestion.stderr @@ -1,20 +1,20 @@ -error[E0596]: cannot borrow immutable argument `arg` as mutable +error[E0596]: cannot borrow `arg` as mutable, as it is not declared as mutable --> $DIR/mut-suggestion.rs:12: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 local variable `local` as mutable - --> $DIR/mut-suggestion.rs:21:5 +error[E0596]: cannot borrow `local` as mutable, as it is not declared as mutable + --> $DIR/mut-suggestion.rs:20:5 | LL | let local = S; - | ----- help: make this binding mutable: `mut local` + | ----- help: consider changing this to be mutable: `mut local` ... LL | local.mutate(); - | ^^^^^ cannot borrow mutably + | ^^^^^ cannot borrow as mutable error: aborting due to 2 previous errors diff --git a/src/test/ui/mut/mutable-class-fields-2.nll.stderr b/src/test/ui/mut/mutable-class-fields-2.nll.stderr deleted file mode 100644 index a27a82ffe46..00000000000 --- a/src/test/ui/mut/mutable-class-fields-2.nll.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0594]: cannot assign to `self.how_hungry` which is behind a `&` reference - --> $DIR/mutable-class-fields-2.rs:9:5 - | -LL | pub fn eat(&self) { - | ----- help: consider changing this to be a mutable reference: `&mut self` -LL | self.how_hungry -= 5; - | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to previous error - diff --git a/src/test/ui/mut/mutable-class-fields-2.stderr b/src/test/ui/mut/mutable-class-fields-2.stderr index 4b3ab2fa894..a27a82ffe46 100644 --- a/src/test/ui/mut/mutable-class-fields-2.stderr +++ b/src/test/ui/mut/mutable-class-fields-2.stderr @@ -1,10 +1,10 @@ -error[E0594]: cannot assign to field `self.how_hungry` of immutable binding +error[E0594]: cannot assign to `self.how_hungry` which is behind a `&` reference --> $DIR/mutable-class-fields-2.rs:9:5 | LL | pub fn eat(&self) { - | ----- use `&mut self` here to make mutable + | ----- help: consider changing this to be a mutable reference: `&mut self` LL | self.how_hungry -= 5; - | ^^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding + | ^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written error: aborting due to previous error diff --git a/src/test/ui/mut/mutable-class-fields.ast.stderr b/src/test/ui/mut/mutable-class-fields.ast.stderr deleted file mode 100644 index 44f7361c3e9..00000000000 --- a/src/test/ui/mut/mutable-class-fields.ast.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0594]: cannot assign to field `nyan.how_hungry` of immutable binding - --> $DIR/mutable-class-fields.rs:18:3 - | -LL | let nyan : Cat = cat(52, 99); - | ---- help: make this binding mutable: `mut nyan` -LL | nyan.how_hungry = 0; - | ^^^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding - -error: aborting due to previous error - diff --git a/src/test/ui/mut/mutable-class-fields.mir.stderr b/src/test/ui/mut/mutable-class-fields.mir.stderr deleted file mode 100644 index b233ed29559..00000000000 --- a/src/test/ui/mut/mutable-class-fields.mir.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0594]: cannot assign to `nyan.how_hungry`, as `nyan` is not declared as mutable - --> $DIR/mutable-class-fields.rs:18:3 - | -LL | let nyan : Cat = cat(52, 99); - | ---- help: consider changing this to be mutable: `mut nyan` -LL | nyan.how_hungry = 0; - | ^^^^^^^^^^^^^^^^^^^ cannot assign - -error: aborting due to previous error - diff --git a/src/test/ui/mut/mutable-class-fields.rs b/src/test/ui/mut/mutable-class-fields.rs index 2a729a5f6e6..30768a1ec9b 100644 --- a/src/test/ui/mut/mutable-class-fields.rs +++ b/src/test/ui/mut/mutable-class-fields.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct Cat { meows : usize, how_hungry : isize, @@ -15,6 +12,5 @@ fn cat(in_x : usize, in_y : isize) -> Cat { fn main() { let nyan : Cat = cat(52, 99); - nyan.how_hungry = 0; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign + nyan.how_hungry = 0; //~ ERROR cannot assign } diff --git a/src/test/ui/mut/mutable-class-fields.ast.nll.stderr b/src/test/ui/mut/mutable-class-fields.stderr similarity index 88% rename from src/test/ui/mut/mutable-class-fields.ast.nll.stderr rename to src/test/ui/mut/mutable-class-fields.stderr index b233ed29559..5391ccc80c5 100644 --- a/src/test/ui/mut/mutable-class-fields.ast.nll.stderr +++ b/src/test/ui/mut/mutable-class-fields.stderr @@ -1,5 +1,5 @@ error[E0594]: cannot assign to `nyan.how_hungry`, as `nyan` is not declared as mutable - --> $DIR/mutable-class-fields.rs:18:3 + --> $DIR/mutable-class-fields.rs:15:3 | LL | let nyan : Cat = cat(52, 99); | ---- help: consider changing this to be mutable: `mut nyan` diff --git a/src/test/ui/nll/cannot-move-block-spans.nll.stderr b/src/test/ui/nll/cannot-move-block-spans.nll.stderr deleted file mode 100644 index c8dd07dabe1..00000000000 --- a/src/test/ui/nll/cannot-move-block-spans.nll.stderr +++ /dev/null @@ -1,85 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:5:15 - | -LL | let x = { *r }; - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:6:22 - | -LL | let y = unsafe { *r }; - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:7:26 - | -LL | let z = loop { break *r; }; - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array - --> $DIR/cannot-move-block-spans.rs:11:15 - | -LL | let x = { arr[0] }; - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&arr[0]` - -error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array - --> $DIR/cannot-move-block-spans.rs:12:22 - | -LL | let y = unsafe { arr[0] }; - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&arr[0]` - -error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array - --> $DIR/cannot-move-block-spans.rs:13:26 - | -LL | let z = loop { break arr[0]; }; - | ^^^^^^ - | | - | cannot move out of here - | help: consider borrowing here: `&arr[0]` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:17:38 - | -LL | let x = { let mut u = 0; u += 1; *r }; - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:18:45 - | -LL | let y = unsafe { let mut u = 0; u += 1; *r }; - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error[E0507]: cannot move out of borrowed content - --> $DIR/cannot-move-block-spans.rs:19:49 - | -LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; - | ^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `r` - -error: aborting due to 9 previous errors - -Some errors have detailed explanations: E0507, E0508. -For more information about an error, try `rustc --explain E0507`. diff --git a/src/test/ui/nll/cannot-move-block-spans.stderr b/src/test/ui/nll/cannot-move-block-spans.stderr index 1f0d91b4b76..c8dd07dabe1 100644 --- a/src/test/ui/nll/cannot-move-block-spans.stderr +++ b/src/test/ui/nll/cannot-move-block-spans.stderr @@ -2,55 +2,82 @@ error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:5:15 | LL | let x = { *r }; - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:6:22 | LL | let y = unsafe { *r }; - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:7:26 | LL | let z = loop { break *r; }; - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array --> $DIR/cannot-move-block-spans.rs:11:15 | LL | let x = { arr[0] }; - | ^^^^^^ cannot move out of here + | ^^^^^^ + | | + | cannot move out of here + | help: consider borrowing here: `&arr[0]` error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array --> $DIR/cannot-move-block-spans.rs:12:22 | LL | let y = unsafe { arr[0] }; - | ^^^^^^ cannot move out of here + | ^^^^^^ + | | + | cannot move out of here + | help: consider borrowing here: `&arr[0]` error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array --> $DIR/cannot-move-block-spans.rs:13:26 | LL | let z = loop { break arr[0]; }; - | ^^^^^^ cannot move out of here + | ^^^^^^ + | | + | cannot move out of here + | help: consider borrowing here: `&arr[0]` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:17:38 | LL | let x = { let mut u = 0; u += 1; *r }; - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:18:45 | LL | let y = unsafe { let mut u = 0; u += 1; *r }; - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:19:49 | LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; - | ^^ cannot move out of borrowed content + | ^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `r` error: aborting due to 9 previous errors diff --git a/src/test/ui/nll/issue-50716-1.rs b/src/test/ui/nll/issue-50716-1.rs index db7e6b30f27..d963a620c9a 100644 --- a/src/test/ui/nll/issue-50716-1.rs +++ b/src/test/ui/nll/issue-50716-1.rs @@ -3,11 +3,11 @@ // bounds derived from `Sized` requirements” that checks that the fixed compiler // accepts this code fragment with both AST and MIR borrow checkers. // -// revisions: ast mir +// revisions: migrate nll // // compile-pass -#![cfg_attr(mir, feature(nll))] +#![cfg_attr(nll, feature(nll))] struct Qey(Q); diff --git a/src/test/ui/nll/issue-53807.nll.stderr b/src/test/ui/nll/issue-53807.nll.stderr deleted file mode 100644 index 2b15da3710e..00000000000 --- a/src/test/ui/nll/issue-53807.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0382]: use of moved value - --> $DIR/issue-53807.rs:4:21 - | -LL | if let Some(thing) = maybe { - | ^^^^^ value moved here, in previous iteration of loop - | - = note: move occurs because value has type `std::vec::Vec`, 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/nll/issue-53807.rs b/src/test/ui/nll/issue-53807.rs index f69d8c14935..d494f7e151d 100644 --- a/src/test/ui/nll/issue-53807.rs +++ b/src/test/ui/nll/issue-53807.rs @@ -2,8 +2,7 @@ pub fn main(){ let maybe = Some(vec![true, true]); loop { if let Some(thing) = maybe { -//~^ ERROR use of partially moved value -//~| ERROR use of moved value +//~^ ERROR use of moved value } } } diff --git a/src/test/ui/nll/issue-53807.stderr b/src/test/ui/nll/issue-53807.stderr index fb6701452cb..2b15da3710e 100644 --- a/src/test/ui/nll/issue-53807.stderr +++ b/src/test/ui/nll/issue-53807.stderr @@ -1,21 +1,11 @@ -error[E0382]: use of partially moved value: `maybe` - --> $DIR/issue-53807.rs:4:30 - | -LL | if let Some(thing) = maybe { - | ----- ^^^^^ value used here after move - | | - | value moved here - | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` +error[E0382]: use of moved value --> $DIR/issue-53807.rs:4:21 | LL | if let Some(thing) = maybe { - | ^^^^^ value moved here in previous iteration of loop + | ^^^^^ value moved here, in previous iteration of loop | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait + = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.nll.stderr b/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.nll.stderr deleted file mode 100644 index 8412cbdc54b..00000000000 --- a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:29 - | -LL | D("other").next(&_thing1) - | ----------------^^^^^^^^- - | | | - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -... -LL | } - | - `_thing1` dropped here while still borrowed -LL | -LL | ; - | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr b/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr index 8d23891e1ba..8412cbdc54b 100644 --- a/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr +++ b/src/test/ui/nll/issue-54382-use-span-of-tail-of-block.stderr @@ -1,14 +1,19 @@ error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:30 + --> $DIR/issue-54382-use-span-of-tail-of-block.rs:7:29 | LL | D("other").next(&_thing1) - | ^^^^^^^ borrowed value does not live long enough + | ----------------^^^^^^^^- + | | | + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... ... LL | } | - `_thing1` dropped here while still borrowed LL | LL | ; - | - borrowed value needs to live until here + | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-niconii.nll.stderr b/src/test/ui/nll/issue-54556-niconii.nll.stderr deleted file mode 100644 index 40cd04de5ec..00000000000 --- a/src/test/ui/nll/issue-54556-niconii.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0597]: `counter` does not live long enough - --> $DIR/issue-54556-niconii.rs:22:20 - | -LL | if let Ok(_) = counter.lock() { } - | ^^^^^^^------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -... -LL | } - | - - | | - | `counter` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result, ()>` - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-niconii.stderr b/src/test/ui/nll/issue-54556-niconii.stderr index 2d0de26ab30..40cd04de5ec 100644 --- a/src/test/ui/nll/issue-54556-niconii.stderr +++ b/src/test/ui/nll/issue-54556-niconii.stderr @@ -2,12 +2,18 @@ error[E0597]: `counter` does not live long enough --> $DIR/issue-54556-niconii.rs:22:20 | LL | if let Ok(_) = counter.lock() { } - | ^^^^^^^ borrowed value does not live long enough + | ^^^^^^^------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... ... LL | } - | - `counter` dropped here while still borrowed + | - + | | + | `counter` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result, ()>` | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr b/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr deleted file mode 100644 index 0bf76485eef..00000000000 --- a/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0597]: `stmt` does not live long enough - --> $DIR/issue-54556-stephaneyfx.rs:27:21 - | -LL | let rows = Rows(&stmt); - | ^^^^^ borrowed value does not live long enough -LL | rows.map(|row| row).next() - | ------------------- a temporary with access to the borrow is created here ... -... -LL | } - | - - | | - | `stmt` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::iter::Map, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23]>` - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-stephaneyfx.stderr b/src/test/ui/nll/issue-54556-stephaneyfx.stderr index 4e581a516b2..0bf76485eef 100644 --- a/src/test/ui/nll/issue-54556-stephaneyfx.stderr +++ b/src/test/ui/nll/issue-54556-stephaneyfx.stderr @@ -1,13 +1,18 @@ error[E0597]: `stmt` does not live long enough - --> $DIR/issue-54556-stephaneyfx.rs:27:22 + --> $DIR/issue-54556-stephaneyfx.rs:27:21 | LL | let rows = Rows(&stmt); - | ^^^^ borrowed value does not live long enough + | ^^^^^ borrowed value does not live long enough +LL | rows.map(|row| row).next() + | ------------------- a temporary with access to the borrow is created here ... ... LL | } - | - `stmt` dropped here while still borrowed + | - + | | + | `stmt` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::iter::Map, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23]>` | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr b/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr deleted file mode 100644 index 513dca7950a..00000000000 --- a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:11 - | -LL | D(&_thing1).end() - | --^^^^^^^^- - | | | - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | } - | - `_thing1` dropped here while still borrowed -LL | -LL | ; - | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr b/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr index a74970f7118..513dca7950a 100644 --- a/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr +++ b/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr @@ -1,13 +1,18 @@ error[E0597]: `_thing1` does not live long enough - --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:12 + --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:11 | LL | D(&_thing1).end() - | ^^^^^^^ borrowed value does not live long enough + | --^^^^^^^^- + | | | + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | } | - `_thing1` dropped here while still borrowed LL | LL | ; - | - borrowed value needs to live until here + | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error: aborting due to previous error diff --git a/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr b/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr deleted file mode 100644 index 52d0870b78f..00000000000 --- a/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr +++ /dev/null @@ -1,113 +0,0 @@ -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:10:55 - | -LL | { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:13:55 - | -LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:16:55 - | -LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` - | --^^^^- -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:19:55 - | -LL | let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:22:55 - | -LL | let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:25:55 - | -LL | let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:30:55 - | -LL | _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | | | - | | | `_t1` dropped here while still borrowed - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:37:55 - | -LL | fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` - | --^^^^- - - | | | | - | | | `_t1` dropped here while still borrowed - | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. - -error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:40:55 - | -LL | fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` - | --^^^^- - - | | | | - | | | `_t1` dropped here while still borrowed - | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` - | | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr b/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr index e9e4e51136d..52d0870b78f 100644 --- a/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr +++ b/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr @@ -1,85 +1,112 @@ error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:10:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:10:55 | LL | { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:13:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:13:55 | LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:16:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:16:55 | LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` - | ^^^ -- borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:19:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:19:55 | LL | let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:22:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:22:55 | LL | let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:25:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:25:55 | LL | let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:30:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:30:55 | LL | _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` - | ^^^ - - borrowed value needs to live until here - | | | - | | `_t1` dropped here while still borrowed - | borrowed value does not live long enough + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:37:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:37:55 | LL | fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` - | ^^^ - `_t1` dropped here while still borrowed - | | - | borrowed value does not live long enough + | --^^^^- - + | | | | + | | | `_t1` dropped here while still borrowed + | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. error[E0597]: `_t1` does not live long enough - --> $DIR/issue-54556-used-vs-unused-tails.rs:40:56 + --> $DIR/issue-54556-used-vs-unused-tails.rs:40:55 | LL | fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` - | ^^^ - `_t1` dropped here while still borrowed - | | - | borrowed value does not live long enough + | --^^^^- - + | | | | + | | | `_t1` dropped here while still borrowed + | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to 9 previous errors diff --git a/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr b/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr deleted file mode 100644 index 9f27fac15a7..00000000000 --- a/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/issue-54556-wrap-it-up.rs:27:5 - | -LL | let wrap = Wrap { p: &mut x }; - | ------ borrow of `x` occurs here -... -LL | x = 1; - | ^^^^^ assignment to borrowed `x` occurs here -LL | } - | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/nll/issue-54556-wrap-it-up.stderr b/src/test/ui/nll/issue-54556-wrap-it-up.stderr index c98b3a9fafb..9f27fac15a7 100644 --- a/src/test/ui/nll/issue-54556-wrap-it-up.stderr +++ b/src/test/ui/nll/issue-54556-wrap-it-up.stderr @@ -2,10 +2,12 @@ error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/issue-54556-wrap-it-up.rs:27:5 | LL | let wrap = Wrap { p: &mut x }; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here ... LL | x = 1; | ^^^^^ assignment to borrowed `x` occurs here +LL | } + | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` error: aborting due to previous error diff --git a/src/test/ui/nll/issue-55850.nll.stderr b/src/test/ui/nll/issue-55850.nll.stderr deleted file mode 100644 index 51bc30a3df2..00000000000 --- a/src/test/ui/nll/issue-55850.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0597]: `s` does not live long enough - --> $DIR/issue-55850.rs:28:16 - | -LL | yield &s[..] - | ^ borrowed value does not live long enough -LL | }) - | - `s` dropped here while still borrowed - -error[E0626]: borrow may still be in use when generator yields - --> $DIR/issue-55850.rs:28:16 - | -LL | yield &s[..] - | -------^---- possible yield occurs here - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0597, E0626. -For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/issue-55850.rs b/src/test/ui/nll/issue-55850.rs index 8b5887224d1..8a016bf8779 100644 --- a/src/test/ui/nll/issue-55850.rs +++ b/src/test/ui/nll/issue-55850.rs @@ -26,6 +26,7 @@ fn bug<'a>() -> impl Iterator { GenIter(move || { let mut s = String::new(); yield &s[..] //~ ERROR `s` does not live long enough [E0597] + //~| ERROR borrow may still be in use when generator yields }) } diff --git a/src/test/ui/nll/issue-55850.stderr b/src/test/ui/nll/issue-55850.stderr index 7deee1d541a..66c2995efc8 100644 --- a/src/test/ui/nll/issue-55850.stderr +++ b/src/test/ui/nll/issue-55850.stderr @@ -3,15 +3,17 @@ error[E0597]: `s` does not live long enough | LL | yield &s[..] | ^ borrowed value does not live long enough +LL | LL | }) - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 25:8... - --> $DIR/issue-55850.rs:25:8 - | -LL | fn bug<'a>() -> impl Iterator { - | ^^ + | - `s` dropped here while still borrowed -error: aborting due to previous error +error[E0626]: borrow may still be in use when generator yields + --> $DIR/issue-55850.rs:28:16 + | +LL | yield &s[..] + | -------^---- possible yield occurs here -For more information about this error, try `rustc --explain E0597`. +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0597, E0626. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr b/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr deleted file mode 100644 index 82a30db1530..00000000000 --- a/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning[E0507]: cannot move out of borrowed content - --> $DIR/match-guards-always-borrow.rs:13:13 - | -LL | (|| { let bar = foo; bar.take() })(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content - | - = 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: compilation successful - --> $DIR/match-guards-always-borrow.rs:47:1 - | -LL | / fn main() { -LL | | should_reject_destructive_mutate_in_guard(); -LL | | allow_mutate_in_arm_body(); -LL | | allow_move_into_arm_body(); -LL | | } - | |_^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/nll/match-guards-always-borrow.ast.stderr b/src/test/ui/nll/match-guards-always-borrow.ast.stderr deleted file mode 100644 index 0c08f206021..00000000000 --- a/src/test/ui/nll/match-guards-always-borrow.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error: compilation successful - --> $DIR/match-guards-always-borrow.rs:47:1 - | -LL | / fn main() { -LL | | should_reject_destructive_mutate_in_guard(); -LL | | allow_mutate_in_arm_body(); -LL | | allow_move_into_arm_body(); -LL | | } - | |_^ - -error: aborting due to previous error - diff --git a/src/test/ui/nll/match-guards-always-borrow.rs b/src/test/ui/nll/match-guards-always-borrow.rs index ec4eed67976..5900dc3ade0 100644 --- a/src/test/ui/nll/match-guards-always-borrow.rs +++ b/src/test/ui/nll/match-guards-always-borrow.rs @@ -1,7 +1,4 @@ -//revisions: ast mir -//[mir] compile-flags: -Z borrowck=mir - -#![feature(rustc_attrs)] +#![feature(nll)] // Here is arielb1's basic example from rust-lang/rust#27282 // that AST borrowck is flummoxed by: @@ -11,7 +8,7 @@ fn should_reject_destructive_mutate_in_guard() { None => {}, ref mut foo if { (|| { let bar = foo; bar.take() })(); - //[mir]~^ ERROR cannot move out of borrowed content [E0507] + //~^ ERROR cannot move out of borrowed content [E0507] false } => { }, Some(s) => std::process::exit(*s), } @@ -39,12 +36,7 @@ fn allow_move_into_arm_body() { } } -// Since this is a compile-fail test that is explicitly encoding the -// different behavior of AST- vs MIR-borrowck where AST-borrowck does -// not error, we need to use rustc_error to placate the test harness -// that wants *some* error to occur. -#[rustc_error] -fn main() { //[ast]~ ERROR compilation successful +fn main() { should_reject_destructive_mutate_in_guard(); allow_mutate_in_arm_body(); allow_move_into_arm_body(); diff --git a/src/test/ui/nll/match-guards-always-borrow.mir.stderr b/src/test/ui/nll/match-guards-always-borrow.stderr similarity index 86% rename from src/test/ui/nll/match-guards-always-borrow.mir.stderr rename to src/test/ui/nll/match-guards-always-borrow.stderr index 3e90c5a1542..2492397c65d 100644 --- a/src/test/ui/nll/match-guards-always-borrow.mir.stderr +++ b/src/test/ui/nll/match-guards-always-borrow.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/match-guards-always-borrow.rs:13:13 + --> $DIR/match-guards-always-borrow.rs:10:13 | LL | (|| { let bar = foo; bar.take() })(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content diff --git a/src/test/ui/nll/reference-carried-through-struct-field.ast.stderr b/src/test/ui/nll/reference-carried-through-struct-field.ast.stderr deleted file mode 100644 index 3104944339c..00000000000 --- a/src/test/ui/nll/reference-carried-through-struct-field.ast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/reference-carried-through-struct-field.rs:11:5 - | -LL | let wrapper = Wrap { w: &mut x }; - | - borrow of `x` occurs here -LL | x += 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/nll/reference-carried-through-struct-field.mir.stderr b/src/test/ui/nll/reference-carried-through-struct-field.mir.stderr deleted file mode 100644 index 1f6eb9a06ba..00000000000 --- a/src/test/ui/nll/reference-carried-through-struct-field.mir.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/reference-carried-through-struct-field.rs:11:5 - | -LL | let wrapper = Wrap { w: &mut x }; - | ------ borrow of `x` occurs here -LL | x += 1; - | ^^^^^^ use of borrowed `x` -LL | -LL | *wrapper.w += 1; - | --------------- 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/nll/reference-carried-through-struct-field.rs b/src/test/ui/nll/reference-carried-through-struct-field.rs index f7903cba6a2..effd6108499 100644 --- a/src/test/ui/nll/reference-carried-through-struct-field.rs +++ b/src/test/ui/nll/reference-carried-through-struct-field.rs @@ -1,15 +1,9 @@ -//revisions: ast mir -//[mir] compile-flags: -Z borrowck=mir - -#![allow(unused_assignments)] - struct Wrap<'a> { w: &'a mut u32 } fn foo() { let mut x = 22; let wrapper = Wrap { w: &mut x }; - x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] - //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] + x += 1; //~ ERROR cannot use `x` because it was mutably borrowed [E0503] *wrapper.w += 1; } diff --git a/src/test/ui/nll/reference-carried-through-struct-field.ast.nll.stderr b/src/test/ui/nll/reference-carried-through-struct-field.stderr similarity index 86% rename from src/test/ui/nll/reference-carried-through-struct-field.ast.nll.stderr rename to src/test/ui/nll/reference-carried-through-struct-field.stderr index 1f6eb9a06ba..56d878e4303 100644 --- a/src/test/ui/nll/reference-carried-through-struct-field.ast.nll.stderr +++ b/src/test/ui/nll/reference-carried-through-struct-field.stderr @@ -1,11 +1,10 @@ error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/reference-carried-through-struct-field.rs:11:5 + --> $DIR/reference-carried-through-struct-field.rs:6:5 | LL | let wrapper = Wrap { w: &mut x }; | ------ borrow of `x` occurs here LL | x += 1; | ^^^^^^ use of borrowed `x` -LL | LL | *wrapper.w += 1; | --------------- borrow later used here diff --git a/src/test/ui/no-capture-arc.nll.stderr b/src/test/ui/no-capture-arc.nll.stderr deleted file mode 100644 index 476b6f75abb..00000000000 --- a/src/test/ui/no-capture-arc.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0382]: borrow of moved value: `arc_v` - --> $DIR/no-capture-arc.rs:14:18 - | -LL | let arc_v = Arc::new(v); - | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait -LL | -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | assert_eq!((*arc_v)[3], 4); - | ----- variable moved due to use in closure -... -LL | assert_eq!((*arc_v)[2], 3); - | ^^^^^ value borrowed 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/no-capture-arc.rs b/src/test/ui/no-capture-arc.rs index 06f5fb3da3c..3f0b075778b 100644 --- a/src/test/ui/no-capture-arc.rs +++ b/src/test/ui/no-capture-arc.rs @@ -1,4 +1,4 @@ -// error-pattern: use of moved value +// error-pattern: borrow of moved value use std::sync::Arc; use std::thread; diff --git a/src/test/ui/no-capture-arc.stderr b/src/test/ui/no-capture-arc.stderr index 0dfa5cdbe9e..476b6f75abb 100644 --- a/src/test/ui/no-capture-arc.stderr +++ b/src/test/ui/no-capture-arc.stderr @@ -1,25 +1,17 @@ -error[E0382]: use of moved value: `arc_v` +error[E0382]: borrow of moved value: `arc_v` --> $DIR/no-capture-arc.rs:14:18 | +LL | let arc_v = Arc::new(v); + | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait +LL | LL | thread::spawn(move|| { - | ------ value moved (into closure) here + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure ... LL | assert_eq!((*arc_v)[2], 3); - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + | ^^^^^ value borrowed here after move -error[E0382]: use of moved value: `arc_v` - --> $DIR/no-capture-arc.rs:16:23 - | -LL | thread::spawn(move|| { - | ------ value moved (into closure) here -... -LL | println!("{:?}", *arc_v); - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/no-reuse-move-arc.nll.stderr b/src/test/ui/no-reuse-move-arc.nll.stderr deleted file mode 100644 index 3f7169e6fcb..00000000000 --- a/src/test/ui/no-reuse-move-arc.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0382]: borrow of moved value: `arc_v` - --> $DIR/no-reuse-move-arc.rs:12:18 - | -LL | let arc_v = Arc::new(v); - | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait -LL | -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | assert_eq!((*arc_v)[3], 4); - | ----- variable moved due to use in closure -... -LL | assert_eq!((*arc_v)[2], 3); - | ^^^^^ value borrowed 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/no-reuse-move-arc.rs b/src/test/ui/no-reuse-move-arc.rs index b60a7f24999..9c957a4e01b 100644 --- a/src/test/ui/no-reuse-move-arc.rs +++ b/src/test/ui/no-reuse-move-arc.rs @@ -9,7 +9,7 @@ fn main() { assert_eq!((*arc_v)[3], 4); }); - assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` + assert_eq!((*arc_v)[2], 3); //~ ERROR borrow of moved value: `arc_v` - println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` + println!("{:?}", *arc_v); } diff --git a/src/test/ui/no-reuse-move-arc.stderr b/src/test/ui/no-reuse-move-arc.stderr index d7123314786..3f7169e6fcb 100644 --- a/src/test/ui/no-reuse-move-arc.stderr +++ b/src/test/ui/no-reuse-move-arc.stderr @@ -1,25 +1,17 @@ -error[E0382]: use of moved value: `arc_v` +error[E0382]: borrow of moved value: `arc_v` --> $DIR/no-reuse-move-arc.rs:12:18 | +LL | let arc_v = Arc::new(v); + | ----- move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait +LL | LL | thread::spawn(move|| { - | ------ value moved (into closure) here + | ------ value moved into closure here +LL | assert_eq!((*arc_v)[3], 4); + | ----- variable moved due to use in closure ... LL | assert_eq!((*arc_v)[2], 3); - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait + | ^^^^^ value borrowed here after move -error[E0382]: use of moved value: `arc_v` - --> $DIR/no-reuse-move-arc.rs:14:23 - | -LL | thread::spawn(move|| { - | ------ value moved (into closure) here -... -LL | println!("{:?}", *arc_v); - | ^^^^^ value used here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/not-copy-closure.nll.stderr b/src/test/ui/not-copy-closure.nll.stderr deleted file mode 100644 index 10bf570727f..00000000000 --- a/src/test/ui/not-copy-closure.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0382]: use of moved value: `hello` - --> $DIR/not-copy-closure.rs:10:13 - | -LL | let b = hello; - | ----- value moved here -LL | let c = hello; - | ^^^^^ value used here after move - | -note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment - --> $DIR/not-copy-closure.rs:6:9 - | -LL | a += 1; - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/not-copy-closure.stderr b/src/test/ui/not-copy-closure.stderr index 41447537978..10bf570727f 100644 --- a/src/test/ui/not-copy-closure.stderr +++ b/src/test/ui/not-copy-closure.stderr @@ -1,12 +1,12 @@ error[E0382]: use of moved value: `hello` - --> $DIR/not-copy-closure.rs:10:9 + --> $DIR/not-copy-closure.rs:10:13 | LL | let b = hello; - | - value moved here + | ----- value moved here LL | let c = hello; - | ^ value used here after move + | ^^^^^ value used here after move | -note: closure cannot be invoked more than once because it moves the variable `a` out of its environment +note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment --> $DIR/not-copy-closure.rs:6:9 | LL | a += 1; diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.nll.stderr b/src/test/ui/object-safety/object-safety-by-value-self-use.nll.stderr deleted file mode 100644 index 1497aa42082..00000000000 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined - --> $DIR/object-safety-by-value-self-use.rs:15:5 - | -LL | t.bar() - | ^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0161`. diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.rs b/src/test/ui/object-safety/object-safety-by-value-self-use.rs index dc8ea64ec9c..0b70c8ad45e 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.rs +++ b/src/test/ui/object-safety/object-safety-by-value-self-use.rs @@ -12,7 +12,7 @@ trait Baz { } fn use_bar(t: Box) { - t.bar() //~ ERROR cannot move a value of type (dyn Bar + 'static) + t.bar() //~ ERROR cannot move a value of type dyn Bar } fn main() { } diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.stderr b/src/test/ui/object-safety/object-safety-by-value-self-use.stderr index 0ab881687e9..1497aa42082 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.stderr +++ b/src/test/ui/object-safety/object-safety-by-value-self-use.stderr @@ -1,4 +1,4 @@ -error[E0161]: cannot move a value of type (dyn Bar + 'static): the size of (dyn Bar + 'static) cannot be statically determined +error[E0161]: cannot move a value of type dyn Bar: the size of dyn Bar cannot be statically determined --> $DIR/object-safety-by-value-self-use.rs:15:5 | LL | t.bar() diff --git a/src/test/ui/once-cant-call-twice-on-heap.nll.stderr b/src/test/ui/once-cant-call-twice-on-heap.nll.stderr deleted file mode 100644 index f98d3d83845..00000000000 --- a/src/test/ui/once-cant-call-twice-on-heap.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0382]: use of moved value: `blk` - --> $DIR/once-cant-call-twice-on-heap.rs:9:5 - | -LL | fn foo(blk: F) { - | - --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | blk(); - | --- value moved here -LL | blk(); - | ^^^ 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/once-cant-call-twice-on-heap.stderr b/src/test/ui/once-cant-call-twice-on-heap.stderr index 40034dae5bc..f98d3d83845 100644 --- a/src/test/ui/once-cant-call-twice-on-heap.stderr +++ b/src/test/ui/once-cant-call-twice-on-heap.stderr @@ -1,12 +1,14 @@ error[E0382]: use of moved value: `blk` --> $DIR/once-cant-call-twice-on-heap.rs:9:5 | +LL | fn foo(blk: F) { + | - --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | blk(); | --- value moved here LL | blk(); | ^^^ value used here after move - | - = note: move occurs because `blk` has type `F`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/ref-suggestion.nll.stderr b/src/test/ui/ref-suggestion.nll.stderr deleted file mode 100644 index 9ff8e21bb58..00000000000 --- a/src/test/ui/ref-suggestion.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0382]: use of moved value: `x` - --> $DIR/ref-suggestion.rs:4:5 - | -LL | let x = vec![1]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let y = x; - | - value moved here -LL | x; - | ^ value used here after move - -error[E0382]: use of moved value: `x` - --> $DIR/ref-suggestion.rs:8:5 - | -LL | let x = vec![1]; - | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | let mut y = x; - | - value moved here -LL | x; - | ^ value used here after move - -error[E0382]: use of moved value: `x` - --> $DIR/ref-suggestion.rs:16:5 - | -LL | (Some(y), ()) => {}, - | - value moved here -... -LL | x; - | ^ value used here after partial move - | - = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/ref-suggestion.rs b/src/test/ui/ref-suggestion.rs index 346d118f0f9..49d199cd9e7 100644 --- a/src/test/ui/ref-suggestion.rs +++ b/src/test/ui/ref-suggestion.rs @@ -13,5 +13,5 @@ fn main() { (Some(y), ()) => {}, _ => {}, } - x; //~ ERROR use of partially moved value + x; //~ ERROR use of moved value } diff --git a/src/test/ui/ref-suggestion.stderr b/src/test/ui/ref-suggestion.stderr index df677a611cd..9ff8e21bb58 100644 --- a/src/test/ui/ref-suggestion.stderr +++ b/src/test/ui/ref-suggestion.stderr @@ -1,33 +1,33 @@ error[E0382]: use of moved value: `x` --> $DIR/ref-suggestion.rs:4:5 | +LL | let x = vec![1]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let y = x; - | - value moved here + | - value moved here LL | x; | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x` --> $DIR/ref-suggestion.rs:8:5 | +LL | let x = vec![1]; + | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let mut y = x; - | ----- value moved here + | - value moved here LL | x; | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -error[E0382]: use of partially moved value: `x` +error[E0382]: use of moved value: `x` --> $DIR/ref-suggestion.rs:16:5 | LL | (Some(y), ()) => {}, | - value moved here ... LL | x; - | ^ value used here after move + | ^ value used here after partial move | - = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait + = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs b/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs index 24676fe5e5b..5cbfe6ebebb 100644 --- a/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs +++ b/src/test/ui/regions/issue-56537-closure-uses-region-from-container.rs @@ -9,13 +9,6 @@ // rust-lang/rust#56537 // compile-pass -// We are already testing NLL explicitly via the revision system below. -// ignore-compare-mode-nll - -// revisions: ll nll migrate -//[ll] compile-flags:-Zborrowck=ast -//[nll] compile-flags:-Zborrowck=mir -Z two-phase-borrows -//[migrate] compile-flags:-Zborrowck=migrate -Z two-phase-borrows fn willy_no_annot<'w>(p: &'w str, q: &str) -> &'w str { let free_dumb = |_x| { p }; // no type annotation at all diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.stderr deleted file mode 100644 index 27d8ce4ab50..00000000000 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:71:43 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough - | | - | capture occurs here -... -LL | }); - | - borrowed value dropped before borrower - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:71:54 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough - | | - | capture occurs here -... -LL | }); - | - borrowed value dropped before borrower - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr deleted file mode 100644 index 8fb1ebbf7d0..00000000000 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 - | -LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.rs b/src/test/ui/regions/region-borrow-params-issue-29793-big.rs index f21140b43de..83b1a6eab57 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.rs +++ b/src/test/ui/regions/region-borrow-params-issue-29793-big.rs @@ -6,10 +6,6 @@ // behavior (because the improperly accepted closure was actually // able to be invoked). -// ignore-tidy-linelength -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - struct WrapA(Option); impl WrapA { @@ -69,10 +65,8 @@ impl WrapA fn main() { let mut w = WrapA::new().set(|x: usize, y: usize| { WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - //[ast]~^ ERROR `x` does not live long enough - //[ast]~| ERROR `y` does not live long enough - //[mir]~^^^ ERROR closure may outlive the current function - //[mir]~| ERROR closure may outlive the current function + //~^ ERROR closure may outlive the current function + //~| ERROR closure may outlive the current function }); w.handle(); // This works diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-big.stderr similarity index 88% rename from src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr rename to src/test/ui/regions/region-borrow-params-issue-29793-big.stderr index 8fb1ebbf7d0..328e602ca76 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr +++ b/src/test/ui/regions/region-borrow-params-issue-29793-big.stderr @@ -1,5 +1,5 @@ error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^ - `x` is borrowed here @@ -7,7 +7,7 @@ LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate erro | may outlive borrowed value `x` | note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:9 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate | ^^^^^^^^^^^^^^ error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-big.rs:71:26 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^ - `y` is borrowed here @@ -25,7 +25,7 @@ LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate erro | may outlive borrowed value `y` | note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-big.rs:71:9 + --> $DIR/region-borrow-params-issue-29793-big.rs:67:9 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr deleted file mode 100644 index 18610b7cffb..00000000000 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr +++ /dev/null @@ -1,363 +0,0 @@ -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 - | -LL | return f; - | ^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 - | -LL | return f; - | ^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 - | -LL | f - | ^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 - | -LL | f - | ^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:55:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:55:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:66:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:66:17 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:90:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:90:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:104:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:104:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:132:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:132:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:147:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:147:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:175:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:175:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 - | -LL | return Box::new(f); - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:189:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `x` is borrowed here - | | - | may outlive borrowed value `x` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/region-borrow-params-issue-29793-small.rs:189:21 - | -LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^ - `y` is borrowed here - | | - | may outlive borrowed value `y` - | -note: closure is returned here - --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 - | -LL | Box::new(f) - | ^^^^^^^^^^^ -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | ^^^^^^^^^^^^^^ - -error: aborting due to 20 previous errors - -For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs index 08ed79cbdbf..0d8c9fb2699 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs +++ b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs @@ -7,8 +7,8 @@ fn escaping_borrow_of_closure_params_1() { let g = |x: usize, y:usize| { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - //~^ ERROR `x` does not live long enough - //~| ERROR `y` does not live long enough + //~^ ERROR E0373 + //~| ERROR E0373 return f; }; @@ -22,8 +22,8 @@ fn escaping_borrow_of_closure_params_1() { fn escaping_borrow_of_closure_params_2() { let g = |x: usize, y:usize| { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - //~^ ERROR `x` does not live long enough - //~| ERROR `y` does not live long enough + //~^ ERROR E0373 + //~| ERROR E0373 f }; diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr b/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr index c2c2d64676b..18610b7cffb 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr +++ b/src/test/ui/regions/region-borrow-params-issue-29793-small.stderr @@ -1,54 +1,74 @@ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:9:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `x` | - = note: values in a scope are dropped in the opposite order they are created +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 + | +LL | return f; + | ^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:9:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:9:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `y` | - = note: values in a scope are dropped in the opposite order they are created +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:12:16 + | +LL | return f; + | ^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:24:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `x` | - = note: values in a scope are dropped in the opposite order they are created +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 + | +LL | f + | ^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:24:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:24:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | capture occurs here -... -LL | }; - | - borrowed value dropped before borrower + | may outlive borrowed value `y` | - = note: values in a scope are dropped in the opposite order they are created +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:27:9 + | +LL | f + | ^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function --> $DIR/region-borrow-params-issue-29793-small.rs:55:17 @@ -57,6 +77,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -69,6 +95,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:58:16 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -81,6 +113,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -93,6 +131,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:69:9 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -105,6 +149,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -117,6 +167,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:93:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -129,6 +185,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -141,6 +203,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:107:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -153,6 +221,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -165,6 +239,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:135:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -177,6 +257,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -189,6 +275,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:150:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -201,6 +293,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -213,6 +311,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:178:20 + | +LL | return Box::new(f); + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -225,6 +329,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `x` is borrowed here | | | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -237,6 +347,12 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo | ^^^^^^^^^ - `y` is borrowed here | | | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:192:13 + | +LL | Box::new(f) + | ^^^^^^^^^^^ help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) @@ -244,5 +360,4 @@ LL | let f = move |t: bool| if t { x } else { y }; // (separate erro error: aborting due to 20 previous errors -Some errors have detailed explanations: E0373, E0597. -For more information about an error, try `rustc --explain E0373`. +For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr b/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr deleted file mode 100644 index d455902ee8c..00000000000 --- a/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr +++ /dev/null @@ -1,24 +0,0 @@ -warning: function cannot return without recursing - --> $DIR/region-bound-on-closure-outlives-call.rs:1:1 - | -LL | fn call_rec(mut f: F) -> usize where F: FnMut(usize) -> usize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing -LL | -LL | (|x| f(x))(call_rec(f)) - | ----------- recursive call site - | - = note: #[warn(unconditional_recursion)] on by default - = help: a `loop` may express intention better if this is on purpose - -error[E0505]: cannot move out of `f` because it is borrowed - --> $DIR/region-bound-on-closure-outlives-call.rs:3:25 - | -LL | (|x| f(x))(call_rec(f)) - | --- - ^ move out of `f` occurs here - | | | - | | borrow occurs due to use in closure - | borrow of `f` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr b/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr index cb888ab66c4..d455902ee8c 100644 --- a/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr +++ b/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr @@ -14,8 +14,9 @@ error[E0505]: cannot move out of `f` because it is borrowed --> $DIR/region-bound-on-closure-outlives-call.rs:3:25 | LL | (|x| f(x))(call_rec(f)) - | --- ^ move out of `f` occurs here - | | + | --- - ^ move out of `f` occurs here + | | | + | | borrow occurs due to use in closure | borrow of `f` occurs here error: aborting due to previous error diff --git a/src/test/ui/regions/region-object-lifetime-5.nll.stderr b/src/test/ui/regions/region-object-lifetime-5.nll.stderr deleted file mode 100644 index b86f6e3a2a1..00000000000 --- a/src/test/ui/regions/region-object-lifetime-5.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*x` - --> $DIR/region-object-lifetime-5.rs:11:5 - | -LL | x.borrowed() - | -^^^^^^^^^^^ - | | - | 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/regions/region-object-lifetime-5.rs b/src/test/ui/regions/region-object-lifetime-5.rs index 5009b2bbf32..bd68aebbeeb 100644 --- a/src/test/ui/regions/region-object-lifetime-5.rs +++ b/src/test/ui/regions/region-object-lifetime-5.rs @@ -8,7 +8,7 @@ trait Foo { // Here, the object is bounded by an anonymous lifetime and returned // as `&'static`, so you get an error. fn owned_receiver(x: Box) -> &'static () { - x.borrowed() //~ ERROR `*x` does not live long enough + x.borrowed() //~ ERROR cannot return value referencing local data `*x` } fn main() {} diff --git a/src/test/ui/regions/region-object-lifetime-5.stderr b/src/test/ui/regions/region-object-lifetime-5.stderr index 1efaee181cb..b86f6e3a2a1 100644 --- a/src/test/ui/regions/region-object-lifetime-5.stderr +++ b/src/test/ui/regions/region-object-lifetime-5.stderr @@ -1,13 +1,12 @@ -error[E0597]: `*x` does not live long enough +error[E0515]: cannot return value referencing local data `*x` --> $DIR/region-object-lifetime-5.rs:11:5 | LL | x.borrowed() - | ^ borrowed value does not live long enough -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 + | `*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/regions/regions-addr-of-arg.nll.stderr b/src/test/ui/regions/regions-addr-of-arg.nll.stderr deleted file mode 100644 index e77289287e5..00000000000 --- a/src/test/ui/regions/regions-addr-of-arg.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/regions-addr-of-arg.rs:5:30 - | -LL | let _p: &'static isize = &a; - | -------------- ^^ borrowed value does not live long enough - | | - | type annotation requires that `a` is borrowed for `'static` -LL | } - | - `a` dropped here while still borrowed - -error[E0515]: cannot return reference to function parameter `a` - --> $DIR/regions-addr-of-arg.rs:13:5 - | -LL | &a - | ^^ returns a reference to data owned by the current function - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0515, E0597. -For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-addr-of-arg.rs b/src/test/ui/regions/regions-addr-of-arg.rs index 06f16be8217..1805141c421 100644 --- a/src/test/ui/regions/regions-addr-of-arg.rs +++ b/src/test/ui/regions/regions-addr-of-arg.rs @@ -10,7 +10,7 @@ fn bar(a: isize) { } fn zed<'a>(a: isize) -> &'a isize { - &a //~ ERROR `a` does not live long enough + &a //~ ERROR cannot return reference to function parameter `a` } fn main() { diff --git a/src/test/ui/regions/regions-addr-of-arg.stderr b/src/test/ui/regions/regions-addr-of-arg.stderr index 3e76a7dda99..e77289287e5 100644 --- a/src/test/ui/regions/regions-addr-of-arg.stderr +++ b/src/test/ui/regions/regions-addr-of-arg.stderr @@ -1,27 +1,20 @@ error[E0597]: `a` does not live long enough - --> $DIR/regions-addr-of-arg.rs:5:31 + --> $DIR/regions-addr-of-arg.rs:5:30 | LL | let _p: &'static isize = &a; - | ^ borrowed value does not live long enough + | -------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `a` is borrowed for `'static` LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `a` dropped here while still borrowed -error[E0597]: `a` does not live long enough - --> $DIR/regions-addr-of-arg.rs:13:6 +error[E0515]: cannot return reference to function parameter `a` + --> $DIR/regions-addr-of-arg.rs:13:5 | LL | &a - | ^ 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 12:8... - --> $DIR/regions-addr-of-arg.rs:12:8 - | -LL | fn zed<'a>(a: isize) -> &'a isize { - | ^^ + | ^^ returns a reference to data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors have detailed explanations: E0515, E0597. +For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr b/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr deleted file mode 100644 index 2c55634445d..00000000000 --- a/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:14:16 - | -LL | v[0].oh_no(&v); - | - ----- ^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | mutable borrow occurs here - -error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:15:16 - | -LL | (*v).oh_no(&v); - | - ----- ^^ immutable borrow occurs here - | | | - | | mutable borrow later used by call - | 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/regions/regions-adjusted-lvalue-op.stderr b/src/test/ui/regions/regions-adjusted-lvalue-op.stderr index 2c4c75f323c..2c55634445d 100644 --- a/src/test/ui/regions/regions-adjusted-lvalue-op.stderr +++ b/src/test/ui/regions/regions-adjusted-lvalue-op.stderr @@ -1,19 +1,19 @@ error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:14:17 + --> $DIR/regions-adjusted-lvalue-op.rs:14:16 | LL | v[0].oh_no(&v); - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable - --> $DIR/regions-adjusted-lvalue-op.rs:15:17 + --> $DIR/regions-adjusted-lvalue-op.rs:15:16 | LL | (*v).oh_no(&v); - | - ^- mutable borrow ends here - | | | - | | immutable borrow occurs here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here error: aborting due to 2 previous errors diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.ast.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.stderr similarity index 87% rename from src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.ast.stderr rename to src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.stderr index 76ead4e94ef..f31f25bf00b 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.ast.stderr +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.migrate.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:45:13 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:43:12 | -LL | let _x: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime 'a as defined on the function body at 37:15 --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:37:15 diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.mir.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr similarity index 65% rename from src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.mir.stderr rename to src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr index ad94d375b5b..867eafe2529 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.mir.stderr +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.nll.stderr @@ -1,13 +1,13 @@ error: lifetime may not live long enough - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:45:13 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:43:12 | LL | fn with_assoc<'a,'b>() { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here ... -LL | let _x: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` +LL | let _: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'b` must outlive `'a` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs index 1d534921992..97c55593600 100644 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs +++ b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs @@ -3,8 +3,8 @@ // outlive the location in which the type appears, even when the // associted type is in a supertype. Issue #22246. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir #![allow(dead_code)] @@ -40,11 +40,9 @@ fn with_assoc<'a,'b>() { // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. - // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if - // `_x` is changed to `_` - let _x: &'a WithAssoc> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + let _: &'a WithAssoc> = loop { }; + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr b/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr deleted file mode 100644 index aa92c59cee0..00000000000 --- a/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:42:13 - | -LL | let _x: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 34:15 - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:34:15 - | -LL | fn with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 34:18 - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:34:18 - | -LL | fn with_assoc<'a,'b>() { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr deleted file mode 100644 index 8e119c4f535..00000000000 --- a/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-1.rs:12:5 - | -LL | box B(&*v) as Box - | ^^^^^^---^^^^^^^^^^^ - | | | - | | `*v` is borrowed here - | 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/regions/regions-close-object-into-object-1.rs b/src/test/ui/regions/regions-close-object-into-object-1.rs index 7a862f97a99..5518c6a94b1 100644 --- a/src/test/ui/regions/regions-close-object-into-object-1.rs +++ b/src/test/ui/regions/regions-close-object-into-object-1.rs @@ -9,7 +9,7 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn f<'a, T:'static, U>(v: Box+'static>) -> Box { - box B(&*v) as Box //~ ERROR `*v` does not live long enough + box B(&*v) as Box //~ ERROR cannot return value referencing local data `*v` } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-1.stderr b/src/test/ui/regions/regions-close-object-into-object-1.stderr index c7bde8dbd6d..8e119c4f535 100644 --- a/src/test/ui/regions/regions-close-object-into-object-1.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-1.stderr @@ -1,13 +1,12 @@ -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-1.rs:12:12 +error[E0515]: cannot return value referencing local data `*v` + --> $DIR/regions-close-object-into-object-1.rs:12:5 | LL | box B(&*v) as Box - | ^^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^^^^^^---^^^^^^^^^^^ + | | | + | | `*v` is borrowed here + | 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/regions/regions-close-object-into-object-3.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr deleted file mode 100644 index 9ea13638f5c..00000000000 --- a/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*v` - --> $DIR/regions-close-object-into-object-3.rs:11:5 - | -LL | box B(&*v) as Box - | ^^^^^^---^^^^^^^^^^^ - | | | - | | `*v` is borrowed here - | 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/regions/regions-close-object-into-object-3.rs b/src/test/ui/regions/regions-close-object-into-object-3.rs index cafbf093224..6f6b3a17002 100644 --- a/src/test/ui/regions/regions-close-object-into-object-3.rs +++ b/src/test/ui/regions/regions-close-object-into-object-3.rs @@ -8,7 +8,7 @@ trait X { } impl<'a, T> X for B<'a, T> {} fn h<'a, T, U:'static>(v: Box+'static>) -> Box { - box B(&*v) as Box //~ ERROR `*v` does not live long enough + box B(&*v) as Box //~ ERROR cannot return value referencing local data `*v` } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-3.stderr b/src/test/ui/regions/regions-close-object-into-object-3.stderr index 122e57a3250..9ea13638f5c 100644 --- a/src/test/ui/regions/regions-close-object-into-object-3.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-3.stderr @@ -1,13 +1,12 @@ -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-3.rs:11:12 +error[E0515]: cannot return value referencing local data `*v` + --> $DIR/regions-close-object-into-object-3.rs:11:5 | LL | box B(&*v) as Box - | ^^ borrowed value does not live long enough -LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^^^^^^---^^^^^^^^^^^ + | | | + | | `*v` is borrowed here + | 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/regions/regions-creating-enums.nll.stderr b/src/test/ui/regions/regions-creating-enums.nll.stderr deleted file mode 100644 index a95d8462901..00000000000 --- a/src/test/ui/regions/regions-creating-enums.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-creating-enums.rs:23:16 - | -LL | return &Ast::Num((*f)(x)); - | ^----------------- - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-creating-enums.rs:28:16 - | -LL | return &Ast::Add(m_x, m_y); - | ^------------------ - | || - | |temporary value created here - | returns a reference to data owned by the current function - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-creating-enums.rs b/src/test/ui/regions/regions-creating-enums.rs index ea8d4373e09..6ed68f8033c 100644 --- a/src/test/ui/regions/regions-creating-enums.rs +++ b/src/test/ui/regions/regions-creating-enums.rs @@ -20,12 +20,12 @@ fn compute(x: &Ast) -> usize { fn map_nums<'a,'b, F>(x: &Ast, f: &mut F) -> &'a Ast<'b> where F: FnMut(usize) -> usize { match *x { Ast::Num(x) => { - return &Ast::Num((*f)(x)); //~ ERROR borrowed value does not live long enough + return &Ast::Num((*f)(x)); //~ ERROR cannot return reference to temporary value } Ast::Add(x, y) => { let m_x = map_nums(x, f); let m_y = map_nums(y, f); - return &Ast::Add(m_x, m_y); //~ ERROR borrowed value does not live long enough + return &Ast::Add(m_x, m_y); //~ ERROR cannot return reference to temporary value } } } diff --git a/src/test/ui/regions/regions-creating-enums.stderr b/src/test/ui/regions/regions-creating-enums.stderr index bb11be9b758..a95d8462901 100644 --- a/src/test/ui/regions/regions-creating-enums.stderr +++ b/src/test/ui/regions/regions-creating-enums.stderr @@ -1,33 +1,21 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-creating-enums.rs:23:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-creating-enums.rs:23:16 | LL | return &Ast::Num((*f)(x)); - | ^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:13... - --> $DIR/regions-creating-enums.rs:20:13 - | -LL | fn map_nums<'a,'b, F>(x: &Ast, f: &mut F) -> &'a Ast<'b> where F: FnMut(usize) -> usize { - | ^^ - = note: consider using a `let` binding to increase its lifetime + | ^----------------- + | || + | |temporary value created here + | returns a reference to data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-creating-enums.rs:28:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-creating-enums.rs:28:16 | LL | return &Ast::Add(m_x, m_y); - | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:13... - --> $DIR/regions-creating-enums.rs:20:13 - | -LL | fn map_nums<'a,'b, F>(x: &Ast, f: &mut F) -> &'a Ast<'b> where F: FnMut(usize) -> usize { - | ^^ - = note: consider using a `let` binding to increase its lifetime + | ^------------------ + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to 2 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/regions/regions-free-region-ordering-caller.ast.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.migrate.stderr similarity index 100% rename from src/test/ui/regions/regions-free-region-ordering-caller.ast.stderr rename to src/test/ui/regions/regions-free-region-ordering-caller.migrate.stderr diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.mir.stderr b/src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr similarity index 100% rename from src/test/ui/regions/regions-free-region-ordering-caller.mir.stderr rename to src/test/ui/regions/regions-free-region-ordering-caller.nll.stderr diff --git a/src/test/ui/regions/regions-free-region-ordering-caller.rs b/src/test/ui/regions/regions-free-region-ordering-caller.rs index 621e6e78b46..c0b12f23cdb 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller.rs +++ b/src/test/ui/regions/regions-free-region-ordering-caller.rs @@ -2,25 +2,25 @@ // than the thing it points at and ensure that they result in // errors. See also regions-free-region-ordering-callee.rs -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir struct Paramd<'a> { x: &'a usize } fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'b &'a usize> = None;//[ast]~ ERROR E0623 - //[mir]~^ ERROR lifetime may not live long enough + let z: Option<&'b &'a usize> = None;//[migrate]~ ERROR E0623 + //[nll]~^ ERROR lifetime may not live long enough } fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { let y: Paramd<'a> = Paramd { x: a }; - let z: Option<&'b Paramd<'a>> = None;//[ast]~ ERROR E0623 - //[mir]~^ ERROR lifetime may not live long enough + let z: Option<&'b Paramd<'a>> = None;//[migrate]~ ERROR E0623 + //[nll]~^ ERROR lifetime may not live long enough } fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { - let z: Option<&'a &'b usize> = None;//[ast]~ ERROR E0623 - //[mir]~^ ERROR lifetime may not live long enough + let z: Option<&'a &'b usize> = None;//[migrate]~ ERROR E0623 + //[nll]~^ ERROR lifetime may not live long enough } fn main() {} diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr b/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr deleted file mode 100644 index 8042b1740b1..00000000000 --- a/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/regions-free-region-ordering-caller1.rs:9:27 - | -LL | fn call1<'a>(x: &'a usize) { - | -- lifetime `'a` defined here -... -LL | let z: &'a & usize = &(&y); - | ----------- ^^^^ creates a temporary which is freed while still in use - | | - | type annotation requires that borrow lasts for `'a` -... -LL | } - | - temporary value is freed at the end of this statement - -error[E0597]: `y` does not live long enough - --> $DIR/regions-free-region-ordering-caller1.rs:9:27 - | -LL | fn call1<'a>(x: &'a usize) { - | -- lifetime `'a` defined here -... -LL | let z: &'a & usize = &(&y); - | ----------- ^^^^ borrowed value does not live long enough - | | - | type annotation requires that `y` is borrowed for `'a` -... -LL | } - | - `y` dropped here while still borrowed - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0597, E0716. -For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.rs b/src/test/ui/regions/regions-free-region-ordering-caller1.rs index d9251c085e1..f3245561669 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller1.rs +++ b/src/test/ui/regions/regions-free-region-ordering-caller1.rs @@ -7,7 +7,7 @@ fn call1<'a>(x: &'a usize) { // &'a &'z usize requires that 'a <= 'z: let y: usize = 3; let z: &'a & usize = &(&y); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed //~^^ ERROR `y` does not live long enough } diff --git a/src/test/ui/regions/regions-free-region-ordering-caller1.stderr b/src/test/ui/regions/regions-free-region-ordering-caller1.stderr index 08aaa35e08c..8042b1740b1 100644 --- a/src/test/ui/regions/regions-free-region-ordering-caller1.stderr +++ b/src/test/ui/regions/regions-free-region-ordering-caller1.stderr @@ -1,33 +1,32 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-free-region-ordering-caller1.rs:9:27 | +LL | fn call1<'a>(x: &'a usize) { + | -- lifetime `'a` defined here +... LL | let z: &'a & usize = &(&y); - | ^^^^ temporary value does not live long enough + | ----------- ^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'a` ... LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 5:10... - --> $DIR/regions-free-region-ordering-caller1.rs:5:10 - | -LL | fn call1<'a>(x: &'a usize) { - | ^^ + | - temporary value is freed at the end of this statement error[E0597]: `y` does not live long enough - --> $DIR/regions-free-region-ordering-caller1.rs:9:29 - | -LL | let z: &'a & usize = &(&y); - | ^ 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 5:10... - --> $DIR/regions-free-region-ordering-caller1.rs:5:10 + --> $DIR/regions-free-region-ordering-caller1.rs:9:27 | LL | fn call1<'a>(x: &'a usize) { - | ^^ + | -- lifetime `'a` defined here +... +LL | let z: &'a & usize = &(&y); + | ----------- ^^^^ borrowed value does not live long enough + | | + | type annotation requires that `y` is borrowed for `'a` +... +LL | } + | - `y` dropped here while still borrowed error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors have detailed explanations: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr b/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr deleted file mode 100644 index 2c7a6e8b5c0..00000000000 --- a/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return value referencing local data `*p` - --> $DIR/regions-infer-borrow-scope-too-big.rs:13:12 - | -LL | let xc = x_coord(&*p); - | --- `*p` is borrowed here -LL | assert_eq!(*xc, 3); -LL | return xc; - | ^^ 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/regions/regions-infer-borrow-scope-too-big.rs b/src/test/ui/regions/regions-infer-borrow-scope-too-big.rs index 3bf1c67da99..250b41da578 100644 --- a/src/test/ui/regions/regions-infer-borrow-scope-too-big.rs +++ b/src/test/ui/regions/regions-infer-borrow-scope-too-big.rs @@ -8,9 +8,9 @@ fn x_coord<'r>(p: &'r Point) -> &'r isize { } fn foo<'a>(p: Box) -> &'a isize { - let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough + let xc = x_coord(&*p); assert_eq!(*xc, 3); - return xc; + return xc; //~ ERROR cannot return value referencing local data `*p` } fn main() {} diff --git a/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr b/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr index ed4bc155040..2c7a6e8b5c0 100644 --- a/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr +++ b/src/test/ui/regions/regions-infer-borrow-scope-too-big.stderr @@ -1,18 +1,12 @@ -error[E0597]: `*p` does not live long enough - --> $DIR/regions-infer-borrow-scope-too-big.rs:11:23 +error[E0515]: cannot return value referencing local data `*p` + --> $DIR/regions-infer-borrow-scope-too-big.rs:13:12 | LL | let xc = x_coord(&*p); - | ^^ 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 10:8... - --> $DIR/regions-infer-borrow-scope-too-big.rs:10:8 - | -LL | fn foo<'a>(p: Box) -> &'a isize { - | ^^ + | --- `*p` is borrowed here +LL | assert_eq!(*xc, 3); +LL | return xc; + | ^^ 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/regions/regions-infer-proc-static-upvar.nll.stderr b/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr deleted file mode 100644 index 803d0d74491..00000000000 --- a/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/regions-infer-proc-static-upvar.rs:10:13 - | -LL | let y = &x; - | ^^ borrowed value does not live long enough -LL | / foo(move|| { -LL | | let _a = *y; -LL | | }); - | |______- argument requires that `x` is borrowed for `'static` -LL | } - | - `x` 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/regions/regions-infer-proc-static-upvar.stderr b/src/test/ui/regions/regions-infer-proc-static-upvar.stderr index 21b2e881a79..803d0d74491 100644 --- a/src/test/ui/regions/regions-infer-proc-static-upvar.stderr +++ b/src/test/ui/regions/regions-infer-proc-static-upvar.stderr @@ -1,13 +1,14 @@ error[E0597]: `x` does not live long enough - --> $DIR/regions-infer-proc-static-upvar.rs:10:14 + --> $DIR/regions-infer-proc-static-upvar.rs:10:13 | -LL | let y = &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... +LL | let y = &x; + | ^^ borrowed value does not live long enough +LL | / foo(move|| { +LL | | let _a = *y; +LL | | }); + | |______- argument requires that `x` is borrowed for `'static` +LL | } + | - `x` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr deleted file mode 100644 index 7984f4f0e54..00000000000 --- a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:16:3 - | -LL | let testValue = &id(Test); - | -------- temporary value created here -LL | -LL | testValue - | ^^^^^^^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:22:3 - | -LL | let testValue = &id(MyEnum::Variant1); - | -------------------- temporary value created here -LL | -LL | testValue - | ^^^^^^^^^ returns a value referencing data owned by the current function - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs index 2d21a511083..1b25294c7e1 100644 --- a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs +++ b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.rs @@ -12,14 +12,14 @@ enum MyEnum { fn structLifetime<'a>() -> &'a Test { let testValue = &id(Test); - //~^ ERROR borrowed value does not live long enough testValue + //~^ ERROR cannot return value referencing temporary value } fn variantLifetime<'a>() -> &'a MyEnum { let testValue = &id(MyEnum::Variant1); - //~^ ERROR borrowed value does not live long enough testValue + //~^ ERROR cannot return value referencing temporary value } diff --git a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr index c0bfc475f19..b4bf2ab312d 100644 --- a/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr +++ b/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.stderr @@ -1,33 +1,19 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:14:20 +error[E0515]: cannot return value referencing temporary value + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:15:3 | LL | let testValue = &id(Test); - | ^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:19... - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:13:19 - | -LL | fn structLifetime<'a>() -> &'a Test { - | ^^ + | -------- temporary value created here +LL | testValue + | ^^^^^^^^^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:20:20 +error[E0515]: cannot return value referencing temporary value + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:21:3 | LL | let testValue = &id(MyEnum::Variant1); - | ^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 19:20... - --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:19:20 - | -LL | fn variantLifetime<'a>() -> &'a MyEnum { - | ^^ + | -------------------- temporary value created here +LL | testValue + | ^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to 2 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/regions/regions-nested-fns-2.nll.stderr b/src/test/ui/regions/regions-nested-fns-2.nll.stderr deleted file mode 100644 index 8627dac5459..00000000000 --- a/src/test/ui/regions/regions-nested-fns-2.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns-2.rs:8:25 - | -LL | |z| { - | --- value captured here -LL | -LL | if false { &y } else { z } - | -^ - | || - | |borrowed value does not live long enough - | returning this value requires that `y` is borrowed for `'static` -LL | }); -LL | } - | - `y` 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/regions/regions-nested-fns-2.rs b/src/test/ui/regions/regions-nested-fns-2.rs index 1b51880f415..3b3e26c4503 100644 --- a/src/test/ui/regions/regions-nested-fns-2.rs +++ b/src/test/ui/regions/regions-nested-fns-2.rs @@ -4,8 +4,8 @@ fn nested() { let y = 3; ignore( |z| { - //~^ ERROR E0373 if false { &y } else { z } + //~^ ERROR `y` does not live long enough }); } diff --git a/src/test/ui/regions/regions-nested-fns-2.stderr b/src/test/ui/regions/regions-nested-fns-2.stderr index 08bab6e9806..43c8d1272c7 100644 --- a/src/test/ui/regions/regions-nested-fns-2.stderr +++ b/src/test/ui/regions/regions-nested-fns-2.stderr @@ -1,16 +1,17 @@ -error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function - --> $DIR/regions-nested-fns-2.rs:6:9 +error[E0597]: `y` does not live long enough + --> $DIR/regions-nested-fns-2.rs:7:25 | LL | |z| { - | ^^^ may outlive borrowed value `y` -LL | + | --- value captured here LL | if false { &y } else { z } - | - `y` is borrowed here -help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword - | -LL | move |z| { - | ^^^^^^^^ + | -^ + | || + | |borrowed value does not live long enough + | returning this value requires that `y` is borrowed for `'static` +... +LL | } + | - `y` dropped here while still borrowed error: aborting due to previous error -For more information about this error, try `rustc --explain E0373`. +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.ast.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-hrtb.ast.stderr rename to src/test/ui/regions/regions-outlives-projection-container-hrtb.migrate.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.mir.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-hrtb.mir.stderr rename to src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs index 2871d962c42..407a4fdf59b 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs +++ b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs @@ -1,8 +1,8 @@ // Test that structs with higher-ranked where clauses don't generate // "outlives" requirements. Issue #22246. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir #![allow(dead_code)] @@ -33,8 +33,8 @@ fn with_assoc<'a,'b>() { // We get an error because 'b:'a does not hold: let _: &'a WithHrAssoc> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } /////////////////////////////////////////////////////////////////////////// @@ -55,8 +55,8 @@ fn with_assoc_sub<'a,'b>() { // below to be well-formed, it is not related to the HR relation. let _: &'a WithHrAssocSub> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.stderr b/src/test/ui/regions/regions-outlives-projection-container-hrtb.stderr deleted file mode 100644 index 856e28f141f..00000000000 --- a/src/test/ui/regions/regions-outlives-projection-container-hrtb.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0491]: in type `&'a WithHrAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container-hrtb.rs:32:12 - | -LL | let _: &'a WithHrAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 29:15 - --> $DIR/regions-outlives-projection-container-hrtb.rs:29:15 - | -LL | fn with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 29:18 - --> $DIR/regions-outlives-projection-container-hrtb.rs:29:18 - | -LL | fn with_assoc<'a,'b>() { - | ^^ - -error[E0491]: in type `&'a WithHrAssocSub>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container-hrtb.rs:53:12 - | -LL | let _: &'a WithHrAssocSub> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 49:19 - --> $DIR/regions-outlives-projection-container-hrtb.rs:49:19 - | -LL | fn with_assoc_sub<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 49:22 - --> $DIR/regions-outlives-projection-container-hrtb.rs:49:22 - | -LL | fn with_assoc_sub<'a,'b>() { - | ^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.ast.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.migrate.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-wc.ast.stderr rename to src/test/ui/regions/regions-outlives-projection-container-wc.migrate.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.mir.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr similarity index 100% rename from src/test/ui/regions/regions-outlives-projection-container-wc.mir.stderr rename to src/test/ui/regions/regions-outlives-projection-container-wc.nll.stderr diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.rs b/src/test/ui/regions/regions-outlives-projection-container-wc.rs index 37622211327..5037ea536da 100644 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.rs +++ b/src/test/ui/regions/regions-outlives-projection-container-wc.rs @@ -3,8 +3,8 @@ // outlive the location in which the type appears, even when the // constraint is in a where clause not a bound. Issue #22246. -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir +// revisions: migrate nll +//[nll]compile-flags: -Z borrowck=mir #![allow(dead_code)] @@ -35,8 +35,8 @@ fn with_assoc<'a,'b>() { // which is &'b (), must outlive 'a. let _: &'a WithAssoc> = loop { }; - //[ast]~^ ERROR reference has a longer lifetime - //[mir]~^^ ERROR lifetime may not live long enough + //[migrate]~^ ERROR reference has a longer lifetime + //[nll]~^^ ERROR lifetime may not live long enough } fn main() { diff --git a/src/test/ui/regions/regions-outlives-projection-container-wc.stderr b/src/test/ui/regions/regions-outlives-projection-container-wc.stderr deleted file mode 100644 index 0d73d3d6432..00000000000 --- a/src/test/ui/regions/regions-outlives-projection-container-wc.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container-wc.rs:34:12 - | -LL | let _: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the function body at 28:15 - --> $DIR/regions-outlives-projection-container-wc.rs:28:15 - | -LL | fn with_assoc<'a,'b>() { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 28:18 - --> $DIR/regions-outlives-projection-container-wc.rs:28:18 - | -LL | fn with_assoc<'a,'b>() { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr deleted file mode 100644 index f77d94a24b8..00000000000 --- a/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `line` does not live long enough - --> $DIR/regions-pattern-typing-issue-19552.rs:5:14 - | -LL | match [&*line] { - | ^^^^ borrowed value does not live long enough -LL | [ word ] => { assert_static(word); } - | ------------------- argument requires that `line` is borrowed for `'static` -LL | } -LL | } - | - `line` 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/regions/regions-pattern-typing-issue-19552.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19552.stderr index 3e3201db240..f77d94a24b8 100644 --- a/src/test/ui/regions/regions-pattern-typing-issue-19552.stderr +++ b/src/test/ui/regions/regions-pattern-typing-issue-19552.stderr @@ -3,11 +3,11 @@ error[E0597]: `line` does not live long enough | LL | match [&*line] { | ^^^^ borrowed value does not live long enough -... +LL | [ word ] => { assert_static(word); } + | ------------------- argument requires that `line` is borrowed for `'static` +LL | } LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `line` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.stderr deleted file mode 100644 index 0074d2b4f77..00000000000 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0506]: cannot assign to `a1` because it is borrowed - --> $DIR/regions-pattern-typing-issue-19997.rs:10:13 - | -LL | match (&a1,) { - | -- borrow of `a1` occurs here -LL | (&ref b0,) => { -LL | a1 = &f; - | ^^^^^^^ assignment to borrowed `a1` occurs here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0506`. diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19997.mir.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19997.mir.stderr deleted file mode 100644 index b1c5878224d..00000000000 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.mir.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0506]: cannot assign to `a1` because it is borrowed - --> $DIR/regions-pattern-typing-issue-19997.rs:10:13 - | -LL | match (&a1,) { - | --- borrow of `a1` occurs here -LL | (&ref b0,) => { -LL | a1 = &f; - | ^^^^^^^ assignment to borrowed `a1` occurs here -LL | -LL | drop(b0); - | -- 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/regions/regions-pattern-typing-issue-19997.rs b/src/test/ui/regions/regions-pattern-typing-issue-19997.rs index 35f38af0cfe..39190697fe7 100644 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.rs +++ b/src/test/ui/regions/regions-pattern-typing-issue-19997.rs @@ -1,14 +1,10 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - fn main() { let a0 = 0; let f = 1; let mut a1 = &a0; match (&a1,) { (&ref b0,) => { - a1 = &f; //[ast]~ ERROR cannot assign - //[mir]~^ ERROR cannot assign to `a1` because it is borrowed + a1 = &f; //~ ERROR cannot assign to `a1` because it is borrowed drop(b0); } } diff --git a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.nll.stderr b/src/test/ui/regions/regions-pattern-typing-issue-19997.stderr similarity index 87% rename from src/test/ui/regions/regions-pattern-typing-issue-19997.ast.nll.stderr rename to src/test/ui/regions/regions-pattern-typing-issue-19997.stderr index b1c5878224d..ae60e3c0d5d 100644 --- a/src/test/ui/regions/regions-pattern-typing-issue-19997.ast.nll.stderr +++ b/src/test/ui/regions/regions-pattern-typing-issue-19997.stderr @@ -1,12 +1,11 @@ error[E0506]: cannot assign to `a1` because it is borrowed - --> $DIR/regions-pattern-typing-issue-19997.rs:10:13 + --> $DIR/regions-pattern-typing-issue-19997.rs:7:13 | LL | match (&a1,) { | --- borrow of `a1` occurs here LL | (&ref b0,) => { LL | a1 = &f; | ^^^^^^^ assignment to borrowed `a1` occurs here -LL | LL | drop(b0); | -- borrow later used here diff --git a/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr b/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr deleted file mode 100644 index ccba6c59b61..00000000000 --- a/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0515]: cannot return value referencing function parameter - --> $DIR/regions-ref-in-fn-arg.rs:5:5 - | -LL | fn arg_item(box ref x: Box) -> &'static isize { - | --------- function parameter borrowed here -LL | x - | ^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing function parameter - --> $DIR/regions-ref-in-fn-arg.rs:11:22 - | -LL | with(|box ref x| x) - | --------- ^ returns a value referencing data owned by the current function - | | - | function parameter borrowed here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-ref-in-fn-arg.rs b/src/test/ui/regions/regions-ref-in-fn-arg.rs index cf9e7b27ed0..d1cbd279b65 100644 --- a/src/test/ui/regions/regions-ref-in-fn-arg.rs +++ b/src/test/ui/regions/regions-ref-in-fn-arg.rs @@ -2,13 +2,13 @@ #![feature(box_syntax)] fn arg_item(box ref x: Box) -> &'static isize { - x //~^ ERROR borrowed value does not live long enough + x //~ ERROR cannot return value referencing function parameter } fn with(f: F) -> R where F: FnOnce(Box) -> R { f(box 3) } fn arg_closure() -> &'static isize { - with(|box ref x| x) //~ ERROR borrowed value does not live long enough + with(|box ref x| x) //~ ERROR cannot return value referencing function parameter } fn main() {} diff --git a/src/test/ui/regions/regions-ref-in-fn-arg.stderr b/src/test/ui/regions/regions-ref-in-fn-arg.stderr index 9ecd327510a..ccba6c59b61 100644 --- a/src/test/ui/regions/regions-ref-in-fn-arg.stderr +++ b/src/test/ui/regions/regions-ref-in-fn-arg.stderr @@ -1,24 +1,19 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ref-in-fn-arg.rs:4:17 +error[E0515]: cannot return value referencing function parameter + --> $DIR/regions-ref-in-fn-arg.rs:5:5 | LL | fn arg_item(box ref x: Box) -> &'static isize { - | ^^^^^ borrowed value does not live long enough + | --------- function parameter borrowed 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/regions-ref-in-fn-arg.rs:11:15 +error[E0515]: cannot return value referencing function parameter + --> $DIR/regions-ref-in-fn-arg.rs:11:22 | LL | with(|box ref x| x) - | ^^^^^ - borrowed value only lives until here - | | - | borrowed value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | --------- ^ returns a value referencing data owned by the current function + | | + | function parameter borrowed here error: aborting due to 2 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/regions/regions-ret.nll.stderr b/src/test/ui/regions/regions-ret.nll.stderr deleted file mode 100644 index 0e4875ac985..00000000000 --- a/src/test/ui/regions/regions-ret.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-ret.rs:4:12 - | -LL | return &id(3); - | ^----- - | || - | |temporary value created here - | 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/regions/regions-ret.rs b/src/test/ui/regions/regions-ret.rs index a094d1af5b7..580545ef856 100644 --- a/src/test/ui/regions/regions-ret.rs +++ b/src/test/ui/regions/regions-ret.rs @@ -1,7 +1,7 @@ fn id(x: T) -> T { x } fn f(_x: &isize) -> &isize { - return &id(3); //~ ERROR borrowed value does not live long enough + return &id(3); //~ ERROR cannot return reference to temporary value } fn main() { diff --git a/src/test/ui/regions/regions-ret.stderr b/src/test/ui/regions/regions-ret.stderr index 77820a34e40..0e4875ac985 100644 --- a/src/test/ui/regions/regions-ret.stderr +++ b/src/test/ui/regions/regions-ret.stderr @@ -1,20 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ret.rs:4:13 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-ret.rs:4:12 | LL | return &id(3); - | ^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 3:1... - --> $DIR/regions-ret.rs:3:1 - | -LL | / fn f(_x: &isize) -> &isize { -LL | | return &id(3); -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime + | ^----- + | || + | |temporary value created here + | 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 E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr b/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr deleted file mode 100644 index 9d87fe266b1..00000000000 --- a/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0515]: cannot return reference to temporary value - --> $DIR/regions-return-stack-allocated-vec.rs:4:5 - | -LL | &[x] - | ^--- - | || - | |temporary value created here - | 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/regions/regions-return-stack-allocated-vec.rs b/src/test/ui/regions/regions-return-stack-allocated-vec.rs index 8d071dbc606..97fbdbf4685 100644 --- a/src/test/ui/regions/regions-return-stack-allocated-vec.rs +++ b/src/test/ui/regions/regions-return-stack-allocated-vec.rs @@ -1,7 +1,7 @@ // Test that we cannot return a stack allocated slice fn function(x: isize) -> &'static [isize] { - &[x] //~ ERROR borrowed value does not live long enough + &[x] //~ ERROR cannot return reference to temporary value } fn main() { diff --git a/src/test/ui/regions/regions-return-stack-allocated-vec.stderr b/src/test/ui/regions/regions-return-stack-allocated-vec.stderr index 3256294473f..9d87fe266b1 100644 --- a/src/test/ui/regions/regions-return-stack-allocated-vec.stderr +++ b/src/test/ui/regions/regions-return-stack-allocated-vec.stderr @@ -1,13 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-return-stack-allocated-vec.rs:4:6 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-return-stack-allocated-vec.rs:4:5 | LL | &[x] - | ^^^ 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 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/regions/regions-static-bound.ll.stderr b/src/test/ui/regions/regions-static-bound.migrate.stderr similarity index 100% rename from src/test/ui/regions/regions-static-bound.ll.stderr rename to src/test/ui/regions/regions-static-bound.migrate.stderr diff --git a/src/test/ui/regions/regions-static-bound.rs b/src/test/ui/regions/regions-static-bound.rs index c1a15e50a4d..1db54881d3e 100644 --- a/src/test/ui/regions/regions-static-bound.rs +++ b/src/test/ui/regions/regions-static-bound.rs @@ -1,4 +1,4 @@ -// revisions: ll nll +// revisions: migrate nll //[nll] compile-flags:-Zborrowck=mir fn static_id<'a,'b>(t: &'a ()) -> &'static () @@ -6,14 +6,14 @@ fn static_id<'a,'b>(t: &'a ()) -> &'static () fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () where 'a: 'b, 'b: 'static { t } fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { - t //[ll]~ ERROR E0312 + t //[migrate]~ ERROR E0312 //[nll]~^ ERROR lifetime may not live long enough } fn error(u: &(), v: &()) { - static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] + static_id(&u); //[migrate]~ ERROR explicit lifetime required in the type of `u` [E0621] //[nll]~^ ERROR explicit lifetime required in the type of `u` [E0621] - static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] + static_id_indirect(&v); //[migrate]~ ERROR explicit lifetime required in the type of `v` [E0621] //[nll]~^ ERROR explicit lifetime required in the type of `v` [E0621] } diff --git a/src/test/ui/regions/regions-steal-closure.nll.stderr b/src/test/ui/regions/regions-steal-closure.nll.stderr deleted file mode 100644 index 5b0efaf9559..00000000000 --- a/src/test/ui/regions/regions-steal-closure.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `i` does not live long enough - --> $DIR/regions-steal-closure.rs:14:28 - | -LL | let mut cl_box = { - | ---------- borrow later stored here -LL | let mut i = 3; -LL | box_it(Box::new(|| i += 1)) - | -- ^ borrowed value does not live long enough - | | - | value captured here -LL | }; - | - `i` 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/regions/regions-steal-closure.stderr b/src/test/ui/regions/regions-steal-closure.stderr index 8cfd5b50312..5b0efaf9559 100644 --- a/src/test/ui/regions/regions-steal-closure.stderr +++ b/src/test/ui/regions/regions-steal-closure.stderr @@ -1,15 +1,15 @@ error[E0597]: `i` does not live long enough --> $DIR/regions-steal-closure.rs:14:28 | +LL | let mut cl_box = { + | ---------- borrow later stored here +LL | let mut i = 3; LL | box_it(Box::new(|| i += 1)) | -- ^ borrowed value does not live long enough | | - | capture occurs here + | value captured here LL | }; - | - borrowed value only lives until here -LL | cl_box.cl.call_mut(()); -LL | } - | - borrowed value needs to live until here + | - `i` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/regions/regions-trait-variance.nll.stderr b/src/test/ui/regions/regions-trait-variance.nll.stderr deleted file mode 100644 index 56c9f89e1f5..00000000000 --- a/src/test/ui/regions/regions-trait-variance.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0515]: cannot return value referencing local data `*b` - --> $DIR/regions-trait-variance.rs:38:5 - | -LL | let bb: &B = &*b; - | --- `*b` is borrowed here -LL | make_a(bb) - | ^^^^^^^^^^ 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/regions/regions-trait-variance.rs b/src/test/ui/regions/regions-trait-variance.rs index d5462b21fa7..73baa84ec90 100644 --- a/src/test/ui/regions/regions-trait-variance.rs +++ b/src/test/ui/regions/regions-trait-variance.rs @@ -34,8 +34,8 @@ fn make_make_a<'a>() -> A<'a> { let b: Box = box B { i: 1, }; - let bb: &B = &*b; //~ ERROR `*b` does not live long enough - make_a(bb) + let bb: &B = &*b; + make_a(bb) //~ ERROR cannot return value referencing local data `*b` } fn main() { diff --git a/src/test/ui/regions/regions-trait-variance.stderr b/src/test/ui/regions/regions-trait-variance.stderr index 32c89b8eeff..56c9f89e1f5 100644 --- a/src/test/ui/regions/regions-trait-variance.stderr +++ b/src/test/ui/regions/regions-trait-variance.stderr @@ -1,18 +1,11 @@ -error[E0597]: `*b` does not live long enough - --> $DIR/regions-trait-variance.rs:37:19 +error[E0515]: cannot return value referencing local data `*b` + --> $DIR/regions-trait-variance.rs:38:5 | LL | let bb: &B = &*b; - | ^^ borrowed value does not live long enough + | --- `*b` is borrowed here LL | make_a(bb) -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 33:16... - --> $DIR/regions-trait-variance.rs:33:16 - | -LL | fn make_make_a<'a>() -> A<'a> { - | ^^ + | ^^^^^^^^^^ 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/regions/regions-var-type-out-of-scope.nll.stderr b/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr deleted file mode 100644 index 146fb8fd81f..00000000000 --- a/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/regions-var-type-out-of-scope.rs:9:14 - | -LL | x = &id(3); - | ^^^^^- temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -LL | assert_eq!(*x, 3); - | ------------------ 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/regions/regions-var-type-out-of-scope.rs b/src/test/ui/regions/regions-var-type-out-of-scope.rs index e9721630974..aba55e9df6a 100644 --- a/src/test/ui/regions/regions-var-type-out-of-scope.rs +++ b/src/test/ui/regions/regions-var-type-out-of-scope.rs @@ -6,7 +6,7 @@ fn foo(cond: bool) { let mut x; if cond { - x = &id(3); //~ ERROR borrowed value does not live long enough + x = &id(3); //~ ERROR temporary value dropped while borrowed assert_eq!(*x, 3); } } diff --git a/src/test/ui/regions/regions-var-type-out-of-scope.stderr b/src/test/ui/regions/regions-var-type-out-of-scope.stderr index 0363fe0d19f..146fb8fd81f 100644 --- a/src/test/ui/regions/regions-var-type-out-of-scope.stderr +++ b/src/test/ui/regions/regions-var-type-out-of-scope.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-var-type-out-of-scope.rs:9:14 | LL | x = &id(3); - | ^^^^^- temporary value dropped here while still borrowed + | ^^^^^- temporary value is freed at the end of this statement | | - | temporary value does not live long enough -... -LL | } - | - temporary value needs to live until here + | creates a temporary which is freed while still in use +LL | assert_eq!(*x, 3); + | ------------------ 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/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr index 4c17ce23b37..34e8b0e1439 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr @@ -1,9 +1,10 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/feature-gate.rs:33:16 +error: compilation successful + --> $DIR/feature-gate.rs:41:1 | -LL | A { a: v } if *v == 42 => v, - | ^ moves value into pattern guard +LL | / fn main() { +LL | | foo(107) +LL | | } + | |_^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0008`. diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr index 4bde9b0c8d9..34e8b0e1439 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr @@ -1,5 +1,5 @@ error: compilation successful - --> $DIR/feature-gate.rs:42:1 + --> $DIR/feature-gate.rs:41:1 | LL | / fn main() { LL | | foo(107) diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr index 4bde9b0c8d9..34e8b0e1439 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr @@ -1,5 +1,5 @@ error: compilation successful - --> $DIR/feature-gate.rs:42:1 + --> $DIR/feature-gate.rs:41:1 | LL | / fn main() { LL | | foo(107) diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr index 4bde9b0c8d9..34e8b0e1439 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr @@ -1,5 +1,5 @@ error: compilation successful - --> $DIR/feature-gate.rs:42:1 + --> $DIR/feature-gate.rs:41:1 | LL | / fn main() { LL | | foo(107) diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr index 4c17ce23b37..2a1a04b3f49 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr @@ -3,6 +3,8 @@ error[E0008]: cannot bind by-move into a pattern guard | LL | A { a: v } if *v == 42 => v, | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable error: aborting due to previous error diff --git a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs index f6df4d07baa..97f90f7762a 100644 --- a/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs +++ b/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs @@ -32,7 +32,6 @@ fn foo(n: i32) { A { a: v } if *v == 42 => v, //[no_gate]~^ ERROR cannot bind by-move into a pattern guard - //[gate_and_2015]~^^ ERROR cannot bind by-move into a pattern guard _ => Box::new(0) }; @@ -42,6 +41,7 @@ fn foo(n: i32) { fn main() { foo(107) } -//[gate_and_2018]~^^^ ERROR compilation successful -//[gate_and_znll]~^^^^ ERROR compilation successful -//[gate_and_feature_nll]~^^^^^ ERROR compilation successful +//[gate_and_2015]~^^^ ERROR compilation successful +//[gate_and_2018]~^^^^ ERROR compilation successful +//[gate_and_znll]~^^^^^ ERROR compilation successful +//[gate_and_feature_nll]~^^^^^^ ERROR compilation successful diff --git a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr deleted file mode 100644 index 04572920ee4..00000000000 --- a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable - --> $DIR/borrowck-issue-49631.rs:20:9 - | -LL | while let Some(Ok(string)) = foo.get() { - | --- immutable borrow occurs here -LL | foo.mutate(); - | ^^^^^^^^^^^^ mutable borrow occurs here -LL | -LL | println!("foo={:?}", *string); - | ------- 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/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr index e946d41e234..04572920ee4 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.stderr @@ -2,11 +2,12 @@ error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immu --> $DIR/borrowck-issue-49631.rs:20:9 | LL | while let Some(Ok(string)) = foo.get() { - | --- - immutable borrow ends here - | | - | immutable borrow occurs here + | --- immutable borrow occurs here LL | foo.mutate(); - | ^^^ mutable borrow occurs here + | ^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | println!("foo={:?}", *string); + | ------- immutable borrow later used here error: aborting due to previous error diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr b/src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr deleted file mode 100644 index 9d53e6d7887..00000000000 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/enum.rs:9:5 - | -LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/enum.rs:13:9 - | -LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*x` which is behind a `&` reference - --> $DIR/enum.rs:19:9 - | -LL | *x += 1; - | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.rs b/src/test/ui/rfc-2005-default-binding-mode/enum.rs index 7609345404f..af82d36f87e 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/enum.rs @@ -6,17 +6,17 @@ use Wrapper::Wrap; pub fn main() { let Wrap(x) = &Wrap(3); - *x += 1; //~ ERROR cannot assign to immutable + *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference if let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to immutable + *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference } else { panic!(); } while let Some(x) = &Some(3) { - *x += 1; //~ ERROR cannot assign to immutable + *x += 1; //~ ERROR cannot assign to `*x` which is behind a `&` reference break; } } diff --git a/src/test/ui/rfc-2005-default-binding-mode/enum.stderr b/src/test/ui/rfc-2005-default-binding-mode/enum.stderr index 286ae09249a..9d53e6d7887 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/enum.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/enum.stderr @@ -1,20 +1,20 @@ -error[E0594]: cannot assign to immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/enum.rs:9:5 | 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 immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/enum.rs:13:9 | 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 immutable borrowed content `*x` +error[E0594]: cannot assign to `*x` which is behind a `&` reference --> $DIR/enum.rs:19:9 | LL | *x += 1; - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr deleted file mode 100644 index 5eace3d263d..00000000000 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.nll.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0594]: cannot assign to `*n` which is behind a `&` reference - --> $DIR/explicit-mut.rs:7:13 - | -LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*n` which is behind a `&` reference - --> $DIR/explicit-mut.rs:15:13 - | -LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error[E0594]: cannot assign to `*n` which is behind a `&` reference - --> $DIR/explicit-mut.rs:23:13 - | -LL | *n += 1; - | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs index 73efddef6cd..212fd94ded3 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs +++ b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.rs @@ -4,7 +4,7 @@ fn main() { match &&Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to immutable + *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference let _ = n; } None => {}, @@ -12,7 +12,7 @@ fn main() { match &mut &Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to immutable + *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference let _ = n; } None => {}, @@ -20,7 +20,7 @@ fn main() { match &&mut Some(5i32) { Some(n) => { - *n += 1; //~ ERROR cannot assign to immutable + *n += 1; //~ ERROR cannot assign to `*n` which is behind a `&` reference let _ = n; } None => {}, diff --git a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr index 75738c2b5e6..5eace3d263d 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/explicit-mut.stderr @@ -1,20 +1,20 @@ -error[E0594]: cannot assign to immutable borrowed content `*n` +error[E0594]: cannot assign to `*n` which is behind a `&` reference --> $DIR/explicit-mut.rs:7:13 | LL | *n += 1; - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to immutable borrowed content `*n` +error[E0594]: cannot assign to `*n` which is behind a `&` reference --> $DIR/explicit-mut.rs:15:13 | LL | *n += 1; - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written -error[E0594]: cannot assign to immutable borrowed content `*n` +error[E0594]: cannot assign to `*n` which is behind a `&` reference --> $DIR/explicit-mut.rs:23:13 | LL | *n += 1; - | ^^^^^^^ cannot borrow as mutable + | ^^^^^^^ `n` is a `&` reference, so the data it refers to cannot be written error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr deleted file mode 100644 index 5f0b3a1d40b..00000000000 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:9:18 - | -LL | let a = NoCopy(0); - | - move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait -LL | let _ = dbg!(a); - | ------- value moved here -LL | let _ = dbg!(a); - | ^ value used here after move - | - = 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 E0382`. diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs index e6ddb3d91bf..9f3c567b641 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs @@ -7,5 +7,4 @@ fn main() { let a = NoCopy(0); let _ = dbg!(a); let _ = dbg!(a); //~ ERROR use of moved value - //~^ ERROR use of moved value } diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr index cfc318c1cd0..5f0b3a1d40b 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr @@ -1,25 +1,15 @@ error[E0382]: use of moved value: `a` --> $DIR/dbg-macro-move-semantics.rs:9:18 | +LL | let a = NoCopy(0); + | - move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait LL | let _ = dbg!(a); | ------- value moved here LL | let _ = dbg!(a); | ^ value used here after move | - = note: move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait = 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[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:9:13 - | -LL | let _ = dbg!(a); - | ------- value moved here -LL | let _ = dbg!(a); - | ^^^^^^^ value used here after move - | - = note: move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait - = 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 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/slice-mut-2.nll.stderr b/src/test/ui/slice-mut-2.nll.stderr deleted file mode 100644 index bad0268772b..00000000000 --- a/src/test/ui/slice-mut-2.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/slice-mut-2.rs:7:18 - | -LL | let x: &[isize] = &[1, 2, 3, 4, 5]; - | ---------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4, 5]` -... -LL | let _ = &mut x[2..4]; - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/slice-mut-2.rs b/src/test/ui/slice-mut-2.rs index 9586103f5f1..216edbb7808 100644 --- a/src/test/ui/slice-mut-2.rs +++ b/src/test/ui/slice-mut-2.rs @@ -4,5 +4,5 @@ fn main() { let x: &[isize] = &[1, 2, 3, 4, 5]; // Can't mutably slice an immutable slice let slice: &mut [isize] = &mut [0, 1]; - let _ = &mut x[2..4]; //~ERROR cannot borrow immutable borrowed content `*x` as mutable + let _ = &mut x[2..4]; //~ERROR cannot borrow `*x` as mutable, as it is behind a `&` reference } diff --git a/src/test/ui/slice-mut-2.stderr b/src/test/ui/slice-mut-2.stderr index 78dbfa56d45..bad0268772b 100644 --- a/src/test/ui/slice-mut-2.stderr +++ b/src/test/ui/slice-mut-2.stderr @@ -1,8 +1,11 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/slice-mut-2.rs:7:18 | +LL | let x: &[isize] = &[1, 2, 3, 4, 5]; + | ---------------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3, 4, 5]` +... LL | let _ = &mut x[2..4]; - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr deleted file mode 100644 index 8fceef64c8c..00000000000 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.nll.stderr +++ /dev/null @@ -1,88 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:53:24 - | -LL | fn deref_mut_field1(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | let __isize = &mut x.y; - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10 - | -LL | fn deref_extend_mut_field1(x: &Own) -> &mut isize { - | ----------- help: consider changing this to be a mutable reference: `&mut Own` -LL | &mut x.y - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19 - | -LL | let _x = &mut x.x; - | - first mutable borrow occurs here -LL | let _y = &mut x.y; - | ^ second mutable borrow occurs here -LL | use_mut(_x); - | -- first borrow later used here - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:5 - | -LL | fn assign_field1<'a>(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | x.y = 3; - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5 - | -LL | fn assign_field2<'a>(x: &'a Own) { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | x.y = 3; - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0499]: cannot borrow `*x` as mutable more than once at a time - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5 - | -LL | let _p: &mut Point = &mut **x; - | -- first mutable borrow occurs here -LL | x.y = 3; - | ^ second mutable borrow occurs here -LL | use_mut(_p); - | -- first borrow later used here - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:109:5 - | -LL | fn deref_mut_method1(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | x.set(0, 0); - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5 - | -LL | fn deref_extend_mut_method1(x: &Own) -> &mut isize { - | ----------- help: consider changing this to be a mutable reference: `&mut Own` -LL | x.y_mut() - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6 - | -LL | fn assign_method1<'a>(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | *x.y_mut() = 3; - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6 - | -LL | fn assign_method2<'a>(x: &'a Own) { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | *x.y_mut() = 3; - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 10 previous errors - -Some errors have detailed explanations: E0499, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr index 5f337712b4b..8fceef64c8c 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-auto-deref-mut.stderr @@ -1,18 +1,18 @@ -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:53:24 | LL | fn deref_mut_field1(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | let __isize = &mut x.y; - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:65:10 | LL | fn deref_extend_mut_field1(x: &Own) -> &mut isize { - | ----------- use `&mut Own` here to make mutable + | ----------- help: consider changing this to be a mutable reference: `&mut Own` LL | &mut x.y - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:78:19 @@ -22,24 +22,23 @@ LL | let _x = &mut x.x; LL | let _y = &mut x.y; | ^ second mutable borrow occurs here LL | use_mut(_x); -LL | } - | - first borrow ends here + | -- first borrow later used here -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:88:5 | LL | fn assign_field1<'a>(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.y = 3; - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:92:5 | LL | fn assign_field2<'a>(x: &'a Own) { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` LL | x.y = 3; - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error[E0499]: cannot borrow `*x` as mutable more than once at a time --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:101:5 @@ -49,40 +48,39 @@ LL | let _p: &mut Point = &mut **x; LL | x.y = 3; | ^ second mutable borrow occurs here LL | use_mut(_p); -LL | } - | - first borrow ends here + | -- first borrow later used here -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:109:5 | LL | fn deref_mut_method1(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.set(0, 0); - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:121:5 | LL | fn deref_extend_mut_method1(x: &Own) -> &mut isize { - | ----------- use `&mut Own` here to make mutable + | ----------- help: consider changing this to be a mutable reference: `&mut Own` LL | x.y_mut() - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:129:6 | LL | fn assign_method1<'a>(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | *x.y_mut() = 3; - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-auto-deref-mut.rs:133:6 | LL | fn assign_method2<'a>(x: &'a Own) { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` LL | *x.y_mut() = 3; - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 10 previous errors diff --git a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.nll.stderr b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.nll.stderr deleted file mode 100644 index 3ebfba7e4de..00000000000 --- a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:29:25 - | -LL | fn deref_mut1(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | let __isize = &mut *x; - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:41:11 - | -LL | fn deref_extend_mut1<'a>(x: &'a Own) -> &'a mut isize { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | &mut **x - | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6 - | -LL | fn assign1<'a>(x: Own) { - | - help: consider changing this to be mutable: `mut x` -LL | *x = 3; - | ^ cannot borrow as mutable - -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:53:6 - | -LL | fn assign2<'a>(x: &'a Own) { - | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` -LL | **x = 3; - | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr index 77f3982b2b4..3ebfba7e4de 100644 --- a/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr +++ b/src/test/ui/span/borrowck-borrow-overloaded-deref-mut.stderr @@ -1,34 +1,34 @@ -error[E0596]: cannot borrow immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:29:25 | LL | fn deref_mut1(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | let __isize = &mut *x; - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:41:11 | LL | fn deref_extend_mut1<'a>(x: &'a Own) -> &'a mut isize { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` 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 immutable argument `x` as mutable +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:49:6 | LL | fn assign1<'a>(x: Own) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | *x = 3; - | ^ cannot borrow mutably + | ^ cannot borrow as mutable -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-overloaded-deref-mut.rs:53:6 | LL | fn assign2<'a>(x: &'a Own) { - | -------------- use `&'a mut Own` here to make mutable + | -------------- help: consider changing this to be a mutable reference: `&'a mut Own` LL | **x = 3; - | ^^ cannot borrow as mutable + | ^^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 4 previous errors diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr deleted file mode 100644 index 51b72613782..00000000000 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error[E0499]: cannot borrow `f` as mutable more than once at a time - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:12:16 - | -LL | f(Box::new(|| { - | - ^^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call -LL | -LL | f((Box::new(|| {}))) - | - second borrow occurs due to use of `f` in closure - -error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5 - | -LL | fn test2(f: &F) where F: FnMut() { - | -- help: consider changing this to be a mutable reference: `&mut F` -LL | (*f)(); - | ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5 - | -LL | fn test4(f: &Test) { - | ----- help: consider changing this to be a mutable reference: `&mut Test<'_>` -LL | f.f.call_mut(()) - | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13 - | -LL | let mut f = move |g: Box, b: isize| { - | ----- captured outer variable -... -LL | foo(f); - | ^ cannot move out of captured variable in an `FnMut` closure - -error[E0505]: cannot move out of `f` because it is borrowed - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16 - | -LL | f(Box::new(|a| { - | - ^^^ move out of `f` occurs here - | | - | borrow of `f` occurs here -LL | foo(f); - | - move occurs due to use in closure - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0499, E0505, E0507, E0596. -For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs index f246f1118bf..db48bdf4c01 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs @@ -23,7 +23,7 @@ fn test1() { fn test2(f: &F) where F: FnMut() { (*f)(); - //~^ ERROR cannot borrow immutable borrowed content `*f` as mutable + //~^ ERROR cannot borrow `*f` as mutable, as it is behind a `&` reference } fn test3(f: &mut F) where F: FnMut() { @@ -32,7 +32,7 @@ fn test3(f: &mut F) where F: FnMut() { fn test4(f: &Test) { f.f.call_mut(()) - //~^ ERROR: cannot borrow field `f.f` of immutable binding as mutable + //~^ ERROR: cannot borrow `f.f` as mutable, as it is behind a `&` reference } fn test5(f: &mut Test) { @@ -53,9 +53,9 @@ fn test7() { let _ = s.len(); }; f(Box::new(|a| { + //~^ ERROR cannot move out of `f` because it is borrowed foo(f); - //~^ ERROR cannot move `f` into closure because it is borrowed - //~| ERROR cannot move out of captured outer variable in an `FnMut` closure + //~^ ERROR cannot move out of captured variable in an `FnMut` closure }), 3); } diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr index 7855c8ed46b..847f6865624 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -5,46 +5,48 @@ LL | f(Box::new(|| { | - ^^ second mutable borrow occurs here | | | first mutable borrow occurs here + | first borrow later used by call LL | LL | f((Box::new(|| {}))) - | - borrow occurs due to use of `f` in closure -LL | })); - | - first borrow ends here + | - second borrow occurs due to use of `f` in closure -error[E0596]: cannot borrow immutable borrowed content `*f` as mutable +error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5 | LL | fn test2(f: &F) where F: FnMut() { - | -- use `&mut F` here to make mutable + | -- help: consider changing this to be a mutable reference: `&mut F` LL | (*f)(); - | ^^^^ cannot borrow as mutable + | ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow field `f.f` of immutable binding as mutable +error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5 | LL | fn test4(f: &Test) { - | ----- use `&mut Test` here to make mutable + | ----- help: consider changing this to be a mutable reference: `&mut Test<'_>` LL | f.f.call_mut(()) - | ^^^ cannot mutably borrow field of immutable binding + | ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0504]: cannot move `f` into closure because it is borrowed - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13 - | -LL | f(Box::new(|a| { - | - borrow of `f` occurs here -LL | foo(f); - | ^ move into closure occurs here - -error[E0507]: cannot move out of captured outer variable in an `FnMut` closure - --> $DIR/borrowck-call-is-borrow-issue-12224.rs:56:13 +error[E0507]: cannot move out of captured variable in an `FnMut` closure + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 | LL | let mut f = move |g: Box, b: isize| { | ----- captured outer variable ... LL | foo(f); - | ^ cannot move out of captured outer variable in an `FnMut` closure + | ^ cannot move out of captured variable in an `FnMut` closure + +error[E0505]: cannot move out of `f` because it is borrowed + --> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16 + | +LL | f(Box::new(|a| { + | - ^^^ move out of `f` occurs here + | | + | borrow of `f` occurs here +LL | +LL | foo(f); + | - move occurs due to use in closure error: aborting due to 5 previous errors -Some errors have detailed explanations: E0499, E0504, E0507, E0596. +Some errors have detailed explanations: E0499, E0505, E0507, E0596. For more information about an error, try `rustc --explain E0499`. diff --git a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.nll.stderr b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.nll.stderr deleted file mode 100644 index 6b5e0779e5f..00000000000 --- a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-call-method-from-mut-aliasable.rs:17:5 - | -LL | fn b(x: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut Foo` -LL | x.f(); -LL | x.h(); - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr index 440c5c9c7c9..6b5e0779e5f 100644 --- a/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr +++ b/src/test/ui/span/borrowck-call-method-from-mut-aliasable.stderr @@ -1,11 +1,11 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-method-from-mut-aliasable.rs:17:5 | LL | fn b(x: &Foo) { - | ---- use `&mut Foo` here to make mutable + | ---- help: consider changing this to be a mutable reference: `&mut Foo` LL | x.f(); LL | x.h(); - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-fn-in-const-b.nll.stderr b/src/test/ui/span/borrowck-fn-in-const-b.nll.stderr deleted file mode 100644 index 9133d482c29..00000000000 --- a/src/test/ui/span/borrowck-fn-in-const-b.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-fn-in-const-b.rs:7:9 - | -LL | fn broken(x: &Vec) { - | ------------ help: consider changing this to be a mutable reference: `&mut std::vec::Vec` -LL | x.push(format!("this is broken")); - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-fn-in-const-b.stderr b/src/test/ui/span/borrowck-fn-in-const-b.stderr index 4a30bdf3b08..9133d482c29 100644 --- a/src/test/ui/span/borrowck-fn-in-const-b.stderr +++ b/src/test/ui/span/borrowck-fn-in-const-b.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-fn-in-const-b.rs:7:9 | LL | fn broken(x: &Vec) { - | ------------ use `&mut Vec` here to make mutable + | ------------ help: consider changing this to be a mutable reference: `&mut std::vec::Vec` LL | x.push(format!("this is broken")); - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to previous error diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr b/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr deleted file mode 100644 index f5f11932648..00000000000 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:19:14 - | -LL | v3.push(&id('x')); // statement 6 - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); - | -- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:29:18 - | -LL | v4.push(&id('y')); - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | v4.use_ref(); - | -- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-let-suggestion-suffixes.rs:40:14 - | -LL | v5.push(&id('z')); - | ^^^^^^^ - temporary value is freed at the end of this statement - | | - | creates a temporary which is freed while still in use -... -LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); - | -- borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs index 4b14907cec0..4744f3710ce 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs @@ -1,4 +1,3 @@ -#![feature(rustc_attrs)] fn id(x: T) -> T { x } fn f() { @@ -7,51 +6,52 @@ fn f() { let mut v2 = Vec::new(); // statement 2 - let young = ['y']; // statement 3 + { + let young = ['y']; // statement 3 - v2.push(&young[0]); // statement 4 - //~^ ERROR `young[..]` does not live long enough - //~| NOTE borrowed value does not live long enough - //~| NOTE values in a scope are dropped in the opposite order they are created + v2.push(&young[0]); // statement 4 + //~^ ERROR `young[_]` does not live long enough + //~| NOTE borrowed value does not live long enough + } //~ NOTE `young[_]` dropped here while still borrowed let mut v3 = Vec::new(); // statement 5 v3.push(&id('x')); // statement 6 - //~^ ERROR borrowed value does not live long enough - //~| NOTE temporary value does not live long enough - //~| NOTE temporary value dropped here while still borrowed - //~| NOTE consider using a `let` binding to increase its lifetime + //~^ ERROR temporary value dropped while borrowed + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE consider using a `let` binding to create a longer lived value { let mut v4 = Vec::new(); // (sub) statement 0 v4.push(&id('y')); - //~^ ERROR borrowed value does not live long enough - //~| NOTE temporary value does not live long enough - //~| NOTE temporary value dropped here while still borrowed - //~| NOTE consider using a `let` binding to increase its lifetime + //~^ ERROR temporary value dropped while borrowed + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE consider using a `let` binding to create a longer lived value v4.use_ref(); + //~^ NOTE borrow later used here } // (statement 7) - //~^ NOTE temporary value needs to live until here let mut v5 = Vec::new(); // statement 8 v5.push(&id('z')); - //~^ ERROR borrowed value does not live long enough - //~| NOTE temporary value does not live long enough - //~| NOTE temporary value dropped here while still borrowed - //~| NOTE consider using a `let` binding to increase its lifetime + //~^ ERROR temporary value dropped while borrowed + //~| NOTE creates a temporary which is freed while still in use + //~| NOTE temporary value is freed at the end of this statement + //~| NOTE consider using a `let` binding to create a longer lived value v1.push(&old[0]); (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + //~^ NOTE borrow later used here + //~| NOTE borrow later used here + //~| NOTE borrow later used here } -//~^ NOTE `young[..]` dropped here while still borrowed -//~| NOTE temporary value needs to live until here -//~| NOTE temporary value needs to live until here -fn main() { #![rustc_error] // rust-lang/rust#49855 +fn main() { f(); } diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr index 8bf542e37ff..7ba909d208a 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.stderr @@ -1,53 +1,55 @@ -error[E0597]: `young[..]` does not live long enough - --> $DIR/borrowck-let-suggestion-suffixes.rs:12:14 +error[E0597]: `young[_]` does not live long enough + --> $DIR/borrowck-let-suggestion-suffixes.rs:12:17 | -LL | v2.push(&young[0]); // statement 4 - | ^^^^^^^^ borrowed value does not live long enough +LL | v2.push(&young[0]); // statement 4 + | ^^^^^^^^^ borrowed value does not live long enough ... -LL | } - | - `young[..]` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created +LL | } + | - `young[_]` dropped here while still borrowed +... +LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + | -- borrow later used here -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:19:14 | LL | v3.push(&id('x')); // statement 6 - | ^^^^^^^ - 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 | } - | - temporary value needs to live until here +LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + | -- 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[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:29:18 | LL | v4.push(&id('y')); - | ^^^^^^^ - 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 | } // (statement 7) - | - temporary value needs to live until here +LL | v4.use_ref(); + | -- 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[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:40:14 | LL | v5.push(&id('z')); - | ^^^^^^^ - 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 | } - | - temporary value needs to live until here +LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); + | -- 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 4 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors have detailed explanations: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/borrowck-object-mutability.nll.stderr b/src/test/ui/span/borrowck-object-mutability.nll.stderr deleted file mode 100644 index fe6014cd5ad..00000000000 --- a/src/test/ui/span/borrowck-object-mutability.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference - --> $DIR/borrowck-object-mutability.rs:8:5 - | -LL | fn borrowed_receiver(x: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut dyn Foo` -LL | x.borrowed(); -LL | x.borrowed_mut(); - | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable - --> $DIR/borrowck-object-mutability.rs:18:5 - | -LL | fn owned_receiver(x: Box) { - | - help: consider changing this to be mutable: `mut x` -LL | x.borrowed(); -LL | x.borrowed_mut(); - | ^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/borrowck-object-mutability.stderr b/src/test/ui/span/borrowck-object-mutability.stderr index 073a70e3610..fe6014cd5ad 100644 --- a/src/test/ui/span/borrowck-object-mutability.stderr +++ b/src/test/ui/span/borrowck-object-mutability.stderr @@ -1,17 +1,17 @@ -error[E0596]: cannot borrow immutable borrowed content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-object-mutability.rs:8:5 | LL | fn borrowed_receiver(x: &Foo) { - | ---- use `&mut Foo` here to make mutable + | ---- help: consider changing this to be a mutable reference: `&mut dyn Foo` LL | x.borrowed(); LL | x.borrowed_mut(); - | ^ cannot borrow as mutable + | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable `Box` content `*x` as mutable +error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-object-mutability.rs:18:5 | LL | fn owned_receiver(x: Box) { - | - help: make this binding mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | x.borrowed(); LL | x.borrowed_mut(); | ^ cannot borrow as mutable diff --git a/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr b/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr deleted file mode 100644 index 4f529ce9511..00000000000 --- a/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/borrowck-ref-into-rvalue.rs:3:11 - | -LL | match Some("Hello".to_string()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use -... -LL | } - | - temporary value is freed at the end of this statement -LL | println!("{}", *msg); - | ---- 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/span/borrowck-ref-into-rvalue.rs b/src/test/ui/span/borrowck-ref-into-rvalue.rs index aeaebf073a7..c11aa1af540 100644 --- a/src/test/ui/span/borrowck-ref-into-rvalue.rs +++ b/src/test/ui/span/borrowck-ref-into-rvalue.rs @@ -1,8 +1,8 @@ fn main() { let msg; match Some("Hello".to_string()) { + //~^ ERROR temporary value dropped while borrowed Some(ref m) => { - //~^ ERROR borrowed value does not live long enough msg = m; }, None => { panic!() } diff --git a/src/test/ui/span/borrowck-ref-into-rvalue.stderr b/src/test/ui/span/borrowck-ref-into-rvalue.stderr index b8e79be8b61..4f529ce9511 100644 --- a/src/test/ui/span/borrowck-ref-into-rvalue.stderr +++ b/src/test/ui/span/borrowck-ref-into-rvalue.stderr @@ -1,17 +1,16 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowck-ref-into-rvalue.rs:4:14 +error[E0716]: temporary value dropped while borrowed + --> $DIR/borrowck-ref-into-rvalue.rs:3:11 | -LL | Some(ref m) => { - | ^^^^^ borrowed value does not live long enough +LL | match Some("Hello".to_string()) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use ... LL | } - | - borrowed value dropped here while still borrowed + | - temporary value is freed at the end of this statement LL | println!("{}", *msg); -LL | } - | - borrowed 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 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/span/destructor-restrictions.nll.stderr b/src/test/ui/span/destructor-restrictions.nll.stderr deleted file mode 100644 index a3c6cfb6ae4..00000000000 --- a/src/test/ui/span/destructor-restrictions.nll.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0597]: `*a` does not live long enough - --> $DIR/destructor-restrictions.rs:8:10 - | -LL | *a.borrow() + 1 - | ^--------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, i32>` - | | - | `*a` dropped here while still borrowed - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/destructor-restrictions.stderr b/src/test/ui/span/destructor-restrictions.stderr index a82e24b9391..a3c6cfb6ae4 100644 --- a/src/test/ui/span/destructor-restrictions.stderr +++ b/src/test/ui/span/destructor-restrictions.stderr @@ -2,11 +2,16 @@ error[E0597]: `*a` does not live long enough --> $DIR/destructor-restrictions.rs:8:10 | LL | *a.borrow() + 1 - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | }; - | -- borrowed value needs to live until here + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, i32>` | | | `*a` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to previous error diff --git a/src/test/ui/span/dropck-object-cycle.nll.stderr b/src/test/ui/span/dropck-object-cycle.nll.stderr deleted file mode 100644 index cfaf470212f..00000000000 --- a/src/test/ui/span/dropck-object-cycle.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `*m` does not live long enough - --> $DIR/dropck-object-cycle.rs:27:31 - | -LL | assert_eq!(object_invoke1(&*m), (4,5)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `*m` dropped here while still borrowed - | borrow might be used here, when `m` is dropped and runs the destructor for type `std::boxed::Box>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck-object-cycle.stderr b/src/test/ui/span/dropck-object-cycle.stderr index 3fc52853d02..cfaf470212f 100644 --- a/src/test/ui/span/dropck-object-cycle.stderr +++ b/src/test/ui/span/dropck-object-cycle.stderr @@ -1,13 +1,14 @@ error[E0597]: `*m` does not live long enough - --> $DIR/dropck-object-cycle.rs:27:32 + --> $DIR/dropck-object-cycle.rs:27:31 | LL | assert_eq!(object_invoke1(&*m), (4,5)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `*m` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `*m` dropped here while still borrowed + | borrow might be used here, when `m` is dropped and runs the destructor for type `std::boxed::Box>` error: aborting due to previous error diff --git a/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr b/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr deleted file mode 100644 index e9caae64beb..00000000000 --- a/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:93:24 - | -LL | b1.a[0].v.set(Some(&b2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `b2` dropped here while still borrowed - | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `b3` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:95:24 - | -LL | b1.a[1].v.set(Some(&b3)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `b3` dropped here while still borrowed - | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `b1` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:101:24 - | -LL | b3.a[0].v.set(Some(&b1)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `b1` dropped here while still borrowed - | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_arr_cycle_checked.rs b/src/test/ui/span/dropck_arr_cycle_checked.rs index 35145014a5a..ac31e4910d5 100644 --- a/src/test/ui/span/dropck_arr_cycle_checked.rs +++ b/src/test/ui/span/dropck_arr_cycle_checked.rs @@ -95,13 +95,10 @@ fn f() { b1.a[1].v.set(Some(&b3)); //~^ ERROR `b3` does not live long enough b2.a[0].v.set(Some(&b2)); - //~^ ERROR `b2` does not live long enough b2.a[1].v.set(Some(&b3)); - //~^ ERROR `b3` does not live long enough b3.a[0].v.set(Some(&b1)); //~^ ERROR `b1` does not live long enough b3.a[1].v.set(Some(&b2)); - //~^ ERROR `b2` does not live long enough } fn main() { diff --git a/src/test/ui/span/dropck_arr_cycle_checked.stderr b/src/test/ui/span/dropck_arr_cycle_checked.stderr index b2bacc7f678..068c779ae52 100644 --- a/src/test/ui/span/dropck_arr_cycle_checked.stderr +++ b/src/test/ui/span/dropck_arr_cycle_checked.stderr @@ -1,69 +1,43 @@ error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:93:25 + --> $DIR/dropck_arr_cycle_checked.rs:93:24 | LL | b1.a[0].v.set(Some(&b2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `b2` dropped here while still borrowed + | - + | | + | `b2` dropped here while still borrowed + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `b3` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:95:25 + --> $DIR/dropck_arr_cycle_checked.rs:95:24 | LL | b1.a[1].v.set(Some(&b3)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `b3` dropped here while still borrowed + | - + | | + | `b3` dropped here while still borrowed + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:97:25 - | -LL | b2.a[0].v.set(Some(&b2)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `b2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `b3` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:99:25 - | -LL | b2.a[1].v.set(Some(&b3)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `b3` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `b1` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:101:25 + --> $DIR/dropck_arr_cycle_checked.rs:99:24 | LL | b3.a[0].v.set(Some(&b1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `b1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `b1` dropped here while still borrowed + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` -error[E0597]: `b2` does not live long enough - --> $DIR/dropck_arr_cycle_checked.rs:103:25 - | -LL | b3.a[1].v.set(Some(&b2)); - | ^^ borrowed value does not live long enough -LL | -LL | } - | - `b2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr b/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr deleted file mode 100644 index 07ae138ac71..00000000000 --- a/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `d2` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:36:19 - | -LL | d1.p.set(Some(&d2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `d2` dropped here while still borrowed - | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `d1` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:38:19 - | -LL | d2.p.set(Some(&d1)); - | ^^^ borrowed value does not live long enough -LL | -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr index 497924208ab..07ae138ac71 100644 --- a/src/test/ui/span/dropck_direct_cycle_with_drop.stderr +++ b/src/test/ui/span/dropck_direct_cycle_with_drop.stderr @@ -1,24 +1,28 @@ error[E0597]: `d2` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:36:20 + --> $DIR/dropck_direct_cycle_with_drop.rs:36:19 | LL | d1.p.set(Some(&d2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `d2` dropped here while still borrowed + | - + | | + | `d2` dropped here while still borrowed + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `d1` does not live long enough - --> $DIR/dropck_direct_cycle_with_drop.rs:38:20 + --> $DIR/dropck_direct_cycle_with_drop.rs:38:19 | LL | d2.p.set(Some(&d1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | LL | } - | - `d1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` error: aborting due to 2 previous errors diff --git a/src/test/ui/span/dropck_misc_variants.nll.stderr b/src/test/ui/span/dropck_misc_variants.nll.stderr deleted file mode 100644 index 76e90574cef..00000000000 --- a/src/test/ui/span/dropck_misc_variants.nll.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0597]: `bomb` does not live long enough - --> $DIR/dropck_misc_variants.rs:23:36 - | -LL | _w = Wrap::<&[&str]>(NoisyDrop(&bomb)); - | ^^^^^ borrowed value does not live long enough -LL | } - | - - | | - | `bomb` dropped here while still borrowed - | borrow might be used here, when `_w` is dropped and runs the destructor for type `Wrap<&[&str]>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `v` does not live long enough - --> $DIR/dropck_misc_variants.rs:31:27 - | -LL | let u = NoisyDrop(&v); - | ^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `v` dropped here while still borrowed - | borrow might be used here, when `_w` is dropped and runs the destructor for closure - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_misc_variants.stderr b/src/test/ui/span/dropck_misc_variants.stderr index b2de455cdc8..76e90574cef 100644 --- a/src/test/ui/span/dropck_misc_variants.stderr +++ b/src/test/ui/span/dropck_misc_variants.stderr @@ -1,23 +1,29 @@ error[E0597]: `bomb` does not live long enough - --> $DIR/dropck_misc_variants.rs:23:37 + --> $DIR/dropck_misc_variants.rs:23:36 | LL | _w = Wrap::<&[&str]>(NoisyDrop(&bomb)); - | ^^^^ borrowed value does not live long enough + | ^^^^^ borrowed value does not live long enough LL | } - | - `bomb` dropped here while still borrowed + | - + | | + | `bomb` dropped here while still borrowed + | borrow might be used here, when `_w` is dropped and runs the destructor for type `Wrap<&[&str]>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `v` does not live long enough - --> $DIR/dropck_misc_variants.rs:31:28 + --> $DIR/dropck_misc_variants.rs:31:27 | LL | let u = NoisyDrop(&v); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } - | - `v` dropped here while still borrowed + | - + | | + | `v` dropped here while still borrowed + | borrow might be used here, when `_w` is dropped and runs the destructor for closure | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr deleted file mode 100644 index 05692515af8..00000000000 --- a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:98:24 - | -LL | c1.v[0].v.set(Some(&c2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c2` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:100:24 - | -LL | c1.v[1].v.set(Some(&c3)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c3` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:106:24 - | -LL | c3.v[0].v.set(Some(&c1)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c1` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/dropck_vec_cycle_checked.rs b/src/test/ui/span/dropck_vec_cycle_checked.rs index c80e0386e6a..bacd99c6825 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.rs +++ b/src/test/ui/span/dropck_vec_cycle_checked.rs @@ -100,13 +100,10 @@ fn f() { c1.v[1].v.set(Some(&c3)); //~^ ERROR `c3` does not live long enough c2.v[0].v.set(Some(&c2)); - //~^ ERROR `c2` does not live long enough c2.v[1].v.set(Some(&c3)); - //~^ ERROR `c3` does not live long enough c3.v[0].v.set(Some(&c1)); //~^ ERROR `c1` does not live long enough c3.v[1].v.set(Some(&c2)); - //~^ ERROR `c2` does not live long enough } fn main() { diff --git a/src/test/ui/span/dropck_vec_cycle_checked.stderr b/src/test/ui/span/dropck_vec_cycle_checked.stderr index 7f902388fac..7ff991c0c37 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.stderr +++ b/src/test/ui/span/dropck_vec_cycle_checked.stderr @@ -1,69 +1,43 @@ error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:98:25 + --> $DIR/dropck_vec_cycle_checked.rs:98:24 | LL | c1.v[0].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c2` dropped here while still borrowed + | - + | | + | `c2` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:100:25 + --> $DIR/dropck_vec_cycle_checked.rs:100:24 | LL | c1.v[1].v.set(Some(&c3)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c3` dropped here while still borrowed + | - + | | + | `c3` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:102:25 - | -LL | c2.v[0].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `c2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:104:25 - | -LL | c2.v[1].v.set(Some(&c3)); - | ^^ borrowed value does not live long enough -... -LL | } - | - `c3` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:106:25 + --> $DIR/dropck_vec_cycle_checked.rs:104:24 | LL | c3.v[0].v.set(Some(&c1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `c1` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` -error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:108:25 - | -LL | c3.v[1].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough -LL | -LL | } - | - `c2` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-11925.nll.stderr b/src/test/ui/span/issue-11925.nll.stderr deleted file mode 100644 index 1d317fc331f..00000000000 --- a/src/test/ui/span/issue-11925.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0515]: cannot return reference to local data `x` - --> $DIR/issue-11925.rs:8:35 - | -LL | let f = to_fn_once(move|| &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/span/issue-11925.rs b/src/test/ui/span/issue-11925.rs index 276aaa1c293..0f6472b05f7 100644 --- a/src/test/ui/span/issue-11925.rs +++ b/src/test/ui/span/issue-11925.rs @@ -5,7 +5,7 @@ fn to_fn_once>(f: F) -> F { f } fn main() { let r = { let x: Box<_> = box 42; - let f = to_fn_once(move|| &x); //~ ERROR does not live long enough + let f = to_fn_once(move|| &x); //~ ERROR cannot return reference to local data `x` f() }; diff --git a/src/test/ui/span/issue-11925.stderr b/src/test/ui/span/issue-11925.stderr index c75022261a8..1d317fc331f 100644 --- a/src/test/ui/span/issue-11925.stderr +++ b/src/test/ui/span/issue-11925.stderr @@ -1,15 +1,9 @@ -error[E0597]: `x` does not live long enough - --> $DIR/issue-11925.rs:8:36 +error[E0515]: cannot return reference to local data `x` + --> $DIR/issue-11925.rs:8:35 | LL | let f = to_fn_once(move|| &x); - | ^ - | | - | borrowed value does not live long enough - | `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here + | ^^ 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 E0597`. +For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/span/issue-15480.nll.stderr b/src/test/ui/span/issue-15480.nll.stderr deleted file mode 100644 index 23ee2256dd8..00000000000 --- a/src/test/ui/span/issue-15480.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-15480.rs:5:10 - | -LL | &id(3) - | ^^^^^ creates a temporary which is freed while still in use -LL | ]; - | - temporary value is freed at the end of this statement -... -LL | for &&x in &v { - | -- 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/span/issue-15480.rs b/src/test/ui/span/issue-15480.rs index c1024234094..b286d94178a 100644 --- a/src/test/ui/span/issue-15480.rs +++ b/src/test/ui/span/issue-15480.rs @@ -4,7 +4,7 @@ fn main() { let v = vec![ &id(3) ]; - //~^^ ERROR borrowed value does not live long enough + //~^^ ERROR temporary value dropped while borrowed for &&x in &v { println!("{}", x + 3); diff --git a/src/test/ui/span/issue-15480.stderr b/src/test/ui/span/issue-15480.stderr index c5e3899faca..23ee2256dd8 100644 --- a/src/test/ui/span/issue-15480.stderr +++ b/src/test/ui/span/issue-15480.stderr @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-15480.rs:5:10 | LL | &id(3) - | ^^^^^ temporary value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use LL | ]; - | - temporary value dropped here while still borrowed + | - temporary value is freed at the end of this statement ... -LL | } - | - temporary value needs to live until here +LL | for &&x in &v { + | -- 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/span/issue-23338-locals-die-before-temps-of-body.nll.stderr b/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr deleted file mode 100644 index 46969458145..00000000000 --- a/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr +++ /dev/null @@ -1,34 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:10:5 - | -LL | y.borrow().clone() - | ^--------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | } - | - - | | - | `y` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error[E0597]: `y` does not live long enough - --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:17:9 - | -LL | y.borrow().clone() - | ^--------- - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -LL | }; - | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` - | | - | `y` dropped here while still borrowed - | - = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr b/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr index f18f0da3199..46969458145 100644 --- a/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr +++ b/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr @@ -2,21 +2,32 @@ error[E0597]: `y` does not live long enough --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:10:5 | LL | y.borrow().clone() - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | } - | - `y` dropped here while still borrowed + | - + | | + | `y` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` | - = note: values in a scope are dropped in the opposite order they are created + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `y` does not live long enough --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:17:9 | LL | y.borrow().clone() - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | }; - | -- borrowed value needs to live until here + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` | | | `y` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr b/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr deleted file mode 100644 index 809e60a8c8a..00000000000 --- a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-child-has-items-via-parent.rs:28:18 - | -LL | _d = D_Child(&d1); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_Child` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr b/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr index ad90fcd54d4..809e60a8c8a 100644 --- a/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr +++ b/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr @@ -1,13 +1,16 @@ error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-child-has-items-via-parent.rs:28:19 + --> $DIR/issue-24805-dropck-child-has-items-via-parent.rs:28:18 | LL | _d = D_Child(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_Child` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr b/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr deleted file mode 100644 index 2e217066915..00000000000 --- a/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:37:26 - | -LL | _d = D_HasSelfMethod(&d1); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasSelfMethod` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:43:33 - | -LL | _d = D_HasMethodWithSelfArg(&d1); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasMethodWithSelfArg` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:49:20 - | -LL | _d = D_HasType(&d1); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasType` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr b/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr index 3de40149287..2e217066915 100644 --- a/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr +++ b/src/test/ui/span/issue-24805-dropck-trait-has-items.stderr @@ -1,32 +1,41 @@ error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:37:27 + --> $DIR/issue-24805-dropck-trait-has-items.rs:37:26 | LL | _d = D_HasSelfMethod(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasSelfMethod` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:43:34 + --> $DIR/issue-24805-dropck-trait-has-items.rs:43:33 | LL | _d = D_HasMethodWithSelfArg(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasMethodWithSelfArg` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `d1` does not live long enough - --> $DIR/issue-24805-dropck-trait-has-items.rs:49:21 + --> $DIR/issue-24805-dropck-trait-has-items.rs:49:20 | LL | _d = D_HasType(&d1); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasType` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 3 previous errors diff --git a/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr b/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr deleted file mode 100644 index 18a3dc9e6de..00000000000 --- a/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `d1` does not live long enough - --> $DIR/issue-24895-copy-clone-dropck.rs:27:14 - | -LL | d2 = D(S(&d1, "inner"), "d2"); - | ^^^ borrowed value does not live long enough -LL | } - | - - | | - | `d1` dropped here while still borrowed - | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-24895-copy-clone-dropck.stderr b/src/test/ui/span/issue-24895-copy-clone-dropck.stderr index 91859194318..18a3dc9e6de 100644 --- a/src/test/ui/span/issue-24895-copy-clone-dropck.stderr +++ b/src/test/ui/span/issue-24895-copy-clone-dropck.stderr @@ -1,12 +1,15 @@ error[E0597]: `d1` does not live long enough - --> $DIR/issue-24895-copy-clone-dropck.rs:27:15 + --> $DIR/issue-24895-copy-clone-dropck.rs:27:14 | LL | d2 = D(S(&d1, "inner"), "d2"); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | } - | - `d1` dropped here while still borrowed + | - + | | + | `d1` dropped here while still borrowed + | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/span/issue-25199.nll.stderr b/src/test/ui/span/issue-25199.nll.stderr deleted file mode 100644 index d70a4afc1bf..00000000000 --- a/src/test/ui/span/issue-25199.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `container` does not live long enough - --> $DIR/issue-25199.rs:70:27 - | -LL | let test = Test{test: &container}; - | ^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `container` dropped here while still borrowed - | borrow might be used here, when `container` is dropped and runs the destructor for type `Container<'_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-25199.rs b/src/test/ui/span/issue-25199.rs index 4ef57457ca3..ed690443d4d 100644 --- a/src/test/ui/span/issue-25199.rs +++ b/src/test/ui/span/issue-25199.rs @@ -71,5 +71,4 @@ fn main() { //~^ ERROR `container` does not live long enough println!("container.v[30]: {:?}", container.v.v[30]); container.store(test); - //~^ ERROR `container` does not live long enough } diff --git a/src/test/ui/span/issue-25199.stderr b/src/test/ui/span/issue-25199.stderr index 6d8320bc053..d70a4afc1bf 100644 --- a/src/test/ui/span/issue-25199.stderr +++ b/src/test/ui/span/issue-25199.stderr @@ -1,25 +1,15 @@ error[E0597]: `container` does not live long enough - --> $DIR/issue-25199.rs:70:28 + --> $DIR/issue-25199.rs:70:27 | LL | let test = Test{test: &container}; - | ^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `container` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `container` dropped here while still borrowed + | borrow might be used here, when `container` is dropped and runs the destructor for type `Container<'_>` -error[E0597]: `container` does not live long enough - --> $DIR/issue-25199.rs:73:5 - | -LL | container.store(test); - | ^^^^^^^^^ borrowed value does not live long enough -LL | -LL | } - | - `container` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-26656.nll.stderr b/src/test/ui/span/issue-26656.nll.stderr deleted file mode 100644 index 1e939c484fb..00000000000 --- a/src/test/ui/span/issue-26656.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `ticking` does not live long enough - --> $DIR/issue-26656.rs:40:35 - | -LL | zook.button = B::BigRedButton(&ticking); - | ^^^^^^^^ borrowed value does not live long enough -LL | } - | - - | | - | `ticking` dropped here while still borrowed - | borrow might be used here, when `zook` is dropped and runs the `Drop` code for type `Zook` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-26656.stderr b/src/test/ui/span/issue-26656.stderr index ba2befb90a9..1e939c484fb 100644 --- a/src/test/ui/span/issue-26656.stderr +++ b/src/test/ui/span/issue-26656.stderr @@ -1,12 +1,15 @@ error[E0597]: `ticking` does not live long enough - --> $DIR/issue-26656.rs:40:36 + --> $DIR/issue-26656.rs:40:35 | LL | zook.button = B::BigRedButton(&ticking); - | ^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^ borrowed value does not live long enough LL | } - | - `ticking` dropped here while still borrowed + | - + | | + | `ticking` dropped here while still borrowed + | borrow might be used here, when `zook` is dropped and runs the `Drop` code for type `Zook` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to previous error diff --git a/src/test/ui/span/issue-29106.nll.stderr b/src/test/ui/span/issue-29106.nll.stderr deleted file mode 100644 index 3b403de12d5..00000000000 --- a/src/test/ui/span/issue-29106.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:16:26 - | -LL | y = Arc::new(Foo(&x)); - | ^^ borrowed value does not live long enough -LL | } - | - - | | - | `x` dropped here while still borrowed - | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::sync::Arc` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:23:25 - | -LL | y = Rc::new(Foo(&x)); - | ^^ borrowed value does not live long enough -LL | } - | - - | | - | `x` dropped here while still borrowed - | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::rc::Rc` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-29106.stderr b/src/test/ui/span/issue-29106.stderr index bb2f8462246..3b403de12d5 100644 --- a/src/test/ui/span/issue-29106.stderr +++ b/src/test/ui/span/issue-29106.stderr @@ -1,22 +1,28 @@ error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:16:27 + --> $DIR/issue-29106.rs:16:26 | LL | y = Arc::new(Foo(&x)); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } - | - `x` dropped here while still borrowed + | - + | | + | `x` dropped here while still borrowed + | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::sync::Arc` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `x` does not live long enough - --> $DIR/issue-29106.rs:23:26 + --> $DIR/issue-29106.rs:23:25 | LL | y = Rc::new(Foo(&x)); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } - | - `x` dropped here while still borrowed + | - + | | + | `x` dropped here while still borrowed + | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::rc::Rc` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-36537.nll.stderr b/src/test/ui/span/issue-36537.nll.stderr deleted file mode 100644 index edb804e850e..00000000000 --- a/src/test/ui/span/issue-36537.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/issue-36537.rs:5:9 - | -LL | p = &a; - | ^^^^^^ borrowed value does not live long enough -... -LL | } - | - `a` dropped here while still borrowed -LL | p.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-36537.stderr b/src/test/ui/span/issue-36537.stderr index d3bcbb25add..edb804e850e 100644 --- a/src/test/ui/span/issue-36537.stderr +++ b/src/test/ui/span/issue-36537.stderr @@ -1,14 +1,13 @@ error[E0597]: `a` does not live long enough - --> $DIR/issue-36537.rs:5:14 + --> $DIR/issue-36537.rs:5:9 | LL | p = &a; - | ^ borrowed value does not live long enough + | ^^^^^^ borrowed value does not live long enough ... LL | } | - `a` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | p.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/issue-40157.nll.stderr b/src/test/ui/span/issue-40157.nll.stderr deleted file mode 100644 index 0b365c3f7b6..00000000000 --- a/src/test/ui/span/issue-40157.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `foo` does not live long enough - --> $DIR/issue-40157.rs:2:53 - | -LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });} - | ------------------------^^^--------- - | | | | - | | | `foo` dropped here while still borrowed - | | borrowed value does not live long enough - | borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue-40157.stderr b/src/test/ui/span/issue-40157.stderr index 55fc8d8ee5f..0b365c3f7b6 100644 --- a/src/test/ui/span/issue-40157.stderr +++ b/src/test/ui/span/issue-40157.stderr @@ -2,13 +2,11 @@ error[E0597]: `foo` does not live long enough --> $DIR/issue-40157.rs:2:53 | LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });} - | -----------------------------------------------^^^---------------------- - | | | | - | | | `foo` dropped here while still borrowed - | | borrowed value does not live long enough - | borrowed value needs to live until here - | - = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + | ------------------------^^^--------- + | | | | + | | | `foo` dropped here while still borrowed + | | borrowed value does not live long enough + | borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/issue28498-reject-ex1.nll.stderr b/src/test/ui/span/issue28498-reject-ex1.nll.stderr deleted file mode 100644 index 86e2d8c56b0..00000000000 --- a/src/test/ui/span/issue28498-reject-ex1.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0713]: borrow may still be in use when destructor runs - --> $DIR/issue28498-reject-ex1.rs:34:29 - | -LL | foo.data[0].1.set(Some(&foo.data[1])); - | ^^^^^^^^ -... -LL | } - | - - | | - | here, drop of `foo` needs exclusive access to `foo.data`, because the type `Foo>` implements the `Drop` trait - | borrow might be used here, when `foo` is dropped and runs the `Drop` code for type `Foo` - | - = 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 E0713`. diff --git a/src/test/ui/span/issue28498-reject-ex1.rs b/src/test/ui/span/issue28498-reject-ex1.rs index 05104d1cdc0..4d1b4125503 100644 --- a/src/test/ui/span/issue28498-reject-ex1.rs +++ b/src/test/ui/span/issue28498-reject-ex1.rs @@ -32,7 +32,6 @@ fn main() { foo.data.push(Concrete(0, Cell::new(None))); foo.data[0].1.set(Some(&foo.data[1])); - //~^ ERROR `foo.data` does not live long enough + //~^ ERROR borrow may still be in use when destructor runs foo.data[1].1.set(Some(&foo.data[0])); - //~^ ERROR `foo.data` does not live long enough } diff --git a/src/test/ui/span/issue28498-reject-ex1.stderr b/src/test/ui/span/issue28498-reject-ex1.stderr index 1438b95d733..86e2d8c56b0 100644 --- a/src/test/ui/span/issue28498-reject-ex1.stderr +++ b/src/test/ui/span/issue28498-reject-ex1.stderr @@ -1,25 +1,17 @@ -error[E0597]: `foo.data` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue28498-reject-ex1.rs:34:29 | LL | foo.data[0].1.set(Some(&foo.data[1])); - | ^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^ ... LL | } - | - `foo.data` dropped here while still borrowed + | - + | | + | here, drop of `foo` needs exclusive access to `foo.data`, because the type `Foo>` implements the `Drop` trait + | borrow might be used here, when `foo` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: consider using a `let` binding to create a longer lived value -error[E0597]: `foo.data` does not live long enough - --> $DIR/issue28498-reject-ex1.rs:36:29 - | -LL | foo.data[1].1.set(Some(&foo.data[0])); - | ^^^^^^^^ borrowed value does not live long enough -LL | -LL | } - | - `foo.data` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created +error: aborting due to previous error -error: aborting due to 2 previous errors - -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/span/issue28498-reject-lifetime-param.nll.stderr b/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr deleted file mode 100644 index 3273b51ba0f..00000000000 --- a/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-lifetime-param.rs:34:19 - | -LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `first_dropped` dropped here while still borrowed - | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-lifetime-param.rs b/src/test/ui/span/issue28498-reject-lifetime-param.rs index 062636af3f1..9bc01766be5 100644 --- a/src/test/ui/span/issue28498-reject-lifetime-param.rs +++ b/src/test/ui/span/issue28498-reject-lifetime-param.rs @@ -29,8 +29,7 @@ fn main() { last_dropped = ScribbleOnDrop(format!("last")); first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped); - //~^ ERROR `last_dropped` does not live long enough + foo0 = Foo(0, &last_dropped); // OK foo1 = Foo(1, &first_dropped); //~^ ERROR `first_dropped` does not live long enough diff --git a/src/test/ui/span/issue28498-reject-lifetime-param.stderr b/src/test/ui/span/issue28498-reject-lifetime-param.stderr index 0e51729f8d6..1dcb40e5d9c 100644 --- a/src/test/ui/span/issue28498-reject-lifetime-param.stderr +++ b/src/test/ui/span/issue28498-reject-lifetime-param.stderr @@ -1,25 +1,17 @@ -error[E0597]: `last_dropped` does not live long enough - --> $DIR/issue28498-reject-lifetime-param.rs:32:20 - | -LL | foo0 = Foo(0, &last_dropped); - | ^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `last_dropped` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-lifetime-param.rs:34:20 + --> $DIR/issue28498-reject-lifetime-param.rs:33:19 | LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `first_dropped` dropped here while still borrowed + | - + | | + | `first_dropped` dropped here while still borrowed + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr b/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr deleted file mode 100644 index ae08e3e5e6c..00000000000 --- a/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-passed-to-fn.rs:36:19 - | -LL | foo1 = Foo(1, &first_dropped, Box::new(callback)); - | ^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `first_dropped` dropped here while still borrowed - | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-passed-to-fn.rs b/src/test/ui/span/issue28498-reject-passed-to-fn.rs index 27a757e850b..c59de5df411 100644 --- a/src/test/ui/span/issue28498-reject-passed-to-fn.rs +++ b/src/test/ui/span/issue28498-reject-passed-to-fn.rs @@ -31,8 +31,7 @@ fn main() { last_dropped = ScribbleOnDrop(format!("last")); first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped, Box::new(callback)); - //~^ ERROR `last_dropped` does not live long enough + foo0 = Foo(0, &last_dropped, Box::new(callback)); // OK foo1 = Foo(1, &first_dropped, Box::new(callback)); //~^ ERROR `first_dropped` does not live long enough diff --git a/src/test/ui/span/issue28498-reject-passed-to-fn.stderr b/src/test/ui/span/issue28498-reject-passed-to-fn.stderr index 80533c79f10..214a6f6d65c 100644 --- a/src/test/ui/span/issue28498-reject-passed-to-fn.stderr +++ b/src/test/ui/span/issue28498-reject-passed-to-fn.stderr @@ -1,25 +1,17 @@ -error[E0597]: `last_dropped` does not live long enough - --> $DIR/issue28498-reject-passed-to-fn.rs:34:20 - | -LL | foo0 = Foo(0, &last_dropped, Box::new(callback)); - | ^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `last_dropped` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-passed-to-fn.rs:36:20 + --> $DIR/issue28498-reject-passed-to-fn.rs:35:19 | LL | foo1 = Foo(1, &first_dropped, Box::new(callback)); - | ^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `first_dropped` dropped here while still borrowed + | - + | | + | `first_dropped` dropped here while still borrowed + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr b/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr deleted file mode 100644 index 600fd539fe4..00000000000 --- a/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-trait-bound.rs:36:19 - | -LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `first_dropped` dropped here while still borrowed - | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/issue28498-reject-trait-bound.rs b/src/test/ui/span/issue28498-reject-trait-bound.rs index 3ea67d1662d..8813180c891 100644 --- a/src/test/ui/span/issue28498-reject-trait-bound.rs +++ b/src/test/ui/span/issue28498-reject-trait-bound.rs @@ -31,8 +31,7 @@ fn main() { last_dropped = ScribbleOnDrop(format!("last")); first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped); - //~^ ERROR `last_dropped` does not live long enough + foo0 = Foo(0, &last_dropped); // OK foo1 = Foo(1, &first_dropped); //~^ ERROR `first_dropped` does not live long enough diff --git a/src/test/ui/span/issue28498-reject-trait-bound.stderr b/src/test/ui/span/issue28498-reject-trait-bound.stderr index 3ce4dd9fdd6..d4fe291bef3 100644 --- a/src/test/ui/span/issue28498-reject-trait-bound.stderr +++ b/src/test/ui/span/issue28498-reject-trait-bound.stderr @@ -1,25 +1,17 @@ -error[E0597]: `last_dropped` does not live long enough - --> $DIR/issue28498-reject-trait-bound.rs:34:20 - | -LL | foo0 = Foo(0, &last_dropped); - | ^^^^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `last_dropped` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - error[E0597]: `first_dropped` does not live long enough - --> $DIR/issue28498-reject-trait-bound.rs:36:20 + --> $DIR/issue28498-reject-trait-bound.rs:35:19 | LL | foo1 = Foo(1, &first_dropped); - | ^^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - `first_dropped` dropped here while still borrowed + | - + | | + | `first_dropped` dropped here while still borrowed + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/mut-arg-hint.nll.stderr b/src/test/ui/span/mut-arg-hint.nll.stderr deleted file mode 100644 index 8027cf69cf4..00000000000 --- a/src/test/ui/span/mut-arg-hint.nll.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference - --> $DIR/mut-arg-hint.rs:3:9 - | -LL | fn foo(mut a: &String) { - | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` -LL | a.push_str("bar"); - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference - --> $DIR/mut-arg-hint.rs:8:5 - | -LL | pub fn foo<'a>(mut a: &'a String) { - | ---------- help: consider changing this to be a mutable reference: `&'a mut String` -LL | a.push_str("foo"); - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference - --> $DIR/mut-arg-hint.rs:15:9 - | -LL | pub fn foo(mut a: &String) { - | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` -LL | a.push_str("foo"); - | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/span/mut-arg-hint.rs b/src/test/ui/span/mut-arg-hint.rs index 3d46613aa7a..d7ff1f0de41 100644 --- a/src/test/ui/span/mut-arg-hint.rs +++ b/src/test/ui/span/mut-arg-hint.rs @@ -1,18 +1,18 @@ trait B { fn foo(mut a: &String) { - a.push_str("bar"); //~ ERROR cannot borrow immutable borrowed content + a.push_str("bar"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference } } pub fn foo<'a>(mut a: &'a String) { - a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content + a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference } struct A {} impl A { pub fn foo(mut a: &String) { - a.push_str("foo"); //~ ERROR cannot borrow immutable borrowed content + a.push_str("foo"); //~ ERROR cannot borrow `*a` as mutable, as it is behind a `&` reference } } diff --git a/src/test/ui/span/mut-arg-hint.stderr b/src/test/ui/span/mut-arg-hint.stderr index ce5786186ea..8027cf69cf4 100644 --- a/src/test/ui/span/mut-arg-hint.stderr +++ b/src/test/ui/span/mut-arg-hint.stderr @@ -1,26 +1,26 @@ -error[E0596]: cannot borrow immutable borrowed content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:3:9 | LL | fn foo(mut a: &String) { - | ------- use `&mut String` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` LL | a.push_str("bar"); - | ^ cannot borrow as mutable + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable borrowed content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:8:5 | LL | pub fn foo<'a>(mut a: &'a String) { - | ---------- use `&'a mut String` here to make mutable + | ---------- help: consider changing this to be a mutable reference: `&'a mut String` LL | a.push_str("foo"); - | ^ cannot borrow as mutable + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0596]: cannot borrow immutable borrowed content `*a` as mutable +error[E0596]: cannot borrow `*a` as mutable, as it is behind a `&` reference --> $DIR/mut-arg-hint.rs:15:9 | LL | pub fn foo(mut a: &String) { - | ------- use `&mut String` here to make mutable + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` LL | a.push_str("foo"); - | ^ cannot borrow as mutable + | ^ `a` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 3 previous errors diff --git a/src/test/ui/span/mut-ptr-cant-outlive-ref.nll.stderr b/src/test/ui/span/mut-ptr-cant-outlive-ref.nll.stderr deleted file mode 100644 index 21b29464df5..00000000000 --- a/src/test/ui/span/mut-ptr-cant-outlive-ref.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `b` does not live long enough - --> $DIR/mut-ptr-cant-outlive-ref.rs:8:15 - | -LL | p = &*b; - | ^ borrowed value does not live long enough -LL | } - | - `b` dropped here while still borrowed -LL | -LL | p.use_ref(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr b/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr index f6cf568a8d2..21b29464df5 100644 --- a/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr +++ b/src/test/ui/span/mut-ptr-cant-outlive-ref.stderr @@ -5,9 +5,9 @@ LL | p = &*b; | ^ borrowed value does not live long enough LL | } | - `b` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | +LL | p.use_ref(); + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/range-2.nll.stderr b/src/test/ui/span/range-2.nll.stderr deleted file mode 100644 index 8ca8156b083..00000000000 --- a/src/test/ui/span/range-2.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0597]: `a` does not live long enough - --> $DIR/range-2.rs:7:9 - | -LL | let r = { - | - borrow later stored here -... -LL | &a..&b - | ^^ borrowed value does not live long enough -LL | }; - | - `a` dropped here while still borrowed - -error[E0597]: `b` does not live long enough - --> $DIR/range-2.rs:7:13 - | -LL | let r = { - | - borrow later stored here -... -LL | &a..&b - | ^^ borrowed value does not live long enough -LL | }; - | - `b` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/range-2.stderr b/src/test/ui/span/range-2.stderr index 7d0edd6971c..8ca8156b083 100644 --- a/src/test/ui/span/range-2.stderr +++ b/src/test/ui/span/range-2.stderr @@ -1,24 +1,24 @@ error[E0597]: `a` does not live long enough - --> $DIR/range-2.rs:7:10 + --> $DIR/range-2.rs:7:9 | +LL | let r = { + | - borrow later stored here +... LL | &a..&b - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `a` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `b` does not live long enough - --> $DIR/range-2.rs:7:14 + --> $DIR/range-2.rs:7:13 | +LL | let r = { + | - borrow later stored here +... LL | &a..&b - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `b` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error: aborting due to 2 previous errors diff --git a/src/test/ui/span/regionck-unboxed-closure-lifetimes.nll.stderr b/src/test/ui/span/regionck-unboxed-closure-lifetimes.nll.stderr deleted file mode 100644 index 8e9cd595154..00000000000 --- a/src/test/ui/span/regionck-unboxed-closure-lifetimes.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `c` does not live long enough - --> $DIR/regionck-unboxed-closure-lifetimes.rs:8:21 - | -LL | let c_ref = &c; - | ^^ borrowed value does not live long enough -... -LL | } - | - `c` dropped here while still borrowed -LL | f.use_mut(); - | - borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr b/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr index b3f09669f5f..8e9cd595154 100644 --- a/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr +++ b/src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr @@ -1,14 +1,13 @@ error[E0597]: `c` does not live long enough - --> $DIR/regionck-unboxed-closure-lifetimes.rs:8:22 + --> $DIR/regionck-unboxed-closure-lifetimes.rs:8:21 | LL | let c_ref = &c; - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } | - `c` dropped here while still borrowed LL | f.use_mut(); -LL | } - | - borrowed value needs to live until here + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr deleted file mode 100644 index 2be2d0ff7b5..00000000000 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:12:27 - | -LL | let ss: &isize = &id(1); - | ^^^^^ creates a temporary which is freed while still in use -... -LL | } - | - temporary value is freed at the end of this statement -LL | } - | - borrow might be used here, when `blah` is dropped and runs the destructor for type `std::boxed::Box` - | - = 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/span/regions-close-over-borrowed-ref-in-obj.rs b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs index 9ca352a07fc..13e651fa56b 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs @@ -10,7 +10,7 @@ fn main() { let blah; { let ss: &isize = &id(1); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed blah = box ss as Box; } } diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr index 8a853e7ce59..2be2d0ff7b5 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.stderr @@ -1,14 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:12:27 | LL | let ss: &isize = &id(1); - | ^^^^^ temporary value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use ... LL | } - | - temporary value dropped here while still borrowed + | - temporary value is freed at the end of this statement LL | } - | - temporary value needs to live until here + | - borrow might be used here, when `blah` is dropped and runs the destructor for type `std::boxed::Box` + | + = 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/span/regions-close-over-type-parameter-2.nll.stderr b/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr deleted file mode 100644 index 2e584d9a884..00000000000 --- a/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `tmp0` does not live long enough - --> $DIR/regions-close-over-type-parameter-2.rs:23:20 - | -LL | let tmp1 = &tmp0; - | ^^^^^ borrowed value does not live long enough -LL | repeater3(tmp1) - | --------------- borrow later captured here by trait object -LL | }; - | - `tmp0` 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/span/regions-close-over-type-parameter-2.stderr b/src/test/ui/span/regions-close-over-type-parameter-2.stderr index 5ee155c1d18..2e584d9a884 100644 --- a/src/test/ui/span/regions-close-over-type-parameter-2.stderr +++ b/src/test/ui/span/regions-close-over-type-parameter-2.stderr @@ -1,13 +1,12 @@ error[E0597]: `tmp0` does not live long enough - --> $DIR/regions-close-over-type-parameter-2.rs:23:21 + --> $DIR/regions-close-over-type-parameter-2.rs:23:20 | LL | let tmp1 = &tmp0; - | ^^^^ borrowed value does not live long enough + | ^^^^^ borrowed value does not live long enough LL | repeater3(tmp1) + | --------------- borrow later captured here by trait object LL | }; - | -- borrowed value needs to live until here - | | - | `tmp0` dropped here while still borrowed + | - `tmp0` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr b/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr deleted file mode 100644 index 42df6685297..00000000000 --- a/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/regions-escape-loop-via-variable.rs:11:13 - | -LL | let x = 1 + *p; - | -- borrow later used here -LL | p = &x; - | ^^ borrowed value does not live long enough -LL | } - | - `x` 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/span/regions-escape-loop-via-variable.stderr b/src/test/ui/span/regions-escape-loop-via-variable.stderr index ef36b81f493..42df6685297 100644 --- a/src/test/ui/span/regions-escape-loop-via-variable.stderr +++ b/src/test/ui/span/regions-escape-loop-via-variable.stderr @@ -1,13 +1,12 @@ error[E0597]: `x` does not live long enough - --> $DIR/regions-escape-loop-via-variable.rs:11:14 + --> $DIR/regions-escape-loop-via-variable.rs:11:13 | +LL | let x = 1 + *p; + | -- borrow later used here LL | p = &x; - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | } | - `x` dropped here while still borrowed -LL | -LL | } - | - borrowed value needs to live until here error: aborting due to previous error diff --git a/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr b/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr deleted file mode 100644 index b47250db723..00000000000 --- a/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:5:11 - | -LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here -LL | while x < 10 { - | ^ use of borrowed `x` -LL | let mut z = x; -LL | _y.push(&mut z); - | -- borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:6:21 - | -LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here -LL | while x < 10 { -LL | let mut z = x; - | ^ use of borrowed `x` -LL | _y.push(&mut z); - | -- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/regions-escape-loop-via-vec.rs:7:17 - | -LL | _y.push(&mut z); - | -- ^^^^^^ borrowed value does not live long enough - | | - | borrow later used here -... -LL | } - | - `z` dropped here while still borrowed - -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:9:9 - | -LL | let mut _y = vec![&mut x]; - | ------ borrow of `x` occurs here -... -LL | _y.push(&mut z); - | -- borrow later used here -LL | -LL | x += 1; - | ^^^^^^ use of borrowed `x` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0503, E0597. -For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/span/regions-escape-loop-via-vec.rs b/src/test/ui/span/regions-escape-loop-via-vec.rs index 52f3dc37c90..1fceb096967 100644 --- a/src/test/ui/span/regions-escape-loop-via-vec.rs +++ b/src/test/ui/span/regions-escape-loop-via-vec.rs @@ -6,7 +6,7 @@ fn broken() { let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed _y.push(&mut z); //~^ ERROR `z` does not live long enough - x += 1; //~ ERROR cannot assign + x += 1; //~ ERROR cannot use `x` because it was mutably borrowed } } diff --git a/src/test/ui/span/regions-escape-loop-via-vec.stderr b/src/test/ui/span/regions-escape-loop-via-vec.stderr index 9e46f86510a..b47250db723 100644 --- a/src/test/ui/span/regions-escape-loop-via-vec.stderr +++ b/src/test/ui/span/regions-escape-loop-via-vec.stderr @@ -1,41 +1,49 @@ -error[E0597]: `z` does not live long enough - --> $DIR/regions-escape-loop-via-vec.rs:7:22 - | -LL | _y.push(&mut z); - | ^ borrowed value does not live long enough -... -LL | } - | - `z` dropped here while still borrowed -LL | } - | - borrowed value needs to live until here - error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:5:11 | LL | let mut _y = vec![&mut x]; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | while x < 10 { | ^ use of borrowed `x` +LL | let mut z = x; +LL | _y.push(&mut z); + | -- borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/regions-escape-loop-via-vec.rs:6:13 + --> $DIR/regions-escape-loop-via-vec.rs:6:21 | LL | let mut _y = vec![&mut x]; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here LL | while x < 10 { LL | let mut z = x; - | ^^^^^ use of borrowed `x` + | ^ use of borrowed `x` +LL | _y.push(&mut z); + | -- borrow later used here -error[E0506]: cannot assign to `x` because it is borrowed +error[E0597]: `z` does not live long enough + --> $DIR/regions-escape-loop-via-vec.rs:7:17 + | +LL | _y.push(&mut z); + | -- ^^^^^^ borrowed value does not live long enough + | | + | borrow later used here +... +LL | } + | - `z` dropped here while still borrowed + +error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:9:9 | LL | let mut _y = vec![&mut x]; - | - borrow of `x` occurs here + | ------ borrow of `x` occurs here ... +LL | _y.push(&mut z); + | -- borrow later used here +LL | LL | x += 1; - | ^^^^^^ assignment to borrowed `x` occurs here + | ^^^^^^ use of borrowed `x` error: aborting due to 4 previous errors -Some errors have detailed explanations: E0503, E0506, E0597. +Some errors have detailed explanations: E0503, E0597. For more information about an error, try `rustc --explain E0503`. diff --git a/src/test/ui/span/regions-infer-borrow-scope-within-loop.nll.stderr b/src/test/ui/span/regions-infer-borrow-scope-within-loop.nll.stderr deleted file mode 100644 index fd67c65c4e9..00000000000 --- a/src/test/ui/span/regions-infer-borrow-scope-within-loop.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `*x` does not live long enough - --> $DIR/regions-infer-borrow-scope-within-loop.rs:13:20 - | -LL | y = borrow(&*x); - | ^^^ borrowed value does not live long enough -... -LL | } - | - `*x` dropped here while still borrowed -LL | assert!(*y != 0); - | -- borrow later used here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr b/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr index 94abbcef035..fd67c65c4e9 100644 --- a/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr +++ b/src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr @@ -1,14 +1,13 @@ error[E0597]: `*x` does not live long enough - --> $DIR/regions-infer-borrow-scope-within-loop.rs:13:21 + --> $DIR/regions-infer-borrow-scope-within-loop.rs:13:20 | LL | y = borrow(&*x); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } | - `*x` dropped here while still borrowed LL | assert!(*y != 0); -LL | } - | - borrowed value needs to live until here + | -- borrow later used here error: aborting due to previous error diff --git a/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr b/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr deleted file mode 100644 index 65d10c1305b..00000000000 --- a/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-ensures-scoping.rs:16:17 - | -LL | let bad = { - | --- borrow later stored here -LL | let x = 1; -LL | let y = &x; - | ^^ borrowed value does not live long enough -... -LL | }; - | - `x` dropped here while still borrowed - -error[E0597]: `y` does not live long enough - --> $DIR/send-is-not-static-ensures-scoping.rs:20:22 - | -LL | let bad = { - | --- borrow later stored here -... -LL | scoped(|| { - | -- value captured here -LL | let _z = y; - | ^ borrowed value does not live long enough -... -LL | }; - | - `y` dropped here while still borrowed - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/send-is-not-static-ensures-scoping.stderr b/src/test/ui/span/send-is-not-static-ensures-scoping.stderr index 47026284fb1..65d10c1305b 100644 --- a/src/test/ui/span/send-is-not-static-ensures-scoping.stderr +++ b/src/test/ui/span/send-is-not-static-ensures-scoping.stderr @@ -1,28 +1,28 @@ error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-ensures-scoping.rs:16:18 + --> $DIR/send-is-not-static-ensures-scoping.rs:16:17 | +LL | let bad = { + | --- borrow later stored here +LL | let x = 1; LL | let y = &x; - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `y` does not live long enough --> $DIR/send-is-not-static-ensures-scoping.rs:20:22 | +LL | let bad = { + | --- borrow later stored here +... LL | scoped(|| { - | -- capture occurs here + | -- value captured here LL | let _z = y; | ^ borrowed value does not live long enough ... LL | }; - | - borrowed value only lives until here -... -LL | } - | - borrowed value needs to live until here + | - `y` dropped here while still borrowed error: aborting due to 2 previous errors diff --git a/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr b/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr deleted file mode 100644 index bcd07e11647..00000000000 --- a/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:11:20 - | -LL | let lock = { - | ---- borrow later stored here -LL | let x = 1; -LL | Mutex::new(&x) - | ^^ borrowed value does not live long enough -LL | }; - | - `x` dropped here while still borrowed - -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:21:21 - | -LL | let lock = { - | ---- borrow later stored here -LL | let x = 1; -LL | RwLock::new(&x) - | ^^ borrowed value does not live long enough -LL | }; - | - `x` dropped here while still borrowed - -error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:31:25 - | -LL | let (_tx, rx) = { - | --- borrow later used here -... -LL | let _ = tx.send(&x); - | ^^ borrowed value does not live long enough -LL | (tx, rx) -LL | }; - | - `x` dropped here while still borrowed - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/send-is-not-static-std-sync-2.stderr b/src/test/ui/span/send-is-not-static-std-sync-2.stderr index 4172731745e..bcd07e11647 100644 --- a/src/test/ui/span/send-is-not-static-std-sync-2.stderr +++ b/src/test/ui/span/send-is-not-static-std-sync-2.stderr @@ -1,36 +1,36 @@ error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:11:21 + --> $DIR/send-is-not-static-std-sync-2.rs:11:20 | +LL | let lock = { + | ---- borrow later stored here +LL | let x = 1; LL | Mutex::new(&x) - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:21:22 + --> $DIR/send-is-not-static-std-sync-2.rs:21:21 | +LL | let lock = { + | ---- borrow later stored here +LL | let x = 1; LL | RwLock::new(&x) - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error[E0597]: `x` does not live long enough - --> $DIR/send-is-not-static-std-sync-2.rs:31:26 + --> $DIR/send-is-not-static-std-sync-2.rs:31:25 | +LL | let (_tx, rx) = { + | --- borrow later used here +... LL | let _ = tx.send(&x); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough LL | (tx, rx) LL | }; | - `x` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error: aborting due to 3 previous errors diff --git a/src/test/ui/span/send-is-not-static-std-sync.nll.stderr b/src/test/ui/span/send-is-not-static-std-sync.nll.stderr deleted file mode 100644 index d00b157d389..00000000000 --- a/src/test/ui/span/send-is-not-static-std-sync.nll.stderr +++ /dev/null @@ -1,72 +0,0 @@ -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/send-is-not-static-std-sync.rs:13:10 - | -LL | *lock.lock().unwrap() = &*y; - | --- borrow of `*y` occurs here -LL | drop(y); - | ^ move out of `y` occurs here -... -LL | *lock.lock().unwrap() = &z; - | ---- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:16:33 - | -LL | *lock.lock().unwrap() = &z; - | ^^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -LL | -LL | lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` => needs explicit use) - | ---- borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/send-is-not-static-std-sync.rs:27:10 - | -LL | *lock.write().unwrap() = &*y; - | --- borrow of `*y` occurs here -LL | drop(y); - | ^ move out of `y` occurs here -... -LL | *lock.write().unwrap() = &z; - | ---- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:30:34 - | -LL | *lock.write().unwrap() = &z; - | ^^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -LL | -LL | lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z` => needs explicit use) - | ---- borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/send-is-not-static-std-sync.rs:43:10 - | -LL | tx.send(&*y); - | --- borrow of `*y` occurs here -LL | drop(y); - | ^ move out of `y` occurs here -... -LL | tx.send(&z).unwrap(); - | -- borrow later used here - -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:46:17 - | -LL | tx.send(&z).unwrap(); - | ^^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -... -LL | } - | - borrow might be used here, when `tx` is dropped and runs the `Drop` code for type `std::sync::mpsc::Sender` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0505, E0597. -For more information about an error, try `rustc --explain E0505`. diff --git a/src/test/ui/span/send-is-not-static-std-sync.stderr b/src/test/ui/span/send-is-not-static-std-sync.stderr index e3024875b94..d00b157d389 100644 --- a/src/test/ui/span/send-is-not-static-std-sync.stderr +++ b/src/test/ui/span/send-is-not-static-std-sync.stderr @@ -1,59 +1,70 @@ -error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:16:34 - | -LL | *lock.lock().unwrap() = &z; - | ^ borrowed value does not live long enough -LL | } - | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here - error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:13:10 | LL | *lock.lock().unwrap() = &*y; - | -- borrow of `*y` occurs here + | --- borrow of `*y` occurs here LL | drop(y); | ^ move out of `y` occurs here +... +LL | *lock.lock().unwrap() = &z; + | ---- borrow later used here error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:30:35 + --> $DIR/send-is-not-static-std-sync.rs:16:33 | -LL | *lock.write().unwrap() = &z; - | ^ borrowed value does not live long enough +LL | *lock.lock().unwrap() = &z; + | ^^ borrowed value does not live long enough LL | } | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | +LL | lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` => needs explicit use) + | ---- borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:27:10 | LL | *lock.write().unwrap() = &*y; - | -- borrow of `*y` occurs here + | --- borrow of `*y` occurs here LL | drop(y); | ^ move out of `y` occurs here +... +LL | *lock.write().unwrap() = &z; + | ---- borrow later used here error[E0597]: `z` does not live long enough - --> $DIR/send-is-not-static-std-sync.rs:46:18 + --> $DIR/send-is-not-static-std-sync.rs:30:34 | -LL | tx.send(&z).unwrap(); - | ^ borrowed value does not live long enough +LL | *lock.write().unwrap() = &z; + | ^^ borrowed value does not live long enough LL | } | - `z` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here +LL | +LL | lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z` => needs explicit use) + | ---- borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/send-is-not-static-std-sync.rs:43:10 | LL | tx.send(&*y); - | -- borrow of `*y` occurs here + | --- borrow of `*y` occurs here LL | drop(y); | ^ move out of `y` occurs here +... +LL | tx.send(&z).unwrap(); + | -- borrow later used here + +error[E0597]: `z` does not live long enough + --> $DIR/send-is-not-static-std-sync.rs:46:17 + | +LL | tx.send(&z).unwrap(); + | ^^ borrowed value does not live long enough +LL | } + | - `z` dropped here while still borrowed +... +LL | } + | - borrow might be used here, when `tx` is dropped and runs the `Drop` code for type `std::sync::mpsc::Sender` + | + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 6 previous errors diff --git a/src/test/ui/span/slice-borrow.nll.stderr b/src/test/ui/span/slice-borrow.nll.stderr deleted file mode 100644 index 84d0c847b7b..00000000000 --- a/src/test/ui/span/slice-borrow.nll.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/slice-borrow.rs:6:28 - | -LL | let x: &[isize] = &vec![1, 2, 3, 4, 5]; - | ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use -... -LL | } - | - temporary value is freed at the end of this statement -LL | y.use_ref(); - | - 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/span/slice-borrow.rs b/src/test/ui/span/slice-borrow.rs index 23e53039e94..38cd7acbdfa 100644 --- a/src/test/ui/span/slice-borrow.rs +++ b/src/test/ui/span/slice-borrow.rs @@ -4,7 +4,7 @@ fn main() { let y; { let x: &[isize] = &vec![1, 2, 3, 4, 5]; - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed y = &x[1..]; } y.use_ref(); diff --git a/src/test/ui/span/slice-borrow.stderr b/src/test/ui/span/slice-borrow.stderr index a03cac58e2e..84d0c847b7b 100644 --- a/src/test/ui/span/slice-borrow.stderr +++ b/src/test/ui/span/slice-borrow.stderr @@ -1,17 +1,17 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/slice-borrow.rs:6:28 | LL | let x: &[isize] = &vec![1, 2, 3, 4, 5]; - | ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use ... LL | } - | - temporary value dropped here while still borrowed + | - temporary value is freed at the end of this statement LL | y.use_ref(); -LL | } - | - temporary value needs to live until here + | - 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 E0597`. +For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr b/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr deleted file mode 100644 index f87c32d1ad0..00000000000 --- a/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0597]: `c2` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:117:24 - | -LL | c1.v[0].v.set(Some(&c2)); - | ^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `c2` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `c1` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:119:24 - | -LL | c2.v[0].v.set(Some(&c1)); - | ^^^ borrowed value does not live long enough -LL | -LL | } - | - - | | - | `c1` dropped here while still borrowed - | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr b/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr index b957243018d..f87c32d1ad0 100644 --- a/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr +++ b/src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr @@ -1,24 +1,28 @@ error[E0597]: `c2` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:117:25 + --> $DIR/vec-must-not-hide-type-from-dropck.rs:117:24 | LL | c1.v[0].v.set(Some(&c2)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough ... LL | } - | - `c2` dropped here while still borrowed + | - + | | + | `c2` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough - --> $DIR/vec-must-not-hide-type-from-dropck.rs:119:25 + --> $DIR/vec-must-not-hide-type-from-dropck.rs:119:24 | LL | c2.v[0].v.set(Some(&c1)); - | ^^ borrowed value does not live long enough + | ^^^ borrowed value does not live long enough LL | LL | } - | - `c1` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `c1` dropped here while still borrowed + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` error: aborting due to 2 previous errors diff --git a/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr b/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr deleted file mode 100644 index 684e7845313..00000000000 --- a/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:17:12 - | -LL | v.push(&x); - | ^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `x` dropped here while still borrowed - | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` - | - = note: values in a scope are dropped in the opposite order they are defined - -error[E0597]: `y` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:19:12 - | -LL | v.push(&y); - | ^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `y` dropped here while still borrowed - | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` - | - = note: values in a scope are dropped in the opposite order they are defined - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/span/vec_refs_data_with_early_death.stderr b/src/test/ui/span/vec_refs_data_with_early_death.stderr index 65fd6b50643..684e7845313 100644 --- a/src/test/ui/span/vec_refs_data_with_early_death.stderr +++ b/src/test/ui/span/vec_refs_data_with_early_death.stderr @@ -1,24 +1,30 @@ error[E0597]: `x` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:17:13 + --> $DIR/vec_refs_data_with_early_death.rs:17:12 | LL | v.push(&x); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } - | - `x` dropped here while still borrowed + | - + | | + | `x` dropped here while still borrowed + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `y` does not live long enough - --> $DIR/vec_refs_data_with_early_death.rs:19:13 + --> $DIR/vec_refs_data_with_early_death.rs:19:12 | LL | v.push(&y); - | ^ borrowed value does not live long enough + | ^^ borrowed value does not live long enough ... LL | } - | - `y` dropped here while still borrowed + | - + | | + | `y` dropped here while still borrowed + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` | - = note: values in a scope are dropped in the opposite order they are created + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff --git a/src/test/ui/span/wf-method-late-bound-regions.nll.stderr b/src/test/ui/span/wf-method-late-bound-regions.nll.stderr deleted file mode 100644 index 6b0b008208f..00000000000 --- a/src/test/ui/span/wf-method-late-bound-regions.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0597]: `pointer` does not live long enough - --> $DIR/wf-method-late-bound-regions.rs:20:18 - | -LL | let dangling = { - | -------- borrow later stored here -LL | let pointer = Box::new(42); -LL | f2.xmute(&pointer) - | ^^^^^^^^ borrowed value does not live long enough -LL | }; - | - `pointer` 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/span/wf-method-late-bound-regions.stderr b/src/test/ui/span/wf-method-late-bound-regions.stderr index a30e0f4d7e0..6b0b008208f 100644 --- a/src/test/ui/span/wf-method-late-bound-regions.stderr +++ b/src/test/ui/span/wf-method-late-bound-regions.stderr @@ -1,13 +1,13 @@ error[E0597]: `pointer` does not live long enough - --> $DIR/wf-method-late-bound-regions.rs:20:19 + --> $DIR/wf-method-late-bound-regions.rs:20:18 | +LL | let dangling = { + | -------- borrow later stored here +LL | let pointer = Box::new(42); LL | f2.xmute(&pointer) - | ^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^ borrowed value does not live long enough LL | }; | - `pointer` dropped here while still borrowed -... -LL | } - | - borrowed value needs to live until here error: aborting due to previous error diff --git a/src/test/ui/static/static-drop-scope.nll.stderr b/src/test/ui/static/static-drop-scope.nll.stderr deleted file mode 100644 index 8a23dad1ba3..00000000000 --- a/src/test/ui/static/static-drop-scope.nll.stderr +++ /dev/null @@ -1,71 +0,0 @@ -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:9:60 - | -LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^ statics cannot evaluate destructors - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-drop-scope.rs:9:60 - | -LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); - | ------^^^^^^^^- - | | | | - | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use - | using this value as a static requires that borrow lasts for `'static` - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:13:59 - | -LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^ constants cannot evaluate destructors - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-drop-scope.rs:13:59 - | -LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); - | ------^^^^^^^^- - | | | | - | | | temporary value is freed at the end of this statement - | | creates a temporary which is freed while still in use - | using this value as a constant requires that borrow lasts for `'static` - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:17:28 - | -LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1; - | ^^^^^^^^^^^^^ statics cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:20:27 - | -LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1; - | ^^^^^^^^^^^^^ constants cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:23:24 - | -LL | const fn const_drop(_: T) {} - | ^ constant functions cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:27:5 - | -LL | (x, ()).1 - | ^^^^^^^ constant functions cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:31:34 - | -LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1; - | ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors - -error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/static-drop-scope.rs:36:43 - | -LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1; - | ^^^^^^^^^^^ constants cannot evaluate destructors - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/static/static-drop-scope.rs b/src/test/ui/static/static-drop-scope.rs index e5a9f2a4056..0de28d5469b 100644 --- a/src/test/ui/static/static-drop-scope.rs +++ b/src/test/ui/static/static-drop-scope.rs @@ -8,11 +8,11 @@ impl Drop for WithDtor { static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); //~^ ERROR destructors cannot be evaluated at compile-time -//~| ERROR borrowed value does not live long enoug +//~| ERROR temporary value dropped while borrowed const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); //~^ ERROR destructors cannot be evaluated at compile-time -//~| ERROR borrowed value does not live long enoug +//~| ERROR temporary value dropped while borrowed static EARLY_DROP_S: i32 = (WithDtor, 0).1; //~^ ERROR destructors cannot be evaluated at compile-time diff --git a/src/test/ui/static/static-drop-scope.stderr b/src/test/ui/static/static-drop-scope.stderr index 9793a1db57f..8a23dad1ba3 100644 --- a/src/test/ui/static/static-drop-scope.stderr +++ b/src/test/ui/static/static-drop-scope.stderr @@ -4,15 +4,15 @@ error[E0493]: destructors cannot be evaluated at compile-time LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); | ^^^^^^^^ statics cannot evaluate destructors -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-drop-scope.rs:9:60 | LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | ------^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a static requires that borrow lasts for `'static` error[E0493]: destructors cannot be evaluated at compile-time --> $DIR/static-drop-scope.rs:13:59 @@ -20,15 +20,15 @@ error[E0493]: destructors cannot be evaluated at compile-time LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); | ^^^^^^^^ constants cannot evaluate destructors -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-drop-scope.rs:13:59 | LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); - | ^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | ------^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a constant requires that borrow lasts for `'static` error[E0493]: destructors cannot be evaluated at compile-time --> $DIR/static-drop-scope.rs:17:28 @@ -68,4 +68,4 @@ LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1; error: aborting due to 10 previous errors -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/static/static-lifetime-bound.nll.stderr b/src/test/ui/static/static-lifetime-bound.nll.stderr deleted file mode 100644 index 90d728204e7..00000000000 --- a/src/test/ui/static/static-lifetime-bound.nll.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning: unnecessary lifetime parameter `'a` - --> $DIR/static-lifetime-bound.rs:1:6 - | -LL | fn f<'a: 'static>(_: &'a i32) {} - | ^^^^^^^^^^^ - | - = help: you can use the `'static` lifetime directly, in place of `'a` - -error[E0597]: `x` does not live long enough - --> $DIR/static-lifetime-bound.rs:5:7 - | -LL | f(&x); - | --^^- - | | | - | | borrowed value does not live long enough - | argument requires that `x` is borrowed for `'static` -LL | } - | - `x` 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/static/static-lifetime-bound.stderr b/src/test/ui/static/static-lifetime-bound.stderr index b9aa4d8722b..90d728204e7 100644 --- a/src/test/ui/static/static-lifetime-bound.stderr +++ b/src/test/ui/static/static-lifetime-bound.stderr @@ -7,14 +7,15 @@ LL | fn f<'a: 'static>(_: &'a i32) {} = help: you can use the `'static` lifetime directly, in place of `'a` error[E0597]: `x` does not live long enough - --> $DIR/static-lifetime-bound.rs:5:8 + --> $DIR/static-lifetime-bound.rs:5:7 | LL | f(&x); - | ^ borrowed value does not live long enough + | --^^- + | | | + | | borrowed value does not live long enough + | argument requires that `x` is borrowed for `'static` LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `x` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/static/static-reference-to-fn-2.nll.stderr b/src/test/ui/static/static-reference-to-fn-2.nll.stderr deleted file mode 100644 index 26f214b9781..00000000000 --- a/src/test/ui/static/static-reference-to-fn-2.nll.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-reference-to-fn-2.rs:18:22 - | -LL | fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { - | ----- has type `&mut StateMachineIter<'1>` -LL | self_.statefn = &id(state2 as StateMachineFunc); - | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | | - | | creates a temporary which is freed while still in use - | assignment requires that borrow lasts for `'1` - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-reference-to-fn-2.rs:24:22 - | -LL | fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { - | ----- has type `&mut StateMachineIter<'1>` -LL | self_.statefn = &id(state3 as StateMachineFunc); - | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | | - | | creates a temporary which is freed while still in use - | assignment requires that borrow lasts for `'1` - -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-reference-to-fn-2.rs:30:22 - | -LL | fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { - | ----- has type `&mut StateMachineIter<'1>` -LL | self_.statefn = &id(finished as StateMachineFunc); - | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement - | | | - | | creates a temporary which is freed while still in use - | assignment requires that borrow lasts for `'1` - -error[E0515]: cannot return value referencing temporary value - --> $DIR/static-reference-to-fn-2.rs:40:5 - | -LL | / StateMachineIter { -LL | | statefn: &id(state1 as StateMachineFunc) - | | ------------------------------ temporary value created here -LL | | -LL | | } - | |_____^ returns a value referencing data owned by the current function - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0515, E0716. -For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/static/static-reference-to-fn-2.rs b/src/test/ui/static/static-reference-to-fn-2.rs index 8e66532cad9..6693667c091 100644 --- a/src/test/ui/static/static-reference-to-fn-2.rs +++ b/src/test/ui/static/static-reference-to-fn-2.rs @@ -16,19 +16,19 @@ impl<'a> Iterator for StateMachineIter<'a> { fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { self_.statefn = &id(state2 as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed return Some("state1"); } fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { self_.statefn = &id(state3 as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed return Some("state2"); } fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { self_.statefn = &id(finished as StateMachineFunc); - //~^ ERROR borrowed value does not live long enough + //~^ ERROR temporary value dropped while borrowed return Some("state3"); } @@ -38,8 +38,8 @@ fn finished(_: &mut StateMachineIter) -> Option<(&'static str)> { fn state_iter() -> StateMachineIter<'static> { StateMachineIter { + //~^ ERROR cannot return value referencing temporary value statefn: &id(state1 as StateMachineFunc) - //~^ ERROR borrowed value does not live long enough } } diff --git a/src/test/ui/static/static-reference-to-fn-2.stderr b/src/test/ui/static/static-reference-to-fn-2.stderr index 17d4a361257..028e11a60ce 100644 --- a/src/test/ui/static/static-reference-to-fn-2.stderr +++ b/src/test/ui/static/static-reference-to-fn-2.stderr @@ -1,71 +1,47 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:18:22 | +LL | fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(state2 as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 17:1... - --> $DIR/static-reference-to-fn-2.rs:17:1 - | -LL | / fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { -LL | | self_.statefn = &id(state2 as StateMachineFunc); -LL | | -LL | | return Some("state1"); -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:24:22 | +LL | fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(state3 as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 23:1... - --> $DIR/static-reference-to-fn-2.rs:23:1 - | -LL | / fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { -LL | | self_.statefn = &id(state3 as StateMachineFunc); -LL | | -LL | | return Some("state2"); -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:30:22 | +LL | fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(finished as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 29:1... - --> $DIR/static-reference-to-fn-2.rs:29:1 - | -LL | / fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { -LL | | self_.statefn = &id(finished as StateMachineFunc); -LL | | -LL | | return Some("state3"); -LL | | } - | |_^ - = note: consider using a `let` binding to increase its lifetime + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough - --> $DIR/static-reference-to-fn-2.rs:41:19 +error[E0515]: cannot return value referencing temporary value + --> $DIR/static-reference-to-fn-2.rs:40:5 | -LL | statefn: &id(state1 as StateMachineFunc) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | / StateMachineIter { +LL | | +LL | | statefn: &id(state1 as StateMachineFunc) + | | ------------------------------ temporary value created here +LL | | } + | |_____^ returns a value referencing data owned by the current function error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors have detailed explanations: E0515, E0716. +For more information about an error, try `rustc --explain E0515`. diff --git a/src/test/ui/static/static-region-bound.nll.stderr b/src/test/ui/static/static-region-bound.nll.stderr deleted file mode 100644 index 15261259ed4..00000000000 --- a/src/test/ui/static/static-region-bound.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/static-region-bound.rs:10:14 - | -LL | let x = &id(3); - | ^^^^^ creates a temporary which is freed while still in use -LL | f(x); - | ---- argument requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/static/static-region-bound.rs b/src/test/ui/static/static-region-bound.rs index ee411370d15..f133133b336 100644 --- a/src/test/ui/static/static-region-bound.rs +++ b/src/test/ui/static/static-region-bound.rs @@ -7,6 +7,6 @@ fn f(_: T) {} fn main() { let x: Box<_> = box 3; f(x); - let x = &id(3); //~ ERROR borrowed value does not live long enough + let x = &id(3); //~ ERROR temporary value dropped while borrowed f(x); } diff --git a/src/test/ui/static/static-region-bound.stderr b/src/test/ui/static/static-region-bound.stderr index f6bbfcecf6f..15261259ed4 100644 --- a/src/test/ui/static/static-region-bound.stderr +++ b/src/test/ui/static/static-region-bound.stderr @@ -1,14 +1,13 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-region-bound.rs:10:14 | LL | let x = &id(3); - | ^^^^^ temporary value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use LL | f(x); + | ---- argument requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement 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/std-uncopyable-atomics.nll.stderr b/src/test/ui/std-uncopyable-atomics.nll.stderr deleted file mode 100644 index 8241f6f1fdb..00000000000 --- a/src/test/ui/std-uncopyable-atomics.nll.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:9:13 - | -LL | let x = *&x; - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:11:13 - | -LL | let x = *&x; - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:13:13 - | -LL | let x = *&x; - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error[E0507]: cannot move out of borrowed content - --> $DIR/std-uncopyable-atomics.rs:15:13 - | -LL | let x = *&x; - | ^^^ - | | - | cannot move out of borrowed content - | help: consider removing the `*`: `&x` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/std-uncopyable-atomics.stderr b/src/test/ui/std-uncopyable-atomics.stderr index 7f01434838c..8241f6f1fdb 100644 --- a/src/test/ui/std-uncopyable-atomics.stderr +++ b/src/test/ui/std-uncopyable-atomics.stderr @@ -5,7 +5,7 @@ LL | let x = *&x; | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:11:13 @@ -14,7 +14,7 @@ LL | let x = *&x; | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:13:13 @@ -23,7 +23,7 @@ LL | let x = *&x; | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:15:13 @@ -32,7 +32,7 @@ LL | let x = *&x; | ^^^ | | | cannot move out of borrowed content - | help: consider using a reference instead: `&*&x` + | help: consider removing the `*`: `&x` error: aborting due to 4 previous errors diff --git a/src/test/ui/suggestions/borrow-for-loop-head.nll.stderr b/src/test/ui/suggestions/borrow-for-loop-head.nll.stderr deleted file mode 100644 index 10287f59cce..00000000000 --- a/src/test/ui/suggestions/borrow-for-loop-head.nll.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/borrow-for-loop-head.rs:4:18 - | -LL | for i in &a { - | -- borrow of `a` occurs here -LL | for j in a { - | ^ move out of `a` occurs here - -error[E0382]: use of moved value: `a` - --> $DIR/borrow-for-loop-head.rs:4:18 - | -LL | let a = vec![1, 2, 3]; - | - move occurs because `a` has type `std::vec::Vec`, which does not implement the `Copy` trait -LL | for i in &a { -LL | for j in a { - | ^ value moved here, in previous iteration of loop -help: consider borrowing this to avoid moving it into the for loop - | -LL | for j in &a { - | ^^ - -error: aborting due to 2 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/suggestions/borrow-for-loop-head.stderr b/src/test/ui/suggestions/borrow-for-loop-head.stderr index ecf351284b4..10287f59cce 100644 --- a/src/test/ui/suggestions/borrow-for-loop-head.stderr +++ b/src/test/ui/suggestions/borrow-for-loop-head.stderr @@ -2,17 +2,18 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrow-for-loop-head.rs:4:18 | LL | for i in &a { - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | for j in a { | ^ move out of `a` occurs here error[E0382]: use of moved value: `a` --> $DIR/borrow-for-loop-head.rs:4:18 | +LL | let a = vec![1, 2, 3]; + | - move occurs because `a` has type `std::vec::Vec`, which does not implement the `Copy` trait +LL | for i in &a { LL | for j in a { - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `a` has type `std::vec::Vec`, which does not implement the `Copy` trait + | ^ value moved here, in previous iteration of loop help: consider borrowing this to avoid moving it into the for loop | LL | for j in &a { diff --git a/src/test/ui/thread-local-in-ctfe.nll.stderr b/src/test/ui/thread-local-in-ctfe.nll.stderr deleted file mode 100644 index 33cef3ef4f7..00000000000 --- a/src/test/ui/thread-local-in-ctfe.nll.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:6:17 - | -LL | static B: u32 = A; - | ^ - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:9:18 - | -LL | static C: &u32 = &A; - | ^^ - -warning[E0712]: thread-local variable borrowed past end of function - --> $DIR/thread-local-in-ctfe.rs:9:18 - | -LL | static C: &u32 = &A; - | ^^- end of enclosing function is here - | | - | thread-local variables cannot be borrowed beyond the end of the function - | - = 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[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:12:16 - | -LL | const D: u32 = A; - | ^ - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:15:17 - | -LL | const E: &u32 = &A; - | ^^ - -warning[E0712]: thread-local variable borrowed past end of function - --> $DIR/thread-local-in-ctfe.rs:15:17 - | -LL | const E: &u32 = &A; - | ^^- end of enclosing function is here - | | - | thread-local variables cannot be borrowed beyond the end of the function - | - = 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[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:19:5 - | -LL | A - | ^ - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0712`. diff --git a/src/test/ui/thread-local-in-ctfe.rs b/src/test/ui/thread-local-in-ctfe.rs index 313d39de36b..7ca1a2e7e90 100644 --- a/src/test/ui/thread-local-in-ctfe.rs +++ b/src/test/ui/thread-local-in-ctfe.rs @@ -8,12 +8,18 @@ static B: u32 = A; static C: &u32 = &A; //~^ ERROR thread-local statics cannot be accessed at compile-time +//~| WARNING thread-local variable borrowed past end of function +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future const D: u32 = A; //~^ ERROR thread-local statics cannot be accessed at compile-time const E: &u32 = &A; //~^ ERROR thread-local statics cannot be accessed at compile-time +//~| WARNING thread-local variable borrowed past end of function +//~| WARNING this error has been downgraded to a warning +//~| WARNING this warning will become a hard error in the future const fn f() -> u32 { A diff --git a/src/test/ui/thread-local-in-ctfe.stderr b/src/test/ui/thread-local-in-ctfe.stderr index 2b60ec1486c..bba5b0c74d9 100644 --- a/src/test/ui/thread-local-in-ctfe.stderr +++ b/src/test/ui/thread-local-in-ctfe.stderr @@ -10,23 +10,46 @@ error[E0625]: thread-local statics cannot be accessed at compile-time LL | static C: &u32 = &A; | ^^ +warning[E0712]: thread-local variable borrowed past end of function + --> $DIR/thread-local-in-ctfe.rs:9:18 + | +LL | static C: &u32 = &A; + | ^^- end of enclosing function is here + | | + | thread-local variables cannot be borrowed beyond the end of the function + | + = 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[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:12:16 + --> $DIR/thread-local-in-ctfe.rs:15:16 | LL | const D: u32 = A; | ^ error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:15:17 + --> $DIR/thread-local-in-ctfe.rs:18:17 | LL | const E: &u32 = &A; | ^^ +warning[E0712]: thread-local variable borrowed past end of function + --> $DIR/thread-local-in-ctfe.rs:18:17 + | +LL | const E: &u32 = &A; + | ^^- end of enclosing function is here + | | + | thread-local variables cannot be borrowed beyond the end of the function + | + = 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[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-in-ctfe.rs:19:5 + --> $DIR/thread-local-in-ctfe.rs:25:5 | LL | A | ^ error: aborting due to 5 previous errors +For more information about this error, try `rustc --explain E0712`. diff --git a/src/test/ui/thread-local-mutation.nll.stderr b/src/test/ui/thread-local-mutation.nll.stderr deleted file mode 100644 index 7f7738b5d65..00000000000 --- a/src/test/ui/thread-local-mutation.nll.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0594]: cannot assign to immutable static item `S` - --> $DIR/thread-local-mutation.rs:11:5 - | -LL | S = "after"; - | ^^^^^^^^^^^ cannot assign - -error: aborting due to previous error - diff --git a/src/test/ui/thread-local-mutation.stderr b/src/test/ui/thread-local-mutation.stderr index 8f9022f4a4e..7f7738b5d65 100644 --- a/src/test/ui/thread-local-mutation.stderr +++ b/src/test/ui/thread-local-mutation.stderr @@ -1,8 +1,8 @@ -error[E0594]: cannot assign to immutable thread-local static item +error[E0594]: cannot assign to immutable static item `S` --> $DIR/thread-local-mutation.rs:11:5 | LL | S = "after"; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ cannot assign error: aborting due to previous error diff --git a/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr b/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr deleted file mode 100644 index 4ee3e4cacc3..00000000000 --- a/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0597]: `person` does not live long enough - --> $DIR/trait-coercion-generic-regions.rs:17:24 - | -LL | let person: &str = &person; - | ^^^^^^^ - | | - | borrowed value does not live long enough - | assignment requires that `person` is borrowed for `'static` -LL | let s: Box> = Box::new(Struct { person: person }); -LL | } - | - `person` 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/traits/trait-coercion-generic-regions.stderr b/src/test/ui/traits/trait-coercion-generic-regions.stderr index 2a9ca4f95f0..4ee3e4cacc3 100644 --- a/src/test/ui/traits/trait-coercion-generic-regions.stderr +++ b/src/test/ui/traits/trait-coercion-generic-regions.stderr @@ -1,13 +1,14 @@ error[E0597]: `person` does not live long enough - --> $DIR/trait-coercion-generic-regions.rs:17:25 + --> $DIR/trait-coercion-generic-regions.rs:17:24 | LL | let person: &str = &person; - | ^^^^^^ borrowed value does not live long enough + | ^^^^^^^ + | | + | borrowed value does not live long enough + | assignment requires that `person` is borrowed for `'static` LL | let s: Box> = Box::new(Struct { person: person }); LL | } - | - borrowed value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - `person` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.nll.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.nll.stderr deleted file mode 100644 index aac119afda5..00000000000 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.nll.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference - --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:6:5 - | -LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` -LL | *t - | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference - --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:10:6 - | -LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` -LL | {*t} - | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr index adaeb9b5d5d..aac119afda5 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy-reborrow.stderr @@ -1,19 +1,19 @@ -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:6:5 | LL | fn reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- use `&'a mut &'a mut i32` here to make mutable + | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` LL | *t - | ^^ assignment into an immutable reference + | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable -error[E0389]: cannot borrow data mutably in a `&` reference +error[E0596]: cannot borrow `**t` as mutable, as it is behind a `&` reference --> $DIR/trivial-bounds-inconsistent-copy-reborrow.rs:10:6 | LL | fn copy_reborrow_mut<'a>(t: &'a &'a mut i32) -> &'a mut i32 where &'a mut i32: Copy { - | --------------- use `&'a mut &'a mut i32` here to make mutable + | --------------- help: consider changing this to be a mutable reference: `&'a mut &'a mut i32` LL | {*t} - | ^^ assignment into an immutable reference + | ^^ `t` is a `&` reference, so the data it refers to cannot be borrowed as mutable error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0389`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr deleted file mode 100644 index 934d057ea09..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/unboxed-closure-illegal-move.rs:15:31 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn(|| drop(x)); - | ^ cannot move out of captured variable in an `Fn` closure - -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/unboxed-closure-illegal-move.rs:19:35 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn_mut(|| drop(x)); - | ^ cannot move out of captured variable in an `FnMut` closure - -error[E0507]: cannot move out of captured variable in an `Fn` closure - --> $DIR/unboxed-closure-illegal-move.rs:28:36 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn(move || drop(x)); - | ^ cannot move out of captured variable in an `Fn` closure - -error[E0507]: cannot move out of captured variable in an `FnMut` closure - --> $DIR/unboxed-closure-illegal-move.rs:32:40 - | -LL | let x = Box::new(0); - | - captured outer variable -LL | let f = to_fn_mut(move || drop(x)); - | ^ cannot move out of captured variable in an `FnMut` closure - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr index 7620f6a3cbe..934d057ea09 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.stderr @@ -1,34 +1,34 @@ -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-closure-illegal-move.rs:15:31 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn(|| drop(x)); - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure -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/unboxed-closure-illegal-move.rs:19:35 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn_mut(|| drop(x)); - | ^ cannot move out of captured outer variable in an `FnMut` closure + | ^ cannot move out of captured variable in an `FnMut` closure -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-closure-illegal-move.rs:28:36 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn(move || drop(x)); - | ^ cannot move out of captured outer variable in an `Fn` closure + | ^ cannot move out of captured variable in an `Fn` closure -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/unboxed-closure-illegal-move.rs:32:40 | LL | let x = Box::new(0); | - captured outer variable LL | let f = to_fn_mut(move || drop(x)); - | ^ 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 4 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.nll.stderr deleted file mode 100644 index 296cba184b9..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.nll.stderr +++ /dev/null @@ -1,74 +0,0 @@ -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:9:13 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -LL | move || x = 1; - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:10:17 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -LL | move || x = 1; -LL | move || set(&mut x); - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:11:13 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | move || x = 1; - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:12:17 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | move || set(&mut x); - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:13:8 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || x = 1; - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:15:12 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || set(&mut x); - | ^^^^^^ cannot borrow as mutable - -error[E0594]: cannot assign to `x`, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:16:8 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || x = 1; - | ^^^^^ cannot assign - -error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:18:12 - | -LL | let x = 0; - | - help: consider changing this to be mutable: `mut x` -... -LL | || set(&mut x); - | ^^^^^^ cannot borrow as mutable - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs index 5d59cecf99a..3eba9c4d431 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.rs @@ -11,9 +11,7 @@ fn main() { move || x = 1; //~ ERROR cannot assign move || set(&mut x); //~ ERROR cannot borrow || x = 1; //~ ERROR cannot assign - // FIXME: this should be `cannot borrow` (issue #18330) - || set(&mut x); //~ ERROR cannot assign + || set(&mut x); //~ ERROR cannot borrow || x = 1; //~ ERROR cannot assign - // FIXME: this should be `cannot borrow` (issue #18330) - || set(&mut x); //~ ERROR cannot assign + || set(&mut x); //~ ERROR cannot borrow } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr index 946a994350a..9fd8aa562f4 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-immutable-capture.stderr @@ -1,69 +1,74 @@ -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:13:5 - | -LL | let x = 0; - | - help: make this binding mutable: `mut x` -... -LL | || x = 1; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:15:5 - | -LL | let x = 0; - | - help: make this binding mutable: `mut x` -... -LL | || set(&mut x); - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:16:5 - | -LL | let x = 0; - | - help: make this binding mutable: `mut x` -... -LL | || x = 1; - | ^^ cannot borrow mutably - -error[E0595]: closure cannot assign to immutable local variable `x` - --> $DIR/unboxed-closure-immutable-capture.rs:18:5 - | -LL | let x = 0; - | - help: make this binding mutable: `mut x` -... -LL | || set(&mut x); - | ^^ cannot borrow mutably - -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/unboxed-closure-immutable-capture.rs:9:13 | LL | let x = 0; - | - help: consider making `x` mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` LL | move || x = 1; - | ^^^^^ + | ^^^^^ cannot assign -error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:10:22 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:10:17 | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +LL | move || x = 1; LL | move || set(&mut x); - | ^ + | ^^^^^^ cannot borrow as mutable -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/unboxed-closure-immutable-capture.rs:11:13 | LL | let x = 0; - | - help: consider making `x` mutable: `mut x` + | - help: consider changing this to be mutable: `mut x` ... LL | move || x = 1; - | ^^^^^ + | ^^^^^ cannot assign -error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable - --> $DIR/unboxed-closure-immutable-capture.rs:12:22 +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:12:17 | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... LL | move || set(&mut x); - | ^ + | ^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:13:8 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || x = 1; + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:14:12 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || set(&mut x); + | ^^^^^^ cannot borrow as mutable + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:15:8 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || x = 1; + | ^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closure-immutable-capture.rs:16:12 + | +LL | let x = 0; + | - help: consider changing this to be mutable: `mut x` +... +LL | || set(&mut x); + | ^^^^^^ cannot borrow as mutable error: aborting due to 8 previous errors -Some errors have detailed explanations: E0595, E0596. -For more information about an error, try `rustc --explain E0595`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr deleted file mode 100644 index b40b2f67d9b..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0597]: `x` does not live long enough - --> $DIR/unboxed-closure-region.rs:8:12 - | -LL | let _f = { - | -- borrow later stored here -LL | let x = 0; -LL | || x - | -- ^ borrowed value does not live long enough - | | - | value captured here -LL | }; - | - `x` 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/unboxed-closures/unboxed-closure-region.stderr b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr index f710342e2ce..b40b2f67d9b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-region.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-region.stderr @@ -1,15 +1,15 @@ error[E0597]: `x` does not live long enough --> $DIR/unboxed-closure-region.rs:8:12 | +LL | let _f = { + | -- borrow later stored here +LL | let x = 0; LL | || x | -- ^ borrowed value does not live long enough | | - | capture occurs here + | value captured here LL | }; - | - borrowed value only lives until here -LL | _f; -LL | } - | - borrowed value needs to live until here + | - `x` dropped here while still borrowed error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr deleted file mode 100644 index 21d6b4fde7e..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.nll.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/unboxed-closures-borrow-conflict.rs:9:14 - | -LL | let f = || x += 1; - | -- - borrow occurs due to use of `x` in closure - | | - | borrow of `x` occurs here -LL | let _y = x; - | ^ use of borrowed `x` -LL | f; - | - 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/unboxed-closures/unboxed-closures-borrow-conflict.stderr b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr index ac0e4ff13c7..21d6b4fde7e 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-borrow-conflict.stderr @@ -1,10 +1,14 @@ error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/unboxed-closures-borrow-conflict.rs:9:9 + --> $DIR/unboxed-closures-borrow-conflict.rs:9:14 | LL | let f = || x += 1; - | -- borrow of `x` occurs here + | -- - borrow occurs due to use of `x` in closure + | | + | borrow of `x` occurs here LL | let _y = x; - | ^^ use of borrowed `x` + | ^ use of borrowed `x` +LL | f; + | - borrow later used here error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr deleted file mode 100644 index 706e59097d7..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error[E0597]: `factorial` does not live long enough - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:15:17 - | -LL | let f = |x: u32| -> u32 { - | --------------- value captured here -LL | let g = factorial.as_ref().unwrap(); - | ^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - - | | - | `factorial` dropped here while still borrowed - | borrow might be used here, when `factorial` is dropped and runs the destructor for type `std::option::Option u32>>` - -error[E0506]: cannot assign to `factorial` because it is borrowed - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:20:5 - | -LL | let f = |x: u32| -> u32 { - | --------------- borrow of `factorial` occurs here -LL | let g = factorial.as_ref().unwrap(); - | --------- borrow occurs due to use in closure -... -LL | factorial = Some(Box::new(f)); - | ^^^^^^^^^ - | | - | assignment to borrowed `factorial` occurs here - | borrow later used here - -error[E0597]: `factorial` does not live long enough - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:28:17 - | -LL | let mut factorial: Option u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` -LL | -LL | let f = |x: u32| -> u32 { - | --------------- value captured here -LL | -LL | let g = factorial.as_ref().unwrap(); - | ^^^^^^^^^ borrowed value does not live long enough -... -LL | } - | - `factorial` dropped here while still borrowed - -error[E0506]: cannot assign to `factorial` because it is borrowed - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:32:5 - | -LL | let mut factorial: Option u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` -LL | -LL | let f = |x: u32| -> u32 { - | --------------- borrow of `factorial` occurs here -LL | -LL | let g = factorial.as_ref().unwrap(); - | --------- borrow occurs due to use in closure -... -LL | factorial = Some(Box::new(f)); - | ^^^^^^^^^ assignment to borrowed `factorial` occurs here - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0506, E0597. -For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs index b72482a7121..82dc536bb56 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs @@ -18,18 +18,20 @@ fn a() { }; factorial = Some(Box::new(f)); + //~^ ERROR cannot assign to `factorial` because it is borrowed } fn b() { let mut factorial: Option u32 + 'static>> = None; let f = |x: u32| -> u32 { - //~^ ERROR closure may outlive the current function, but it borrows `factorial` let g = factorial.as_ref().unwrap(); + //~^ ERROR `factorial` does not live long enough if x == 0 {1} else {x * g(x-1)} }; factorial = Some(Box::new(f)); + //~^ ERROR cannot assign to `factorial` because it is borrowed } fn main() { } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr index abd17ab79e1..8d39fb026b3 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr @@ -2,29 +2,59 @@ error[E0597]: `factorial` does not live long enough --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:15:17 | LL | let f = |x: u32| -> u32 { - | --------------- capture occurs here + | --------------- value captured here LL | let g = factorial.as_ref().unwrap(); | ^^^^^^^^^ borrowed value does not live long enough ... LL | } - | - borrowed value dropped before borrower - | - = note: values in a scope are dropped in the opposite order they are created + | - + | | + | `factorial` dropped here while still borrowed + | borrow might be used here, when `factorial` is dropped and runs the destructor for type `std::option::Option u32>>` -error[E0373]: closure may outlive the current function, but it borrows `factorial`, which is owned by the current function - --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:26:13 +error[E0506]: cannot assign to `factorial` because it is borrowed + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:20:5 | LL | let f = |x: u32| -> u32 { - | ^^^^^^^^^^^^^^^ may outlive borrowed value `factorial` -LL | + | --------------- borrow of `factorial` occurs here LL | let g = factorial.as_ref().unwrap(); - | --------- `factorial` is borrowed here -help: to force the closure to take ownership of `factorial` (and any other referenced variables), use the `move` keyword + | --------- borrow occurs due to use in closure +... +LL | factorial = Some(Box::new(f)); + | ^^^^^^^^^ + | | + | assignment to borrowed `factorial` occurs here + | borrow later used here + +error[E0597]: `factorial` does not live long enough + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:28:17 | -LL | let f = move |x: u32| -> u32 { - | ^^^^^^^^^^^^^^^^^^^^ +LL | let mut factorial: Option u32 + 'static>> = None; + | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | +LL | let f = |x: u32| -> u32 { + | --------------- value captured here +LL | let g = factorial.as_ref().unwrap(); + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `factorial` dropped here while still borrowed -error: aborting due to 2 previous errors +error[E0506]: cannot assign to `factorial` because it is borrowed + --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:33:5 + | +LL | let mut factorial: Option u32 + 'static>> = None; + | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | +LL | let f = |x: u32| -> u32 { + | --------------- borrow of `factorial` occurs here +LL | let g = factorial.as_ref().unwrap(); + | --------- borrow occurs due to use in closure +... +LL | factorial = Some(Box::new(f)); + | ^^^^^^^^^ assignment to borrowed `factorial` occurs here -Some errors have detailed explanations: E0373, E0597. -For more information about an error, try `rustc --explain E0373`. +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0506, E0597. +For more information about an error, try `rustc --explain E0506`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr deleted file mode 100644 index 1e1172cdbf2..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.nll.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `tick1` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:17:9 - | -LL | let tick1 = || { - | ----- help: consider changing this to be mutable: `mut tick1` -... -LL | tick1(); - | ^^^^^ cannot borrow as mutable - -error[E0596]: cannot borrow `tick2` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:20:5 - | -LL | let tick2 = || { - | ----- help: consider changing this to be mutable: `mut tick2` -... -LL | tick2(); - | ^^^^^ cannot borrow as mutable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs index aaa692c109f..6401b5e01fc 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs @@ -11,10 +11,9 @@ fn main() { }; // In turn, tick2 must be inferred to FnMut so that it can call - // tick1, but we forgot the mut. The error message we currently - // get seems... suboptimal. - let tick2 = || { //~ ERROR closure cannot assign to immutable local variable `tick1` - tick1(); + // tick1, but we forgot the mut. + let tick2 = || { + tick1(); //~ ERROR cannot borrow `tick1` as mutable }; tick2(); //~ ERROR cannot borrow diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr index 2b4ac414279..5dea424596e 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.stderr @@ -1,22 +1,21 @@ -error[E0595]: closure cannot assign to immutable local variable `tick1` - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:16:17 +error[E0596]: cannot borrow `tick1` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:16:9 | LL | let tick1 = || { - | ----- help: make this binding mutable: `mut tick1` + | ----- help: consider changing this to be mutable: `mut tick1` ... -LL | let tick2 = || { - | ^^ cannot borrow mutably +LL | tick1(); + | ^^^^^ cannot borrow as mutable -error[E0596]: cannot borrow immutable local variable `tick2` as mutable - --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:20:5 +error[E0596]: cannot borrow `tick2` as mutable, as it is not declared as mutable + --> $DIR/unboxed-closures-infer-fnmut-calling-fnmut-no-mut.rs:19:5 | LL | let tick2 = || { - | ----- help: make this binding mutable: `mut tick2` + | ----- help: consider changing this to be mutable: `mut tick2` ... LL | tick2(); - | ^^^^^ cannot borrow mutably + | ^^^^^ cannot borrow as mutable error: aborting due to 2 previous errors -Some errors have detailed explanations: E0595, E0596. -For more information about an error, try `rustc --explain E0595`. +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.nll.stderr deleted file mode 100644 index eb398628846..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:7:5 - | -LL | let tick = || counter += 1; - | ---- help: consider changing this to be mutable: `mut tick` -LL | tick(); - | ^^^^ 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/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs index de3f9839d26..5c0ceb23d61 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.rs @@ -4,5 +4,5 @@ fn main() { let mut counter = 0; let tick = || counter += 1; - tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + tick(); //~ ERROR cannot borrow `tick` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr index 33e21544858..eb398628846 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-missing-mut.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `tick` as mutable +error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable --> $DIR/unboxed-closures-infer-fnmut-missing-mut.rs:7:5 | LL | let tick = || counter += 1; - | ---- help: make this binding mutable: `mut tick` + | ---- help: consider changing this to be mutable: `mut tick` LL | tick(); - | ^^^^ cannot borrow mutably + | ^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr deleted file mode 100644 index b9d76d9a752..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable - --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:7:5 - | -LL | let tick = move || counter += 1; - | ---- help: consider changing this to be mutable: `mut tick` -LL | tick(); - | ^^^^ 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/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs index b011c5a58bc..144a674ac58 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.rs @@ -4,5 +4,5 @@ fn main() { let mut counter = 0; let tick = move || counter += 1; - tick(); //~ ERROR cannot borrow immutable local variable `tick` as mutable + tick(); //~ ERROR cannot borrow `tick` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr index 585577ae82a..b9d76d9a752 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-infer-fnmut-move-missing-mut.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `tick` as mutable +error[E0596]: cannot borrow `tick` as mutable, as it is not declared as mutable --> $DIR/unboxed-closures-infer-fnmut-move-missing-mut.rs:7:5 | LL | let tick = move || counter += 1; - | ---- help: make this binding mutable: `mut tick` + | ---- help: consider changing this to be mutable: `mut tick` LL | tick(); - | ^^^^ cannot borrow mutably + | ^^^^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.nll.stderr deleted file mode 100644 index fef6c23a501..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.nll.stderr +++ /dev/null @@ -1,44 +0,0 @@ -error[E0594]: cannot assign to `n`, as it is not declared as mutable - --> $DIR/unboxed-closures-mutate-upvar.rs:15:9 - | -LL | let n = 0; - | - help: consider changing this to be mutable: `mut n` -LL | let mut f = to_fn_mut(|| { -LL | n += 1; - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `n`, as it is not declared as mutable - --> $DIR/unboxed-closures-mutate-upvar.rs:32:9 - | -LL | let n = 0; - | - help: consider changing this to be mutable: `mut n` -... -LL | n += 1; - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `n`, as it is not declared as mutable - --> $DIR/unboxed-closures-mutate-upvar.rs:46:9 - | -LL | let n = 0; - | - help: consider changing this to be mutable: `mut n` -LL | let mut f = to_fn(move || { -LL | n += 1; - | ^^^^^^ cannot assign - -error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure - --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 - | -LL | n += 1; - | ^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/unboxed-closures-mutate-upvar.rs:52:23 - | -LL | let mut f = to_fn(move || { - | _______________________^ -LL | | n += 1; -LL | | }); - | |_____^ - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs index 3bea9226f21..57e6d30658c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.rs @@ -11,8 +11,8 @@ fn to_fn_mut>(f: F) -> F { f } fn a() { let n = 0; - let mut f = to_fn_mut(|| { //~ ERROR closure cannot assign - n += 1; + let mut f = to_fn_mut(|| { + n += 1; //~ ERROR cannot assign to `n`, as it is not declared as mutable }); } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr index 14a77df04b6..fef6c23a501 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutate-upvar.stderr @@ -1,44 +1,37 @@ -error[E0595]: closure cannot assign to immutable local variable `n` - --> $DIR/unboxed-closures-mutate-upvar.rs:14:27 +error[E0594]: cannot assign to `n`, as it is not declared as mutable + --> $DIR/unboxed-closures-mutate-upvar.rs:15:9 | LL | let n = 0; - | - help: make this binding mutable: `mut n` + | - help: consider changing this to be mutable: `mut n` LL | let mut f = to_fn_mut(|| { - | ^^ cannot borrow mutably +LL | n += 1; + | ^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `FnMut` closure +error[E0594]: cannot assign to `n`, as it is not declared as mutable --> $DIR/unboxed-closures-mutate-upvar.rs:32:9 | LL | let n = 0; - | - help: consider making `n` mutable: `mut n` + | - help: consider changing this to be mutable: `mut n` ... LL | n += 1; - | ^^^^^^ + | ^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `n`, as it is not declared as mutable --> $DIR/unboxed-closures-mutate-upvar.rs:46:9 | +LL | let n = 0; + | - help: consider changing this to be mutable: `mut n` +LL | let mut f = to_fn(move || { LL | n += 1; - | ^^^^^^ - | - = note: `Fn` closures cannot capture their enclosing environment for modifications -help: consider changing this closure to take self by mutable reference - --> $DIR/unboxed-closures-mutate-upvar.rs:45:23 - | -LL | let mut f = to_fn(move || { - | _______________________^ -LL | | n += 1; -LL | | }); - | |_____^ + | ^^^^^^ cannot assign -error[E0594]: cannot assign to captured outer variable in an `Fn` closure +error[E0594]: cannot assign to `n`, as it is a captured variable in a `Fn` closure --> $DIR/unboxed-closures-mutate-upvar.rs:53:9 | LL | n += 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/unboxed-closures-mutate-upvar.rs:52:23 | LL | let mut f = to_fn(move || { @@ -49,4 +42,3 @@ LL | | }); error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0595`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr deleted file mode 100644 index 07883500b82..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:14:9 - | -LL | counter += 1; - | ^^^^^^^^^^^^ - | -help: consider changing this closure to take self by mutable reference - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:13:10 - | -LL | call(|| { - | __________^ -LL | | counter += 1; -LL | | -LL | | -LL | | }); - | |_____^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0387`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr deleted file mode 100644 index a438ec2f5b9..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.mir.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:14:9 - | -LL | counter += 1; - | ^^^^^^^^^^^^ cannot assign - | -help: consider changing this to accept closures that implement `FnMut` - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:13:10 - | -LL | call(|| { - | __________^ -LL | | counter += 1; -LL | | -LL | | -LL | | }); - | |_____^ - -error: aborting due to previous error - diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs index a5dcb57d33a..174ad245d59 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.rs @@ -1,6 +1,3 @@ -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - // Test that a by-ref `FnMut` closure gets an error when it tries to // mutate a value. @@ -12,7 +9,6 @@ fn main() { let mut counter = 0; call(|| { counter += 1; - //[ast]~^ ERROR cannot assign to data in a captured outer variable in an `Fn` closure - //[mir]~^^ ERROR cannot assign to `counter` + //~^ ERROR cannot assign to `counter` }); } diff --git a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr similarity index 74% rename from src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr rename to src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr index a438ec2f5b9..2bc1f01af98 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.ast.nll.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-mutated-upvar-from-fn-closure.stderr @@ -1,17 +1,16 @@ error[E0594]: cannot assign to `counter`, as it is a captured variable in a `Fn` closure - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:14:9 + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:11:9 | LL | counter += 1; | ^^^^^^^^^^^^ cannot assign | help: consider changing this to accept closures that implement `FnMut` - --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:13:10 + --> $DIR/unboxed-closures-mutated-upvar-from-fn-closure.rs:10:10 | LL | call(|| { | __________^ LL | | counter += 1; LL | | -LL | | LL | | }); | |_____^ diff --git a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr deleted file mode 100644 index 830f6bc993d..00000000000 --- a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `*self` as mutable more than once at a time - --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:22:21 - | -LL | (self.func)(self, arg) - | ----------- ^^^^ second mutable borrow occurs here - | | - | first mutable borrow occurs here - | first borrow later used by call - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0499`. diff --git a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr index f881d1982a5..830f6bc993d 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.stderr @@ -2,10 +2,10 @@ error[E0499]: cannot borrow `*self` as mutable more than once at a time --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:22:21 | LL | (self.func)(self, arg) - | ----------- ^^^^ - first borrow ends here - | | | - | | second mutable borrow occurs here + | ----------- ^^^^ second mutable borrow occurs here + | | | first mutable borrow occurs here + | first borrow later used by call error: aborting due to previous error diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr b/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr deleted file mode 100644 index 2f4c921ea08..00000000000 --- a/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr +++ /dev/null @@ -1,70 +0,0 @@ -error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0`) - --> $DIR/union-borrow-move-parent-sibling.rs:15:13 - | -LL | let a = &mut u.x.0; - | ---------- mutable borrow occurs here (via `u.x.0`) -LL | let b = &u.y; - | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0` -- occurs here -LL | use_borrow(a); - | - mutable borrow later used here - | - = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0` - -error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:22:13 - | -LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - | - move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = u.x.0; - | ----- value moved here -LL | let b = u.y; - | ^^^ value used here after move - -error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0.0`) - --> $DIR/union-borrow-move-parent-sibling.rs:28:13 - | -LL | let a = &mut (u.x.0).0; - | -------------- mutable borrow occurs here (via `u.x.0.0`) -LL | let b = &u.y; - | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0.0` -- occurs here -LL | use_borrow(a); - | - mutable borrow later used here - | - = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0.0` - -error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:35:13 - | -LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - | - move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = (u.x.0).0; - | --------- value moved here -LL | let b = u.y; - | ^^^ value used here after move - -error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `*u.y`) - --> $DIR/union-borrow-move-parent-sibling.rs:41:13 - | -LL | let a = &mut *u.y; - | --------- mutable borrow occurs here (via `*u.y`) -LL | let b = &u.x; - | ^^^^ immutable borrow of `u.x` -- which overlaps with `*u.y` -- occurs here -LL | use_borrow(a); - | - mutable borrow later used here - | - = note: `u.x` is a field of the union `U`, so it overlaps the field `*u.y` - -error[E0382]: use of moved value: `u` - --> $DIR/union-borrow-move-parent-sibling.rs:48:13 - | -LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; - | - move occurs because `u` has type `U`, which does not implement the `Copy` trait -LL | let a = *u.y; - | ---- value moved here -LL | let b = u.x; - | ^^^ value used here after move - -error: aborting due to 6 previous errors - -Some errors have detailed explanations: E0382, E0502. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.rs b/src/test/ui/union/union-borrow-move-parent-sibling.rs index 43abbd374fc..1b6052f10ba 100644 --- a/src/test/ui/union/union-borrow-move-parent-sibling.rs +++ b/src/test/ui/union/union-borrow-move-parent-sibling.rs @@ -12,27 +12,27 @@ fn use_borrow(_: &T) {} unsafe fn parent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut u.x.0; - let b = &u.y; //~ ERROR cannot borrow `u.y` + let b = &u.y; //~ ERROR cannot borrow `u` (via `u.y`) use_borrow(a); } unsafe fn parent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = u.x.0; - let b = u.y; //~ ERROR use of moved value: `u.y` + let b = u.y; //~ ERROR use of moved value: `u` } unsafe fn grandparent_sibling_borrow() { let mut u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = &mut (u.x.0).0; - let b = &u.y; //~ ERROR cannot borrow `u.y` + let b = &u.y; //~ ERROR cannot borrow `u` (via `u.y`) use_borrow(a); } unsafe fn grandparent_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = (u.x.0).0; - let b = u.y; //~ ERROR use of moved value: `u.y` + let b = u.y; //~ ERROR use of moved value: `u` } unsafe fn deref_sibling_borrow() { @@ -45,7 +45,7 @@ unsafe fn deref_sibling_borrow() { unsafe fn deref_sibling_move() { let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; let a = *u.y; - let b = u.x; //~ ERROR use of moved value: `u.x` + let b = u.x; //~ ERROR use of moved value: `u` } diff --git a/src/test/ui/union/union-borrow-move-parent-sibling.stderr b/src/test/ui/union/union-borrow-move-parent-sibling.stderr index a7df3d5f76d..2f4c921ea08 100644 --- a/src/test/ui/union/union-borrow-move-parent-sibling.stderr +++ b/src/test/ui/union/union-borrow-move-parent-sibling.stderr @@ -1,65 +1,68 @@ -error[E0502]: cannot borrow `u.y` as immutable because `u.x.0` is also borrowed as mutable - --> $DIR/union-borrow-move-parent-sibling.rs:15:14 +error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0`) + --> $DIR/union-borrow-move-parent-sibling.rs:15:13 | LL | let a = &mut u.x.0; - | ----- mutable borrow occurs here + | ---------- mutable borrow occurs here (via `u.x.0`) LL | let b = &u.y; - | ^^^ immutable borrow occurs here + | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0` -- occurs here LL | use_borrow(a); -LL | } - | - mutable borrow ends here - -error[E0382]: use of moved value: `u.y` - --> $DIR/union-borrow-move-parent-sibling.rs:22:9 + | - mutable borrow later used here | + = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0` + +error[E0382]: use of moved value: `u` + --> $DIR/union-borrow-move-parent-sibling.rs:22:13 + | +LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + | - move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = u.x.0; - | - value moved here + | ----- value moved here LL | let b = u.y; - | ^ value used here after move - | - = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait + | ^^^ value used here after move -error[E0502]: cannot borrow `u.y` as immutable because `u.x.0.0` is also borrowed as mutable - --> $DIR/union-borrow-move-parent-sibling.rs:28:14 +error[E0502]: cannot borrow `u` (via `u.y`) as immutable because it is also borrowed as mutable (via `u.x.0.0`) + --> $DIR/union-borrow-move-parent-sibling.rs:28:13 | LL | let a = &mut (u.x.0).0; - | --------- mutable borrow occurs here + | -------------- mutable borrow occurs here (via `u.x.0.0`) LL | let b = &u.y; - | ^^^ immutable borrow occurs here + | ^^^^ immutable borrow of `u.y` -- which overlaps with `u.x.0.0` -- occurs here LL | use_borrow(a); -LL | } - | - mutable borrow ends here - -error[E0382]: use of moved value: `u.y` - --> $DIR/union-borrow-move-parent-sibling.rs:35:9 + | - mutable borrow later used here | + = note: `u.y` is a field of the union `U`, so it overlaps the field `u.x.0.0` + +error[E0382]: use of moved value: `u` + --> $DIR/union-borrow-move-parent-sibling.rs:35:13 + | +LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + | - move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = (u.x.0).0; - | - value moved here + | --------- value moved here LL | let b = u.y; - | ^ value used here after move - | - = note: move occurs because `u.y` has type `[type error]`, which does not implement the `Copy` trait + | ^^^ value used here after move -error[E0502]: cannot borrow `u` (via `u.x`) as immutable because `u` is also borrowed as mutable (via `*u.y`) - --> $DIR/union-borrow-move-parent-sibling.rs:41:14 +error[E0502]: cannot borrow `u` (via `u.x`) as immutable because it is also borrowed as mutable (via `*u.y`) + --> $DIR/union-borrow-move-parent-sibling.rs:41:13 | LL | let a = &mut *u.y; - | ---- mutable borrow occurs here (via `*u.y`) + | --------- mutable borrow occurs here (via `*u.y`) LL | let b = &u.x; - | ^^^ immutable borrow of `u.x` -- which overlaps with `*u.y` -- occurs here + | ^^^^ immutable borrow of `u.x` -- which overlaps with `*u.y` -- occurs here LL | use_borrow(a); -LL | } - | - mutable borrow ends here + | - mutable borrow later used here + | + = note: `u.x` is a field of the union `U`, so it overlaps the field `*u.y` -error[E0382]: use of moved value: `u.x` - --> $DIR/union-borrow-move-parent-sibling.rs:48:9 +error[E0382]: use of moved value: `u` + --> $DIR/union-borrow-move-parent-sibling.rs:48:13 | +LL | let u = U { x: ((Vec::new(), Vec::new()), Vec::new()) }; + | - move occurs because `u` has type `U`, which does not implement the `Copy` trait LL | let a = *u.y; - | - value moved here + | ---- value moved here LL | let b = u.x; - | ^ value used here after move - | - = note: move occurs because `u.x` 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/unop-move-semantics.nll.stderr b/src/test/ui/unop-move-semantics.nll.stderr deleted file mode 100644 index 5122d16bd93..00000000000 --- a/src/test/ui/unop-move-semantics.nll.stderr +++ /dev/null @@ -1,52 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/unop-move-semantics.rs:8:5 - | -LL | fn move_then_borrow + Clone>(x: T) { - | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait - | | - | consider adding a `Copy` constraint to this type argument -LL | !x; - | - value moved here -LL | -LL | x.clone(); - | ^ value borrowed here after move - -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/unop-move-semantics.rs:15:6 - | -LL | let m = &x; - | -- borrow of `x` occurs here -... -LL | !x; - | ^ move out of `x` occurs here -... -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0505]: cannot move out of `y` because it is borrowed - --> $DIR/unop-move-semantics.rs:17:6 - | -LL | let n = &mut y; - | ------ borrow of `y` occurs here -... -LL | !y; - | ^ move out of `y` occurs here -LL | use_mut(n); use_imm(m); - | - borrow later used here - -error[E0507]: cannot move out of borrowed content - --> $DIR/unop-move-semantics.rs:24:6 - | -LL | !*m; - | ^^ cannot move out of borrowed content - -error[E0507]: cannot move out of borrowed content - --> $DIR/unop-move-semantics.rs:26:6 - | -LL | !*n; - | ^^ cannot move out of borrowed content - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0382, E0505, E0507. -For more information about an error, try `rustc --explain E0382`. diff --git a/src/test/ui/unop-move-semantics.rs b/src/test/ui/unop-move-semantics.rs index 24bd89d4c39..80f737e6c4e 100644 --- a/src/test/ui/unop-move-semantics.rs +++ b/src/test/ui/unop-move-semantics.rs @@ -5,7 +5,7 @@ use std::ops::Not; fn move_then_borrow + Clone>(x: T) { !x; - x.clone(); //~ ERROR: use of moved value + x.clone(); //~ ERROR: borrow of moved value } fn move_borrowed>(x: T, mut y: T) { diff --git a/src/test/ui/unop-move-semantics.stderr b/src/test/ui/unop-move-semantics.stderr index 90e1bfd24ee..5122d16bd93 100644 --- a/src/test/ui/unop-move-semantics.stderr +++ b/src/test/ui/unop-move-semantics.stderr @@ -1,31 +1,38 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/unop-move-semantics.rs:8:5 | +LL | fn move_then_borrow + Clone>(x: T) { + | - - move occurs because `x` has type `T`, which does not implement the `Copy` trait + | | + | consider adding a `Copy` constraint to this type argument LL | !x; | - value moved here LL | LL | x.clone(); - | ^ value used here after move - | - = note: move occurs because `x` has type `T`, which does not implement the `Copy` trait + | ^ value borrowed here after move error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/unop-move-semantics.rs:15:6 | LL | let m = &x; - | - borrow of `x` occurs here + | -- borrow of `x` occurs here ... LL | !x; | ^ move out of `x` occurs here +... +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0505]: cannot move out of `y` because it is borrowed --> $DIR/unop-move-semantics.rs:17:6 | LL | let n = &mut y; - | - borrow of `y` occurs here + | ------ borrow of `y` occurs here ... LL | !y; | ^ move out of `y` occurs here +LL | use_mut(n); use_imm(m); + | - borrow later used here error[E0507]: cannot move out of borrowed content --> $DIR/unop-move-semantics.rs:24:6 diff --git a/src/test/ui/unsized-locals/borrow-after-move.nll.stderr b/src/test/ui/unsized-locals/borrow-after-move.nll.stderr deleted file mode 100644 index 010e182674b..00000000000 --- a/src/test/ui/unsized-locals/borrow-after-move.nll.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:20:24 - | -LL | let y = *x; - | -- value moved here -LL | drop_unsized(y); -LL | println!("{}", &x); - | ^^ value borrowed here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `y` - --> $DIR/borrow-after-move.rs:22:24 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | drop_unsized(y); - | - value moved here -... -LL | println!("{}", &y); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:30:24 - | -LL | let y = *x; - | -- value moved here -LL | y.foo(); -LL | println!("{}", &x); - | ^^ value borrowed here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `y` - --> $DIR/borrow-after-move.rs:32:24 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | y.foo(); - | - value moved here -... -LL | println!("{}", &y); - | ^^ value borrowed here after move - -error[E0382]: borrow of moved value: `x` - --> $DIR/borrow-after-move.rs:39:24 - | -LL | x.foo(); - | - value moved here -LL | println!("{}", &x); - | ^^ value borrowed here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/unsized-locals/borrow-after-move.rs b/src/test/ui/unsized-locals/borrow-after-move.rs index 587a2180c15..3299fdf3a9c 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.rs +++ b/src/test/ui/unsized-locals/borrow-after-move.rs @@ -18,9 +18,9 @@ fn main() { let y = *x; drop_unsized(y); println!("{}", &x); - //~^ERROR use of moved value + //~^ERROR borrow of moved value println!("{}", &y); - //~^ERROR use of moved value + //~^ERROR borrow of moved value } { @@ -28,15 +28,15 @@ fn main() { let y = *x; y.foo(); println!("{}", &x); - //~^ERROR use of moved value + //~^ERROR borrow of moved value println!("{}", &y); - //~^ERROR use of moved value + //~^ERROR borrow of moved value } { let x = "hello".to_owned().into_boxed_str(); x.foo(); println!("{}", &x); - //~^ERROR use of moved value + //~^ERROR borrow of moved value } } diff --git a/src/test/ui/unsized-locals/borrow-after-move.stderr b/src/test/ui/unsized-locals/borrow-after-move.stderr index 8eea01f25c8..010e182674b 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.stderr +++ b/src/test/ui/unsized-locals/borrow-after-move.stderr @@ -1,54 +1,54 @@ -error[E0382]: use of moved value: `x` - --> $DIR/borrow-after-move.rs:20:25 +error[E0382]: borrow of moved value: `x` + --> $DIR/borrow-after-move.rs:20:24 | LL | let y = *x; - | - value moved here + | -- value moved here LL | drop_unsized(y); LL | println!("{}", &x); - | ^ value used here after move + | ^^ value borrowed here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `y` - --> $DIR/borrow-after-move.rs:22:25 +error[E0382]: borrow of moved value: `y` + --> $DIR/borrow-after-move.rs:22:24 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | drop_unsized(y); | - value moved here ... LL | println!("{}", &y); - | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/borrow-after-move.rs:30:25 +error[E0382]: borrow of moved value: `x` + --> $DIR/borrow-after-move.rs:30:24 | LL | let y = *x; - | - value moved here + | -- value moved here LL | y.foo(); LL | println!("{}", &x); - | ^ value used here after move + | ^^ value borrowed here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `y` - --> $DIR/borrow-after-move.rs:32:25 +error[E0382]: borrow of moved value: `y` + --> $DIR/borrow-after-move.rs:32:24 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | y.foo(); | - value moved here ... LL | println!("{}", &y); - | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait + | ^^ value borrowed here after move -error[E0382]: use of moved value: `x` - --> $DIR/borrow-after-move.rs:39:25 +error[E0382]: borrow of moved value: `x` + --> $DIR/borrow-after-move.rs:39:24 | LL | x.foo(); | - value moved here LL | println!("{}", &x); - | ^ value used here after move + | ^^ value borrowed here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait diff --git a/src/test/ui/unsized-locals/double-move.nll.stderr b/src/test/ui/unsized-locals/double-move.nll.stderr deleted file mode 100644 index 47fa0d4a437..00000000000 --- a/src/test/ui/unsized-locals/double-move.nll.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:20:22 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | drop_unsized(y); - | - value moved here -LL | drop_unsized(y); - | ^ value used here after move - -error[E0382]: use of moved value: `x` - --> $DIR/double-move.rs:26:22 - | -LL | let _y = *x; - | -- value moved here -LL | drop_unsized(x); - | ^ value used here after partial move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:32:18 - | -LL | let x = "hello".to_owned().into_boxed_str(); - | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | drop_unsized(x); - | - value moved here -LL | let _y = *x; - | ^^ value used here after move - -error[E0382]: use of moved value: `y` - --> $DIR/double-move.rs:39:9 - | -LL | let y = *x; - | - move occurs because `y` has type `str`, which does not implement the `Copy` trait -LL | y.foo(); - | - value moved here -LL | y.foo(); - | ^ value used here after move - -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:45:9 - | -LL | let _y = *x; - | -- value moved here -LL | x.foo(); - | ^ value used here after move - | - = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:51:18 - | -LL | x.foo(); - | - value moved here -LL | let _y = *x; - | ^^ value used here after move - | - = note: move occurs because `*x` has type `str`, 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/unsized-locals/double-move.stderr b/src/test/ui/unsized-locals/double-move.stderr index e6573af5a36..47fa0d4a437 100644 --- a/src/test/ui/unsized-locals/double-move.stderr +++ b/src/test/ui/unsized-locals/double-move.stderr @@ -1,60 +1,60 @@ error[E0382]: use of moved value: `y` --> $DIR/double-move.rs:20:22 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | drop_unsized(y); | - value moved here LL | drop_unsized(y); | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `x` --> $DIR/double-move.rs:26:22 | LL | let _y = *x; - | -- value moved here + | -- value moved here LL | drop_unsized(x); - | ^ value used here after move + | ^ value used here after partial move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:32:13 + --> $DIR/double-move.rs:32:18 | +LL | let x = "hello".to_owned().into_boxed_str(); + | - move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | drop_unsized(x); | - value moved here LL | let _y = *x; - | ^^ value used here after move - | - = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^^ value used here after move error[E0382]: use of moved value: `y` --> $DIR/double-move.rs:39:9 | +LL | let y = *x; + | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | y.foo(); | - value moved here LL | y.foo(); | ^ value used here after move - | - = note: move occurs because `y` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `*x` --> $DIR/double-move.rs:45:9 | LL | let _y = *x; - | -- value moved here + | -- value moved here LL | x.foo(); | ^ value used here after move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait error[E0382]: use of moved value: `*x` - --> $DIR/double-move.rs:51:13 + --> $DIR/double-move.rs:51:18 | LL | x.foo(); | - value moved here LL | let _y = *x; - | ^^ value used here after move + | ^^ value used here after move | = note: move occurs because `*x` has type `str`, which does not implement the `Copy` trait diff --git a/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr b/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr deleted file mode 100644 index a94414ef560..00000000000 --- a/src/test/ui/unsized-locals/unsized-exprs2.nll.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0508]: cannot move out of type `[u8]`, a non-copy slice - --> $DIR/unsized-exprs2.rs:22:19 - | -LL | udrop::<[u8]>(foo()[..]); - | ^^^^^^^^^ cannot move out of here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/unsized-locals/unsized-exprs2.rs b/src/test/ui/unsized-locals/unsized-exprs2.rs index 3fb5a002e0e..534439aa6c4 100644 --- a/src/test/ui/unsized-locals/unsized-exprs2.rs +++ b/src/test/ui/unsized-locals/unsized-exprs2.rs @@ -20,5 +20,5 @@ impl std::ops::Add for A<[u8]> { fn main() { udrop::<[u8]>(foo()[..]); - //~^ERROR cannot move out of indexed content + //~^ERROR cannot move out of type `[u8]`, a non-copy slice } diff --git a/src/test/ui/unsized-locals/unsized-exprs2.stderr b/src/test/ui/unsized-locals/unsized-exprs2.stderr index d7cb4bffb48..a94414ef560 100644 --- a/src/test/ui/unsized-locals/unsized-exprs2.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs2.stderr @@ -1,9 +1,9 @@ -error[E0507]: cannot move out of indexed content +error[E0508]: cannot move out of type `[u8]`, a non-copy slice --> $DIR/unsized-exprs2.rs:22:19 | LL | udrop::<[u8]>(foo()[..]); - | ^^^^^^^^^ cannot move out of indexed content + | ^^^^^^^^^ cannot move out of here error: aborting due to previous error -For more information about this error, try `rustc --explain E0507`. +For more information about this error, try `rustc --explain E0508`. diff --git a/src/test/ui/use/use-after-move-based-on-type.nll.stderr b/src/test/ui/use/use-after-move-based-on-type.nll.stderr deleted file mode 100644 index 520f88f55dc..00000000000 --- a/src/test/ui/use/use-after-move-based-on-type.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `x` - --> $DIR/use-after-move-based-on-type.rs:4:20 - | -LL | let x = "Hello!".to_string(); - | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait -LL | let _y = x; - | - value moved here -LL | println!("{}", x); - | ^ value borrowed 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/use/use-after-move-based-on-type.rs b/src/test/ui/use/use-after-move-based-on-type.rs index fc8ea6f79eb..ba7aa0345e1 100644 --- a/src/test/ui/use/use-after-move-based-on-type.rs +++ b/src/test/ui/use/use-after-move-based-on-type.rs @@ -1,5 +1,5 @@ fn main() { let x = "Hello!".to_string(); let _y = x; - println!("{}", x); //~ ERROR use of moved value + println!("{}", x); //~ ERROR borrow of moved value } diff --git a/src/test/ui/use/use-after-move-based-on-type.stderr b/src/test/ui/use/use-after-move-based-on-type.stderr index b9e0aaf1f84..520f88f55dc 100644 --- a/src/test/ui/use/use-after-move-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-based-on-type.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `x` +error[E0382]: borrow of moved value: `x` --> $DIR/use-after-move-based-on-type.rs:4:20 | +LL | let x = "Hello!".to_string(); + | - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait LL | let _y = x; - | -- value moved here + | - value moved here LL | println!("{}", x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.nll.stderr b/src/test/ui/use/use-after-move-implicity-coerced-object.nll.stderr deleted file mode 100644 index e16bca38067..00000000000 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0382]: borrow of moved value: `n` - --> $DIR/use-after-move-implicity-coerced-object.rs:28:13 - | -LL | let n: Box<_> = box Number { n: 42 }; - | - move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait -LL | let mut l: Box<_> = box List { list: Vec::new() }; -LL | l.push(n); - | - value moved here -LL | let x = n.to_string(); - | ^ value borrowed 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/use/use-after-move-implicity-coerced-object.rs b/src/test/ui/use/use-after-move-implicity-coerced-object.rs index e4350691664..2e465ee8962 100644 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.rs +++ b/src/test/ui/use/use-after-move-implicity-coerced-object.rs @@ -26,5 +26,5 @@ fn main() { let mut l: Box<_> = box List { list: Vec::new() }; l.push(n); let x = n.to_string(); - //~^ ERROR: use of moved value: `n` + //~^ ERROR: borrow of moved value: `n` } diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr index babff9be252..e16bca38067 100644 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr +++ b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr @@ -1,12 +1,13 @@ -error[E0382]: use of moved value: `n` +error[E0382]: borrow of moved value: `n` --> $DIR/use-after-move-implicity-coerced-object.rs:28:13 | +LL | let n: Box<_> = box Number { n: 42 }; + | - move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait +LL | let mut l: Box<_> = box List { list: Vec::new() }; LL | l.push(n); | - value moved here LL | let x = n.to_string(); - | ^ value used here after move - | - = note: move occurs because `n` has type `std::boxed::Box`, which does not implement the `Copy` trait + | ^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr b/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr deleted file mode 100644 index 9bf1175430c..00000000000 --- a/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `self` - --> $DIR/use-after-move-self-based-on-type.rs:12:16 - | -LL | pub fn foo(self) -> isize { - | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait -LL | self.bar(); - | ---- value moved here -LL | return self.x; - | ^^^^^^ 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/use/use-after-move-self-based-on-type.rs b/src/test/ui/use/use-after-move-self-based-on-type.rs index 4d84ae9b271..9325834954f 100644 --- a/src/test/ui/use/use-after-move-self-based-on-type.rs +++ b/src/test/ui/use/use-after-move-self-based-on-type.rs @@ -9,7 +9,7 @@ impl Drop for S { impl S { pub fn foo(self) -> isize { self.bar(); - return self.x; //~ ERROR use of moved value: `self.x` + return self.x; //~ ERROR use of moved value: `self` } pub fn bar(self) {} diff --git a/src/test/ui/use/use-after-move-self-based-on-type.stderr b/src/test/ui/use/use-after-move-self-based-on-type.stderr index d1d26069fdf..9bf1175430c 100644 --- a/src/test/ui/use/use-after-move-self-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-self-based-on-type.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `self.x` +error[E0382]: use of moved value: `self` --> $DIR/use-after-move-self-based-on-type.rs:12:16 | +LL | pub fn foo(self) -> isize { + | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait LL | self.bar(); | ---- value moved here LL | return self.x; | ^^^^^^ value used here after move - | - = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/use/use-after-move-self.nll.stderr b/src/test/ui/use/use-after-move-self.nll.stderr deleted file mode 100644 index 3be0a65550b..00000000000 --- a/src/test/ui/use/use-after-move-self.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: use of moved value: `self` - --> $DIR/use-after-move-self.rs:10:16 - | -LL | pub fn foo(self) -> isize { - | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait -LL | self.bar(); - | ---- value moved here -LL | return *self.x; - | ^^^^^^^ 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/use/use-after-move-self.rs b/src/test/ui/use/use-after-move-self.rs index 1337d61a6d8..a6f6c45573d 100644 --- a/src/test/ui/use/use-after-move-self.rs +++ b/src/test/ui/use/use-after-move-self.rs @@ -7,7 +7,7 @@ struct S { impl S { pub fn foo(self) -> isize { self.bar(); - return *self.x; //~ ERROR use of moved value: `*self.x` + return *self.x; //~ ERROR use of moved value: `self` } pub fn bar(self) {} diff --git a/src/test/ui/use/use-after-move-self.stderr b/src/test/ui/use/use-after-move-self.stderr index 2c4bd202681..3be0a65550b 100644 --- a/src/test/ui/use/use-after-move-self.stderr +++ b/src/test/ui/use/use-after-move-self.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `*self.x` +error[E0382]: use of moved value: `self` --> $DIR/use-after-move-self.rs:10:16 | +LL | pub fn foo(self) -> isize { + | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait LL | self.bar(); | ---- value moved here LL | return *self.x; | ^^^^^^^ value used here after move - | - = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait error: aborting due to previous error diff --git a/src/test/ui/variance/variance-issue-20533.nll.stderr b/src/test/ui/variance/variance-issue-20533.nll.stderr deleted file mode 100644 index 008e2a002bb..00000000000 --- a/src/test/ui/variance/variance-issue-20533.nll.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/variance-issue-20533.rs:28:14 - | -LL | let x = foo(&a); - | -- borrow of `a` occurs here -LL | drop(a); - | ^ move out of `a` occurs here -LL | drop(x); - | - borrow later used here - -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/variance-issue-20533.rs:34:14 - | -LL | let x = bar(&a); - | -- borrow of `a` occurs here -LL | drop(a); - | ^ move out of `a` occurs here -LL | drop(x); - | - borrow later used here - -error[E0505]: cannot move out of `a` because it is borrowed - --> $DIR/variance-issue-20533.rs:40:14 - | -LL | let x = baz(&a); - | -- borrow of `a` occurs here -LL | drop(a); - | ^ move out of `a` occurs here -LL | drop(x); - | - borrow later used here - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0505`. diff --git a/src/test/ui/variance/variance-issue-20533.stderr b/src/test/ui/variance/variance-issue-20533.stderr index bcf99bcb962..008e2a002bb 100644 --- a/src/test/ui/variance/variance-issue-20533.stderr +++ b/src/test/ui/variance/variance-issue-20533.stderr @@ -2,25 +2,31 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:28:14 | LL | let x = foo(&a); - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | drop(a); | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:34:14 | LL | let x = bar(&a); - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | drop(a); | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:40:14 | LL | let x = baz(&a); - | - borrow of `a` occurs here + | -- borrow of `a` occurs here LL | drop(a); | ^ move out of `a` occurs here +LL | drop(x); + | - borrow later used here error: aborting due to 3 previous errors diff --git a/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr b/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr deleted file mode 100644 index 679fd899773..00000000000 --- a/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0499]: cannot borrow `xs` as mutable more than once at a time - --> $DIR/vec-mut-iter-borrow.rs:5:9 - | -LL | for x in &mut xs { - | ------- - | | - | first mutable borrow occurs here - | first borrow later used here -LL | xs.push(1) - | ^^ 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/vec/vec-mut-iter-borrow.stderr b/src/test/ui/vec/vec-mut-iter-borrow.stderr index ec16d2bebd6..679fd899773 100644 --- a/src/test/ui/vec/vec-mut-iter-borrow.stderr +++ b/src/test/ui/vec/vec-mut-iter-borrow.stderr @@ -2,10 +2,10 @@ error[E0499]: cannot borrow `xs` as mutable more than once at a time --> $DIR/vec-mut-iter-borrow.rs:5:9 | LL | for x in &mut xs { - | -- - | || - | |first borrow ends here - | first mutable borrow occurs here + | ------- + | | + | first mutable borrow occurs here + | first borrow later used here LL | xs.push(1) | ^^ second mutable borrow occurs here diff --git a/src/test/ui/walk-struct-literal-with.nll.stderr b/src/test/ui/walk-struct-literal-with.nll.stderr deleted file mode 100644 index eeb594a21f3..00000000000 --- a/src/test/ui/walk-struct-literal-with.nll.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0382]: borrow of moved value: `start` - --> $DIR/walk-struct-literal-with.rs:16:20 - | -LL | let start = Mine{test:"Foo".to_string(), other_val:0}; - | ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait -LL | let end = Mine{other_val:1, ..start.make_string_bar()}; - | ----- value moved here -LL | println!("{}", start.test); - | ^^^^^^^^^^ value borrowed 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/walk-struct-literal-with.rs b/src/test/ui/walk-struct-literal-with.rs index 31dfd58fa98..ee1a77eb9a4 100644 --- a/src/test/ui/walk-struct-literal-with.rs +++ b/src/test/ui/walk-struct-literal-with.rs @@ -13,5 +13,5 @@ impl Mine{ fn main(){ let start = Mine{test:"Foo".to_string(), other_val:0}; let end = Mine{other_val:1, ..start.make_string_bar()}; - println!("{}", start.test); //~ ERROR use of moved value: `start.test` + println!("{}", start.test); //~ ERROR borrow of moved value: `start` } diff --git a/src/test/ui/walk-struct-literal-with.stderr b/src/test/ui/walk-struct-literal-with.stderr index d5351eb0ce5..eeb594a21f3 100644 --- a/src/test/ui/walk-struct-literal-with.stderr +++ b/src/test/ui/walk-struct-literal-with.stderr @@ -1,12 +1,12 @@ -error[E0382]: use of moved value: `start.test` +error[E0382]: borrow of moved value: `start` --> $DIR/walk-struct-literal-with.rs:16:20 | +LL | let start = Mine{test:"Foo".to_string(), other_val:0}; + | ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait LL | let end = Mine{other_val:1, ..start.make_string_bar()}; | ----- value moved here LL | println!("{}", start.test); - | ^^^^^^^^^^ value used here after move - | - = note: move occurs because `start` has type `Mine`, which does not implement the `Copy` trait + | ^^^^^^^^^^ value borrowed here after move error: aborting due to previous error diff --git a/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr b/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr deleted file mode 100644 index fc58984345a..00000000000 --- a/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:22:5 - | -LL | s.transmute_inherent(&mut 42) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^--^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `four` - --> $DIR/wf-misc-methods-issue-28609.rs:36:5 - | -LL | s.bomb = Some(&four); - | ----- `four` is borrowed here -LL | &s - | ^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing local variable `four` - --> $DIR/wf-misc-methods-issue-28609.rs:43:5 - | -LL | s.bomb = Some(&four); - | ----- `four` is borrowed here -LL | &*s - | ^^^ returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:53:5 - | -LL | s << &mut 3 - | ^^^^^^^^^^- - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:58:5 - | -LL | s.shl(&mut 3) - | ^^^^^^^^^^^-^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error[E0515]: cannot return value referencing temporary value - --> $DIR/wf-misc-methods-issue-28609.rs:63:5 - | -LL | S2::shl(s, &mut 3) - | ^^^^^^^^^^^^^^^^-^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0515`. diff --git a/src/test/ui/wf/wf-misc-methods-issue-28609.rs b/src/test/ui/wf/wf-misc-methods-issue-28609.rs index 505d7d75d53..050f866e1c8 100644 --- a/src/test/ui/wf/wf-misc-methods-issue-28609.rs +++ b/src/test/ui/wf/wf-misc-methods-issue-28609.rs @@ -19,7 +19,7 @@ impl<'a, 'b> S<'a, 'b> { fn return_dangling_pointer_inherent(s: S2) -> &u32 { let s = s; - s.transmute_inherent(&mut 42) //~ ERROR does not live long enough + s.transmute_inherent(&mut 42) //~ ERROR cannot return value referencing temporary value } impl<'a, 'b> Deref for S<'a, 'b> { @@ -32,15 +32,15 @@ impl<'a, 'b> Deref for S<'a, 'b> { fn return_dangling_pointer_coerce(s: S2) -> &u32 { let four = 4; let mut s = s; - s.bomb = Some(&four); //~ ERROR does not live long enough - &s + s.bomb = Some(&four); + &s //~ ERROR cannot return value referencing local variable `four` } fn return_dangling_pointer_unary_op(s: S2) -> &u32 { let four = 4; let mut s = s; - s.bomb = Some(&four); //~ ERROR does not live long enough - &*s + s.bomb = Some(&four); + &*s //~ ERROR cannot return value referencing local variable `four` } impl<'a, 'b> Shl<&'b u32> for S<'a, 'b> { @@ -50,17 +50,17 @@ impl<'a, 'b> Shl<&'b u32> for S<'a, 'b> { fn return_dangling_pointer_binary_op(s: S2) -> &u32 { let s = s; - s << &mut 3 //~ ERROR does not live long enough + s << &mut 3 //~ ERROR cannot return value referencing temporary value } fn return_dangling_pointer_method(s: S2) -> &u32 { let s = s; - s.shl(&mut 3) //~ ERROR does not live long enough + s.shl(&mut 3) //~ ERROR cannot return value referencing temporary value } fn return_dangling_pointer_ufcs(s: S2) -> &u32 { let s = s; - S2::shl(s, &mut 3) //~ ERROR does not live long enough + S2::shl(s, &mut 3) //~ ERROR cannot return value referencing temporary value } fn main() { diff --git a/src/test/ui/wf/wf-misc-methods-issue-28609.stderr b/src/test/ui/wf/wf-misc-methods-issue-28609.stderr index d470aecd266..fc58984345a 100644 --- a/src/test/ui/wf/wf-misc-methods-issue-28609.stderr +++ b/src/test/ui/wf/wf-misc-methods-issue-28609.stderr @@ -1,111 +1,55 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:22:31 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:22:5 | LL | s.transmute_inherent(&mut 42) - | ^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 20:1... - --> $DIR/wf-misc-methods-issue-28609.rs:20:1 - | -LL | / fn return_dangling_pointer_inherent(s: S2) -> &u32 { -LL | | let s = s; -LL | | s.transmute_inherent(&mut 42) -LL | | } - | |_^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^--^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: `four` does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:35:20 +error[E0515]: cannot return value referencing local variable `four` + --> $DIR/wf-misc-methods-issue-28609.rs:36:5 | LL | s.bomb = Some(&four); - | ^^^^ borrowed value does not live long enough + | ----- `four` is borrowed here LL | &s -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 32:1... - --> $DIR/wf-misc-methods-issue-28609.rs:32:1 - | -LL | / fn return_dangling_pointer_coerce(s: S2) -> &u32 { -LL | | let four = 4; -LL | | let mut s = s; -LL | | s.bomb = Some(&four); -LL | | &s -LL | | } - | |_^ + | ^^ returns a value referencing data owned by the current function -error[E0597]: `four` does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:42:20 +error[E0515]: cannot return value referencing local variable `four` + --> $DIR/wf-misc-methods-issue-28609.rs:43:5 | LL | s.bomb = Some(&four); - | ^^^^ borrowed value does not live long enough + | ----- `four` is borrowed here LL | &*s -LL | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 39:1... - --> $DIR/wf-misc-methods-issue-28609.rs:39:1 - | -LL | / fn return_dangling_pointer_unary_op(s: S2) -> &u32 { -LL | | let four = 4; -LL | | let mut s = s; -LL | | s.bomb = Some(&four); -LL | | &*s -LL | | } - | |_^ + | ^^^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:53:15 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:53:5 | LL | s << &mut 3 - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 51:1... - --> $DIR/wf-misc-methods-issue-28609.rs:51:1 - | -LL | / fn return_dangling_pointer_binary_op(s: S2) -> &u32 { -LL | | let s = s; -LL | | s << &mut 3 -LL | | } - | |_^ + | ^^^^^^^^^^- + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:58:16 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:58:5 | LL | s.shl(&mut 3) - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 56:1... - --> $DIR/wf-misc-methods-issue-28609.rs:56:1 - | -LL | / fn return_dangling_pointer_method(s: S2) -> &u32 { -LL | | let s = s; -LL | | s.shl(&mut 3) -LL | | } - | |_^ + | ^^^^^^^^^^^-^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:63:21 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:63:5 | LL | S2::shl(s, &mut 3) - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 61:1... - --> $DIR/wf-misc-methods-issue-28609.rs:61:1 - | -LL | / fn return_dangling_pointer_ufcs(s: S2) -> &u32 { -LL | | let s = s; -LL | | S2::shl(s, &mut 3) -LL | | } - | |_^ + | ^^^^^^^^^^^^^^^^-^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function error: aborting due to 6 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/writing-to-immutable-vec.nll.stderr b/src/test/ui/writing-to-immutable-vec.nll.stderr deleted file mode 100644 index a65765c86c8..00000000000 --- a/src/test/ui/writing-to-immutable-vec.nll.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable - --> $DIR/writing-to-immutable-vec.rs:3:5 - | -LL | let v: Vec = vec![1, 2, 3]; - | - help: consider changing this to be mutable: `mut v` -LL | v[1] = 4; - | ^ 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/writing-to-immutable-vec.rs b/src/test/ui/writing-to-immutable-vec.rs index ad2bf33fc20..dbcc3f0bbe9 100644 --- a/src/test/ui/writing-to-immutable-vec.rs +++ b/src/test/ui/writing-to-immutable-vec.rs @@ -1,4 +1,4 @@ fn main() { let v: Vec = vec![1, 2, 3]; - v[1] = 4; //~ ERROR cannot borrow immutable local variable `v` as mutable + v[1] = 4; //~ ERROR cannot borrow `v` as mutable, as it is not declared as mutable } diff --git a/src/test/ui/writing-to-immutable-vec.stderr b/src/test/ui/writing-to-immutable-vec.stderr index 9bc82dfd358..a65765c86c8 100644 --- a/src/test/ui/writing-to-immutable-vec.stderr +++ b/src/test/ui/writing-to-immutable-vec.stderr @@ -1,10 +1,10 @@ -error[E0596]: cannot borrow immutable local variable `v` as mutable +error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable --> $DIR/writing-to-immutable-vec.rs:3:5 | LL | let v: Vec = vec![1, 2, 3]; - | - help: make this binding mutable: `mut v` + | - help: consider changing this to be mutable: `mut v` LL | v[1] = 4; - | ^ cannot borrow mutably + | ^ cannot borrow as mutable error: aborting due to previous error diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 6df56168973..d7a5395757f 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1886,10 +1886,11 @@ impl<'test> TestCx<'test> { match self.config.compare_mode { Some(CompareMode::Nll) => { - rustc.args(&["-Zborrowck=migrate", "-Ztwo-phase-borrows"]); + // FIXME(#56993) use -Zborrowck=mir + rustc.args(&["-Zborrowck=migrate"]); } Some(CompareMode::Polonius) => { - rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]); + rustc.args(&["-Zpolonius", "-Zborrowck=mir"]); } None => {} }