@@ -170,30 +170,29 @@ fn check_self_in_format_args<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>,
170
170
if let Some ( outer_macro) = root_macro_call_first_node ( cx, expr)
171
171
&& let macro_def_id = outer_macro. def_id
172
172
&& is_format_macro ( cx, macro_def_id)
173
+ && let Some ( format_args) = find_format_args ( cx, expr, outer_macro. expn )
173
174
{
174
- find_format_args ( cx, expr, outer_macro. expn , |format_args| {
175
- for piece in & format_args. template {
176
- if let FormatArgsPiece :: Placeholder ( placeholder) = piece
177
- && let trait_name = match placeholder. format_trait {
178
- FormatTrait :: Display => sym:: Display ,
179
- FormatTrait :: Debug => sym:: Debug ,
180
- FormatTrait :: LowerExp => sym ! ( LowerExp ) ,
181
- FormatTrait :: UpperExp => sym ! ( UpperExp ) ,
182
- FormatTrait :: Octal => sym ! ( Octal ) ,
183
- FormatTrait :: Pointer => sym:: Pointer ,
184
- FormatTrait :: Binary => sym ! ( Binary ) ,
185
- FormatTrait :: LowerHex => sym ! ( LowerHex ) ,
186
- FormatTrait :: UpperHex => sym ! ( UpperHex ) ,
187
- }
188
- && trait_name == impl_trait. name
189
- && let Ok ( index) = placeholder. argument . index
190
- && let Some ( arg) = format_args. arguments . all_args ( ) . get ( index)
191
- && let Ok ( arg_expr) = find_format_arg_expr ( expr, arg)
192
- {
193
- check_format_arg_self ( cx, expr. span , arg_expr, impl_trait) ;
175
+ for piece in & format_args. template {
176
+ if let FormatArgsPiece :: Placeholder ( placeholder) = piece
177
+ && let trait_name = match placeholder. format_trait {
178
+ FormatTrait :: Display => sym:: Display ,
179
+ FormatTrait :: Debug => sym:: Debug ,
180
+ FormatTrait :: LowerExp => sym ! ( LowerExp ) ,
181
+ FormatTrait :: UpperExp => sym ! ( UpperExp ) ,
182
+ FormatTrait :: Octal => sym ! ( Octal ) ,
183
+ FormatTrait :: Pointer => sym:: Pointer ,
184
+ FormatTrait :: Binary => sym ! ( Binary ) ,
185
+ FormatTrait :: LowerHex => sym ! ( LowerHex ) ,
186
+ FormatTrait :: UpperHex => sym ! ( UpperHex ) ,
194
187
}
188
+ && trait_name == impl_trait. name
189
+ && let Ok ( index) = placeholder. argument . index
190
+ && let Some ( arg) = format_args. arguments . all_args ( ) . get ( index)
191
+ && let Ok ( arg_expr) = find_format_arg_expr ( expr, arg)
192
+ {
193
+ check_format_arg_self ( cx, expr. span , arg_expr, impl_trait) ;
195
194
}
196
- } ) ;
195
+ }
197
196
}
198
197
}
199
198
0 commit comments