@@ -33,12 +33,16 @@ declare_lint_pass!(AssertionsOnConstants => [ASSERTIONS_ON_CONSTANTS]);
33
33
34
34
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for AssertionsOnConstants {
35
35
fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , e : & ' tcx Expr < ' _ > ) {
36
- let lint_true = || {
36
+ let lint_true = |is_debug : bool | {
37
37
span_help_and_lint (
38
38
cx,
39
39
ASSERTIONS_ON_CONSTANTS ,
40
40
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
+ } ,
42
46
"remove it" ,
43
47
) ;
44
48
} ;
@@ -70,7 +74,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssertionsOnConstants {
70
74
if let Some ( ( Constant :: Bool ( is_true) , _) ) = constant( cx, cx. tables, lit) ;
71
75
if is_true;
72
76
then {
73
- lint_true( ) ;
77
+ lint_true( true ) ;
74
78
}
75
79
} ;
76
80
} 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 {
81
85
match assert_match {
82
86
// matched assert but not message
83
87
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 ) ,
85
89
AssertKind :: WithMessage ( panic_message, false ) => lint_false_with_message ( panic_message) ,
86
90
} ;
87
91
}
0 commit comments