@@ -37,8 +37,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
3737 desc,
3838 ) ;
3939
40- err. span_label ( borrow_span, format ! ( "{} is borrowed here" , borrow_desc ) ) ;
41- err. span_label ( span, format ! ( "use of borrowed {}" , borrow_desc ) ) ;
40+ err. span_label ( borrow_span, format ! ( "{borrow_desc } is borrowed here" ) ) ;
41+ err. span_label ( span, format ! ( "use of borrowed {borrow_desc}" ) ) ;
4242 err
4343 }
4444
@@ -51,8 +51,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
5151 old_opt_via : & str ,
5252 old_load_end_span : Option < Span > ,
5353 ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
54- let via =
55- |msg : & str | if msg. is_empty ( ) { "" . to_string ( ) } else { format ! ( " (via {})" , msg) } ;
54+ let via = |msg : & str | if msg. is_empty ( ) { "" . to_string ( ) } else { format ! ( " (via {msg})" ) } ;
5655 let mut err = struct_span_err ! (
5756 self ,
5857 new_loan_span,
@@ -143,9 +142,9 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
143142 ) ;
144143 err. span_label (
145144 new_loan_span,
146- format ! ( "{} construction occurs here{}" , container_name , opt_via ) ,
145+ format ! ( "{container_name } construction occurs here{opt_via}" ) ,
147146 ) ;
148- err. span_label ( old_loan_span, format ! ( "borrow occurs here{}" , old_opt_via ) ) ;
147+ err. span_label ( old_loan_span, format ! ( "borrow occurs here{old_opt_via}" ) ) ;
149148 if let Some ( previous_end_span) = previous_end_span {
150149 err. span_label ( previous_end_span, "borrow ends here" ) ;
151150 }
@@ -173,13 +172,10 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
173172 opt_via,
174173 kind_new,
175174 ) ;
176- err. span_label (
177- new_loan_span,
178- format ! ( "{}borrow occurs here{}" , second_borrow_desc, opt_via) ,
179- ) ;
175+ err. span_label ( new_loan_span, format ! ( "{second_borrow_desc}borrow occurs here{opt_via}" ) ) ;
180176 err. span_label (
181177 old_loan_span,
182- format ! ( "{} construction occurs here{}" , container_name , old_opt_via ) ,
178+ format ! ( "{container_name } construction occurs here{old_opt_via}" ) ,
183179 ) ;
184180 if let Some ( previous_end_span) = previous_end_span {
185181 err. span_label ( previous_end_span, "borrow from closure ends here" ) ;
@@ -199,8 +195,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
199195 msg_old : & str ,
200196 old_load_end_span : Option < Span > ,
201197 ) -> DiagnosticBuilder < ' cx , ErrorGuaranteed > {
202- let via =
203- |msg : & str | if msg. is_empty ( ) { "" . to_string ( ) } else { format ! ( " (via {})" , msg) } ;
198+ let via = |msg : & str | if msg. is_empty ( ) { "" . to_string ( ) } else { format ! ( " (via {msg})" ) } ;
204199 let mut err = struct_span_err ! (
205200 self ,
206201 span,
@@ -216,22 +211,21 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
216211
217212 if msg_new == "" {
218213 // If `msg_new` is empty, then this isn't a borrow of a union field.
219- err. span_label ( span, format ! ( "{} borrow occurs here" , kind_new ) ) ;
220- err. span_label ( old_span, format ! ( "{} borrow occurs here" , kind_old ) ) ;
214+ err. span_label ( span, format ! ( "{kind_new } borrow occurs here" ) ) ;
215+ err. span_label ( old_span, format ! ( "{kind_old } borrow occurs here" ) ) ;
221216 } else {
222217 // If `msg_new` isn't empty, then this a borrow of a union field.
223218 err. span_label (
224219 span,
225220 format ! (
226- "{} borrow of {} -- which overlaps with {} -- occurs here" ,
227- kind_new, msg_new, msg_old,
221+ "{kind_new} borrow of {msg_new} -- which overlaps with {msg_old} -- occurs here" ,
228222 ) ,
229223 ) ;
230224 err. span_label ( old_span, format ! ( "{} borrow occurs here{}" , kind_old, via( msg_old) ) ) ;
231225 }
232226
233227 if let Some ( old_load_end_span) = old_load_end_span {
234- err. span_label ( old_load_end_span, format ! ( "{} borrow ends here" , kind_old ) ) ;
228+ err. span_label ( old_load_end_span, format ! ( "{kind_old } borrow ends here" ) ) ;
235229 }
236230 err
237231 }
@@ -250,8 +244,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
250244 desc,
251245 ) ;
252246
253- err. span_label ( borrow_span, format ! ( "{} is borrowed here" , desc ) ) ;
254- err. span_label ( span, format ! ( "{} is assigned to here but it was already borrowed" , desc ) ) ;
247+ err. span_label ( borrow_span, format ! ( "{desc } is borrowed here" ) ) ;
248+ err. span_label ( span, format ! ( "{desc } is assigned to here but it was already borrowed" ) ) ;
255249 err
256250 }
257251
@@ -330,7 +324,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
330324 optional_adverb_for_moved : & str ,
331325 moved_path : Option < String > ,
332326 ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
333- let moved_path = moved_path. map ( |mp| format ! ( ": `{}`" , mp ) ) . unwrap_or_default ( ) ;
327+ let moved_path = moved_path. map ( |mp| format ! ( ": `{mp }`" ) ) . unwrap_or_default ( ) ;
334328
335329 struct_span_err ! (
336330 self ,
@@ -369,8 +363,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
369363 immutable_place,
370364 immutable_section,
371365 ) ;
372- err. span_label ( mutate_span, format ! ( "cannot {}" , action ) ) ;
373- err. span_label ( immutable_span, format ! ( "value is immutable in {}" , immutable_section ) ) ;
366+ err. span_label ( mutate_span, format ! ( "cannot {action}" ) ) ;
367+ err. span_label ( immutable_span, format ! ( "value is immutable in {immutable_section}" ) ) ;
374368 err
375369 }
376370
@@ -428,7 +422,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
428422
429423 err. span_label (
430424 span,
431- format ! ( "{}s a {} data owned by the current function" , return_kind , reference_desc ) ,
425+ format ! ( "{return_kind }s a {reference_desc } data owned by the current function" ) ,
432426 ) ;
433427
434428 err
@@ -449,8 +443,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
449443 "{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
450444 which is owned by the current {scope}",
451445 ) ;
452- err. span_label ( capture_span, format ! ( "{} is borrowed here" , borrowed_path ) )
453- . span_label ( closure_span, format ! ( "may outlive borrowed value {}" , borrowed_path ) ) ;
446+ err. span_label ( capture_span, format ! ( "{borrowed_path } is borrowed here" ) )
447+ . span_label ( closure_span, format ! ( "may outlive borrowed value {borrowed_path}" ) ) ;
454448 err
455449 }
456450
0 commit comments