Skip to content

Commit

Permalink
Change lint name to WILDCARD_IN_OR_PATTERNS
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibsG committed Jan 5, 2020
1 parent cd3dcf9 commit ad16718
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,6 @@ Released 2018-09-13
[`panicking_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#panicking_unwrap
[`partialeq_ne_impl`]: https://rust-lang.github.io/rust-clippy/master/index.html#partialeq_ne_impl
[`path_buf_push_overwrite`]: https://rust-lang.github.io/rust-clippy/master/index.html#path_buf_push_overwrite
[`pats_with_wild_match_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#pats_with_wild_match_arm
[`possible_missing_comma`]: https://rust-lang.github.io/rust-clippy/master/index.html#possible_missing_comma
[`precedence`]: https://rust-lang.github.io/rust-clippy/master/index.html#precedence
[`print_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#print_literal
Expand Down Expand Up @@ -1361,6 +1360,7 @@ Released 2018-09-13
[`while_let_on_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator
[`wildcard_dependencies`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_dependencies
[`wildcard_enum_match_arm`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_enum_match_arm
[`wildcard_in_or_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_in_or_patterns
[`write_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#write_literal
[`write_with_newline`]: https://rust-lang.github.io/rust-clippy/master/index.html#write_with_newline
[`writeln_empty_string`]: https://rust-lang.github.io/rust-clippy/master/index.html#writeln_empty_string
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.

[There are 344 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
[There are 345 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)

We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:

Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,10 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
&matches::MATCH_OVERLAPPING_ARM,
&matches::MATCH_REF_PATS,
&matches::MATCH_WILD_ERR_ARM,
&matches::PATS_WITH_WILD_MATCH_ARM,
&matches::SINGLE_MATCH,
&matches::SINGLE_MATCH_ELSE,
&matches::WILDCARD_ENUM_MATCH_ARM,
&matches::WILDCARD_IN_OR_PATTERNS,
&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM,
&mem_forget::MEM_FORGET,
&mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
Expand Down Expand Up @@ -1182,8 +1182,8 @@ 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(&matches::WILDCARD_IN_OR_PATTERNS),
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
LintId::of(&mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
LintId::of(&mem_replace::MEM_REPLACE_WITH_DEFAULT),
Expand Down Expand Up @@ -1457,7 +1457,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(&matches::WILDCARD_IN_OR_PATTERNS),
LintId::of(&methods::CHARS_NEXT_CMP),
LintId::of(&methods::CLONE_ON_COPY),
LintId::of(&methods::FILTER_NEXT),
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ declare_clippy_lint! {
/// "bar" | _ => {},
/// }
/// ```
pub PATS_WITH_WILD_MATCH_ARM,
pub WILDCARD_IN_OR_PATTERNS,
complexity,
"a wildcard pattern used with others patterns in same match arm"
}
Expand All @@ -252,7 +252,7 @@ declare_lint_pass!(Matches => [
MATCH_WILD_ERR_ARM,
MATCH_AS_REF,
WILDCARD_ENUM_MATCH_ARM,
PATS_WITH_WILD_MATCH_ARM
WILDCARD_IN_OR_PATTERNS
]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches {
Expand All @@ -267,7 +267,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Matches {
check_wild_err_arm(cx, ex, arms);
check_wild_enum_match(cx, ex, arms);
check_match_as_ref(cx, ex, arms, expr);
check_pats_wild_match(cx, ex, arms);
check_wild_in_or_pats(cx, ex, arms);
}
if let ExprKind::Match(ref ex, ref arms, _) = expr.kind {
check_match_ref_pats(cx, ex, arms, expr);
Expand Down Expand Up @@ -686,7 +686,7 @@ fn check_match_as_ref(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>],
}
}

fn check_pats_wild_match(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
fn check_wild_in_or_pats(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>]) {
let mut is_non_exhaustive_enum = false;
let ty = cx.tables.expr_ty(ex);
if ty.is_enum() {
Expand All @@ -703,7 +703,7 @@ fn check_pats_wild_match(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_
if fields.len() > 1 && fields.iter().any(is_wild) {
span_lint_and_then(
cx,
PATS_WITH_WILD_MATCH_ARM,
WILDCARD_IN_OR_PATTERNS,
arm.pat.span,
"wildcard pattern covers any other pattern as it will match anyway.",
|db| {
Expand Down
16 changes: 8 additions & 8 deletions src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use lint::Lint;
pub use lint::LINT_LEVELS;

// begin lint list, do not remove this comment, it’s used in `update_lints`
pub const ALL_LINTS: [Lint; 344] = [
pub const ALL_LINTS: [Lint; 345] = [
Lint {
name: "absurd_extreme_comparisons",
group: "correctness",
Expand Down Expand Up @@ -1561,13 +1561,6 @@ pub const ALL_LINTS: [Lint; 344] = [
deprecation: None,
module: "path_buf_push_overwrite",
},
Lint {
name: "pats_with_wild_match_arm",
group: "complexity",
desc: "a wildcard pattern used with others patterns in same match arm",
deprecation: None,
module: "matches",
},
Lint {
name: "possible_missing_comma",
group: "correctness",
Expand Down Expand Up @@ -2345,6 +2338,13 @@ pub const ALL_LINTS: [Lint; 344] = [
deprecation: None,
module: "matches",
},
Lint {
name: "wildcard_in_or_patterns",
group: "complexity",
desc: "a wildcard pattern used with others patterns in same match arm",
deprecation: None,
module: "matches",
},
Lint {
name: "write_literal",
group: "style",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-rustfix

#![warn(clippy::pats_with_wild_match_arm)]
#![warn(clippy::wildcard_in_or_patterns)]

fn main() {
match "foo" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// run-rustfix

#![warn(clippy::pats_with_wild_match_arm)]
#![warn(clippy::wildcard_in_or_patterns)]

fn main() {
match "foo" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
error: wildcard pattern covers any other pattern as it will match anyway.
--> $DIR/pats_with_wild_match_arm.rs:10:9
--> $DIR/wild_in_or_pats.rs:10:9
|
LL | "bar" | _ => {
| ^^^^^^^^^ help: consider replacing with wildcard pattern only: `_`
|
= note: `-D clippy::pats-with-wild-match-arm` implied by `-D warnings`
= note: `-D clippy::wildcard-in-or-patterns` implied by `-D warnings`

error: wildcard pattern covers any other pattern as it will match anyway.
--> $DIR/pats_with_wild_match_arm.rs:18:9
--> $DIR/wild_in_or_pats.rs:18:9
|
LL | "bar" | "bar2" | _ => {
| ^^^^^^^^^^^^^^^^^^ help: consider replacing with wildcard pattern only: `_`

error: wildcard pattern covers any other pattern as it will match anyway.
--> $DIR/pats_with_wild_match_arm.rs:26:9
--> $DIR/wild_in_or_pats.rs:26:9
|
LL | _ | "bar" | _ => {
| ^^^^^^^^^^^^^ help: consider replacing with wildcard pattern only: `_`

error: wildcard pattern covers any other pattern as it will match anyway.
--> $DIR/pats_with_wild_match_arm.rs:34:9
--> $DIR/wild_in_or_pats.rs:34:9
|
LL | _ | "bar" => {
| ^^^^^^^^^ help: consider replacing with wildcard pattern only: `_`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/wildcard_enum_match_arm.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
unused_variables,
dead_code,
clippy::single_match,
clippy::pats_with_wild_match_arm
clippy::wildcard_in_or_patterns
)]

use std::io::ErrorKind;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/wildcard_enum_match_arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
unused_variables,
dead_code,
clippy::single_match,
clippy::pats_with_wild_match_arm
clippy::wildcard_in_or_patterns
)]

use std::io::ErrorKind;
Expand Down

0 comments on commit ad16718

Please sign in to comment.