Skip to content

Commit 04e540b

Browse files
Heinz GiesLicenser
authored andcommitted
Working on panic
1 parent 0a87173 commit 04e540b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

clippy_lints/src/panic_unimplemented.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ declare_clippy_lint! {
2525
"missing parameters in `panic!` calls"
2626
}
2727

28+
declare_clippy_lint! {
29+
/// **What it does:** Checks for usage of `panic!`.
30+
///
31+
/// **Why is this bad?** `panic!` will stop the execution of the executable
32+
///
33+
/// **Known problems:** None.
34+
///
35+
/// **Example:**
36+
/// ```no_run
37+
/// panic!("even with a good reason");
38+
/// ```
39+
pub PANIC,
40+
restriction,
41+
"missing parameters in `panic!` calls"
42+
}
43+
2844
declare_clippy_lint! {
2945
/// **What it does:** Checks for usage of `unimplemented!`.
3046
///
@@ -75,7 +91,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented {
7591
let span = get_outer_span(expr);
7692
span_lint(cx, UNREACHABLE, span,
7793
"`unreachable` should not be present in production code");
78-
} else {
94+
} else if is_expn_of(expr.span, "panic").is_some() {
95+
let span = get_outer_span(expr);
96+
span_lint(cx, PANIC, span,
97+
"`panic` should not be present in production code");
98+
//} else {
7999
match_panic(params, expr, cx);
80100
}
81101
}

0 commit comments

Comments
 (0)