-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.