Clippy · Reliability
mem::forget on a value with drop semantics
clippy::mem_forget
Avoid leaking a value with drop semantics; use an explicit ownership or lifetime strategy.
- Category
- Reliability
- Default level
- warn
- Tier
- P2
- Producer
- Clippy
- Diff scope
- line
Not a defect when
Ownership of the resource was handed elsewhere, such as a raw handle or pointer passed to C code or a value already moved out with ptr::read, so running its destructor would double-free.
What it reads
Clippy, with the compiler behind it. The only pass that compiles.
Tier
Ordinary defect.
The tier bounds how severe a rule may be; its category bounds the tier.Diff scope
The changed line itself.
What--scope contextual looks at to decide whether a change caused the finding.Change it
Turn it off, or make it blocking, without touching the code it flags:
rust-doctor --rule clippy::mem_forget=off .
rust-doctor --rule clippy::mem_forget=error .