@@ -164,6 +164,10 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs {
164164}
165165
166166fn check_uninlined_args ( cx : & LateContext < ' _ > , args : & FormatArgsExpn < ' _ > , call_site : Span ) {
167+ if args. format_string . span . from_expansion ( ) {
168+ return ;
169+ }
170+
167171 let mut fixes = Vec :: new ( ) ;
168172 // If any of the arguments are referenced by an index number,
169173 // and that argument is not a simple variable and cannot be inlined,
@@ -204,17 +208,17 @@ fn check_one_arg(cx: &LateContext<'_>, param: &FormatParam<'_>, fixes: &mut Vec<
204208 && let [ segment] = segments
205209 {
206210 let replacement = match param. usage {
207- FormatParamUsage :: Argument => segment. ident . name . to_string ( ) ,
211+ FormatParamUsage :: Argument => segment. ident . name . to_string ( ) ,
208212 FormatParamUsage :: Width => format ! ( "{}$" , segment. ident. name) ,
209213 FormatParamUsage :: Precision => format ! ( ".{}$" , segment. ident. name) ,
210- } ;
211- fixes. push ( ( param. span , replacement) ) ;
212- let arg_span = expand_past_previous_comma ( cx, * span) ;
213- fixes. push ( ( arg_span, String :: new ( ) ) ) ;
214- true // successful inlining, continue checking
215- } else {
216- // if we can't inline a numbered argument, we can't continue
217- param. kind != Numbered
214+ } ;
215+ fixes. push ( ( param. span , replacement) ) ;
216+ let arg_span = expand_past_previous_comma ( cx, * span) ;
217+ fixes. push ( ( arg_span, String :: new ( ) ) ) ;
218+ true // successful inlining, continue checking
219+ } else {
220+ // if we can't inline a numbered argument, we can't continue
221+ param. kind != Numbered
218222 }
219223}
220224
0 commit comments