Closed
Description
The following code works fine if drop(x)
is used instead of let _ = x
. The closure function generated contains just a _0 = ()
and a return
. Trans probably does some magic, but I haven't been able to locate it.
struct Foo<'a>(&'a mut bool);
impl<'a> Drop for Foo<'a> {
fn drop(&mut self) {
*self.0 = true;
}
}
fn f<T: FnOnce()>(t: T) {
t()
}
fn main() {
let mut ran_drop = false;
{
let x = Foo(&mut ran_drop);
let x = move || { let _ = x; };
f(x);
}
assert!(ran_drop);
}