-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-enable len_zero for ranges now that
is_empty
is stable on them
- Loading branch information
Showing
6 changed files
with
21 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
// run-rustfix | ||
|
||
#![feature(range_is_empty)] | ||
#![warn(clippy::len_zero)] | ||
#![allow(unused)] | ||
#![allow(stable_features)] // TODO: https://github.com/rust-lang/rust-clippy/issues/5956 | ||
|
||
// Now that `Range(Inclusive)::is_empty` is stable (1.47), we can always suggest this | ||
mod issue_3807 { | ||
// With the feature enabled, `is_empty` should be suggested | ||
fn suggestion_is_fine() { | ||
fn suggestion_is_fine_range() { | ||
let _ = (0..42).is_empty(); | ||
} | ||
|
||
fn suggestion_is_fine_range_inclusive() { | ||
let _ = (0_u8..=42).is_empty(); | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
// run-rustfix | ||
|
||
#![feature(range_is_empty)] | ||
#![warn(clippy::len_zero)] | ||
#![allow(unused)] | ||
#![allow(stable_features)] // TODO: https://github.com/rust-lang/rust-clippy/issues/5956 | ||
|
||
// Now that `Range(Inclusive)::is_empty` is stable (1.47), we can always suggest this | ||
mod issue_3807 { | ||
// With the feature enabled, `is_empty` should be suggested | ||
fn suggestion_is_fine() { | ||
fn suggestion_is_fine_range() { | ||
let _ = (0..42).len() == 0; | ||
} | ||
|
||
fn suggestion_is_fine_range_inclusive() { | ||
let _ = (0_u8..=42).len() == 0; | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
error: length comparison to zero | ||
--> $DIR/len_zero_ranges.rs:11:17 | ||
--> $DIR/len_zero_ranges.rs:9:17 | ||
| | ||
LL | let _ = (0..42).len() == 0; | ||
| ^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0..42).is_empty()` | ||
| | ||
= note: `-D clippy::len-zero` implied by `-D warnings` | ||
|
||
error: aborting due to previous error | ||
error: length comparison to zero | ||
--> $DIR/len_zero_ranges.rs:13:17 | ||
| | ||
LL | let _ = (0_u8..=42).len() == 0; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(0_u8..=42).is_empty()` | ||
|
||
error: aborting due to 2 previous errors | ||
|