diff options
| author | bors <bors@rust-lang.org> | 2022-05-31 16:17:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-31 16:17:12 +0000 |
| commit | 5b1a4c0d763f51ba6ecd7e378e18a94d8b55c2bd (patch) | |
| tree | 4005824c214b484fb18af07ae8508e52e07f3ff2 /tests/debuginfo/enum-thinlto.rs | |
| parent | 7000e758c19472bb1e642e5b4bd463a3b5c8ca68 (diff) | |
| parent | 257f09776a9c68ac903d1f23b80c414b70de1185 (diff) | |
| download | rust-5b1a4c0d763f51ba6ecd7e378e18a94d8b55c2bd.tar.gz rust-5b1a4c0d763f51ba6ecd7e378e18a94d8b55c2bd.zip | |
Auto merge of #8884 - evantypanski:manual_range_contains_multiple, r=Manishearth
Fix `manual_range_contains` false negative with chains of `&&` and `||`
Fixes #8745
Since the precedence for `&&` is the same as itself the HIR for a chain of `&&` ends up with a right skewed tree like:
```
&&
/ \
&& c2
/ \
... c1
```
So only the leftmost `&&` was actually "fully" checked, the top level was just `c2` and `&&` so the `manual_range_contains` lint won't apply. This change makes it also check `c2` with `c1`.
There's a bit of a hacky solution in the [second commit](https://github.com/rust-lang/rust-clippy/commit/257f09776a9c68ac903d1f23b80c414b70de1185) to check if the number of open/closing parens in the snippet match. This is to prevent a case like `((x % 2 == 0) || (x < 0)) || (x >= 10)` from offering a suggestion like `((x % 2 == 0) || !(0..10).contains(&x)` which now won't compile.
Any suggestions for that paren hack welcome, kinda new to working on this so not too sure about possible solutions :) it's weird because I don't know how else to check for parens in HIR considering they're removed when lowering AST.
changelog: Fix [`manual_range_contains`] false negative with chains of `&&` and `||`
Diffstat (limited to 'tests/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions
