rustc_lint::drop_forget_useless

Static FORGETTING_REFERENCES

source
pub static FORGETTING_REFERENCES: &Lint
Expand description

The forgetting_references lint checks for calls to std::mem::forget with a reference instead of an owned value.

§Example

let x = Box::new(1);
std::mem::forget(&x); // Should have been forget(x), x will still be dropped

{{produces}}

§Explanation

Calling forget on a reference will only forget the reference itself, which is a no-op. It will not forget the underlying referenced value, which is likely what was intended.