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

Open
philipjonsen opened this issue Sep 22, 2024 · 0 comments
Open

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

philipjonsen opened this issue Sep 22, 2024 · 0 comments

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
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

1 participant