-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #67687 - estebank:issue-67634, r=matthewjasper
Do not ICE on lifetime error involving closures Fix #67634.
- Loading branch information
Showing
3 changed files
with
38 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
3 changes: 3 additions & 0 deletions
3
src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.rs
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,3 @@ | ||
fn main() { | ||
[0].iter().flat_map(|a| [0].iter().map(|_| &a)); //~ ERROR `a` does not live long enough | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/lifetimes/unnamed-closure-doesnt-life-long-enough-issue-67634.stderr
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,15 @@ | ||
error[E0597]: `a` does not live long enough | ||
--> $DIR/unnamed-closure-doesnt-life-long-enough-issue-67634.rs:2:49 | ||
| | ||
LL | [0].iter().flat_map(|a| [0].iter().map(|_| &a)); | ||
| - ^- ...but `a` will be dropped here, when the enclosing closure returns | ||
| | | | ||
| | `a` would have to be valid for `'_`... | ||
| has type `&i32` | ||
| | ||
= note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments | ||
= note: to learn more, visit <https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#dangling-references> | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |