Skip to content

Commit ecd0a67

Browse files
committed
Make match_wild_err_arm pedantic, and update help messages
1 parent cafa946 commit ecd0a67

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

clippy_lints/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11411141
LintId::of(&match_on_vec_items::MATCH_ON_VEC_ITEMS),
11421142
LintId::of(&matches::MATCH_BOOL),
11431143
LintId::of(&matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS),
1144+
LintId::of(&matches::MATCH_WILD_ERR_ARM),
11441145
LintId::of(&matches::SINGLE_MATCH_ELSE),
11451146
LintId::of(&methods::FILTER_MAP),
11461147
LintId::of(&methods::FILTER_MAP_NEXT),
@@ -1285,7 +1286,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
12851286
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
12861287
LintId::of(&matches::MATCH_REF_PATS),
12871288
LintId::of(&matches::MATCH_SINGLE_BINDING),
1288-
LintId::of(&matches::MATCH_WILD_ERR_ARM),
12891289
LintId::of(&matches::SINGLE_MATCH),
12901290
LintId::of(&matches::WILDCARD_IN_OR_PATTERNS),
12911291
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
@@ -1476,7 +1476,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
14761476
LintId::of(&matches::INFALLIBLE_DESTRUCTURING_MATCH),
14771477
LintId::of(&matches::MATCH_OVERLAPPING_ARM),
14781478
LintId::of(&matches::MATCH_REF_PATS),
1479-
LintId::of(&matches::MATCH_WILD_ERR_ARM),
14801479
LintId::of(&matches::SINGLE_MATCH),
14811480
LintId::of(&mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
14821481
LintId::of(&mem_replace::MEM_REPLACE_WITH_DEFAULT),

clippy_lints/src/matches.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ declare_clippy_lint! {
168168
/// **What it does:** Checks for arm which matches all errors with `Err(_)`
169169
/// and take drastic actions like `panic!`.
170170
///
171-
/// **Why is this bad?** It is generally a bad practice, just like
171+
/// **Why is this bad?** It is generally a bad practice, similar to
172172
/// catching all exceptions in java with `catch(Exception)`
173173
///
174174
/// **Known problems:** None.
@@ -182,7 +182,7 @@ declare_clippy_lint! {
182182
/// }
183183
/// ```
184184
pub MATCH_WILD_ERR_ARM,
185-
style,
185+
pedantic,
186186
"a `match` with `Err(_)` arm and take drastic actions"
187187
}
188188

@@ -711,7 +711,7 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>])
711711
arm.pat.span,
712712
&format!("`Err({})` matches all errors", &ident_bind_name),
713713
None,
714-
"match each error separately or use the error output",
714+
"match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable",
715715
);
716716
}
717717
}

src/lintlist/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
11951195
},
11961196
Lint {
11971197
name: "match_wild_err_arm",
1198-
group: "style",
1198+
group: "pedantic",
11991199
desc: "a `match` with `Err(_)` arm and take drastic actions",
12001200
deprecation: None,
12011201
module: "matches",

tests/ui/match_wild_err_arm.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ LL | Err(_) => panic!("err"),
55
| ^^^^^^
66
|
77
= note: `-D clippy::match-wild-err-arm` implied by `-D warnings`
8-
= note: match each error separately or use the error output
8+
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
99

1010
error: `Err(_)` matches all errors
1111
--> $DIR/match_wild_err_arm.rs:17:9
1212
|
1313
LL | Err(_) => panic!(),
1414
| ^^^^^^
1515
|
16-
= note: match each error separately or use the error output
16+
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
1717

1818
error: `Err(_)` matches all errors
1919
--> $DIR/match_wild_err_arm.rs:23:9
2020
|
2121
LL | Err(_) => {
2222
| ^^^^^^
2323
|
24-
= note: match each error separately or use the error output
24+
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
2525

2626
error: `Err(_e)` matches all errors
2727
--> $DIR/match_wild_err_arm.rs:31:9
2828
|
2929
LL | Err(_e) => panic!(),
3030
| ^^^^^^^
3131
|
32-
= note: match each error separately or use the error output
32+
= note: match each error separately or use the error output, or use `.except(msg)` if the error case is unreachable
3333

3434
error: aborting due to 4 previous errors
3535

0 commit comments

Comments
 (0)