@@ -15,7 +15,7 @@ pub(super) fn check<'tcx>(
15
15
e : & ' tcx Expr < ' _ > ,
16
16
from_ty : Ty < ' tcx > ,
17
17
to_ty : Ty < ' tcx > ,
18
- arg : & ' tcx Expr < ' _ > ,
18
+ mut arg : & ' tcx Expr < ' _ > ,
19
19
const_context : bool ,
20
20
) -> bool {
21
21
match ( & from_ty. kind ( ) , & to_ty. kind ( ) ) {
@@ -26,37 +26,36 @@ pub(super) fn check<'tcx>(
26
26
e. span ,
27
27
& format ! ( "transmute from a `{}` to a `{}`" , from_ty, to_ty) ,
28
28
|diag| {
29
- let mut expr = arg;
30
- let mut arg = sugg:: Sugg :: hir ( cx, expr, ".." ) ;
29
+ let mut sugg = sugg:: Sugg :: hir ( cx, arg, ".." ) ;
31
30
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;
34
33
}
35
34
36
35
if_chain ! {
37
36
// if the expression is a float literal and it is unsuffixed then
38
37
// 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;
40
39
if let ast:: LitKind :: Float ( _, ast:: LitFloatType :: Unsuffixed ) = lit. node;
41
40
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)
46
45
}
47
46
}
48
47
}
49
48
50
- arg = sugg:: Sugg :: NonParen ( format ! ( "{}.to_bits()" , arg . maybe_par( ) ) . into ( ) ) ;
49
+ sugg = sugg:: Sugg :: NonParen ( format ! ( "{}.to_bits()" , sugg . maybe_par( ) ) . into ( ) ) ;
51
50
52
51
// 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 ( ) )
55
54
} else {
56
- arg
55
+ sugg
57
56
} ;
58
57
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 ) ;
60
59
} ,
61
60
) ;
62
61
true
0 commit comments