Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
philipjonsen opened this issue Sep 22, 2024 · 1 comment
Closed

Comments

@philipjonsen
Copy link

Description
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
l```
et x: Vec = Vec::with_capacity(10);
let y: String = String::new();

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

Recommended¨

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

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


Using drop with a reference at https://github.com/nitro/blob/master/arbitrator/arbutil/src/evm/req.rs#L118-L118
@joshuacolvin0
Copy link
Member

This is just a linter false positive.

@joshuacolvin0 joshuacolvin0 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants