Change lint name to WILDCARD_IN_OR_PATTERNS

This commit is contained in:
ThibsG 2020-01-05 15:05:16 +01:00
parent 58deaad42d
commit 8ae8b08e32
9 changed files with 25 additions and 25 deletions

View file

@ -1241,7 +1241,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
@ -1362,6 +1361,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

View file

@ -597,10 +597,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,
@ -1188,8 +1188,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),
@ -1463,7 +1463,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),

View file

@ -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"
}
@ -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 {
@ -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);
@ -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() {
@ -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| {

View file

@ -1568,13 +1568,6 @@ pub const ALL_LINTS: [Lint; 345] = [
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",
@ -2352,6 +2345,13 @@ pub const ALL_LINTS: [Lint; 345] = [
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",

View file

@ -1,6 +1,6 @@
// run-rustfix
#![warn(clippy::pats_with_wild_match_arm)]
#![warn(clippy::wildcard_in_or_patterns)]
fn main() {
match "foo" {

View file

@ -1,6 +1,6 @@
// run-rustfix
#![warn(clippy::pats_with_wild_match_arm)]
#![warn(clippy::wildcard_in_or_patterns)]
fn main() {
match "foo" {

View file

@ -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: `_`

View file

@ -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;

View file

@ -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;