-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemP-lowLow priorityLow 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
fn direct<F: Fn()>(_: F) {}
trait Foo { fn method(&self) {} }
impl<F: Fn()> Foo for F {}
fn blanket<F: Foo>(_: F) {}
struct Moves;
fn main() {
let x = Moves; direct(|| drop(x));
// let y = Moves; blanket(|| drop(y));
}
The x
line gives
<anon>:11:37: 11:38 error: cannot move out of captured outer variable in an `Fn` closure
<anon>:11 let x = Moves; direct(|| drop(x));
^
while the y
line gives:
<anon>:13:22: 13:29 error: the trait `core::ops::Fn<()>` is not implemented for the type `[closure <anon>:13:30: 13:40]` [E0277]
<anon>:13 let y = Moves; blanket(|| drop(y));
^~~~~~~
The latter doesn't really give much information about the problem (moving out of y
) and, AFAIK, the most effective way to debug is to find the offending statement via binary search commenting out chunks of code. :(
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemP-lowLow priorityLow 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.