diff --git a/src/test/ui/consts/promote_const_let.nll.stderr b/src/test/ui/consts/promote_const_let.nll.stderr new file mode 100644 index 000000000000..d8749bb5fd90 --- /dev/null +++ b/src/test/ui/consts/promote_const_let.nll.stderr @@ -0,0 +1,14 @@ +error[E0597]: `y` does not live long enough + --> $DIR/promote_const_let.rs:6:9 + | +LL | let x: &'static u32 = { + | ------------ type annotation requires that `y` is borrowed for `'static` +LL | let y = 42; +LL | &y //~ ERROR does not live long enough + | ^^ borrowed value does not live long enough +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/consts/promote_const_let.rs b/src/test/ui/consts/promote_const_let.rs new file mode 100644 index 000000000000..1ba406a957d2 --- /dev/null +++ b/src/test/ui/consts/promote_const_let.rs @@ -0,0 +1,8 @@ +#![feature(const_let)] + +fn main() { + let x: &'static u32 = { + let y = 42; + &y //~ ERROR does not live long enough + }; +} \ No newline at end of file diff --git a/src/test/ui/consts/promote_const_let.stderr b/src/test/ui/consts/promote_const_let.stderr new file mode 100644 index 000000000000..6bbb7495fb0d --- /dev/null +++ b/src/test/ui/consts/promote_const_let.stderr @@ -0,0 +1,13 @@ +error[E0597]: `y` does not live long enough + --> $DIR/promote_const_let.rs:6:10 + | +LL | &y //~ ERROR 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... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`.