Skip to content

Commit 9387b52

Browse files
committed
fix: all of the errors in test files from introducing new lint
1 parent b02fc51 commit 9387b52

22 files changed

+282
-260
lines changed

tests/ui/manual_is_variant_and.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@aux-build:option_helpers.rs
22
#![warn(clippy::manual_is_variant_and)]
3+
#![allow(clippy::concealed_obvious_default)]
34

45
#[macro_use]
56
extern crate option_helpers;

tests/ui/manual_is_variant_and.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@aux-build:option_helpers.rs
22
#![warn(clippy::manual_is_variant_and)]
3+
#![allow(clippy::concealed_obvious_default)]
34

45
#[macro_use]
56
extern crate option_helpers;

tests/ui/manual_is_variant_and.stderr

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: called `map(<f>).unwrap_or_default()` on an `Option` value
2-
--> tests/ui/manual_is_variant_and.rs:51:17
2+
--> tests/ui/manual_is_variant_and.rs:52:17
33
|
44
LL | let _ = opt.map(|x| x > 1)
55
| _________________^
@@ -11,7 +11,7 @@ LL | | .unwrap_or_default();
1111
= help: to override `-D warnings` add `#[allow(clippy::manual_is_variant_and)]`
1212

1313
error: called `map(<f>).unwrap_or_default()` on an `Option` value
14-
--> tests/ui/manual_is_variant_and.rs:56:17
14+
--> tests/ui/manual_is_variant_and.rs:57:17
1515
|
1616
LL | let _ = opt.map(|x| {
1717
| _________________^
@@ -30,13 +30,13 @@ LL ~ });
3030
|
3131

3232
error: called `map(<f>).unwrap_or_default()` on an `Option` value
33-
--> tests/ui/manual_is_variant_and.rs:61:17
33+
--> tests/ui/manual_is_variant_and.rs:62:17
3434
|
3535
LL | let _ = opt.map(|x| x > 1).unwrap_or_default();
3636
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_some_and(|x| x > 1)`
3737

3838
error: called `map(<f>).unwrap_or_default()` on an `Option` value
39-
--> tests/ui/manual_is_variant_and.rs:64:10
39+
--> tests/ui/manual_is_variant_and.rs:65:10
4040
|
4141
LL | .map(|x| x > 1)
4242
| __________^
@@ -45,37 +45,37 @@ LL | | .unwrap_or_default();
4545
| |____________________________^ help: use: `is_some_and(|x| x > 1)`
4646

4747
error: called `.map() == Some()`
48-
--> tests/ui/manual_is_variant_and.rs:68:13
48+
--> tests/ui/manual_is_variant_and.rs:69:13
4949
|
5050
LL | let _ = Some(2).map(|x| x % 2 == 0) == Some(true);
5151
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Some(2).is_some_and(|x| x % 2 == 0)`
5252

5353
error: called `.map() != Some()`
54-
--> tests/ui/manual_is_variant_and.rs:70:13
54+
--> tests/ui/manual_is_variant_and.rs:71:13
5555
|
5656
LL | let _ = Some(2).map(|x| x % 2 == 0) != Some(true);
5757
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Some(2).is_none_or(|x| x % 2 == 0)`
5858

5959
error: called `.map() == Some()`
60-
--> tests/ui/manual_is_variant_and.rs:72:13
60+
--> tests/ui/manual_is_variant_and.rs:73:13
6161
|
6262
LL | let _ = Some(2).map(|x| x % 2 == 0) == some_true!();
6363
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Some(2).is_some_and(|x| x % 2 == 0)`
6464

6565
error: called `.map() != Some()`
66-
--> tests/ui/manual_is_variant_and.rs:74:13
66+
--> tests/ui/manual_is_variant_and.rs:75:13
6767
|
6868
LL | let _ = Some(2).map(|x| x % 2 == 0) != some_false!();
6969
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Some(2).is_none_or(|x| x % 2 == 0)`
7070

7171
error: called `map(<f>).unwrap_or_default()` on an `Option` value
72-
--> tests/ui/manual_is_variant_and.rs:81:18
72+
--> tests/ui/manual_is_variant_and.rs:82:18
7373
|
7474
LL | let _ = opt2.map(char::is_alphanumeric).unwrap_or_default(); // should lint
7575
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_some_and(char::is_alphanumeric)`
7676

