Rust

Rust

Made by DeepSource

Called mem::forget or mem::drop on a non-Drop type RS-E1021

Bug risk
Major

Calling std::mem::forget (or std::mem::drop) on types that do not implement the Drop trait is a no-op.

Consider revisiting this function call.

Bad practice

struct T {}

fn foo() {
    let x = T {};
    // Both function calls below are no-ops
    // as T does not implement Drop
    std::mem::forget(x);
    std::mem::drop(x);
}