Skip to content

Commit 252f04c

Browse files
author
Heinz Gies
committed
Working on panic
1 parent dc84704 commit 252f04c

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
@@ -26,6 +26,22 @@ declare_clippy_lint! {
2626
"missing parameters in `panic!` calls"
2727
}
2828

29+
declare_clippy_lint! {
30+
/// **What it does:** Checks for usage of `panic!`.
31+
///
32+
/// **Why is this bad?** `panic!` will stop the execution of the executable
33+
///
34+
/// **Known problems:** None.
35+
///
36+
/// **Example:**
37+
/// ```no_run
38+
/// panic!("even with a good reason");
39+
/// ```
40+
pub PANIC,
41+
restriction,
42+
"missing parameters in `panic!` calls"
43+
}
44+
2945
declare_clippy_lint! {
3046
/// **What it does:** Checks for usage of `unimplemented!`.
3147
///
@@ -79,7 +95,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented {
7995
let span = get_outer_span(expr);
8096
span_lint(cx, UNREACHABLE, span,
8197
"`unreachable` should not be present in production code");
82-
} else {
98+
} else if is_expn_of(expr.span, "panic").is_some() {
99+
let span = get_outer_span(expr);
100+
span_lint(cx, PANIC, span,
101+
"`panic` should not be present in production code");
102+
//} else {
83103
match_panic(params, expr, cx);
84104
}
85105
}

0 commit comments

Comments
 (0)