Closed
Description
struct Foo(i32);
impl Foo {
pub fn dowork(&self) {
println!("foo: doing work {}", self.0);
}
}
impl Drop for Foo {
fn drop(&mut self) {
println!("foo: drop {}", self.0);
}
}
fn f<T: FnOnce()>(t: T) {
t()
}
fn main() {
let x = Foo(1);
let x = move || x.dowork();
f(x);
}
Somehow, the Foo object leaks: my guess is that it has something to do with the way we generate code for the FnOnce()
trait for closures which also implement Fn()
.
Originally reported at #28796 (comment) .