Skip to content

mem::forget on !Drop #1897

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

Closed
Manishearth opened this issue Jul 20, 2017 · 2 comments · Fixed by #8630
Closed

mem::forget on !Drop #1897

Manishearth opened this issue Jul 20, 2017 · 2 comments · Fixed by #8630
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types

Comments

@Manishearth
Copy link
Member

We should warn if you call mem::forget on:

  • a generic type known to be Copy
  • a non generic type known to not be Drop

since it's a no op, and likely means you mem::forgot the wrong thing.

(I hit this issue today)

@Manishearth Manishearth added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. A-lint Area: New lints T-middle Type: Probably requires verifiying types labels Jul 20, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Jul 21, 2017

https://github.com/rust-lang-nursery/rust-clippy/wiki#drop_copy ;)

There's a use case for types that are not Drop: if the type is !Copy, then you just got rid of it. But we might prefer to suggest let _ = foo; instead, not sure?

@Manishearth
Copy link
Member Author

Yeah, that makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants