Skip to content

Commit ef28361

Browse files
committed
Downgrade match_bool to pedantic
1 parent 02c9435 commit ef28361

10 files changed

+30
-27
lines changed

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11341134
LintId::of(&loops::EXPLICIT_INTO_ITER_LOOP),
11351135
LintId::of(&loops::EXPLICIT_ITER_LOOP),
11361136
LintId::of(&macro_use::MACRO_USE_IMPORTS),
1137+
LintId::of(&matches::MATCH_BOOL),
11371138
LintId::of(&matches::SINGLE_MATCH_ELSE),
11381139
LintId::of(&methods::FILTER_MAP),
11391140
LintId::of(&methods::FILTER_MAP_NEXT),
@@ -1279,7 +1280,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
12791280
LintId::of(&map_unit_fn::RESULT_MAP_UNIT_FN),
12801281
LintId::of(&matches::INFALLIBLE_DESTRUCTURING_MATCH),
12811282
LintId::of(&matches::MATCH_AS_REF),
1282-
LintId::of(&matches::MATCH_BOOL),
12831283
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
12841284
LintId::of(&matches::MATCH_REF_PATS),
12851285
LintId::of(&matches::MATCH_SINGLE_BINDING),
@@ -1470,7 +1470,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
14701470
LintId::of(&main_recursion::MAIN_RECURSION),
14711471
LintId::of(&map_clone::MAP_CLONE),
14721472
LintId::of(&matches::INFALLIBLE_DESTRUCTURING_MATCH),
1473-
LintId::of(&matches::MATCH_BOOL),
14741473
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
14751474
LintId::of(&matches::MATCH_REF_PATS),
14761475
LintId::of(&matches::MATCH_WILD_ERR_ARM),

clippy_lints/src/matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ declare_clippy_lint! {
138138
/// }
139139
/// ```
140140
pub MATCH_BOOL,
141-
style,
141+
pedantic,
142142
"a `match` on a boolean expression instead of an `if..else` block"
143143
}
144144

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
11391139
},
11401140
Lint {
11411141
name: "match_bool",
1142-
group: "style",
1142+
group: "pedantic",
11431143
desc: "a `match` on a boolean expression instead of an `if..else` block",
11441144
deprecation: None,
11451145
module: "matches",

tests/ui/implicit_return.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ fn test_if_block() -> bool {
2121
}
2222
}
2323

