-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
- if_chain! {
- if let ExprKind::Block(ref block, _) = expr.node;
- if let Some(ref ex) = block.expr;
- if let ExprKind::Call(ref fun, ref params) = ex.node;
- if let ExprKind::Path(ref qpath) = fun.node;
- if let Some(fun_def_id) = opt_def_id(resolve_node(cx, qpath, fun.hir_id));
- if match_def_path(cx.tcx, fun_def_id, &paths::BEGIN_PANIC);
- if params.len() == 2;
- then {
- if is_expn_of(expr.span, "unimplemented").is_some() {
- let span = get_outer_span(expr);
- span_lint(cx, UNIMPLEMENTED, span,
- "`unimplemented` should not be present in production code");
- } else {
- match_panic(params, expr, cx);
- }
+declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]);
+
+impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
+ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
+ if match_panic_call(cx, expr).is_some() {
+ let span = get_outer_span(expr);
+ if is_expn_of(expr.span, "unimplemented").is_some() {
+ span_lint(
+ cx,
+ UNIMPLEMENTED,
+ span,
+ "`unimplemented` should not be present in production code",
+ );
+ } else if is_expn_of(expr.span, "todo").is_some() {
+ span_lint(cx, TODO, span, "`todo` should not be present in production code");
+ } else if is_expn_of(expr.span, "unreachable").is_some() {
+ span_lint(cx, UNREACHABLE, span, "usage of the `unreachable!` macro");
+ } else if is_expn_of(expr.span, "panic").is_some() {
+ span_lint(cx, PANIC, span, "`panic` should not be present in production code");