7777
error: called `map(<f>).unwrap_or_default()` on a `Result` value
78-
--> tests/ui/manual_is_variant_and.rs:99:17
78+
--> tests/ui/manual_is_variant_and.rs:100:17
7979
|
8080
LL | let _ = res.map(|x| {
8181
| _________________^
@@ -94,7 +94,7 @@ LL ~ });
9494
|
9595

9696
error: called `map(<f>).unwrap_or_default()` on a `Result` value
97-
--> tests/ui/manual_is_variant_and.rs:104:17
97+
--> tests/ui/manual_is_variant_and.rs:105:17
9898
|
9999
LL | let _ = res.map(|x| x > 1)
100100
| _________________^
@@ -103,25 +103,25 @@ LL | | .unwrap_or_default();
103103
| |____________________________^ help: use: `is_ok_and(|x| x > 1)`
104104

105105
error: called `.map() == Ok()`
106-
--> tests/ui/manual_is_variant_and.rs:108:13
106+
--> tests/ui/manual_is_variant_and.rs:109:13
107107
|
108108
LL | let _ = Ok::<usize, ()>(2).map(|x| x % 2 == 0) == Ok(true);
109109
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `Ok::<usize, ()>(2).is_ok_and(|x| x % 2 == 0)`
110110

111111
error: called `.map() != Ok()`
112-
--> tests/ui/manual_is_variant_and.rs:110:13
112+
--> tests/ui/manual_is_variant_and.rs:111:13
113113
|
114114
LL | let _ = Ok::<usize, ()>(2).map(|x| x % 2 == 0) != Ok(true);
115115
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `!Ok::<usize, ()>(2).is_ok_and(|x| x % 2 == 0)`
116116

117117
error: called `.map() != Ok()`
118-
--> tests/ui/manual_is_variant_and.rs:112:13
118+
--> tests/ui/manual_is_variant_and.rs:113:13
119119
|
120120
LL | let _ = Ok::<usize, ()>(2).map(|x| x % 2 == 0) != Ok(true);
121121
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `!Ok::<usize, ()>(2).is_ok_and(|x| x % 2 == 0)`
122122

123123
error: called `map(<f>).unwrap_or_default()` on a `Result` value
124-
--> tests/ui/manual_is_variant_and.rs:119:18
124+
--> tests/ui/manual_is_variant_and.rs:120:18
125125
|
126126
LL | let _ = res2.map(char::is_alphanumeric).unwrap_or_default(); // should lint
127127
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `is_ok_and(char::is_alphanumeric)`

tests/ui/manual_unwrap_or_default.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::manual_unwrap_or_default)]
2-
#![allow(clippy::unnecessary_literal_unwrap)]
2+
#![allow(clippy::unnecessary_literal_unwrap, clippy::concealed_obvious_default)]
33

44
fn main() {
55
let x: Option<Vec<String>> = None;

tests/ui/manual_unwrap_or_default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::manual_unwrap_or_default)]
2-
#![allow(clippy::unnecessary_literal_unwrap)]
2+
#![allow(clippy::unnecessary_literal_unwrap, clippy::concealed_obvious_default)]
33

44
fn main() {
55
let x: Option<Vec<String>> = None;

tests/ui/obfuscated_if_else.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
clippy::unnecessary_lazy_evaluations,
44
clippy::unit_arg,
55
clippy::unused_unit,
6-
clippy::unwrap_or_default
6+
clippy::unwrap_or_default,
7+
clippy::concealed_obvious_default
78
)]
89

910
fn main() {

tests/ui/obfuscated_if_else.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
clippy::unnecessary_lazy_evaluations,
44
clippy::unit_arg,
55
clippy::unused_unit,
6-
clippy::unwrap_or_default
6+
clippy::unwrap_or_default,
7+
clippy::concealed_obvious_default
78
)]
89

910
fn main() {

tests/ui/obfuscated_if_else.stderr

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this method chain can be written more clearly with `if .. else ..`
2-
--> tests/ui/obfuscated_if_else.rs:10:5
2+
--> tests/ui/obfuscated_if_else.rs:11:5
33
|
44
LL | true.then_some("a").unwrap_or("b");
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }`
@@ -8,133 +8,133 @@ LL | true.then_some("a").unwrap_or("b");
88
= help: to override `-D warnings` add `#[allow(clippy::obfuscated_if_else)]`
99

