RS.CLIPPY.FORGET_NON_DROP

Call to `std::mem::forget` with a value which does not implement `Drop`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: forget_non_drop. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for calls to std::mem::forget with a value that does not implement Drop.

Why is this bad?

Calling std::mem::forget is no different than dropping such a type. A different value may have been intended.

Example

struct Foo;
let x = Foo;
std::mem::forget(x);