Skip to content

Commit f108599

Browse files
committed
chore: update some tests to allow const_is_empty
1 parent 1daad06 commit f108599

11 files changed

+46
-30
lines changed

tests/ui/bool_assert_comparison.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(unused, clippy::assertions_on_constants)]
1+
#![allow(unused, clippy::assertions_on_constants, clippy::const_is_empty)]
22
#![warn(clippy::bool_assert_comparison)]
33

44
use std::ops::Not;

tests/ui/bool_assert_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(unused, clippy::assertions_on_constants)]
1+
#![allow(unused, clippy::assertions_on_constants, clippy::const_is_empty)]
22
#![warn(clippy::bool_assert_comparison)]
33

44
use std::ops::Not;

tests/ui/len_zero.fixed

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![warn(clippy::len_zero)]
2-
#![allow(dead_code, unused, clippy::needless_if, clippy::len_without_is_empty)]
2+
#![allow(
3+
dead_code,
4+
unused,
5+
clippy::needless_if,
6+
clippy::len_without_is_empty,
7+
clippy::const_is_empty
8+
)]
39

410
extern crate core;
511
use core::ops::Deref;

tests/ui/len_zero.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![warn(clippy::len_zero)]
2-
#![allow(dead_code, unused, clippy::needless_if, clippy::len_without_is_empty)]
2+
#![allow(
3+
dead_code,
4+
unused,
5+
clippy::needless_if,
6+
clippy::len_without_is_empty,
7+
clippy::const_is_empty
8+
)]
39

410
extern crate core;
511
use core::ops::Deref;

