Closed
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. :(