diff options
| author | bors <bors@rust-lang.org> | 2023-10-27 14:10:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-27 14:10:42 +0000 |
| commit | 9d6d5d48948945debca5a693f6030246f7bb2baf (patch) | |
| tree | f29b6ecb8e8c3281019fbbc77da3b7eecdf46a72 /compiler/rustc_interface/src/interface.rs | |
| parent | 688892938e825312fcf808236af95cadb4f088e9 (diff) | |
| parent | 3fa2e71ce14508c28637889501055342378d051f (diff) | |
| download | rust-9d6d5d48948945debca5a693f6030246f7bb2baf.tar.gz rust-9d6d5d48948945debca5a693f6030246f7bb2baf.zip | |
Auto merge of #116751 - Nadrieril:lint-overlap-per-column, r=davidtwco
Lint overlapping ranges as a separate pass
This reworks the [`overlapping_range_endpoints`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_lint_defs/builtin/static.OVERLAPPING_RANGE_ENDPOINTS.html) lint. My motivations are:
- It was annoying to have this lint entangled with the exhaustiveness algorithm, especially wrt librarification;
- This makes the lint behave consistently.
Here's the consistency story. Take the following matches:
```rust
match (0u8, true) {
(0..=10, true) => {}
(10..20, true) => {}
(10..20, false) => {}
_ => {}
}
match (true, 0u8) {
(true, 0..=10) => {}
(true, 10..20) => {}
(false, 10..20) => {}
_ => {}
}
```
There are two semantically consistent options: option 1 we lint all overlaps between the ranges, option 2 we only lint the overlaps that could actually occur (i.e. the ones with `true`). Option 1 is what this PR does. Option 2 is possible but would require the exhaustiveness algorithm to track more things for the sake of the lint. The status quo is that we're inconsistent between the two.
Option 1 generates more false postives, but I prefer it from a maintainer's perspective. I do think the difference is minimal; cases where the difference is observable seem rare.
This PR adds a separate pass, so this will have a perf impact. Let's see how bad, it looked ok locally.
Diffstat (limited to 'compiler/rustc_interface/src/interface.rs')
0 files changed, 0 insertions, 0 deletions