tests/ui/len_zero.stderr

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: length comparison to zero
2-
--> tests/ui/len_zero.rs:82:8
2+
--> tests/ui/len_zero.rs:88:8
33
|
44
LL | if x.len() == 0 {
55
| ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `x.is_empty()`
@@ -8,13 +8,13 @@ LL | if x.len() == 0 {
88
= help: to override `-D warnings` add `#[allow(clippy::len_zero)]`
99

1010
error: length comparison to zero
11-
--> tests/ui/len_zero.rs:86:8
11+
--> tests/ui/len_zero.rs:92:8
1212
|
1313
LL | if "".len() == 0 {}
1414
| ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `"".is_empty()`
1515

1616
error: comparison to empty slice
17-
--> tests/ui/len_zero.rs:95:20
17+
--> tests/ui/len_zero.rs:101:20
1818
|
1919
LL | println!("{}", *s1 == "");
2020
| ^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s1.is_empty()`
@@ -23,121 +23,121 @@ LL | println!("{}", *s1 == "");
2323
= help: to override `-D warnings` add `#[allow(clippy::comparison_to_empty)]`
2424

2525
error: comparison to empty slice
26-
--> tests/ui/len_zero.rs:96:20
26+
--> tests/ui/len_zero.rs:102:20
2727
|
2828
LL | println!("{}", **s2 == "");
2929
| ^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s2.is_empty()`
3030

3131
error: comparison to empty slice
32-
--> tests/ui/len_zero.rs:97:20
32+
--> tests/ui/len_zero.rs:103:20
3333
|
3434
LL | println!("{}", ***s3 == "");
3535
| ^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s3.is_empty()`
3636

3737
error: comparison to empty slice
38-
--> tests/ui/len_zero.rs:98:20
38+
--> tests/ui/len_zero.rs:104:20
3939
|
4040
LL | println!("{}", ****s4 == "");
4141
| ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s4.is_empty()`
4242

4343
error: comparison to empty slice
44-
--> tests/ui/len_zero.rs:99:20
44+
--> tests/ui/len_zero.rs:105:20
4545
|
4646
LL | println!("{}", *****s5 == "");
4747
| ^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `s5.is_empty()`
4848

4949
error: comparison to empty slice
50-
--> tests/ui/len_zero.rs:100:20
50+
--> tests/ui/len_zero.rs:106:20
5151
|
5252
LL | println!("{}", ******(s6) == "");
5353
| ^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(s6).is_empty()`
5454

5555
error: comparison to empty slice
56-
--> tests/ui/len_zero.rs:103:20
56+
--> tests/ui/len_zero.rs:109:20
5757
|
5858
LL | println!("{}", &**d2s == "");
5959
| ^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `(**d2s).is_empty()`
6060

6161
error: length comparison to zero
62-
--> tests/ui/len_zero.rs:118:8
62+
--> tests/ui/len_zero.rs:124:8
6363
|
6464
LL | if has_is_empty.len() == 0 {
6565
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
6666

6767
error: length comparison to zero
68-
--> tests/ui/len_zero.rs:121:8
68+
--> tests/ui/len_zero.rs:127:8
6969
|
7070
LL | if has_is_empty.len() != 0 {
7171
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
7272

7373
error: length comparison to zero
74-
--> tests/ui/len_zero.rs:124:8
74+
--> tests/ui/len_zero.rs:130:8
7575
|
7676
LL | if has_is_empty.len() > 0 {
7777
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
7878

7979
error: length comparison to one
80-
--> tests/ui/len_zero.rs:127:8
80+
--> tests/ui/len_zero.rs:133:8
8181
|
8282
LL | if has_is_empty.len() < 1 {
8383
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
8484

8585
error: length comparison to one
86-
--> tests/ui/len_zero.rs:130:8
86+
--> tests/ui/len_zero.rs:136:8
8787
|
8888
LL | if has_is_empty.len() >= 1 {
8989
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
9090

9191
error: length comparison to zero
92-
--> tests/ui/len_zero.rs:141:8
92+
--> tests/ui/len_zero.rs:147:8
9393
|
9494
LL | if 0 == has_is_empty.len() {
9595
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
9696

9797
error: length comparison to zero
98-
--> tests/ui/len_zero.rs:144:8
98+
--> tests/ui/len_zero.rs:150:8
9999
|
100100
LL | if 0 != has_is_empty.len() {
101101
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
102102

103103
error: length comparison to zero
104-
--> tests/ui/len_zero.rs:147:8
104+
--> tests/ui/len_zero.rs:153:8
105105
|
106106
LL | if 0 < has_is_empty.len() {
107107
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
108108

109109
error: length comparison to one
110-
--> tests/ui/len_zero.rs:150:8
110+
--> tests/ui/len_zero.rs:156:8
111111
|
112112
LL | if 1 <= has_is_empty.len() {
113113
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
114114

115115
error: length comparison to one
116-
--> tests/ui/len_zero.rs:153:8
116+
--> tests/ui/len_zero.rs:159:8
117117
|
118118
LL | if 1 > has_is_empty.len() {
119119
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
120120

121121
error: length comparison to zero
122-
--> tests/ui/len_zero.rs:167:8
122+
--> tests/ui/len_zero.rs:173:8
123123
|
124124
LL | if with_is_empty.len() == 0 {
125125
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `with_is_empty.is_empty()`
126126

127127
error: length comparison to zero
128-
--> tests/ui/len_zero.rs:179:6
128+
--> tests/ui/len_zero.rs:185:6
129129
|
130130
LL | (has_is_empty.len() > 0).then(|| println!("This can happen."));
131131
| ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!has_is_empty.is_empty()`
132132

133133
error: length comparison to zero
134-
--> tests/ui/len_zero.rs:180:6
134+
--> tests/ui/len_zero.rs:186:6
135135
|
136136
LL | (has_is_empty.len() == 0).then(|| println!("Or this!"));
137137
| ^^^^^^^^^^^^^^^^^^^^^^^ help: using `is_empty` is clearer and more explicit: `has_is_empty.is_empty()`
138138

139139
error: length comparison to zero
140-
--> tests/ui/len_zero.rs:184:8
140+
--> tests/ui/len_zero.rs:190:8
141141
|
142142
LL | if b.len() != 0 {}
143143
| ^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!b.is_empty()`

tests/ui/needless_bitwise_bool.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(clippy::needless_bitwise_bool)]
2+
#![allow(clippy::const_is_empty)]
23

34
fn returns_bool() -> bool {
45
true

tests/ui/needless_bitwise_bool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(clippy::needless_bitwise_bool)]
2+
#![allow(clippy::const_is_empty)]
23

34
fn returns_bool() -> bool {
45
true

tests/ui/needless_bitwise_bool.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: use of bitwise operator instead of lazy operator between booleans
2-
--> tests/ui/needless_bitwise_bool.rs:22:8
2+
--> tests/ui/needless_bitwise_bool.rs:23:8
33
|
44
LL | if y & !x {
55
| ^^^^^^ help: try: `y && !x`

tests/ui/redundant_as_str.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(clippy::redundant_as_str)]
2+
#![allow(clippy::const_is_empty)]
23

34
fn main() {
45
let string = "Hello, world!".to_owned();

tests/ui/redundant_as_str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(clippy::redundant_as_str)]
2+
#![allow(clippy::const_is_empty)]
23

34
fn main() {
45
let string = "Hello, world!".to_owned();

tests/ui/redundant_as_str.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too
2-
--> tests/ui/redundant_as_str.rs:7:29
2+
--> tests/ui/redundant_as_str.rs:8:29
33
|
44
LL | let _redundant = string.as_str().as_bytes();
55
| ^^^^^^^^^^^^^^^^^ help: try: `as_bytes`
@@ -8,7 +8,7 @@ LL | let _redundant = string.as_str().as_bytes();
88
= help: to override `-D warnings` add `#[allow(clippy::redundant_as_str)]`
99

1010
error: this `as_str` is redundant and can be removed as the method immediately following exists on `String` too
11-
--> tests/ui/redundant_as_str.rs:8:29
11+
--> tests/ui/redundant_as_str.rs:9:29
1212
|
1313
LL | let _redundant = string.as_str().is_empty();
1414
| ^^^^^^^^^^^^^^^^^ help: try: `is_empty`

0 commit comments

Comments
 (0)