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

New lint: replace place statement with drop(place) #5206

Open
CAD97 opened this issue Feb 20, 2020 · 0 comments
Open

New lint: replace place statement with drop(place) #5206

CAD97 opened this issue Feb 20, 2020 · 0 comments
Labels
A-lint Area: New lints L-complexity Lint: Belongs in the complexity lint group

Comments

@CAD97
Copy link
Contributor

CAD97 commented Feb 20, 2020

As featured in this Twitter poll.

The statement <place>; causes a move from and drop of the value at place. For clarity of intent, this is better written as drop(<place>); to emphasize the destructor is what is being invoked.

> 65% of votes on the linked poll had intuition that this (var;) did not invoke the destructor, so this lint would definitely help avoid potentially misleading code. (rustc does already lint this as path_statements, so perhaps this should instead be an improvement to that lint. rust-lang/rust#48852 is a 2018 issue to remove the lint (which is currently incorrect) for path statements that invoke a destructor.

@flip1995 flip1995 added L-complexity Lint: Belongs in the complexity lint group A-lint Area: New lints labels Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints L-complexity Lint: Belongs in the complexity lint group
Projects
None yet
Development

No branches or pull requests

2 participants