This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
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`.
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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`.
You can’t perform that action at this time.
0 commit comments