Add sanity test for promotion and const_let
This commit is contained in:
parent
6bcb0d6152
commit
f70abe8d07
3 changed files with 35 additions and 0 deletions
14
src/test/ui/consts/promote_const_let.nll.stderr
Normal file
14
src/test/ui/consts/promote_const_let.nll.stderr
Normal 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`.
|
||||
8
src/test/ui/consts/promote_const_let.rs
Normal file
8
src/test/ui/consts/promote_const_let.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#![feature(const_let)]
|
||||
|
||||
fn main() {
|
||||
let x: &'static u32 = {
|
||||
let y = 42;
|
||||
&y //~ ERROR does not live long enough
|
||||
};
|
||||
}
|
||||
13
src/test/ui/consts/promote_const_let.stderr
Normal file
13
src/test/ui/consts/promote_const_let.stderr
Normal 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue