@@ -310,19 +310,19 @@ impl<'a> Sugg<'a> {
310
310
311
311
/// Convenience method to transform suggestion into a return call
312
312
pub fn make_return ( self ) -> Sugg < ' static > {
313
- Sugg :: NonParen ( Cow :: Owned ( format ! ( "return {}" , self ) ) )
313
+ Sugg :: NonParen ( Cow :: Owned ( format ! ( "return {self}" ) ) )
314
314
}
315
315
316
316
/// Convenience method to transform suggestion into a block
317
317
/// where the suggestion is a trailing expression
318
318
pub fn blockify ( self ) -> Sugg < ' static > {
319
- Sugg :: NonParen ( Cow :: Owned ( format ! ( "{{ {} }}" , self ) ) )
319
+ Sugg :: NonParen ( Cow :: Owned ( format ! ( "{{ {self } }}" ) ) )
320
320
}
321
321
322
322
/// Convenience method to prefix the expression with the `async` keyword.
323
323
/// Can be used after `blockify` to create an async block.
324
324
pub fn asyncify ( self ) -> Sugg < ' static > {
325
- Sugg :: NonParen ( Cow :: Owned ( format ! ( "async {}" , self ) ) )
325
+ Sugg :: NonParen ( Cow :: Owned ( format ! ( "async {self}" ) ) )
326
326
}
327
327
328
328
/// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
@@ -346,12 +346,12 @@ impl<'a> Sugg<'a> {
346
346
if has_enclosing_paren ( & sugg) {
347
347
Sugg :: MaybeParen ( sugg)
348
348
} else {
349
- Sugg :: NonParen ( format ! ( "({})" , sugg ) . into ( ) )
349
+ Sugg :: NonParen ( format ! ( "({sugg })" ) . into ( ) )
350
350
}
351
351
} ,
352
352
Sugg :: BinOp ( op, lhs, rhs) => {
353
353
let sugg = binop_to_string ( op, & lhs, & rhs) ;
354
- Sugg :: NonParen ( format ! ( "({})" , sugg ) . into ( ) )
354
+ Sugg :: NonParen ( format ! ( "({sugg })" ) . into ( ) )
355
355
} ,
356
356
}
357
357
}
@@ -379,20 +379,18 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
379
379
| AssocOp :: Greater
380
380
| AssocOp :: GreaterEqual => {
381
381
format ! (
382
- "{} {} {}" ,
383
- lhs,
384
- op. to_ast_binop( ) . expect( "Those are AST ops" ) . to_string( ) ,
385
- rhs
382
+ "{lhs} {} {rhs}" ,
383
+ op. to_ast_binop( ) . expect( "Those are AST ops" ) . to_string( )
386
384
)
387
385
} ,
388
- AssocOp :: Assign => format ! ( "{} = {}" , lhs , rhs ) ,
386
+ AssocOp :: Assign => format ! ( "{lhs } = {rhs}" ) ,
389
387
AssocOp :: AssignOp ( op) => {
390
- format ! ( "{} {}= {}" , lhs , token_kind_to_string( & token:: BinOp ( op) ) , rhs )
388
+ format ! ( "{lhs } {}= {rhs }" , token_kind_to_string( & token:: BinOp ( op) ) )
391
389
} ,
392
- AssocOp :: As => format ! ( "{} as {}" , lhs , rhs ) ,
393
- AssocOp :: DotDot => format ! ( "{}..{}" , lhs , rhs ) ,
394
- AssocOp :: DotDotEq => format ! ( "{}..={}" , lhs , rhs ) ,
395
- AssocOp :: Colon => format ! ( "{}: {}" , lhs , rhs ) ,
390
+ AssocOp :: As => format ! ( "{lhs } as {rhs}" ) ,
391
+ AssocOp :: DotDot => format ! ( "{lhs }..{rhs}" ) ,
392
+ AssocOp :: DotDotEq => format ! ( "{lhs }..={rhs}" ) ,
393
+ AssocOp :: Colon => format ! ( "{lhs }: {rhs}" ) ,
396
394
}
397
395
}
398
396
@@ -523,7 +521,7 @@ impl<T: Display> Display for ParenHelper<T> {
523
521
/// operators have the same
524
522
/// precedence.
525
523
pub fn make_unop ( op : & str , expr : Sugg < ' _ > ) -> Sugg < ' static > {
526
- Sugg :: MaybeParen ( format ! ( "{}{}" , op , expr. maybe_par( ) ) . into ( ) )
524
+ Sugg :: MaybeParen ( format ! ( "{op }{}" , expr. maybe_par( ) ) . into ( ) )
527
525
}
528
526
529
527
/// Builds the string for `<lhs> <op> <rhs>` adding parenthesis when necessary.
@@ -744,7 +742,7 @@ impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
744
742
if let Some ( indent) = indentation ( cx, item) {
745
743
let span = item. with_hi ( item. lo ( ) ) ;
746
744
747
- self . span_suggestion ( span, msg, format ! ( "{}\n {}" , attr , indent ) , applicability) ;
745
+ self . span_suggestion ( span, msg, format ! ( "{attr }\n {indent}" ) , applicability) ;
748
746
}
749
747
}
750
748
@@ -758,14 +756,14 @@ impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
758
756
. map ( |l| {
759
757
if first {
760
758
first = false ;
761
- format ! ( "{}\n " , l )
759
+ format ! ( "{l }\n " )
762
760
} else {
763
- format ! ( "{}{ }\n " , indent , l )
761
+ format ! ( "{indent}{l }\n " )
764
762
}
765
763
} )
766
764
. collect :: < String > ( ) ;
767
765
768
- self . span_suggestion ( span, msg, format ! ( "{}\n {}" , new_item , indent ) , applicability) ;
766
+ self . span_suggestion ( span, msg, format ! ( "{new_item }\n {indent}" ) , applicability) ;
769
767
}
770
768
}
771
769
@@ -863,7 +861,7 @@ impl<'tcx> DerefDelegate<'_, 'tcx> {
863
861
pub fn finish ( & mut self ) -> String {
864
862
let end_span = Span :: new ( self . next_pos , self . closure_span . hi ( ) , self . closure_span . ctxt ( ) , None ) ;
865
863
let end_snip = snippet_with_applicability ( self . cx , end_span, ".." , & mut self . applicability ) ;
866
- let sugg = format ! ( "{}{}" , self . suggestion_start, end_snip ) ;
864
+ let sugg = format ! ( "{}{end_snip }" , self . suggestion_start) ;
867
865
if self . closure_arg_is_type_annotated_double_ref {
868
866
sugg. replacen ( '&' , "" , 1 )
869
867
} else {
@@ -925,7 +923,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
925
923
if cmt. place . projections . is_empty ( ) {
926
924
// handle item without any projection, that needs an explicit borrowing
927
925
// i.e.: suggest `&x` instead of `x`
928
- let _ = write ! ( self . suggestion_start, "{}&{}" , start_snip , ident_str ) ;
926
+ let _ = write ! ( self . suggestion_start, "{start_snip }&{ident_str}" ) ;
929
927
} else {
930
928
// cases where a parent `Call` or `MethodCall` is using the item
931
929
// i.e.: suggest `.contains(&x)` for `.find(|x| [1, 2, 3].contains(x)).is_none()`
@@ -940,7 +938,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
940
938
// given expression is the self argument and will be handled completely by the compiler
941
939
// i.e.: `|x| x.is_something()`
942
940
ExprKind :: MethodCall ( _, self_expr, ..) if self_expr. hir_id == cmt. hir_id => {
943
- let _ = write ! ( self . suggestion_start, "{}{}" , start_snip , ident_str_with_proj ) ;
941
+ let _ = write ! ( self . suggestion_start, "{start_snip}{ident_str_with_proj}" ) ;
944
942
self . next_pos = span. hi ( ) ;
945
943
return ;
946
944
} ,
@@ -973,9 +971,9 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
973
971
} else {
974
972
ident_str
975
973
} ;
976
- format ! ( "{}{}" , start_snip , ident )
974
+ format ! ( "{start_snip}{ident}" )
977
975
} else {
978
- format ! ( "{}&{}" , start_snip , ident_str )
976
+ format ! ( "{start_snip }&{ident_str}" )
979
977
} ;
980
978
self . suggestion_start . push_str ( & ident_sugg) ;
981
979
self . next_pos = span. hi ( ) ;
@@ -1042,13 +1040,13 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
1042
1040
1043
1041
for item in projections {
1044
1042
if item. kind == ProjectionKind :: Deref {
1045
- replacement_str = format ! ( "*{}" , replacement_str ) ;
1043
+ replacement_str = format ! ( "*{replacement_str}" ) ;
1046
1044
}
1047
1045
}
1048
1046
}
1049
1047
}
1050
1048
1051
- let _ = write ! ( self . suggestion_start, "{}{}" , start_snip , replacement_str ) ;
1049
+ let _ = write ! ( self . suggestion_start, "{start_snip}{replacement_str}" ) ;
1052
1050
}
1053
1051
self . next_pos = span. hi ( ) ;
1054
1052
}
0 commit comments