-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)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
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) .
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)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.