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: detect if
expressions with simple boolean assignments to the same target
#10432
Conversation
r? @Manishearth (rustbot has picked a reviewer for you, use r? to override) |
If we have comments inside the if expr that explain what is happening, will clippy remove these? This might be annoying :/ if needless_bool_condition() {
// the crazy brown fox
a.field = true;
} else {
// jumps over the lazy cow
a.field = true;
} |
Yeah I'm concerned about sticking this within an existing lint, and worried about impact. |
I agree with both remarks. I'll make this into a new lint and check for comments. I'll put it in draft status in the meantime. |
cf45b1b
to
e99e89f
Compare
if
expressions with simple boolean assignments to the same targetif
expressions with simple boolean assignments to the same target
@Manishearth I made it into a new lint. @matthiaskrgr The lint does not trigger when there are comments in the Note that expanded code is excluded already. |
e99e89f
to
c3a16fe
Compare
cc @rust-lang/clippy Do we think this lint is going to be too noisy? Should we nursery it first or something? |
I don't expect this lint to trigger much except on beginner programmers' code (as does |
If we want to have a trial period, I'd first put this into |
lintcheck does not trigger this lint. Running it with clippy 0.1.69
### Reports
### Stats:
| lint | count |
| -------------------------------------------------- | ----- |
### ICEs: |
Checked with the 500 most recently downloaded crates of crates.io: this lint was not triggered (the complete 470klines report is available at https://rfc1149.net/tmp/top500_logs.txt.gz). |
@Manishearth Is there anything more you'd like me to do on this one? |
I don't think we have consensus as a team on whether we should release this lint enabled by default. (Also I'm a bit busy and will be slow to review) |
This has been lingering for more than one month now. What is the next step? (I'll rebase it in the meantime) |
c3a16fe
to
506aceb
Compare
506aceb
to
69da902
Compare
@bors r+ given lintcheck results I guess it's fine |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Closes #10430
changelog: [
needless_bool_assign
] new lint to detect simple boolean assignment to the same target inif
branches