@@ -103,8 +103,11 @@ impl<'tcx> MirPass<'tcx> for SimplifyPowOfTwo {
103
103
) ;
104
104
105
105
let num_shl = tcx. mk_place_field ( checked_mul. into ( ) , FieldIdx :: from_u32 ( 0 ) , exp_ty) ;
106
- let mul_result =
107
- tcx. mk_place_field ( checked_mul. into ( ) , FieldIdx :: from_u32 ( 1 ) , Ty :: new_bool ( tcx) ) ;
106
+ let mul_result = tcx. mk_place_field (
107
+ checked_mul. into ( ) ,
108
+ FieldIdx :: from_u32 ( 1 ) ,
109
+ Ty :: new_bool ( tcx) ,
110
+ ) ;
108
111
let shl_result = patch. new_temp ( Ty :: new_bool ( tcx) , span) ;
109
112
110
113
// Whether the shl will overflow, if so we return 0
@@ -118,7 +121,10 @@ impl<'tcx> MirPass<'tcx> for SimplifyPowOfTwo {
118
121
Operand :: Constant ( Box :: new ( Constant {
119
122
span,
120
123
user_ty : None ,
121
- literal : ConstantKind :: Val ( ConstValue :: from_u32 ( 32 ) , exp_ty) ,
124
+ literal : ConstantKind :: Val (
125
+ ConstValue :: from_u32 ( recv_int. size ( ) . bits ( ) as u32 ) ,
126
+ exp_ty,
127
+ ) ,
122
128
} ) ) ,
123
129
) ) ,
124
130
) ,
@@ -171,11 +177,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyPowOfTwo {
171
177
patch. add_assign (
172
178
loc,
173
179
shl. into ( ) ,
174
- Rvalue :: Cast (
175
- CastKind :: IntToInt ,
176
- Operand :: Copy ( shl_exp_ty. into ( ) ) ,
177
- recv_ty,
178
- ) ,
180
+ Rvalue :: Cast ( CastKind :: IntToInt , Operand :: Copy ( shl_exp_ty. into ( ) ) , recv_ty) ,
179
181
) ;
180
182
181
183
patch. add_assign (
@@ -221,7 +223,10 @@ impl<'tcx> MirPass<'tcx> for SimplifyPowOfTwo {
221
223
overflowed. into ( ) ,
222
224
Rvalue :: BinaryOp (
223
225
BinOp :: BitAnd ,
224
- Box :: new ( ( Operand :: Copy ( shl_eq_shr. into ( ) ) , Operand :: Copy ( shl_result. into ( ) ) ) ) ,
226
+ Box :: new ( (
227
+ Operand :: Copy ( shl_eq_shr. into ( ) ) ,
228
+ Operand :: Copy ( shl_result. into ( ) ) ,
229
+ ) ) ,
225
230
) ,
226
231
) ;
227
232
@@ -237,7 +242,10 @@ impl<'tcx> MirPass<'tcx> for SimplifyPowOfTwo {
237
242
Operand :: Constant ( Box :: new ( Constant {
238
243
span,
239
244
user_ty : None ,
240
- literal : ConstantKind :: Val ( ConstValue :: Scalar ( Scalar :: from_u32 ( 1 ) ) , exp_ty) ,
245
+ literal : ConstantKind :: Val (
246
+ ConstValue :: Scalar ( Scalar :: from_u32 ( 1 ) ) ,
247
+ exp_ty,
248
+ ) ,
241
249
} ) ) ,
242
250
Operand :: Copy ( num_shl. into ( ) ) ,
243
251
) ) ,
0 commit comments