1010
error: this method chain can be written more clearly with `if .. else ..`
11-
--> tests/ui/obfuscated_if_else.rs:13:5
11+
--> tests/ui/obfuscated_if_else.rs:14:5
1212
|
1313
LL | true.then(|| "a").unwrap_or("b");
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { "a" } else { "b" }`
1515

1616
error: this method chain can be written more clearly with `if .. else ..`
17-
--> tests/ui/obfuscated_if_else.rs:17:5
17+
--> tests/ui/obfuscated_if_else.rs:18:5
1818
|
1919
LL | (a == 1).then_some("a").unwrap_or("b");
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if a == 1 { "a" } else { "b" }`
2121

2222
error: this method chain can be written more clearly with `if .. else ..`
23-
--> tests/ui/obfuscated_if_else.rs:20:5
23+
--> tests/ui/obfuscated_if_else.rs:21:5
2424
|
2525
LL | (a == 1).then(|| "a").unwrap_or("b");
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if a == 1 { "a" } else { "b" }`
2727

2828
error: this method chain can be written more clearly with `if .. else ..`
29-
--> tests/ui/obfuscated_if_else.rs:27:5
29+
--> tests/ui/obfuscated_if_else.rs:28:5
3030
|
3131
LL | true.then_some(a += 1).unwrap_or(());
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { a += 1 } else { () }`
3333

3434
error: this method chain can be written more clearly with `if .. else ..`
35-
--> tests/ui/obfuscated_if_else.rs:30:5
35+
--> tests/ui/obfuscated_if_else.rs:31:5
3636
|
3737
LL | true.then_some(()).unwrap_or(a += 2);
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { () } else { a += 2 }`
3939

4040
error: this method chain can be written more clearly with `if .. else ..`
41-
--> tests/ui/obfuscated_if_else.rs:34:5
41+
--> tests/ui/obfuscated_if_else.rs:35:5
4242
|
4343
LL | true.then(|| n = 1).unwrap_or_else(|| n = 2);
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { n = 1 } else { n = 2 }`
4545

4646
error: this method chain can be written more clearly with `if .. else ..`
47-
--> tests/ui/obfuscated_if_else.rs:36:5
47+
--> tests/ui/obfuscated_if_else.rs:37:5
4848
|
4949
LL | true.then_some(1).unwrap_or_else(|| n * 2);
5050
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 1 } else { n * 2 }`
5151

5252
error: this method chain can be written more clearly with `if .. else ..`
53-
--> tests/ui/obfuscated_if_else.rs:38:5
53+
--> tests/ui/obfuscated_if_else.rs:39:5
5454
|
5555
LL | true.then_some(n += 1).unwrap_or_else(|| ());
5656
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { n += 1 } else { () }`
5757

5858
error: this method chain can be written more clearly with `if .. else ..`
59-
--> tests/ui/obfuscated_if_else.rs:41:13
59+
--> tests/ui/obfuscated_if_else.rs:42:13
6060
|
6161
LL | let _ = true.then_some(1).unwrap_or_else(|| n * 2);
6262
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 1 } else { n * 2 }`
6363

6464
error: this method chain can be written more clearly with `if .. else ..`
65-
--> tests/ui/obfuscated_if_else.rs:44:5
65+
--> tests/ui/obfuscated_if_else.rs:45:5
6666
|
6767
LL | true.then_some(1).unwrap_or_else(Default::default);
6868
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 1 } else { Default::default() }`
6969

7070
error: this method chain can be written more clearly with `if .. else ..`
71-
--> tests/ui/obfuscated_if_else.rs:50:5
71+
--> tests/ui/obfuscated_if_else.rs:51:5
7272
|
7373
LL | true.then_some(()).unwrap_or_default();
7474
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { () } else { Default::default() }`
7575

7676
error: this method chain can be written more clearly with `if .. else ..`
77-
--> tests/ui/obfuscated_if_else.rs:53:5
77+
--> tests/ui/obfuscated_if_else.rs:54:5
7878
|
7979
LL | true.then(|| ()).unwrap_or_default();
8080
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { () } else { Default::default() }`
8181

