Auto merge of #54188 - lqd:fallout-53695, r=nikomatsakis
NLL: disallow creation of immediately unusable variables Fix #53695 Original description follows ---- This WIP PR is for discussing the impact of fixing #53695 by injecting a fake read in let patterns. (Travis will fail, at least the `mir-opt` suite is failing in its current state)
This commit is contained in:
commit
4591a245c7
52 changed files with 185 additions and 102 deletions
|
|
@ -47,6 +47,7 @@ fn main() {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const false;
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_2);
|
||||
// StorageLive(_3);
|
||||
// _3 = _1;
|
||||
|
|
@ -55,6 +56,7 @@ fn main() {
|
|||
// StorageLive(_4);
|
||||
// _4 = std::option::Option<std::boxed::Box<u32>>::None;
|
||||
// AscribeUserType(_4, o, Canonical { variables: [], value: std::option::Option<std::boxed::Box<u32>> });
|
||||
// FakeRead(ForLet, _4);
|
||||
// StorageLive(_5);
|
||||
// StorageLive(_6);
|
||||
// _6 = move _4;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ impl Drop for S {
|
|||
//
|
||||
// bb4: {
|
||||
// StorageDead(_2);
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_4);
|
||||
// _4 = move _1;
|
||||
// _3 = const std::mem::drop(move _4) -> [return: bb5, unwind: bb7];
|
||||
|
|
|
|||
|
|
@ -29,8 +29,10 @@ fn main() {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const 3i32;
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_2);
|
||||
// _2 = &'10_1rs _1;
|
||||
// FakeRead(ForLet, _2);
|
||||
// _0 = ();
|
||||
// EndRegion('10_1rs);
|
||||
// StorageDead(_2);
|
||||
|
|
|
|||
|
|
@ -45,8 +45,10 @@ fn main() {
|
|||
// bb2: {
|
||||
// StorageLive(_2);
|
||||
// _2 = const true;
|
||||
// FakeRead(ForLet, _2);
|
||||
// StorageLive(_3);
|
||||
// _3 = &'23_1rs _2;
|
||||
// FakeRead(ForLet, _3);
|
||||
// StorageLive(_5);
|
||||
// _5 = _2;
|
||||
// switchInt(move _5) -> [false: bb5, otherwise: bb4];
|
||||
|
|
@ -67,6 +69,7 @@ fn main() {
|
|||
// StorageDead(_5);
|
||||
// StorageLive(_7);
|
||||
// _7 = &'23_3rs _2;
|
||||
// FakeRead(ForLet, _7);
|
||||
// _1 = ();
|
||||
// EndRegion('23_3rs);
|
||||
// StorageDead(_7);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ fn main() {
|
|||
// _1 = const true;
|
||||
// StorageLive(_3);
|
||||
// _3 = &'26_1rs _1;
|
||||
// FakeRead(ForLet, _3);
|
||||
// StorageLive(_5);
|
||||
// _5 = _1;
|
||||
// switchInt(move _5) -> [false: bb5, otherwise: bb4];
|
||||
|
|
@ -69,6 +70,7 @@ fn main() {
|
|||
// StorageDead(_5);
|
||||
// StorageLive(_7);
|
||||
// _7 = &'26_3rs _1;
|
||||
// FakeRead(ForLet, _7);
|
||||
// _2 = ();
|
||||
// EndRegion('26_3rs);
|
||||
// StorageDead(_7);
|
||||
|
|
|
|||
|
|
@ -45,10 +45,13 @@ fn foo(i: i32) {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = D::{{constructor}}(const 0i32,);
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_2);
|
||||
// _2 = const 0i32;
|
||||
// FakeRead(ForLet, _2);
|
||||
// StorageLive(_3);
|
||||
// _3 = &'26_2rs _2;
|
||||
// FakeRead(ForLet, _3);
|
||||
// StorageLive(_5);
|
||||
// _5 = (*_3);
|
||||
// _4 = const foo(move _5) -> [return: bb2, unwind: bb3];
|
||||
|
|
@ -60,6 +63,7 @@ fn foo(i: i32) {
|
|||
// StorageDead(_5);
|
||||
// StorageLive(_6);
|
||||
// _6 = &'26_4rs _2;
|
||||
// FakeRead(ForLet, _6);
|
||||
// _0 = ();
|
||||
// EndRegion('26_4rs);
|
||||
// StorageDead(_6);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = D::{{constructor}}(const 0i32,);
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_3);
|
||||
// StorageLive(_4);
|
||||
// _4 = &'14s _1;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = D::{{constructor}}(const 0i32,);
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_3);
|
||||
// StorageLive(_4);
|
||||
// _4 = &'19s _1;
|
||||
|
|
@ -73,6 +74,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
|
|||
// bb0: {
|
||||
// StorageLive(_2);
|
||||
// _2 = &'16_0rs (*(_1.0: &'19s D));
|
||||
// FakeRead(ForLet, _2);
|
||||
// _0 = ((*_2).0: i32);
|
||||
// EndRegion('16_0rs);
|
||||
// StorageDead(_2);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = D::{{constructor}}(const 0i32,);
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_3);
|
||||
// _3 = [closure@NodeId(22)] { d: move _1 };
|
||||
// _2 = const foo(move _3) -> [return: bb2, unwind: bb4];
|
||||
|
|
@ -74,6 +75,7 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
|
|||
// bb0: {
|
||||
// StorageLive(_2);
|
||||
// _2 = &'16_0rs (_1.0: D);
|
||||
// FakeRead(ForLet, _2);
|
||||
// _0 = ((*_2).0: i32);
|
||||
// EndRegion('16_0rs);
|
||||
// StorageDead(_2);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,10 @@ fn foo<F>(f: F) where F: FnOnce() -> i32 {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = D::{{constructor}}(const 0i32,);
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_2);
|
||||
// _2 = &'21_1rs _1;
|
||||
// FakeRead(ForLet, _2);
|
||||
// StorageLive(_4);
|
||||
// _4 = [closure@NodeId(22)] { r: _2 };
|
||||
// _3 = const foo(move _4) -> [return: bb2, unwind: bb3];
|
||||
|
|
|
|||
|
|
@ -55,8 +55,10 @@ fn main() {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const false;
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_2);
|
||||
// _2 = const 3i32;
|
||||
// FakeRead(ForLet, _2);
|
||||
// falseUnwind -> [real: bb2, cleanup: bb1];
|
||||
// }
|
||||
// bb1: {
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ fn query() -> bool { true }
|
|||
// StorageDead(_4);
|
||||
// _2 = S<'36_0rs> { r: move _3 };
|
||||
// StorageDead(_3);
|
||||
// FakeRead(ForLet, _2);
|
||||
// StorageLive(_6);
|
||||
// _6 = &'17s (_2.0: std::cell::Cell<std::option::Option<&'36_0rs S<'36_0rs>>>);
|
||||
// StorageLive(_7);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 {
|
|||
// _5 = (move _6, move _7);
|
||||
// _8 = move (_5.0: &i32);
|
||||
// _9 = move (_5.1: &i32);
|
||||
// ...
|
||||
// _0 = (*_8);
|
||||
// ...
|
||||
// return;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ fn main() {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const false;
|
||||
// FakeRead(ForLet, _1);
|
||||
// goto -> bb2;
|
||||
// }
|
||||
// bb1: {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ fn main() {
|
|||
// goto -> bb6;
|
||||
// }
|
||||
// bb14: {
|
||||
// FakeRead(ForLet, _2);
|
||||
// StorageDead(_3);
|
||||
// StorageLive(_7);
|
||||
// _7 = &_2;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ fn main() {
|
|||
// bb5: { // The loop body (body_block)
|
||||
// StorageLive(_5);
|
||||
// _5 = const 1i32;
|
||||
// FakeRead(ForLet, _5);
|
||||
// StorageDead(_5);
|
||||
// goto -> bb4;
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -66,15 +66,15 @@ fn main() {
|
|||
// goto -> bb13;
|
||||
// }
|
||||
// bb3: { // binding3(empty) and arm3
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
|
||||
// }
|
||||
// bb4: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding2
|
||||
// }
|
||||
// bb5: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb2, imaginary: bb6]; //pre_binding3
|
||||
// }
|
||||
// bb6: {
|
||||
|
|
@ -136,15 +136,15 @@ fn main() {
|
|||
// goto -> bb13;
|
||||
// }
|
||||
// bb3: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1
|
||||
// }
|
||||
// bb4: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb2, imaginary: bb5]; //pre_binding2
|
||||
// }
|
||||
// bb5: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb12, imaginary: bb6]; //pre_binding3
|
||||
// }
|
||||
// bb6: {
|
||||
|
|
@ -202,19 +202,19 @@ fn main() {
|
|||
// resume;
|
||||
// }
|
||||
// bb2: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb7, imaginary: bb3]; //pre_binding1
|
||||
// }
|
||||
// bb3: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb11, imaginary: bb4]; //pre_binding2
|
||||
// }
|
||||
// bb4: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding3
|
||||
// }
|
||||
// bb5: {
|
||||
// ReadForMatch(_4);
|
||||
// FakeRead(ForMatch, _4);
|
||||
// falseEdges -> [real: bb16, imaginary: bb6]; //pre_binding4
|
||||
// }
|
||||
// bb6: {
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ fn main() {
|
|||
|
||||
// END RUST SOURCE
|
||||
// START rustc.main.nll.0.mir
|
||||
// | '_#2r | U0 | {bb2[0..=3], bb3[0..=1]}
|
||||
// | '_#3r | U0 | {bb2[1..=3], bb3[0..=1]}
|
||||
// | '_#4r | U0 | {bb2[3], bb3[0..=1]}
|
||||
// | '_#2r | U0 | {bb2[0..=5], bb3[0..=1]}
|
||||
// | '_#3r | U0 | {bb2[1..=5], bb3[0..=1]}
|
||||
// | '_#4r | U0 | {bb2[4..=5], bb3[0..=1]}
|
||||
// END rustc.main.nll.0.mir
|
||||
// START rustc.main.nll.0.mir
|
||||
// let _6: &'_#4r usize;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ fn main() {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const 0i32;
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_3);
|
||||
// StorageLive(_4);
|
||||
// StorageLive(_5);
|
||||
|
|
@ -30,11 +31,13 @@ fn main() {
|
|||
// _4 = std::option::Option<i32>::Some(move _5,);
|
||||
// StorageDead(_5);
|
||||
// _3 = &_4;
|
||||
// FakeRead(ForLet, _3);
|
||||
// _2 = ();
|
||||
// StorageDead(_4);
|
||||
// StorageDead(_3);
|
||||
// StorageLive(_6);
|
||||
// _6 = const 1i32;
|
||||
// FakeRead(ForLet, _6);
|
||||
// _0 = ();
|
||||
// StorageDead(_6);
|
||||
// StorageDead(_1);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ fn main() {
|
|||
// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 })), [(*_2): i32]);
|
||||
// _3 = &ReErased (*_2);
|
||||
// Validate(Acquire, [(*_3): i32/ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 }) (imm)]);
|
||||
// FakeRead(ForLet, _3);
|
||||
// _0 = (*_3);
|
||||
// EndRegion(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 }));
|
||||
// StorageDead(_3);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ fn main() {
|
|||
// Validate(Acquire, [_1: std::boxed::Box<[i32]>]);
|
||||
// StorageDead(_2);
|
||||
// StorageDead(_3);
|
||||
// FakeRead(ForLet, _1);
|
||||
// _0 = ();
|
||||
// Validate(Release, [_1: std::boxed::Box<[i32]>]);
|
||||
// drop(_1) -> [return: bb2, unwind: bb3];
|
||||
|
|
|
|||
|
|
@ -47,10 +47,12 @@ fn main() {
|
|||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = Test { x: const 0i32 };
|
||||
// FakeRead(ForLet, _1);
|
||||
// StorageLive(_2);
|
||||
// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 })), [_1: Test]);
|
||||
// _2 = &ReErased _1;
|
||||
// Validate(Acquire, [(*_2): Test/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
|
||||
// FakeRead(ForLet, _2);
|
||||
// StorageLive(_4);
|
||||
// StorageLive(_5);
|
||||
// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [((*_2).0: i32): i32/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
|
||||
|
|
|
|||
25
src/test/ui/extern/extern-const.fixed
vendored
25
src/test/ui/extern/extern-const.fixed
vendored
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-rustfix
|
||||
// compile-flags: -Z continue-parse-after-error
|
||||
|
||||
extern "C" {
|
||||
static C: u8; //~ ERROR extern items cannot be `const`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// We suggest turning the (illegal) extern `const` into an extern `static`,
|
||||
// but this also requires `unsafe` (a deny-by-default lint at comment time,
|
||||
// future error; Issue #36247)
|
||||
unsafe {
|
||||
let _x = C;
|
||||
}
|
||||
}
|
||||
2
src/test/ui/extern/extern-const.rs
vendored
2
src/test/ui/extern/extern-const.rs
vendored
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// run-rustfix
|
||||
// FIXME(#54388): re-enable rustfix later, when this test has consistent output across targets
|
||||
// compile-flags: -Z continue-parse-after-error
|
||||
|
||||
extern "C" {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ LL | };
|
|||
error[E0597]: `a` does not live long enough
|
||||
--> $DIR/borrowing.rs:24:9
|
||||
|
|
||||
LL | let _b = {
|
||||
| -- borrow later stored here
|
||||
LL | let a = 3;
|
||||
LL | / || {
|
||||
LL | | yield &a
|
||||
LL | | //~^ ERROR: `a` does not live long enough
|
||||
|
|
@ -17,8 +20,6 @@ LL | | }
|
|||
| |_________^ borrowed value does not live long enough
|
||||
LL | };
|
||||
| - `a` dropped here while still borrowed
|
||||
LL | }
|
||||
| - borrow later used here, when `_b` is dropped
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
error[E0597]: `i` does not live long enough
|
||||
--> $DIR/regions-steal-closure.rs:24:28
|
||||
|
|
||||
LL | let mut cl_box = {
|
||||
| ---------- borrow later stored here
|
||||
LL | let mut i = 3;
|
||||
LL | box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough
|
||||
| -- ^ borrowed value does not live long enough
|
||||
| |
|
||||
| value captured here
|
||||
LL | };
|
||||
| - `i` dropped here while still borrowed
|
||||
LL | cl_box.cl.call_mut(());
|
||||
| --------- borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
error[E0597]: `a` does not live long enough
|
||||
--> $DIR/range-2.rs:17: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
|
||||
...
|
||||
LL | r.use_ref();
|
||||
| - borrow later used here
|
||||
|
||||
error[E0597]: `b` does not live long enough
|
||||
--> $DIR/range-2.rs:17: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
|
||||
...
|
||||
LL | r.use_ref();
|
||||
| - borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
error[E0597]: `x` does not live long enough
|
||||
--> $DIR/send-is-not-static-ensures-scoping.rs:26: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
|
||||
LL |
|
||||
LL | bad.join();
|
||||
| --- borrow later used here
|
||||
|
||||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/send-is-not-static-ensures-scoping.rs:30:22
|
||||
|
|
||||
LL | let bad = {
|
||||
| --- borrow later stored here
|
||||
...
|
||||
LL | scoped(|| {
|
||||
| -- value captured here
|
||||
LL | let _z = y;
|
||||
|
|
@ -20,9 +23,6 @@ LL | let _z = y;
|
|||
...
|
||||
LL | };
|
||||
| - `y` dropped here while still borrowed
|
||||
LL |
|
||||
LL | bad.join();
|
||||
| --- borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
error[E0597]: `x` does not live long enough
|
||||
--> $DIR/send-is-not-static-std-sync-2.rs:21: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
|
||||
...
|
||||
LL | let _dangling = *lock.lock().unwrap();
|
||||
| ---- borrow later used here
|
||||
|
||||
error[E0597]: `x` does not live long enough
|
||||
--> $DIR/send-is-not-static-std-sync-2.rs:31: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
|
||||
LL | //~^^ ERROR `x` does not live long enough
|
||||
LL | let _dangling = *lock.read().unwrap();
|
||||
| ---- borrow later used here
|
||||
|
||||
error[E0597]: `x` does not live long enough
|
||||
--> $DIR/send-is-not-static-std-sync-2.rs:41:25
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
error[E0597]: `pointer` does not live long enough
|
||||
--> $DIR/wf-method-late-bound-regions.rs:30: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
|
||||
LL | //~^^ ERROR `pointer` does not live long enough
|
||||
LL | println!("{}", dangling);
|
||||
| -------- borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
error[E0597]: `x` does not live long enough
|
||||
--> $DIR/unboxed-closure-region.rs:18:12
|
||||
|
|
||||
LL | let _f = {
|
||||
| -- borrow later stored here
|
||||
LL | let x = 0;
|
||||
LL | || x //~ ERROR `x` does not live long enough
|
||||
| -- ^ borrowed value does not live long enough
|
||||
| |
|
||||
| value captured here
|
||||
LL | };
|
||||
| - `x` dropped here while still borrowed
|
||||
LL | _f;
|
||||
| -- borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue