Correctly mark the ending span of a match arm

Closes #74050

r? @matthewjasper
This commit is contained in:
Ayaz Hafiz 2020-07-07 07:50:49 -07:00
parent 8ac1525e09
commit 3c63fba03d
No known key found for this signature in database
GPG key ID: B443F7A3030C9AED
21 changed files with 115 additions and 87 deletions

View file

@ -0,0 +1,13 @@
fn main() {
let mut args = std::env::args_os();
let _arg = match args.next() {
Some(arg) => {
match arg.to_str() {
//~^ ERROR `arg` does not live long enough
Some(s) => s,
None => return,
}
}
None => return,
};
}

View file

@ -0,0 +1,15 @@
error[E0597]: `arg` does not live long enough
--> $DIR/issue-74050-end-span.rs:5:19
|
LL | let _arg = match args.next() {
| ---- borrow later stored here
LL | Some(arg) => {
LL | match arg.to_str() {
| ^^^ borrowed value does not live long enough
...
LL | }
| - `arg` dropped here while still borrowed
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.