@@ -15,7 +15,7 @@ pub(super) fn check<'tcx>(
1515 e : & ' tcx Expr < ' _ > ,
1616 from_ty : Ty < ' tcx > ,
1717 to_ty : Ty < ' tcx > ,
18- arg : & ' tcx Expr < ' _ > ,
18+ mut arg : & ' tcx Expr < ' _ > ,
1919 const_context : bool ,
2020) -> bool {
2121 match ( & from_ty. kind ( ) , & to_ty. kind ( ) ) {
@@ -26,37 +26,36 @@ pub(super) fn check<'tcx>(
2626 e. span ,
2727 & format ! ( "transmute from a `{}` to a `{}`" , from_ty, to_ty) ,
2828 |diag| {
29- let mut expr = arg;
30- let mut arg = sugg:: Sugg :: hir ( cx, expr, ".." ) ;
29+ let mut sugg = sugg:: Sugg :: hir ( cx, arg, ".." ) ;
3130
32- if let ExprKind :: Unary ( UnOp :: Neg , inner_expr) = & expr . kind {
33- expr = inner_expr;
31+ if let ExprKind :: Unary ( UnOp :: Neg , inner_expr) = & arg . kind {
32+ arg = inner_expr;
3433 }
3534
3635 if_chain ! {
3736 // if the expression is a float literal and it is unsuffixed then
3837 // add a suffix so the suggestion is valid and unambiguous
39- if let ExprKind :: Lit ( lit) = & expr . kind;
38+ if let ExprKind :: Lit ( lit) = & arg . kind;
4039 if let ast:: LitKind :: Float ( _, ast:: LitFloatType :: Unsuffixed ) = lit. node;
4140 then {
42- let op = format!( "{}{}" , arg , float_ty. name_str( ) ) . into( ) ;
43- match arg {
44- sugg:: Sugg :: MaybeParen ( _) => arg = sugg:: Sugg :: MaybeParen ( op) ,
45- _ => arg = sugg:: Sugg :: NonParen ( op)
41+ let op = format!( "{}{}" , sugg , float_ty. name_str( ) ) . into( ) ;
42+ match sugg {
43+ sugg:: Sugg :: MaybeParen ( _) => sugg = sugg:: Sugg :: MaybeParen ( op) ,
44+ _ => sugg = sugg:: Sugg :: NonParen ( op)
4645 }
4746 }
4847 }
4948
50- arg = sugg:: Sugg :: NonParen ( format ! ( "{}.to_bits()" , arg . maybe_par( ) ) . into ( ) ) ;
49+ sugg = sugg:: Sugg :: NonParen ( format ! ( "{}.to_bits()" , sugg . maybe_par( ) ) . into ( ) ) ;
5150
5251 // cast the result of `to_bits` if `to_ty` is signed
53- arg = if let ty:: Int ( int_ty) = to_ty. kind ( ) {
54- arg . as_ty ( int_ty. name_str ( ) . to_string ( ) )
52+ sugg = if let ty:: Int ( int_ty) = to_ty. kind ( ) {
53+ sugg . as_ty ( int_ty. name_str ( ) . to_string ( ) )
5554 } else {
56- arg
55+ sugg
5756 } ;
5857
59- diag. span_suggestion ( e. span , "consider using" , arg . to_string ( ) , Applicability :: Unspecified ) ;
58+ diag. span_suggestion ( e. span , "consider using" , sugg . to_string ( ) , Applicability :: Unspecified ) ;
6059 } ,
6160 ) ;
6261 true
0 commit comments