-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
See this example, which fails to compile:
fn foo<F>(f: F)
where F: FnOnce()
{
}
fn main() {
let x = Some(vec![1, 2, 3]);
foo(|| {
match x {
Some(y) => { }
None => { }
}
});
}
Error:
<anon>:9:15: 9:16 error: cannot move out of captured outer variable in an `FnOnce` closure
<anon>:9 match x {
^
<anon>:10:18: 10:19 note: attempting to move value to here
<anon>:10 Some(y) => { }
^
<anon>:10:18: 10:19 help: to prevent the move, use `ref y` or `ref mut y` to capture value by reference
error: aborting due to previous error
playpen: application terminated with error code 101
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.