- Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh 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.T-langRelevant to the language teamRelevant to the language team
Description
STR
struct NoisyDrop; impl Drop for NoisyDrop { fn drop(&mut self) { println!("dropping a NoisyDrop"); } } impl NoisyDrop { fn new() -> Self { println!("creating a NoisyDrop"); NoisyDrop } } struct PanickyDrop; impl Drop for PanickyDrop { fn drop(&mut self) { panic!() } } fn foo() -> NoisyDrop { let p = PanickyDrop; NoisyDrop::new() } fn main() { foo(); }
Expected Result
"creating a NoisyDrop" and "dropping a NoisyDrop" should appear the same number of times
Actual Result
creating a NoisyDrop thread 'main' panicked at 'explicit panic', src/main.rs:18:8 note: Run with `RUST_BACKTRACE=1` for a backtrace.
The destructor is ignored.
Metadata
Metadata
Assignees
Labels
A-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh 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.T-langRelevant to the language teamRelevant to the language team