@@ -3,7 +3,7 @@ use crate::rustc::hir::{Expr, ExprKind};
3
3
use crate :: rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
4
4
use crate :: rustc:: { declare_tool_lint, lint_array} ;
5
5
use crate :: syntax:: ast:: LitKind ;
6
- use crate :: utils:: { is_direct_expn_of, span_help_and_lint} ;
6
+ use crate :: utils:: { in_macro , is_direct_expn_of, span_help_and_lint} ;
7
7
use if_chain:: if_chain;
8
8
9
9
/// **What it does:** Check to call assert!(true/false)
@@ -43,7 +43,9 @@ impl LintPass for AssertionsOnConstants {
43
43
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for AssertionsOnConstants {
44
44
fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , e : & ' tcx Expr ) {
45
45
if_chain ! {
46
- if is_direct_expn_of( e. span, "assert" ) . is_some( ) ;
46
+ if let Some ( assert_span) = is_direct_expn_of( e. span, "assert" ) ;
47
+ if !in_macro( assert_span)
48
+ || is_direct_expn_of( assert_span, "debug_assert" ) . map_or( false , |span| !in_macro( span) ) ;
47
49
if let ExprKind :: Unary ( _, ref lit) = e. node;
48
50
then {
49
51
if let ExprKind :: Lit ( ref inner) = lit. node {
0 commit comments