8282
error: this method chain can be written more clearly with `if .. else ..`
83-
--> tests/ui/obfuscated_if_else.rs:56:5
83+
--> tests/ui/obfuscated_if_else.rs:57:5
8484
|
8585
LL | true.then_some(1).unwrap_or_default();
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 1 } else { Default::default() }`
8787

8888
error: this method chain can be written more clearly with `if .. else ..`
89-
--> tests/ui/obfuscated_if_else.rs:59:5
89+
--> tests/ui/obfuscated_if_else.rs:60:5
9090
|
9191
LL | true.then(|| 1).unwrap_or_default();
9292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 1 } else { Default::default() }`
9393

9494
error: this method chain can be written more clearly with `if .. else ..`
95-
--> tests/ui/obfuscated_if_else.rs:65:13
95+
--> tests/ui/obfuscated_if_else.rs:66:13
9696
|
9797
LL | let _ = true.then_some(40).unwrap_or(17) | 2;
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(if true { 40 } else { 17 })`
9999

100100
error: this method chain can be written more clearly with `if .. else ..`
101-
--> tests/ui/obfuscated_if_else.rs:69:13
101+
--> tests/ui/obfuscated_if_else.rs:70:13
102102
|
103103
LL | let _ = true.then_some(30).unwrap_or(17) | true.then_some(2).unwrap_or(3) | true.then_some(10).unwrap_or(1);
104104
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(if true { 30 } else { 17 })`
105105

106106
error: this method chain can be written more clearly with `if .. else ..`
107-
--> tests/ui/obfuscated_if_else.rs:69:48
107+
--> tests/ui/obfuscated_if_else.rs:70:48
108108
|
109109
LL | let _ = true.then_some(30).unwrap_or(17) | true.then_some(2).unwrap_or(3) | true.then_some(10).unwrap_or(1);
110110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 2 } else { 3 }`
111111

112112
error: this method chain can be written more clearly with `if .. else ..`
113-
--> tests/ui/obfuscated_if_else.rs:69:81
113+
--> tests/ui/obfuscated_if_else.rs:70:81
114114
|
115115
LL | let _ = true.then_some(30).unwrap_or(17) | true.then_some(2).unwrap_or(3) | true.then_some(10).unwrap_or(1);
116116
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 10 } else { 1 }`
117117

118118
error: this method chain can be written more clearly with `if .. else ..`
119-
--> tests/ui/obfuscated_if_else.rs:75:17
119+
--> tests/ui/obfuscated_if_else.rs:76:17
120120
|
121121
LL | let _ = 2 | true.then_some(40).unwrap_or(17);
122122
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 40 } else { 17 }`
123123

124124
error: this method chain can be written more clearly with `if .. else ..`
125-
--> tests/ui/obfuscated_if_else.rs:79:13
125+
--> tests/ui/obfuscated_if_else.rs:80:13
126126
|
127127
LL | let _ = true.then_some(42).unwrap_or(17) as u8;
128128
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { 42 } else { 17 }`
129129

130130
error: this method chain can be written more clearly with `if .. else ..`
131-
--> tests/ui/obfuscated_if_else.rs:83:14
131+
--> tests/ui/obfuscated_if_else.rs:84:14
132132
|
133133
LL | let _ = *true.then_some(&42).unwrap_or(&17);
134134
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { &42 } else { &17 }`
135135

136136
error: this method chain can be written more clearly with `if .. else ..`
137-
--> tests/ui/obfuscated_if_else.rs:87:14
137+
--> tests/ui/obfuscated_if_else.rs:88:14
138138
|
139139
LL | let _ = *true.then_some(&42).unwrap_or(&17) as u8;
140140
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `if true { &42 } else { &17 }`

tests/ui/or_fun_call.fixed

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
clippy::uninlined_format_args,
66
clippy::unnecessary_wraps,
77
clippy::unnecessary_literal_unwrap,
8-
clippy::useless_vec
8+
clippy::useless_vec,
9+
clippy::concealed_obvious_default
910
)]
1011

1112
use std::collections::{BTreeMap, HashMap};

tests/ui/or_fun_call.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
clippy::uninlined_format_args,
66
clippy::unnecessary_wraps,
77
clippy::unnecessary_literal_unwrap,
8-
clippy::useless_vec
8+
clippy::useless_vec,
9+
clippy::concealed_obvious_default
910
)]
1011

1112
use std::collections::{BTreeMap, HashMap};

0 commit comments

Comments
 (0)