-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[NLL] Use span of the closure args in free region errors #53088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
error: unsatisfied lifetime constraints | ||
--> $DIR/issue-40510-1.rs:18:9 | ||
| | ||
LL | || { | ||
| _____- | ||
| |_____| | ||
| || | ||
LL | || &mut x | ||
| || ^^^^^^ return requires that `'1` must outlive `'2` | ||
LL | || }; | ||
| || - | ||
| ||_____| | ||
| |______lifetime `'1` represents the closure body | ||
| lifetime `'2` appears in return type | ||
LL | || { | ||
| -- | ||
| || | ||
| |return type of closure is &'2 mut std::boxed::Box<()> | ||
| lifetime `'1` represents this closure's body | ||
LL | &mut x | ||
| ^^^^^^ return requires that `'1` must outlive `'2` | ||
| | ||
= note: closure implements `FnMut`, so references to captured variables can't escape the closure | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also so nice — I do wonder if we can "re-orient" the message around this note though. Something like this:
maybe we should shelve this for a later improvement, though -- in particular, I would really like to do a bit more analysis and connect the message to the variable
|
||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
error: unsatisfied lifetime constraints | ||
--> $DIR/issue-40510-3.rs:18:9 | ||
| | ||
LL | || { | ||
| _____- | ||
| |_____| | ||
| || | ||
LL | || || { | ||
| ||_________^ | ||
LL | ||| x.push(()) | ||
LL | ||| } | ||
| |||_________^ requires that `'1` must outlive `'2` | ||
LL | || }; | ||
| || - | ||
| ||_____| | ||
| |______lifetime `'1` represents the closure body | ||
| lifetime `'2` appears in return type | ||
LL | || { | ||
| -- | ||
| || | ||
| |return type of closure is [closure@$DIR/issue-40510-3.rs:18:9: 20:10 x:&'2 mut std::vec::Vec<()>] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another place we should take a note for future improvement: rather than printing the return type here, I'd rather we found some way to describe the role that |
||
| lifetime `'1` represents this closure's body | ||
LL | / || { | ||
LL | | x.push(()) | ||
LL | | } | ||
| |_________^ requires that `'1` must outlive `'2` | ||
| | ||
= note: closure implements `FnMut`, so references to captured variables can't escape the closure | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
error: unsatisfied lifetime constraints | ||
--> $DIR/issue-49824.rs:22:9 | ||
| | ||
LL | || { | ||
| _____- | ||
| |_____| | ||
| || | ||
LL | || || { | ||
| ||_________^ | ||
LL | ||| let _y = &mut x; | ||
LL | ||| } | ||
| |||_________^ requires that `'1` must outlive `'2` | ||
LL | || }; | ||
| || - | ||
| ||_____| | ||
| |______lifetime `'1` represents the closure body | ||
| lifetime `'2` appears in return type | ||
LL | || { | ||
| -- | ||
| || | ||
| |return type of closure is [closure@$DIR/issue-49824.rs:22:9: 24:10 x:&'2 mut i32] | ||
| lifetime `'1` represents this closure's body | ||
LL | / || { | ||
LL | | let _y = &mut x; | ||
LL | | } | ||
| |_________^ requires that `'1` must outlive `'2` | ||
| | ||
= note: closure implements `FnMut`, so references to captured variables can't escape the closure | ||
|
||
error: aborting due to previous error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so nice