Open
Description
Code
fn main() {
let targets = String::new();
let queue = targets.as_str();
(move || require_static(queue))();
}
fn require_static(_: &'static str) {}
Current output
error[E0597]: `targets` does not live long enough
--> src/main.rs:3:17
|
2 | let targets = String::new();
| ------- binding `targets` declared here
3 | let queue = targets.as_str();
| ^^^^^^^---------
| |
| borrowed value does not live long enough
| argument requires that `targets` is borrowed for `'static`
...
6 | }
| - `targets` dropped here while still borrowed
For more information about this error, try `rustc --explain E0597`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Desired output
error[E0597]: `targets` does not live long enough
--> src/main.rs:3:17
|
2 | let targets = String::new();
| ------- binding `targets` declared here
3 | let queue = targets.as_str();
| ^^^^^^^ borrowed value does not live long enough
4 |
5 | (move || require_static(queue))();
| --------------------- argument requires that `targets` is borrowed for `'static`
6 | }
| - `targets` dropped here while still borrowed
For more information about this error, try `rustc --explain E0597`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Rationale and extra context
No response
Other cases
This works on stable, but regressed on nightly.
Rust Version
rustc 1.80.0-nightly (804421dff 2024-06-07)
Anything else?
No response