@@ -653,7 +653,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
653
653
err. span_suggestion_verbose (
654
654
sugg_span. shrink_to_hi ( ) ,
655
655
"consider assigning a value" ,
656
- format ! ( " = {}" , assign_value ) ,
656
+ format ! ( " = {assign_value}" ) ,
657
657
Applicability :: MaybeIncorrect ,
658
658
) ;
659
659
}
@@ -738,7 +738,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
738
738
// Try to find predicates on *generic params* that would allow copying `ty`
739
739
let suggestion =
740
740
if let Some ( symbol) = tcx. hir ( ) . maybe_get_struct_pattern_shorthand_field ( expr) {
741
- format ! ( ": {}.clone()" , symbol )
741
+ format ! ( ": {symbol }.clone()" )
742
742
} else {
743
743
".clone()" . to_owned ( )
744
744
} ;
@@ -1162,8 +1162,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1162
1162
1163
1163
if union_type_name != "" {
1164
1164
err. note ( format ! (
1165
- "{} is a field of the union `{}`, so it overlaps the field {}" ,
1166
- msg_place, union_type_name, msg_borrow,
1165
+ "{msg_place} is a field of the union `{union_type_name}`, so it overlaps the field {msg_borrow}" ,
1167
1166
) ) ;
1168
1167
}
1169
1168
@@ -1353,8 +1352,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1353
1352
let Some ( trait_did) = tcx. trait_of_item ( def_id) &&
1354
1353
tcx. is_diagnostic_item ( sym:: Iterator , trait_did) {
1355
1354
err. note ( format ! (
1356
- "a for loop advances the iterator for you, the result is stored in `{}`." ,
1357
- loop_bind
1355
+ "a for loop advances the iterator for you, the result is stored in `{loop_bind}`."
1358
1356
) ) ;
1359
1357
err. help ( "if you want to call `next` on a iterator within the loop, consider using `while let`." ) ;
1360
1358
}
@@ -1825,7 +1823,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1825
1823
} ,
1826
1824
ConstraintCategory :: CallArgument ( None ) ,
1827
1825
var_or_use_span,
1828
- & format ! ( "`{}`" , name ) ,
1826
+ & format ! ( "`{name }`" ) ,
1829
1827
"block" ,
1830
1828
) ,
1831
1829
(
@@ -1847,7 +1845,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1847
1845
region_name,
1848
1846
category,
1849
1847
span,
1850
- & format ! ( "`{}`" , name ) ,
1848
+ & format ! ( "`{name }`" ) ,
1851
1849
"function" ,
1852
1850
) ,
1853
1851
(
@@ -1921,14 +1919,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1921
1919
}
1922
1920
}
1923
1921
1924
- let mut err = self . path_does_not_live_long_enough ( borrow_span, & format ! ( "`{}`" , name ) ) ;
1922
+ let mut err = self . path_does_not_live_long_enough ( borrow_span, & format ! ( "`{name }`" ) ) ;
1925
1923
1926
1924
if let Some ( annotation) = self . annotate_argument_and_return_for_borrow ( borrow) {
1927
1925
let region_name = annotation. emit ( self , & mut err) ;
1928
1926
1929
1927
err. span_label (
1930
1928
borrow_span,
1931
- format ! ( "`{}` would have to be valid for `{}`..." , name , region_name ) ,
1929
+ format ! ( "`{name }` would have to be valid for `{region_name }`..." ) ,
1932
1930
) ;
1933
1931
1934
1932
err. span_label (
@@ -1939,7 +1937,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1939
1937
self . infcx
1940
1938
. tcx
1941
1939
. opt_item_name( self . mir_def_id( ) . to_def_id( ) )
1942
- . map( |name| format!( "function `{}`" , name ) )
1940
+ . map( |name| format!( "function `{name }`" ) )
1943
1941
. unwrap_or_else( || {
1944
1942
match & self . infcx. tcx. def_kind( self . mir_def_id( ) ) {
1945
1943
DefKind :: Closure => "enclosing closure" ,
@@ -1974,7 +1972,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
1974
1972
}
1975
1973
} else {
1976
1974
err. span_label ( borrow_span, "borrowed value does not live long enough" ) ;
1977
- err. span_label ( drop_span, format ! ( "`{}` dropped here while still borrowed" , name ) ) ;
1975
+ err. span_label ( drop_span, format ! ( "`{name }` dropped here while still borrowed" ) ) ;
1978
1976
1979
1977
borrow_spans. args_subdiag ( & mut err, |args_span| {
1980
1978
crate :: session_diagnostics:: CaptureArgLabel :: Capture {
@@ -2018,22 +2016,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2018
2016
let mut err = self . cannot_borrow_across_destructor ( borrow_span) ;
2019
2017
2020
2018
let what_was_dropped = match self . describe_place ( place. as_ref ( ) ) {
2021
- Some ( name) => format ! ( "`{}`" , name ) ,
2019
+ Some ( name) => format ! ( "`{name }`" ) ,
2022
2020
None => String :: from ( "temporary value" ) ,
2023
2021
} ;
2024
2022
2025
2023
let label = match self . describe_place ( borrow. borrowed_place . as_ref ( ) ) {
2026
2024
Some ( borrowed) => format ! (
2027
- "here, drop of {D} needs exclusive access to `{B}`, \
2028
- because the type `{T}` implements the `Drop` trait",
2029
- D = what_was_dropped,
2030
- T = dropped_ty,
2031
- B = borrowed
2025
+ "here, drop of {what_was_dropped} needs exclusive access to `{borrowed}`, \
2026
+ because the type `{dropped_ty}` implements the `Drop` trait"
2032
2027
) ,
2033
2028
None => format ! (
2034
- "here is drop of {D}; whose type `{T}` implements the `Drop` trait" ,
2035
- D = what_was_dropped,
2036
- T = dropped_ty
2029
+ "here is drop of {what_was_dropped}; whose type `{dropped_ty}` implements the `Drop` trait"
2037
2030
) ,
2038
2031
} ;
2039
2032
err. span_label ( drop_span, label) ;
@@ -2245,10 +2238,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2245
2238
} else {
2246
2239
"local data "
2247
2240
} ;
2248
- (
2249
- format ! ( "{}`{}`" , local_kind, place_desc) ,
2250
- format ! ( "`{}` is borrowed here" , place_desc) ,
2251
- )
2241
+ ( format ! ( "{local_kind}`{place_desc}`" ) , format ! ( "`{place_desc}` is borrowed here" ) )
2252
2242
} else {
2253
2243
let root_place =
2254
2244
self . prefixes ( borrow. borrowed_place . as_ref ( ) , PrefixSet :: All ) . last ( ) . unwrap ( ) ;
@@ -2350,17 +2340,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2350
2340
err. span_suggestion_verbose (
2351
2341
sugg_span,
2352
2342
format ! (
2353
- "to force the {} to take ownership of {} (and any \
2354
- other referenced variables), use the `move` keyword",
2355
- kind, captured_var
2343
+ "to force the {kind} to take ownership of {captured_var} (and any \
2344
+ other referenced variables), use the `move` keyword"
2356
2345
) ,
2357
2346
suggestion,
2358
2347
Applicability :: MachineApplicable ,
2359
2348
) ;
2360
2349
2361
2350
match category {
2362
2351
ConstraintCategory :: Return ( _) | ConstraintCategory :: OpaqueType => {
2363
- let msg = format ! ( "{} is returned here" , kind ) ;
2352
+ let msg = format ! ( "{kind } is returned here" ) ;
2364
2353
err. span_note ( constraint_span, msg) ;
2365
2354
}
2366
2355
ConstraintCategory :: CallArgument ( _) => {
@@ -2402,21 +2391,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2402
2391
2403
2392
err. span_label (
2404
2393
upvar_span,
2405
- format ! ( "`{}` declared here, outside of the {} body" , upvar_name , escapes_from ) ,
2394
+ format ! ( "`{upvar_name }` declared here, outside of the {escapes_from } body" ) ,
2406
2395
) ;
2407
2396
2408
- err. span_label ( borrow_span, format ! ( "borrow is only valid in the {} body" , escapes_from ) ) ;
2397
+ err. span_label ( borrow_span, format ! ( "borrow is only valid in the {escapes_from } body" ) ) ;
2409
2398
2410
2399
if let Some ( name) = name {
2411
2400
err. span_label (
2412
2401
escape_span,
2413
- format ! ( "reference to `{}` escapes the {} body here" , name , escapes_from ) ,
2402
+ format ! ( "reference to `{name }` escapes the {escapes_from } body here" ) ,
2414
2403
) ;
2415
2404
} else {
2416
- err. span_label (
2417
- escape_span,
2418
- format ! ( "reference escapes the {} body here" , escapes_from) ,
2419
- ) ;
2405
+ err. span_label ( escape_span, format ! ( "reference escapes the {escapes_from} body here" ) ) ;
2420
2406
}
2421
2407
2422
2408
err
@@ -2697,10 +2683,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2697
2683
} ) ;
2698
2684
if let Some ( Ok ( instance) ) = deref_target {
2699
2685
let deref_target_ty = instance. ty ( tcx, self . param_env ) ;
2700
- err. note ( format ! (
2701
- "borrow occurs due to deref coercion to `{}`" ,
2702
- deref_target_ty
2703
- ) ) ;
2686
+ err. note ( format ! ( "borrow occurs due to deref coercion to `{deref_target_ty}`" ) ) ;
2704
2687
err. span_note ( tcx. def_span ( instance. def_id ( ) ) , "deref defined here" ) ;
2705
2688
}
2706
2689
}
@@ -2756,7 +2739,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2756
2739
"cannot assign twice to immutable variable"
2757
2740
} ;
2758
2741
if span != assigned_span && !from_arg {
2759
- err. span_label ( assigned_span, format ! ( "first assignment to {}" , place_description ) ) ;
2742
+ err. span_label ( assigned_span, format ! ( "first assignment to {place_description}" ) ) ;
2760
2743
}
2761
2744
if let Some ( decl) = local_decl
2762
2745
&& let Some ( name) = local_name
@@ -2765,7 +2748,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
2765
2748
err. span_suggestion (
2766
2749
decl. source_info . span ,
2767
2750
"consider making this binding mutable" ,
2768
- format ! ( "mut {}" , name ) ,
2751
+ format ! ( "mut {name}" ) ,
2769
2752
Applicability :: MachineApplicable ,
2770
2753
) ;
2771
2754
}
@@ -3226,7 +3209,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
3226
3209
return_span,
3227
3210
} => {
3228
3211
let argument_ty_name = cx. get_name_for_ty ( argument_ty, 0 ) ;
3229
- diag. span_label ( argument_span, format ! ( "has type `{}`" , argument_ty_name ) ) ;
3212
+ diag. span_label ( argument_span, format ! ( "has type `{argument_ty_name }`" ) ) ;
3230
3213
3231
3214
let return_ty_name = cx. get_name_for_ty ( return_ty, 0 ) ;
3232
3215
let types_equal = return_ty_name == argument_ty_name;
@@ -3253,15 +3236,14 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
3253
3236
// Region of return type and arguments checked to be the same earlier.
3254
3237
let region_name = cx. get_region_name_for_ty ( * return_ty, 0 ) ;
3255
3238
for ( _, argument_span) in arguments {
3256
- diag. span_label ( * argument_span, format ! ( "has lifetime `{}`" , region_name ) ) ;
3239
+ diag. span_label ( * argument_span, format ! ( "has lifetime `{region_name }`" ) ) ;
3257
3240
}
3258
3241
3259
- diag. span_label ( * return_span, format ! ( "also has lifetime `{}`" , region_name , ) ) ;
3242
+ diag. span_label ( * return_span, format ! ( "also has lifetime `{region_name }`" , ) ) ;
3260
3243
3261
3244
diag. help ( format ! (
3262
- "use data from the highlighted arguments which match the `{}` lifetime of \
3245
+ "use data from the highlighted arguments which match the `{region_name }` lifetime of \
3263
3246
the return type",
3264
- region_name,
3265
3247
) ) ;
3266
3248
3267
3249
region_name
0 commit comments