@@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicFmt {
4747fn check_panic < ' tcx > ( cx : & LateContext < ' tcx > , f : & ' tcx hir:: Expr < ' tcx > , arg : & ' tcx hir:: Expr < ' tcx > ) {
4848 if let hir:: ExprKind :: Lit ( lit) = & arg. kind {
4949 if let ast:: LitKind :: Str ( sym, _) = lit. node {
50- let expn = f. span . ctxt ( ) . outer_expn_data ( ) ;
50+ let mut expn = f. span . ctxt ( ) . outer_expn_data ( ) ;
5151 if let Some ( id) = expn. macro_def_id {
5252 if cx. tcx . is_diagnostic_item ( sym:: std_panic_macro, id)
5353 || cx. tcx . is_diagnostic_item ( sym:: core_panic_macro, id)
@@ -59,19 +59,17 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
5959 let s = s. replace ( "{{" , "" ) . replace ( "}}" , "" ) ;
6060 let looks_like_placeholder =
6161 s. find ( '{' ) . map_or ( false , |i| s[ i + 1 ..] . contains ( '}' ) ) ;
62- let expn = {
63- // Unwrap another level of macro expansion if this
64- // panic!() was expanded from assert!().
62+ // Unwrap another level of macro expansion if this panic!()
63+ // was expanded from assert!() or debug_assert!().
64+ for & assert in & [ sym :: assert_macro , sym :: debug_assert_macro ] {
6565 let parent = expn. call_site . ctxt ( ) . outer_expn_data ( ) ;
6666 if parent
6767 . macro_def_id
68- . map_or ( false , |id| cx. tcx . is_diagnostic_item ( sym :: assert_macro , id) )
68+ . map_or ( false , |id| cx. tcx . is_diagnostic_item ( assert , id) )
6969 {
70- parent
71- } else {
72- expn
70+ expn = parent;
7371 }
74- } ;
72+ }
7573 if looks_like_placeholder {
7674 cx. struct_span_lint ( PANIC_FMT , arg. span . source_callsite ( ) , |lint| {
7775 let mut l = lint. build ( "Panic message contains an unused formatting placeholder" ) ;
0 commit comments