about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-01-20 11:52:58 +0900
committerYuki Okushi <huyuumi.dev@gmail.com>2020-01-20 11:52:58 +0900
commitfdda3c3f25b91eb37ef9685aa1479cb4100f8ee5 (patch)
tree31ef7c535f95faf20875fef7fdebfad46ab13ca7
parentf7b3e4f29c5360bb8bc7de906c8959178ab43d0b (diff)
downloadrust-fdda3c3f25b91eb37ef9685aa1479cb4100f8ee5.tar.gz
rust-fdda3c3f25b91eb37ef9685aa1479cb4100f8ee5.zip
Tweak wording in `assertions_on_constants`
-rw-r--r--clippy_lints/src/assertions_on_constants.rs12
-rw-r--r--tests/ui/assertions_on_constants.stderr2
2 files changed, 9 insertions, 5 deletions
diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs
index 2d6832f125f..b13f2573923 100644
--- a/clippy_lints/src/assertions_on_constants.rs
+++ b/clippy_lints/src/assertions_on_constants.rs
@@ -33,12 +33,16 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
-        let lint_true = || {
+        let lint_true = |is_debug: bool| {
             span_help_and_lint(
                 cx,
                 ASSERTIONS_ON_CONSTANTS,
                 e.span,
-                "`assert!(true)` will be optimized out by the compiler",
+                if is_debug {
+                    "`debug_assert!(true)` will be optimized out by the compiler"
+                } else {
+                    "`assert!(true)` will be optimized out by the compiler"
+                },
                 "remove it",
             );
         };
@@ -70,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
                 if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.tables, lit);
                 if is_true;
                 then {
-                    lint_true();
+                    lint_true(true);
                 }
             };
         } else if let Some(assert_span) = is_direct_expn_of(e.span, "assert") {
@@ -81,7 +85,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
                 match assert_match {
                     // matched assert but not message
                     AssertKind::WithoutMessage(false) => lint_false_without_message(),
-                    AssertKind::WithoutMessage(true) | AssertKind::WithMessage(_, true) => lint_true(),
+                    AssertKind::WithoutMessage(true) | AssertKind::WithMessage(_, true) => lint_true(false),
                     AssertKind::WithMessage(panic_message, false) => lint_false_with_message(panic_message),
                 };
             }
diff --git a/tests/ui/assertions_on_constants.stderr b/tests/ui/assertions_on_constants.stderr
index 215012f2ad7..0ff0f51ce8c 100644
--- a/tests/ui/assertions_on_constants.stderr
+++ b/tests/ui/assertions_on_constants.stderr
@@ -63,7 +63,7 @@ LL |     assert!(C, "C message");
    |
    = help: use `panic!("C message")` or `unreachable!("C message")`
 
-error: `assert!(true)` will be optimized out by the compiler
+error: `debug_assert!(true)` will be optimized out by the compiler
   --> $DIR/assertions_on_constants.rs:24:5
    |
 LL |     debug_assert!(true);