-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.P-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
I tried this code:
fn main() {
let mut args = std::env::args_os();
let _arg = match args.next() {
Some(arg) => {
match arg.to_str() {
Some(s) => s,
None => return,
}
}
None => return,
};
}
Previously, in 1.36 or earlier, it presented an error like this:
error[E0597]: `arg` does not live long enough
--> src/main.rs:7:19
|
5 | let _arg = match args.next() {
| ---- borrow later stored here
6 | Some(arg) => {
7 | match arg.to_str() {
| ^^^ borrowed value does not live long enough
...
13 | };
| - `arg` dropped here while still borrowed
Starting with 1.37, the "dropped here while still borrowed" message points to an odd location:
error[E0597]: `arg` does not live long enough
--> src/main.rs:7:19
|
5 | let _arg = match args.next() {
| ---- borrow later stored here
6 | Some(arg) => {
7 | match arg.to_str() {
| ^^^ borrowed value does not live long enough
...
12 | None => return,
| - `arg` dropped here while still borrowed
The earlier error looks more correct to me.
Bisected the change to nightly-2019-05-24, I would guess maybe it is #60174.
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.P-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.