-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PanicUnimplemented {
- fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) {
- if_chain! {
- if let ExprKind::Block(ref block, _) = expr.kind;
- if let Some(ref ex) = block.expr;
- if let Some(params) = match_function_call(cx, ex, &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 if is_expn_of(expr.span, "todo").is_some() {
- let span = get_outer_span(expr);
- span_lint(cx, TODO, span,
- "`todo` should not be present in production code");
- } else if is_expn_of(expr.span, "unreachable").is_some() {
- let span = get_outer_span(expr);
- span_lint(cx, UNREACHABLE, span,
- "`unreachable` should not be present in production code");
- } else if is_expn_of(expr.span, "panic").is_some() {
- let span = get_outer_span(expr);
- span_lint(cx, PANIC, span,
- "`panic` should not be present in production code");
- match_panic(params, expr, cx);
- }
+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");