-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.P-mediumMedium priorityMedium priority
Milestone
Description
I was playing around with #21407, and I think I found a distinct bug in FRU – if a field initialiser escapes (panics/returns/break
s), some of the fields in the original struct get leaked.
For example:
struct Noisy(u32);
impl Drop for Noisy {
fn drop(&mut self) {
println!("splat #{}!", self.0);
}
}
struct Foo { n0: Noisy, n1: Noisy }
fn leak() -> Foo {
let old_foo = Foo { n0: Noisy(0), n1: Noisy(1) };
Foo { n0: { return Foo { n0: Noisy(3), n1: Noisy(4) } }, ..old_foo } ;
}
fn main() {
drop(leak());
}
This prints
splat #0!
splat #3!
splat #4!
Observe that the Noisy(1)
is never destroyed.
Metadata
Metadata
Assignees
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.P-mediumMedium priorityMedium priority