mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Make match_wild_err_arm pedantic, and update help messages
This commit is contained in:
parent
cafa94662c
commit
ecd0a67b01
@ -1141,6 +1141,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||||||
LintId::of(&match_on_vec_items::MATCH_ON_VEC_ITEMS),
|
LintId::of(&match_on_vec_items::MATCH_ON_VEC_ITEMS),
|
||||||
LintId::of(&matches::MATCH_BOOL),
|
LintId::of(&matches::MATCH_BOOL),
|
||||||
LintId::of(&matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS),
|
LintId::of(&matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS),
|
||||||
|
LintId::of(&matches::MATCH_WILD_ERR_ARM),
|
||||||
LintId::of(&matches::SINGLE_MATCH_ELSE),
|
LintId::of(&matches::SINGLE_MATCH_ELSE),
|
||||||
LintId::of(&methods::FILTER_MAP),
|
LintId::of(&methods::FILTER_MAP),
|
||||||
LintId::of(&methods::FILTER_MAP_NEXT),
|
LintId::of(&methods::FILTER_MAP_NEXT),
|
||||||
@ -1285,7 +1286,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||||||
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
|
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
|
||||||
LintId::of(&matches::MATCH_REF_PATS),
|
LintId::of(&matches::MATCH_REF_PATS),
|
||||||
LintId::of(&matches::MATCH_SINGLE_BINDING),
|
LintId::of(&matches::MATCH_SINGLE_BINDING),
|
||||||
LintId::of(&matches::MATCH_WILD_ERR_ARM),
|
|
||||||
LintId::of(&matches::SINGLE_MATCH),
|
LintId::of(&matches::SINGLE_MATCH),
|
||||||
LintId::of(&matches::WILDCARD_IN_OR_PATTERNS),
|
LintId::of(&matches::WILDCARD_IN_OR_PATTERNS),
|
||||||
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
|
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
|
||||||
@ -1476,7 +1476,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||||||
LintId::of(&matches::INFALLIBLE_DESTRUCTURING_MATCH),
|
LintId::of(&matches::INFALLIBLE_DESTRUCTURING_MATCH),
|
||||||
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
|
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
|
||||||
LintId::of(&matches::MATCH_REF_PATS),
|
LintId::of(&matches::MATCH_REF_PATS),
|
||||||
LintId::of(&matches::MATCH_WILD_ERR_ARM),
|
|
||||||
LintId::of(&matches::SINGLE_MATCH),
|
LintId::of(&matches::SINGLE_MATCH),
|
||||||
LintId::of(&mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
|
LintId::of(&mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
|
||||||
LintId::of(&mem_replace::MEM_REPLACE_WITH_DEFAULT),
|
LintId::of(&mem_replace::MEM_REPLACE_WITH_DEFAULT),
|
||||||
|
@ -168,7 +168,7 @@ declare_clippy_lint! {
|
|||||||
/// **What it does:** Checks for arm which matches all errors with `Err(_)`
|
/// **What it does:** Checks for arm which matches all errors with `Err(_)`
|
||||||
/// and take drastic actions like `panic!`.
|
/// and take drastic actions like `panic!`.
|
||||||
///
|
///
|
||||||
/// **Why is this bad?** It is generally a bad practice, just like
|
/// **Why is this bad?** It is generally a bad practice, similar to
|
||||||
/// catching all exceptions in java with `catch(Exception)`
|
/// catching all exceptions in java with `catch(Exception)`
|
||||||
///
|
///
|
||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
@ -182,7 +182,7 @@ declare_clippy_lint! {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub MATCH_WILD_ERR_ARM,
|
pub MATCH_WILD_ERR_ARM,
|
||||||
style,
|
pedantic,
|
||||||
"a `match` with `Err(_)` arm and take drastic actions"
|
"a `match` with `Err(_)` arm and take drastic actions"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,7 +711,7 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>])
|
|||||||
arm.pat.span,
|
arm.pat.span,
|
||||||
&format!("`Err({})` matches all errors", &ident_bind_name),
|
&format!("`Err({})` matches all errors", &ident_bind_name),
|
||||||
None,
|
None,
|
||||||
"match each error separately or use the error output",
|
"match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1195,7 +1195,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
|
|||||||
},
|
},
|
||||||
Lint {
|
Lint {
|
||||||
name: "match_wild_err_arm",
|
name: "match_wild_err_arm",
|
||||||
group: "style",
|
group: "pedantic",
|
||||||
desc: "a `match` with `Err(_)` arm and take drastic actions",
|
desc: "a `match` with `Err(_)` arm and take drastic actions",
|
||||||
deprecation: None,
|
deprecation: None,
|
||||||
module: "matches",
|
module: "matches",
|
||||||
|
@ -5,7 +5,7 @@ LL | Err(_) => panic!("err"),
|
|||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::match-wild-err-arm` implied by `-D warnings`
|
= note: `-D clippy::match-wild-err-arm` implied by `-D warnings`
|
||||||
= note: match each error separately or use the error output
|
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
|
||||||
|
|
||||||
error: `Err(_)` matches all errors
|
error: `Err(_)` matches all errors
|
||||||
--> $DIR/match_wild_err_arm.rs:17:9
|
--> $DIR/match_wild_err_arm.rs:17:9
|
||||||
@ -13,7 +13,7 @@ error: `Err(_)` matches all errors
|
|||||||
LL | Err(_) => panic!(),
|
LL | Err(_) => panic!(),
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
|
|
||||||
= note: match each error separately or use the error output
|
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
|
||||||
|
|
||||||
error: `Err(_)` matches all errors
|
error: `Err(_)` matches all errors
|
||||||
--> $DIR/match_wild_err_arm.rs:23:9
|
--> $DIR/match_wild_err_arm.rs:23:9
|
||||||
@ -21,7 +21,7 @@ error: `Err(_)` matches all errors
|
|||||||
LL | Err(_) => {
|
LL | Err(_) => {
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
|
|
||||||
= note: match each error separately or use the error output
|
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
|
||||||
|
|
||||||
error: `Err(_e)` matches all errors
|
error: `Err(_e)` matches all errors
|
||||||
--> $DIR/match_wild_err_arm.rs:31:9
|
--> $DIR/match_wild_err_arm.rs:31:9
|
||||||
@ -29,7 +29,7 @@ error: `Err(_e)` matches all errors
|
|||||||
LL | Err(_e) => panic!(),
|
LL | Err(_e) => panic!(),
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
|
|
||||||
= note: match each error separately or use the error output
|
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user