Skip to content

Commit f70abe8

Browse files
committed
Add sanity test for promotion and const_let
1 parent 6bcb0d6 commit f70abe8

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0597]: `y` does not live long enough
2+
--> $DIR/promote_const_let.rs:6:9
3+
|
4+
LL | let x: &'static u32 = {
5+
| ------------ type annotation requires that `y` is borrowed for `'static`
6+
LL | let y = 42;
7+
LL | &y //~ ERROR does not live long enough
8+
| ^^ borrowed value does not live long enough
9+
LL | };
10+
| - `y` dropped here while still borrowed
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0597`.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(const_let)]
2+
3+
fn main() {
4+
let x: &'static u32 = {
5+
let y = 42;
6+
&y //~ ERROR does not live long enough
7+
};
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0597]: `y` does not live long enough
2+
--> $DIR/promote_const_let.rs:6:10
3+
|
4+
LL | &y //~ ERROR does not live long enough
5+
| ^ borrowed value does not live long enough
6+
LL | };
7+
| - borrowed value only lives until here
8+
|
9+
= note: borrowed value must be valid for the static lifetime...
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0597`.

0 commit comments

Comments
 (0)