issue_6357 update unreachable macro usage

This commit is contained in:
Rajkumar Natarajan 2020-11-28 12:19:57 -05:00
parent 7a73a25622
commit 76f2c10fb6
2 changed files with 6 additions and 11 deletions

View file

@ -66,7 +66,7 @@ declare_clippy_lint! {
/// ``` /// ```
pub UNREACHABLE, pub UNREACHABLE,
restriction, restriction,
"`unreachable!` should not be present in production code" "usage of the `unreachable!` macro"
} }
declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]); declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]);
@ -85,12 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
} else if is_expn_of(expr.span, "todo").is_some() { } else if is_expn_of(expr.span, "todo").is_some() {
span_lint(cx, TODO, span, "`todo` should not be present in production code"); span_lint(cx, TODO, span, "`todo` should not be present in production code");
} else if is_expn_of(expr.span, "unreachable").is_some() { } else if is_expn_of(expr.span, "unreachable").is_some() {
span_lint( span_lint(cx, UNREACHABLE, span, "usage of the `unreachable!` macro");
cx,
UNREACHABLE,
span,
"`unreachable` should not be present in production code",
);
} else if is_expn_of(expr.span, "panic").is_some() { } else if is_expn_of(expr.span, "panic").is_some() {
span_lint(cx, PANIC, span, "`panic` should not be present in production code"); span_lint(cx, PANIC, span, "`panic` should not be present in production code");
} }

View file

@ -62,7 +62,7 @@ error: `unimplemented` should not be present in production code
LL | unimplemented!("{} {}", "panic with", "multiple arguments"); LL | unimplemented!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `unreachable` should not be present in production code error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:32:5 --> $DIR/panicking_macros.rs:32:5
| |
LL | unreachable!(); LL | unreachable!();
@ -70,7 +70,7 @@ LL | unreachable!();
| |
= note: `-D clippy::unreachable` implied by `-D warnings` = note: `-D clippy::unreachable` implied by `-D warnings`
error: `unreachable` should not be present in production code error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:33:5 --> $DIR/panicking_macros.rs:33:5
| |
LL | unreachable!("message"); LL | unreachable!("message");
@ -78,7 +78,7 @@ LL | unreachable!("message");
| |
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `unreachable` should not be present in production code error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:34:5 --> $DIR/panicking_macros.rs:34:5
| |
LL | unreachable!("{} {}", "panic with", "multiple arguments"); LL | unreachable!("{} {}", "panic with", "multiple arguments");
@ -102,7 +102,7 @@ error: `unimplemented` should not be present in production code
LL | unimplemented!(); LL | unimplemented!();
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
error: `unreachable` should not be present in production code error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:43:5 --> $DIR/panicking_macros.rs:43:5
| |
LL | unreachable!(); LL | unreachable!();