Closed
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
Area: The borrow checkerArea: Messages for errors, warnings, and lintsCategory: This is a bug.Diagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: Confusing error or lint; hard to understand for new users.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.