@@ -304,9 +304,15 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
304
304
) -> Option < Const < ' tcx > > {
305
305
let span = source_info. span ;
306
306
match * rvalue {
307
+ Rvalue :: Repeat ( ..) |
308
+ Rvalue :: Aggregate ( ..) |
309
+ Rvalue :: NullaryOp ( NullOp :: Box , _) |
310
+ Rvalue :: Discriminant ( ..) => None ,
311
+
307
312
Rvalue :: Use ( _) |
308
313
Rvalue :: Len ( _) |
309
- Rvalue :: Cast ( ..) => {
314
+ Rvalue :: Cast ( ..) |
315
+ Rvalue :: NullaryOp ( ..) => {
310
316
self . use_ecx ( source_info, |this| {
311
317
this. ecx . eval_rvalue_into_place ( rvalue, place) ?;
312
318
this. ecx . eval_place_to_op ( place, Some ( place_layout) )
@@ -317,19 +323,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
317
323
let mplace = src. try_as_mplace ( ) . ok ( ) ?;
318
324
Some ( ImmTy :: from_scalar ( mplace. ptr . into ( ) , place_layout) . into ( ) )
319
325
} ,
320
- Rvalue :: Repeat ( ..) |
321
- Rvalue :: Aggregate ( ..) |
322
- Rvalue :: NullaryOp ( NullOp :: Box , _) |
323
- Rvalue :: Discriminant ( ..) => None ,
324
326
325
- Rvalue :: NullaryOp ( NullOp :: SizeOf , ty) => {
326
- type_size_of ( self . tcx , self . param_env , ty) . and_then ( |n| Some (
327
- ImmTy :: from_uint (
328
- n,
329
- self . tcx . layout_of ( self . param_env . and ( self . tcx . types . usize ) ) . ok ( ) ?,
330
- ) . into ( )
331
- ) )
332
- }
333
327
Rvalue :: UnaryOp ( op, ref arg) => {
334
328
let def_id = if self . tcx . is_closure ( self . source . def_id ( ) ) {
335
329
self . tcx . closure_base_def_id ( self . source . def_id ( ) )
@@ -515,14 +509,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
515
509
}
516
510
}
517
511
518
- fn type_size_of < ' tcx > (
519
- tcx : TyCtxt < ' tcx > ,
520
- param_env : ty:: ParamEnv < ' tcx > ,
521
- ty : Ty < ' tcx > ,
522
- ) -> Option < u64 > {
523
- tcx. layout_of ( param_env. and ( ty) ) . ok ( ) . map ( |layout| layout. size . bytes ( ) )
524
- }
525
-
526
512
struct CanConstProp {
527
513
can_const_prop : IndexVec < Local , bool > ,
528
514
// false at the beginning, once set, there are not allowed to be any more assignments
0 commit comments