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

Lint against --foo when foo is a numeric binding #88669

Closed
estebank opened this issue Sep 5, 2021 · 3 comments
Closed

Lint against --foo when foo is a numeric binding #88669

estebank opened this issue Sep 5, 2021 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-parser Area: The parsing of Rust source code to an AST D-papercut Diagnostics: An error or lint that needs small tweaks. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Sep 5, 2021

As noted in #88553 (comment), let x = --y; is syntactically valid as a double negation, but it looks like C's pre-decrement. We should lint against it and suggest both removing the -- or writing y -= 1; let x = y;.

pre-increment, post-increment and post-decrement are not likely to confuse people too much because they are syntax errors, but we might also want to modify the parser to detect them specifically and provide a structured suggestion for appropriate code.

@estebank estebank added A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-papercut Diagnostics: An error or lint that needs small tweaks. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Sep 5, 2021
@camelid
Copy link
Member

camelid commented Sep 5, 2021

Isn't there a clippy lint that's proposed to be uplifted that catches --y? See #82987.

@estebank
Copy link
Contributor Author

estebank commented Sep 5, 2021

Yeah, you're right. We can still keep this ticket open for the "handle ++x/x++/x-- more gracefully in the parser".

@camelid
Copy link
Member

camelid commented Sep 5, 2021

We can still keep this ticket open for the "handle ++x/x++/x-- more gracefully in the parser".

I think #83502 might cover that. I've been meaning to get back to it...

@estebank estebank closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-parser Area: The parsing of Rust source code to an AST D-papercut Diagnostics: An error or lint that needs small tweaks. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants