Add unreachable!() as option

This commit is contained in:
A.A.Abroskin 2018-12-27 16:12:11 +03:00 committed by Arkweid
parent 98c5f37ad2
commit 3d9535a106
2 changed files with 4 additions and 4 deletions

View File

@ -32,7 +32,7 @@ declare_clippy_lint! {
/// **What it does:** Check explicit call assert!(false) /// **What it does:** Check explicit call assert!(false)
/// ///
/// **Why is this bad?** Should probably be replaced by a panic!() /// **Why is this bad?** Should probably be replaced by a panic!() or unreachable!()
/// ///
/// **Known problems:** None /// **Known problems:** None
/// ///
@ -43,7 +43,7 @@ declare_clippy_lint! {
declare_clippy_lint! { declare_clippy_lint! {
pub EXPLICIT_FALSE, pub EXPLICIT_FALSE,
correctness, correctness,
"assert!(false) should probably be replaced by a panic!()r" "assert!(false) should probably be replaced by a panic!() or unreachable!()"
} }
pub struct AssertChecks; pub struct AssertChecks;
@ -68,7 +68,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertChecks {
}, },
LitKind::Bool(false) => { LitKind::Bool(false) => {
span_lint(cx, EXPLICIT_FALSE, e.span, span_lint(cx, EXPLICIT_FALSE, e.span,
"assert!(false) should probably be replaced by a panic!()"); "assert!(false) should probably be replaced by a panic!() or unreachable!()");
}, },
_ => (), _ => (),
} }

View File

@ -6,7 +6,7 @@ error: assert!(true) will be optimized out by the compiler
| |
= note: #[deny(clippy::explicit_true)] on by default = note: #[deny(clippy::explicit_true)] on by default
error: assert!(false) should probably be replaced by a panic!() error: assert!(false) should probably be replaced by a panic!() or unreachable!()
--> $DIR/assert_checks.rs:12:5 --> $DIR/assert_checks.rs:12:5
| |
12 | assert!(false); 12 | assert!(false);