Correctly mark the ending span of a match arm
Closes #74050 r? @matthewjasper
This commit is contained in:
parent
8ac1525e09
commit
3c63fba03d
21 changed files with 115 additions and 87 deletions
13
src/test/ui/match/issue-74050-end-span.rs
Normal file
13
src/test/ui/match/issue-74050-end-span.rs
Normal 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,
|
||||
};
|
||||
}
|
||||
15
src/test/ui/match/issue-74050-end-span.stderr
Normal file
15
src/test/ui/match/issue-74050-end-span.stderr
Normal 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue