Skip to content

Commit 8bea285

Browse files
committed
Move to complexity and adapt test
- test wildcard_enum_match_arm has been impacted by this new lint
1 parent b0a4cae commit 8bea285

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

clippy_lints/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
992992
LintId::of(&integer_division::INTEGER_DIVISION),
993993
LintId::of(&let_underscore::LET_UNDERSCORE_MUST_USE),
994994
LintId::of(&literal_representation::DECIMAL_LITERAL_REPRESENTATION),
995-
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
996995
LintId::of(&matches::WILDCARD_ENUM_MATCH_ARM),
997996
LintId::of(&mem_forget::MEM_FORGET),
998997
LintId::of(&methods::CLONE_ON_REF_PTR),
@@ -1177,6 +1176,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
11771176
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
11781177
LintId::of(&matches::MATCH_REF_PATS),
11791178
LintId::of(&matches::MATCH_WILD_ERR_ARM),
1179+
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
11801180
LintId::of(&matches::SINGLE_MATCH),
11811181
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
11821182
LintId::of(&mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
@@ -1447,6 +1447,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
14471447
LintId::of(&map_unit_fn::OPTION_MAP_UNIT_FN),
14481448
LintId::of(&map_unit_fn::RESULT_MAP_UNIT_FN),
14491449
LintId::of(&matches::MATCH_AS_REF),
1450+
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
14501451
LintId::of(&methods::CHARS_NEXT_CMP),
14511452
LintId::of(&methods::CLONE_ON_COPY),
14521453
LintId::of(&methods::FILTER_NEXT),

src/lintlist/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ pub const ALL_LINTS: [Lint; 342] = [
15421542
},
15431543
Lint {
15441544
name: "pats_with_wild_match_arm",
1545-
group: "restriction",
1545+
group: "complexity",
15461546
desc: "a wildcard pattern used with others patterns in same match arm",
15471547
deprecation: None,
15481548
module: "matches",

tests/ui/wildcard_enum_match_arm.fixed

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// run-rustfix
22

33
#![deny(clippy::wildcard_enum_match_arm)]
4-
#![allow(unreachable_code, unused_variables, dead_code, clippy::single_match)]
4+
#![allow(
5+
unreachable_code,
6+
unused_variables,
7+
dead_code,
8+
clippy::single_match,
9+
clippy::pats_with_wild_match_arm
10+
)]
511

612
use std::io::ErrorKind;
713

tests/ui/wildcard_enum_match_arm.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// run-rustfix
22

33
#![deny(clippy::wildcard_enum_match_arm)]
4-
#![allow(unreachable_code, unused_variables, dead_code, clippy::single_match)]
4+
#![allow(
5+
unreachable_code,
6+
unused_variables,
7+
dead_code,
8+
clippy::single_match,
9+
clippy::pats_with_wild_match_arm
10+
)]
511

612
use std::io::ErrorKind;
713

tests/ui/wildcard_enum_match_arm.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: wildcard match will miss any future added variants
2-
--> $DIR/wildcard_enum_match_arm.rs:31:9
2+
--> $DIR/wildcard_enum_match_arm.rs:37:9
33
|
44
LL | _ => eprintln!("Not red"),
55
| ^ help: try this: `Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
@@ -11,25 +11,25 @@ LL | #![deny(clippy::wildcard_enum_match_arm)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: wildcard match will miss any future added variants
14-
--> $DIR/wildcard_enum_match_arm.rs:35:9
14+
--> $DIR/wildcard_enum_match_arm.rs:41:9
1515
|
1616
LL | _not_red => eprintln!("Not red"),
1717
| ^^^^^^^^ help: try this: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan`
1818

1919
error: wildcard match will miss any future added variants
20-
--> $DIR/wildcard_enum_match_arm.rs:39:9
20+
--> $DIR/wildcard_enum_match_arm.rs:45:9
2121
|
2222
LL | not_red => format!("{:?}", not_red),
2323
| ^^^^^^^ help: try this: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan`
2424

2525
error: wildcard match will miss any future added variants
26-
--> $DIR/wildcard_enum_match_arm.rs:55:9
26+
--> $DIR/wildcard_enum_match_arm.rs:61:9
2727
|
2828
LL | _ => "No red",
2929
| ^ help: try this: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
3030

3131
error: match on non-exhaustive enum doesn't explicitly match all known variants
32-
--> $DIR/wildcard_enum_match_arm.rs:72:9
32+
--> $DIR/wildcard_enum_match_arm.rs:78:9
3333
|
3434
LL | _ => {},
3535
| ^ help: try this: `std::io::ErrorKind::PermissionDenied | std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted | std::io::ErrorKind::NotConnected | std::io::ErrorKind::AddrInUse | std::io::ErrorKind::AddrNotAvailable | std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::AlreadyExists | std::io::ErrorKind::WouldBlock | std::io::ErrorKind::InvalidInput | std::io::ErrorKind::InvalidData | std::io::ErrorKind::TimedOut | std::io::ErrorKind::WriteZero | std::io::ErrorKind::Interrupted | std::io::ErrorKind::Other | std::io::ErrorKind::UnexpectedEof | _`

0 commit comments

Comments
 (0)