-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Description
This snippet does not compile with the following error:
pub fn main() {
|i: u32| { || i };
}
error[E0597]: `i` does not live long enough
--> src/main.rs:2:19
|
2 | |i: u32| { || i };
| -- ^ - borrowed value dropped before borrower
| | |
| | borrowed value does not live long enough
| capture occurs here
|
= note: values in a scope are dropped in the opposite order they are created
But adding a move
fixes it:
pub fn main() {
|i: u32| { move || i };
}
I believe the compiler tries to suggest move
where appropriate, and it seems that this case has been missed.
Metadata
Metadata
Assignees
Labels
fixed-by-NLLBugs fixed, but only when NLL is enabled.Bugs fixed, but only when NLL is enabled.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
grantslatton commentedon Dec 7, 2018
With Rust 2018 this now provides the correct error message:
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=<try>
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix
Auto merge of #59114 - matthewjasper:enable-migate-2015, r=pnkfelix