2018-11-20 10:33:46 +00:00
|
|
|
error[E0597]: `y` does not live long enough
|
2019-04-22 07:40:08 +00:00
|
|
|
--> $DIR/promote_const_let.rs:4:9
|
2018-11-20 10:33:46 +00:00
|
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
LL | let x: &'static u32 = {
|
|
|
|
| ------------ type annotation requires that `y` is borrowed for `'static`
|
|
|
|
LL | let y = 42;
|
2023-01-15 03:06:44 +00:00
|
|
|
| - binding `y` declared here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | &y
|
2019-04-22 07:40:08 +00:00
|
|
|
| ^^ borrowed value does not live long enough
|
2018-11-20 10:33:46 +00:00
|
|
|
LL | };
|
2019-04-22 07:40:08 +00:00
|
|
|
| - `y` dropped here while still borrowed
|
2018-11-20 10:33:46 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0716]: temporary value dropped while borrowed
|
2018-12-28 19:05:22 +00:00
|
|
|
--> $DIR/promote_const_let.rs:6:28
|
|
|
|
|
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let x: &'static u32 = &{
|
2019-04-22 07:40:08 +00:00
|
|
|
| ____________------------____^
|
|
|
|
| | |
|
|
|
|
| | type annotation requires that borrow lasts for `'static`
|
2018-12-28 19:05:22 +00:00
|
|
|
LL | | let y = 42;
|
|
|
|
LL | | y
|
|
|
|
LL | | };
|
2022-10-20 15:43:27 +00:00
|
|
|
| |_____^ creates a temporary value which is freed while still in use
|
2018-12-28 19:05:22 +00:00
|
|
|
LL | }
|
2019-04-22 07:40:08 +00:00
|
|
|
| - temporary value is freed at the end of this statement
|
2018-12-28 19:05:22 +00:00
|
|
|
|
|
|
|
error: aborting due to 2 previous errors
|
2018-11-20 10:33:46 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
Some errors have detailed explanations: E0597, E0716.
|
|
|
|
For more information about an error, try `rustc --explain E0597`.
|