Rust

Rust

Made by DeepSource

Called mem::forget or mem::drop on a reference RS-E1010

Bug risk
Major

Calling std::mem::forget (or std::mem::drop) on a reference will forget (or drop) the reference itself, which effectively does nothing. The underlying reference value will remain unaffected.

Consider revisiting this function call. Perhaps you meant to call mem::forget (or mem::drop) on the underlying reference value instead.

Bad practice

let x: Vec<u32> = Vec::with_capacity(10);
let y: String = String::new();

std::mem::forget(&x);
std::mem::drop(&y);

Recommended

let x: Vec<u32> = Vec::with_capacity(10);
let y: String = String::new();

std::mem::forget(x);
std::mem::drop(y);