Skip to content

Commit

Permalink
Move to complexity and adapt test
Browse files Browse the repository at this point in the history
 - test wildcard_enum_match_arm has been impacted by this new lint
  • Loading branch information
ThibsG committed Dec 27, 2019
1 parent b0a4cae commit 8bea285
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
LintId::of(&integer_division::INTEGER_DIVISION),
LintId::of(&let_underscore::LET_UNDERSCORE_MUST_USE),
LintId::of(&literal_representation::DECIMAL_LITERAL_REPRESENTATION),
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
LintId::of(&matches::WILDCARD_ENUM_MATCH_ARM),
LintId::of(&mem_forget::MEM_FORGET),
LintId::of(&methods::CLONE_ON_REF_PTR),
Expand Down Expand Up @@ -1177,6 +1176,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
LintId::of(&matches::MATCH_REF_PATS),
LintId::of(&matches::MATCH_WILD_ERR_ARM),
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
LintId::of(&matches::SINGLE_MATCH),
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
LintId::of(&mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
Expand Down Expand Up @@ -1447,6 +1447,7 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
LintId::of(&map_unit_fn::OPTION_MAP_UNIT_FN),
LintId::of(&map_unit_fn::RESULT_MAP_UNIT_FN),
LintId::of(&matches::MATCH_AS_REF),
LintId::of(&matches::PATS_WITH_WILD_MATCH_ARM),
LintId::of(&methods::CHARS_NEXT_CMP),
LintId::of(&methods::CLONE_ON_COPY),
LintId::of(&methods::FILTER_NEXT),
Expand Down
2 changes: 1 addition & 1 deletion src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ pub const ALL_LINTS: [Lint; 342] = [
},
Lint {
name: "pats_with_wild_match_arm",
group: "restriction",
group: "complexity",
desc: "a wildcard pattern used with others patterns in same match arm",
deprecation: None,
module: "matches",
Expand Down
8 changes: 7 additions & 1 deletion tests/ui/wildcard_enum_match_arm.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// run-rustfix

#![deny(clippy::wildcard_enum_match_arm)]
#![allow(unreachable_code, unused_variables, dead_code, clippy::single_match)]
#![allow(
unreachable_code,
unused_variables,
dead_code,
clippy::single_match,
clippy::pats_with_wild_match_arm
)]

use std::io::ErrorKind;

Expand Down
8 changes: 7 additions & 1 deletion tests/ui/wildcard_enum_match_arm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// run-rustfix

#![deny(clippy::wildcard_enum_match_arm)]
#![allow(unreachable_code, unused_variables, dead_code, clippy::single_match)]
#![allow(
unreachable_code,
unused_variables,
dead_code,
clippy::single_match,
clippy::pats_with_wild_match_arm
)]

use std::io::ErrorKind;

Expand Down
10 changes: 5 additions & 5 deletions tests/ui/wildcard_enum_match_arm.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: wildcard match will miss any future added variants
--> $DIR/wildcard_enum_match_arm.rs:31:9
--> $DIR/wildcard_enum_match_arm.rs:37:9
|
LL | _ => eprintln!("Not red"),
| ^ help: try this: `Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan`
Expand All @@ -11,25 +11,25 @@ LL | #![deny(clippy::wildcard_enum_match_arm)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

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

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

error: match on non-exhaustive enum doesn't explicitly match all known variants
--> $DIR/wildcard_enum_match_arm.rs:72:9
--> $DIR/wildcard_enum_match_arm.rs:78:9
|
LL | _ => {},
| ^ 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 | _`
Expand Down

0 comments on commit 8bea285

Please sign in to comment.