@@ -33,12 +33,16 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
3333
3434impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for AssertionsOnConstants {
3535 fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , e : & ' tcx Expr < ' _ > ) {
36- let lint_true = || {
36+ let lint_true = |is_debug : bool | {
3737 span_help_and_lint (
3838 cx,
3939 ASSERTIONS_ON_CONSTANTS ,
4040 e. span ,
41- "`assert!(true)` will be optimized out by the compiler" ,
41+ if is_debug {
42+ "`debug_assert!(true)` will be optimized out by the compiler"
43+ } else {
44+ "`assert!(true)` will be optimized out by the compiler"
45+ } ,
4246 "remove it" ,
4347 ) ;
4448 } ;
@@ -70,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
7074 if let Some ( ( Constant :: Bool ( is_true) , _) ) = constant( cx, cx. tables, lit) ;
7175 if is_true;
7276 then {
73- lint_true( ) ;
77+ lint_true( true ) ;
7478 }
7579 } ;
7680 } 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 {
8185 match assert_match {
8286 // matched assert but not message
8387 AssertKind :: WithoutMessage ( false ) => lint_false_without_message ( ) ,
84- AssertKind :: WithoutMessage ( true ) | AssertKind :: WithMessage ( _, true ) => lint_true ( ) ,
88+ AssertKind :: WithoutMessage ( true ) | AssertKind :: WithMessage ( _, true ) => lint_true ( false ) ,
8589 AssertKind :: WithMessage ( panic_message, false ) => lint_false_with_message ( panic_message) ,
8690 } ;
8791 }
0 commit comments