Rust

Rust

Made by DeepSource

Called mem::forget or mem::drop on a Copy type RS-E1011

Bug risk
Major

For types that implement the Copy trait, std::mem::forget (or std::mem::drop) effectively does nothing because the type is copied into the function call, and the newly copied type is forgotten (or dropped). Additionally, Copy types do not have destructors; there is nothing for std::mem::forget or (or std::mem::drop) to do.

Consider revisiting this function call.

Bad practice

let x = 42;

// `x` is copied into the function call
// the original `x` is left unaffected
std::mem::forget(x);
std::mem::drop(x);