24-
#[allow(clippy::match_bool)]
2524
#[rustfmt::skip]
2625
fn test_match(x: bool) -> bool {
2726
match x {
@@ -30,7 +29,7 @@ fn test_match(x: bool) -> bool {
3029
}
3130
}
3231

33-
#[allow(clippy::match_bool, clippy::needless_return)]
32+
#[allow(clippy::needless_return)]
3433
fn test_match_with_unreachable(x: bool) -> bool {
3534
match x {
3635
true => return false,

tests/ui/implicit_return.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ fn test_if_block() -> bool {
2121
}
2222
}
2323

24-
#[allow(clippy::match_bool)]
2524
#[rustfmt::skip]
2625
fn test_match(x: bool) -> bool {
2726
match x {
@@ -30,7 +29,7 @@ fn test_match(x: bool) -> bool {
3029
}
3130
}
3231

33-
#[allow(clippy::match_bool, clippy::needless_return)]
32+
#[allow(clippy::needless_return)]
3433
fn test_match_with_unreachable(x: bool) -> bool {
3534
match x {
3635
true => return false,

tests/ui/implicit_return.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,49 +19,49 @@ LL | false
1919
| ^^^^^ help: add `return` as shown: `return false`
2020

2121
error: missing `return` statement
22-
--> $DIR/implicit_return.rs:28:17
22+
--> $DIR/implicit_return.rs:27:17
2323
|
2424
LL | true => false,
2525
| ^^^^^ help: add `return` as shown: `return false`
2626

2727
error: missing `return` statement
28-
--> $DIR/implicit_return.rs:29:20
28+
--> $DIR/implicit_return.rs:28:20
2929
|
3030
LL | false => { true },
3131
| ^^^^ help: add `return` as shown: `return true`
3232

3333
error: missing `return` statement
34-
--> $DIR/implicit_return.rs:44:9
34+
--> $DIR/implicit_return.rs:43:9
3535
|
3636
LL | break true;
3737
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
3838

3939
error: missing `return` statement
40-
--> $DIR/implicit_return.rs:52:13
40+
--> $DIR/implicit_return.rs:51:13
4141
|
4242
LL | break true;
4343
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
4444

4545
error: missing `return` statement
46-
--> $DIR/implicit_return.rs:61:13
46+
--> $DIR/implicit_return.rs:60:13
4747
|
4848
LL | break true;
4949
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
5050

5151
error: missing `return` statement
52-
--> $DIR/implicit_return.rs:79:18
52+
--> $DIR/implicit_return.rs:78:18
5353
|
5454
LL | let _ = || { true };
5555
| ^^^^ help: add `return` as shown: `return true`
5656

5757
error: missing `return` statement
58-
--> $DIR/implicit_return.rs:80:16
58+
--> $DIR/implicit_return.rs:79:16
5959
|
6060
LL | let _ = || true;
6161
| ^^^^ help: add `return` as shown: `return true`
6262

6363
error: missing `return` statement
64-
--> $DIR/implicit_return.rs:88:5
64+
--> $DIR/implicit_return.rs:87:5
6565
|
6666
LL | format!("test {}", "test")
6767
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")`

tests/ui/match_bool.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![deny(clippy::match_bool)]
2+
13
fn match_bool() {
24
let test: bool = true;
35

tests/ui/match_bool.stderr

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
error: this boolean expression can be simplified
2-
--> $DIR/match_bool.rs:29:11
2+
--> $DIR/match_bool.rs:31:11
33
|
44
LL | match test && test {
55
| ^^^^^^^^^^^^ help: try: `test`
66
|
77
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
88

99
error: you seem to be trying to match on a boolean expression
10-
--> $DIR/match_bool.rs:4:5
10+
--> $DIR/match_bool.rs:6:5
1111
|
1212
LL | / match test {
1313
LL | | true => 0,
1414
LL | | false => 42,
1515
LL | | };
1616
| |_____^ help: consider using an `if`/`else` expression: `if test { 0 } else { 42 }`
1717
|
18-
= note: `-D clippy::match-bool` implied by `-D warnings`
18+
note: the lint level is defined here
19+
--> $DIR/match_bool.rs:1:9
20+
|
21+
LL | #![deny(clippy::match_bool)]
22+
| ^^^^^^^^^^^^^^^^^^
1923

2024
error: you seem to be trying to match on a boolean expression
21-
--> $DIR/match_bool.rs:10:5
25+
--> $DIR/match_bool.rs:12:5
2226
|
2327
LL | / match option == 1 {
2428
LL | | true => 1,
@@ -27,7 +31,7 @@ LL | | };
2731
| |_____^ help: consider using an `if`/`else` expression: `if option == 1 { 1 } else { 0 }`
2832

2933
error: you seem to be trying to match on a boolean expression
30-
--> $DIR/match_bool.rs:15:5
34+
--> $DIR/match_bool.rs:17:5
3135
|
3236
LL | / match test {
3337
LL | | true => (),
@@ -45,7 +49,7 @@ LL | };
4549
|
4650

4751
error: you seem to be trying to match on a boolean expression
48-
--> $DIR/match_bool.rs:22:5
52+
--> $DIR/match_bool.rs:24:5
4953
|
5054
LL | / match test {
5155
LL | | false => {
@@ -63,7 +67,7 @@ LL | };
6367
|
6468

6569
error: you seem to be trying to match on a boolean expression
66-
--> $DIR/match_bool.rs:29:5
70+
--> $DIR/match_bool.rs:31:5
6771
|
6872
LL | / match test && test {
6973
LL | | false => {
@@ -81,15 +85,15 @@ LL | };
8185
|
8286

8387
error: equal expressions as operands to `&&`
84-
--> $DIR/match_bool.rs:29:11
88+
--> $DIR/match_bool.rs:31:11
8589
|
8690
LL | match test && test {
8791
| ^^^^^^^^^^^^
8892
|
8993
= note: `#[deny(clippy::eq_op)]` on by default
9094

9195
error: you seem to be trying to match on a boolean expression
92-
--> $DIR/match_bool.rs:36:5
96+
--> $DIR/match_bool.rs:38:5
9397
|
9498
LL | / match test {
9599
LL | | false => {

tests/ui/needless_return.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![allow(unused, clippy::needless_bool, clippy::match_bool)]
3+
#![allow(unused, clippy::needless_bool)]
44
#![allow(clippy::if_same_then_else, clippy::single_match)]
55
#![warn(clippy::needless_return)]
66

tests/ui/needless_return.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![allow(unused, clippy::needless_bool, clippy::match_bool)]
3+
#![allow(unused, clippy::needless_bool)]
44
#![allow(clippy::if_same_then_else, clippy::single_match)]
55
#![warn(clippy::needless_return)]
66

0 commit comments

Comments
 (0)