@@ -37,8 +37,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
37
37
desc,
38
38
) ;
39
39
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}" ) ) ;
42
42
err
43
43
}
44
44
@@ -51,8 +51,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
51
51
old_opt_via : & str ,
52
52
old_load_end_span : Option < Span > ,
53
53
) -> 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})" ) } ;
56
55
let mut err = struct_span_err ! (
57
56
self ,
58
57
new_loan_span,
@@ -143,9 +142,9 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
143
142
) ;
144
143
err. span_label (
145
144
new_loan_span,
146
- format ! ( "{} construction occurs here{}" , container_name , opt_via ) ,
145
+ format ! ( "{container_name } construction occurs here{opt_via}" ) ,
147
146
) ;
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}" ) ) ;
149
148
if let Some ( previous_end_span) = previous_end_span {
150
149
err. span_label ( previous_end_span, "borrow ends here" ) ;
151
150
}
@@ -173,13 +172,10 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
173
172
opt_via,
174
173
kind_new,
175
174
) ;
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}" ) ) ;
180
176
err. span_label (
181
177
old_loan_span,
182
- format ! ( "{} construction occurs here{}" , container_name , old_opt_via ) ,
178
+ format ! ( "{container_name } construction occurs here{old_opt_via}" ) ,
183
179
) ;
184
180
if let Some ( previous_end_span) = previous_end_span {
185
181
err. span_label ( previous_end_span, "borrow from closure ends here" ) ;
@@ -199,8 +195,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
199
195
msg_old : & str ,
200
196
old_load_end_span : Option < Span > ,
201
197
) -> 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})" ) } ;
204
199
let mut err = struct_span_err ! (
205
200
self ,
206
201
span,
@@ -216,22 +211,21 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
216
211
217
212
if msg_new == "" {
218
213
// 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" ) ) ;
221
216
} else {
222
217
// If `msg_new` isn't empty, then this a borrow of a union field.
223
218
err. span_label (
224
219
span,
225
220
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" ,
228
222
) ,
229
223
) ;
230
224
err. span_label ( old_span, format ! ( "{} borrow occurs here{}" , kind_old, via( msg_old) ) ) ;
231
225
}
232
226
233
227
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" ) ) ;
235
229
}
236
230
err
237
231
}
@@ -250,8 +244,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
250
244
desc,
251
245
) ;
252
246
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" ) ) ;
255
249
err
256
250
}
257
251
@@ -330,7 +324,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
330
324
optional_adverb_for_moved : & str ,
331
325
moved_path : Option < String > ,
332
326
) -> 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 ( ) ;
334
328
335
329
struct_span_err ! (
336
330
self ,
@@ -369,8 +363,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
369
363
immutable_place,
370
364
immutable_section,
371
365
) ;
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}" ) ) ;
374
368
err
375
369
}
376
370
@@ -428,7 +422,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
428
422
429
423
err. span_label (
430
424
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" ) ,
432
426
) ;
433
427
434
428
err
@@ -449,8 +443,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
449
443
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
450
444
which is owned by the current {scope}",
451
445
) ;
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}" ) ) ;
454
448
err
455
449
}
456
450
0 commit comments