RS.CLIPPY.MEM_FORGET
`mem::forget` usage on `Drop` types, likely to cause memory leaks
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: mem_forget. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage of std::mem::forget(t) where t is
Drop or has a field that implements Drop.
Why restrict this?
std::mem::forget(t) prevents t from running its destructor, possibly causing leaks.
It is not possible to detect all means of creating leaks, but it may be desirable to
prohibit the simple ones.
Example
mem::forget(Rc::new(55))