diff options
| author | bors <bors@rust-lang.org> | 2020-08-25 05:24:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-08-25 05:24:30 +0000 |
| commit | c30341ddec0b99bb3bd8bb5fd8c8451778c78330 (patch) | |
| tree | a7482a95b884e75d2a2bd66e4d2c40223a552e05 /src/tools | |
| parent | ee541284bf5008bb0425fae02412352025099707 (diff) | |
| parent | d6185f931435a161525f41d270207e33faa26ea2 (diff) | |
Auto merge of #75132 - scottmcm:stabilize-range-is-empty, r=dtolnay
Stabilize Range[Inclusive]::is_empty I would like to propose these two simple methods for stabilization: - Knowing that a range is exhausted isn't otherwise trivial - Clippy would like to suggest them, but had to do extra work to disable that path <https://github.com/rust-lang/rust-clippy/issues/3807> because they're unstable - These work on `PartialOrd`, consistently with the stable `contains` method, and are thus more general than iterator-based approaches that need `Step` - They've been unchanged for some time, and have picked up uses in the compiler - Stabilizing them doesn't block any future iterator-based `is_empty` plans, as these inherent ones are preferred in name resolution https://doc.rust-lang.org/nightly/std/ops/struct.Range.html#method.is_empty https://doc.rust-lang.org/nightly/std/ops/struct.RangeInclusive.html#method.is_empty Closes #48111
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/clippy/tests/ui/len_zero_ranges.fixed | 1 | ||||
| -rw-r--r-- | src/tools/clippy/tests/ui/len_zero_ranges.rs | 1 | ||||
| -rw-r--r-- | src/tools/clippy/tests/ui/len_zero_ranges.stderr | 2 |
3 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/clippy/tests/ui/len_zero_ranges.fixed b/src/tools/clippy/tests/ui/len_zero_ranges.fixed index 7da26f8ff4d..eee3db9b7d4 100644 --- a/src/tools/clippy/tests/ui/len_zero_ranges.fixed +++ b/src/tools/clippy/tests/ui/len_zero_ranges.fixed @@ -3,6 +3,7 @@ #![feature(range_is_empty)] #![warn(clippy::len_zero)] #![allow(unused)] +#![allow(stable_features)] // TODO: https://github.com/rust-lang/rust-clippy/issues/5956 mod issue_3807 { // With the feature enabled, `is_empty` should be suggested diff --git a/src/tools/clippy/tests/ui/len_zero_ranges.rs b/src/tools/clippy/tests/ui/len_zero_ranges.rs index be7b4244bc0..be2e0f38fd1 100644 --- a/src/tools/clippy/tests/ui/len_zero_ranges.rs +++ b/src/tools/clippy/tests/ui/len_zero_ranges.rs @@ -3,6 +3,7 @@ #![feature(range_is_empty)] #![warn(clippy::len_zero)] #![allow(unused)] +#![allow(stable_features)] // TODO: https://github.com/rust-lang/rust-clippy/issues/5956 mod issue_3807 { // With the feature enabled, `is_empty` should be suggested diff --git a/src/tools/clippy/tests/ui/len_zero_ranges.stderr b/src/tools/clippy/tests/ui/len_zero_ranges.stderr index 6e5fa41fb08..acb85f7100a 100644 --- a/src/tools/clippy/tests/ui/len_zero_ranges.stderr +++ b/src/tools/clippy/tests/ui/len_zero_ranges.stderr @@ -1,5 +1,5 @@ error: length comparison to zero - --> $DIR/len_zero_ranges.rs:10:17 + --> $DIR/len_zero_ranges.rs:11:17 | LL | let _ = (0..42).len() == 0; | ^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0..42).is_empty()` |
