Skip to content

Commit 97546f1

Browse files
committed
Move to complexity and adapt test
- test wildcard_enum_match_arm has been impacted by this new lint
1 parent 9666392 commit 97546f1

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

clippy_lints/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
997997
LintId::of(&integer_division::INTEGER_DIVISION),
998998
LintId::of(&let_underscore::LET_UNDERSCORE_MUST_USE),
999999
LintId::of(&literal_representation::DECIMAL_LITERAL_REPRESENTATION),
1000-
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
10011000
LintId::of(&matches::WILDCARD_ENUM_MATCH_ARM),
10021001
LintId::of(&mem_forget::MEM_FORGET),
10031002
LintId::of(&methods::CLONE_ON_REF_PTR),
@@ -1183,6 +1182,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
11831182
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
11841183
LintId::of(&matches::MATCH_REF_PATS),
11851184
LintId::of(&matches::MATCH_WILD_ERR_ARM),
1185+
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
11861186
LintId::of(&matches::SINGLE_MATCH),
11871187
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
11881188
LintId::of(&mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
@@ -1457,6 +1457,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
14571457
LintId::of(&map_unit_fn::OPTION_MAP_UNIT_FN),
14581458
LintId::of(&map_unit_fn::RESULT_MAP_UNIT_FN),
14591459
LintId::of(&matches::MATCH_AS_REF),
1460+
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
14601461
LintId::of(&methods::CHARS_NEXT_CMP),
14611462
LintId::of(&methods::CLONE_ON_COPY),
14621463
LintId::of(&methods::FILTER_NEXT),

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ pub const ALL_LINTS: [Lint; 344] = [
15631563
},
15641564
Lint {
15651565
name: "pats_with_wild_match_arm",
1566-
group: "restriction",
1566+
group: "complexity",
15671567
desc: "a wildcard pattern used with others patterns in same match arm",
15681568
deprecation: None,
15691569
module: "matches",

tests/ui/wildcard_enum_match_arm.fixed

Lines changed: 7 additions & 1 deletion
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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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)