Skip to content

Commit

Permalink
issue_6357 update unreachable macro usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajkumar Natarajan committed Nov 28, 2020
1 parent 7a73a25 commit 76f2c10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
9 changes: 2 additions & 7 deletions clippy_lints/src/panic_unimplemented.rs
Expand Up @@ -66,7 +66,7 @@ declare_clippy_lint! {
/// ```
pub UNREACHABLE,
restriction,
"`unreachable!` should not be present in production code"
"usage of the `unreachable!` macro"
}

declare_lint_pass!(PanicUnimplemented => [UNIMPLEMENTED, UNREACHABLE, TODO, PANIC]);
Expand All @@ -85,12 +85,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
} 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,
"`unreachable` should not be present in production code",
);
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");
}
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/panicking_macros.stderr
Expand Up @@ -62,23 +62,23 @@ error: `unimplemented` should not be present in production code
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
|
LL | unreachable!();
| ^^^^^^^^^^^^^^^
|
= 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
|
LL | unreachable!("message");
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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
|
LL | unreachable!("{} {}", "panic with", "multiple arguments");
Expand All @@ -102,7 +102,7 @@ error: `unimplemented` should not be present in production code
LL | unimplemented!();
| ^^^^^^^^^^^^^^^^^

error: `unreachable` should not be present in production code
error: usage of the `unreachable!` macro
--> $DIR/panicking_macros.rs:43:5
|
LL | unreachable!();
Expand Down

0 comments on commit 76f2c10

Please sign in to comment.