forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#58180 - davidtwco:issue-58053, r=estebank
Fix span for closure return type when annotated. Fixes rust-lang#58053. This PR adjusts the span used to label closure return types so that if the user specifies the return type, i.e. `|_| -> X {}` instead of `|_| {}`, we correctly highlight all of it and not just the last character. r? @pnkfelix
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![allow(warnings)] | ||
#![feature(nll)] | ||
|
||
fn main() { | ||
let i = &3; | ||
|
||
let f = |x: &i32| -> &i32 { x }; | ||
//~^ ERROR lifetime may not live long enough | ||
let j = f(i); | ||
|
||
let g = |x: &i32| { x }; | ||
//~^ ERROR lifetime may not live long enough | ||
let k = g(i); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: lifetime may not live long enough | ||
--> $DIR/issue-58053.rs:7:33 | ||
| | ||
LL | let f = |x: &i32| -> &i32 { x }; | ||
| - ---- ^ returning this value requires that `'1` must outlive `'2` | ||
| | | | ||
| | return type of closure is &'2 i32 | ||
| let's call the lifetime of this reference `'1` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/issue-58053.rs:11:25 | ||
| | ||
LL | let g = |x: &i32| { x }; | ||
| - - ^ returning this value requires that `'1` must outlive `'2` | ||
| | | | ||
| | return type of closure is &'2 i32 | ||
| let's call the lifetime of this reference `'1` | ||
|
||
error: aborting due to 2 previous errors | ||
|