@@ -310,19 +310,19 @@ impl<'a> Sugg<'a> {
310310
311311 /// Convenience method to transform suggestion into a return call
312312 pub fn make_return ( self ) -> Sugg < ' static > {
313- Sugg :: NonParen ( Cow :: Owned ( format ! ( "return {}" , self ) ) )
313+ Sugg :: NonParen ( Cow :: Owned ( format ! ( "return {self}" ) ) )
314314 }
315315
316316 /// Convenience method to transform suggestion into a block
317317 /// where the suggestion is a trailing expression
318318 pub fn blockify ( self ) -> Sugg < ' static > {
319- Sugg :: NonParen ( Cow :: Owned ( format ! ( "{{ {} }}" , self ) ) )
319+ Sugg :: NonParen ( Cow :: Owned ( format ! ( "{{ {self } }}" ) ) )
320320 }
321321
322322 /// Convenience method to prefix the expression with the `async` keyword.
323323 /// Can be used after `blockify` to create an async block.
324324 pub fn asyncify ( self ) -> Sugg < ' static > {
325- Sugg :: NonParen ( Cow :: Owned ( format ! ( "async {}" , self ) ) )
325+ Sugg :: NonParen ( Cow :: Owned ( format ! ( "async {self}" ) ) )
326326 }
327327
328328 /// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
@@ -346,12 +346,12 @@ impl<'a> Sugg<'a> {
346346 if has_enclosing_paren ( & sugg) {
347347 Sugg :: MaybeParen ( sugg)
348348 } else {
349- Sugg :: NonParen ( format ! ( "({})" , sugg ) . into ( ) )
349+ Sugg :: NonParen ( format ! ( "({sugg })" ) . into ( ) )
350350 }
351351 } ,
352352 Sugg :: BinOp ( op, lhs, rhs) => {
353353 let sugg = binop_to_string ( op, & lhs, & rhs) ;
354- Sugg :: NonParen ( format ! ( "({})" , sugg ) . into ( ) )
354+ Sugg :: NonParen ( format ! ( "({sugg })" ) . into ( ) )
355355 } ,
356356 }
357357 }
@@ -379,20 +379,18 @@ fn binop_to_string(op: AssocOp, lhs: &str, rhs: &str) -> String {
379379 | AssocOp :: Greater
380380 | AssocOp :: GreaterEqual => {
381381 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( )
386384 )
387385 } ,
388- AssocOp :: Assign => format ! ( "{} = {}" , lhs , rhs ) ,
386+ AssocOp :: Assign => format ! ( "{lhs } = {rhs}" ) ,
389387 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) ) )
391389 } ,
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}" ) ,
396394 }
397395}
398396
@@ -523,7 +521,7 @@ impl<T: Display> Display for ParenHelper<T> {
523521/// operators have the same
524522/// precedence.
525523pub 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 ( ) )
527525}
528526
529527/// Builds the string for `<lhs> <op> <rhs>` adding parenthesis when necessary.
@@ -744,7 +742,7 @@ impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
744742 if let Some ( indent) = indentation ( cx, item) {
745743 let span = item. with_hi ( item. lo ( ) ) ;
746744
747- self . span_suggestion ( span, msg, format ! ( "{}\n {}" , attr , indent ) , applicability) ;
745+ self . span_suggestion ( span, msg, format ! ( "{attr }\n {indent}" ) , applicability) ;
748746 }
749747 }
750748
@@ -758,14 +756,14 @@ impl<T: LintContext> DiagnosticExt<T> for rustc_errors::Diagnostic {
758756 . map ( |l| {
759757 if first {
760758 first = false ;
761- format ! ( "{}\n " , l )
759+ format ! ( "{l }\n " )
762760 } else {
763- format ! ( "{}{ }\n " , indent , l )
761+ format ! ( "{indent}{l }\n " )
764762 }
765763 } )
766764 . collect :: < String > ( ) ;
767765
768- self . span_suggestion ( span, msg, format ! ( "{}\n {}" , new_item , indent ) , applicability) ;
766+ self . span_suggestion ( span, msg, format ! ( "{new_item }\n {indent}" ) , applicability) ;
769767 }
770768 }
771769
@@ -863,7 +861,7 @@ impl<'tcx> DerefDelegate<'_, 'tcx> {
863861 pub fn finish ( & mut self ) -> String {
864862 let end_span = Span :: new ( self . next_pos , self . closure_span . hi ( ) , self . closure_span . ctxt ( ) , None ) ;
865863 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) ;
867865 if self . closure_arg_is_type_annotated_double_ref {
868866 sugg. replacen ( '&' , "" , 1 )
869867 } else {
@@ -925,7 +923,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
925923 if cmt. place . projections . is_empty ( ) {
926924 // handle item without any projection, that needs an explicit borrowing
927925 // 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}" ) ;
929927 } else {
930928 // cases where a parent `Call` or `MethodCall` is using the item
931929 // 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> {
940938 // given expression is the self argument and will be handled completely by the compiler
941939 // i.e.: `|x| x.is_something()`
942940 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}" ) ;
944942 self . next_pos = span. hi ( ) ;
945943 return ;
946944 } ,
@@ -973,9 +971,9 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
973971 } else {
974972 ident_str
975973 } ;
976- format ! ( "{}{}" , start_snip , ident )
974+ format ! ( "{start_snip}{ident}" )
977975 } else {
978- format ! ( "{}&{}" , start_snip , ident_str )
976+ format ! ( "{start_snip }&{ident_str}" )
979977 } ;
980978 self . suggestion_start . push_str ( & ident_sugg) ;
981979 self . next_pos = span. hi ( ) ;
@@ -1042,13 +1040,13 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
10421040
10431041 for item in projections {
10441042 if item. kind == ProjectionKind :: Deref {
1045- replacement_str = format ! ( "*{}" , replacement_str ) ;
1043+ replacement_str = format ! ( "*{replacement_str}" ) ;
10461044 }
10471045 }
10481046 }
10491047 }
10501048
1051- let _ = write ! ( self . suggestion_start, "{}{}" , start_snip , replacement_str ) ;
1049+ let _ = write ! ( self . suggestion_start, "{start_snip}{replacement_str}" ) ;
10521050 }
10531051 self . next_pos = span. hi ( ) ;
10541052 }
0 commit comments