@@ -3,7 +3,7 @@ use crate::rustc::hir::{Expr, ExprKind};
33use crate :: rustc:: lint:: { LateContext , LateLintPass , LintArray , LintPass } ;
44use crate :: rustc:: { declare_tool_lint, lint_array} ;
55use 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} ;
77use if_chain:: if_chain;
88
99/// **What it does:** Check to call assert!(true/false)
@@ -43,7 +43,9 @@ impl LintPass for AssertionsOnConstants {
4343impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for AssertionsOnConstants {
4444 fn check_expr ( & mut self , cx : & LateContext < ' a , ' tcx > , e : & ' tcx Expr ) {
4545 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) ) ;
4749 if let ExprKind :: Unary ( _, ref lit) = e. node;
4850 then {
4951 if let ExprKind :: Lit ( ref inner) = lit. node {
0 commit comments