Add sanity test for promotion and const_let

This commit is contained in:
Oliver Scherer 2018-11-20 11:33:46 +01:00
parent 6bcb0d6152
commit f70abe8d07
3 changed files with 35 additions and 0 deletions

View file

@ -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`.

View file

@ -0,0 +1,8 @@
#![feature(const_let)]
fn main() {
let x: &'static u32 = {
let y = 42;
&y //~ ERROR does not live long enough
};
}

View file

@ -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`.