@@ -1466,38 +1466,29 @@ impl<'tcx> VnState<'_, 'tcx> {
1466
1466
// This was already constant in MIR, do not change it.
1467
1467
let value = self . get ( index) ;
1468
1468
debug ! ( ?index, ?value) ;
1469
- match value {
1470
- // If the constant is not deterministic, adding an additional mention of it in MIR will
1471
- // not give the same value as the former mention.
1472
- Value :: Constant { value, disambiguator : _ } if value. is_deterministic ( ) => {
1473
- return Some ( ConstOperand { span : DUMMY_SP , user_ty : None , const_ : * value } ) ;
1474
- }
1469
+ // If the constant is not deterministic, adding an additional mention of it in MIR will
1470
+ // not give the same value as the former mention.
1471
+ if let Value :: Constant { value, disambiguator : _ } = value
1472
+ && value. is_deterministic ( )
1473
+ {
1474
+ return Some ( ConstOperand { span : DUMMY_SP , user_ty : None , const_ : * value } ) ;
1475
+ }
1476
+
1477
+ let op = self . evaluated [ index] . as_ref ( ) ?;
1478
+
1479
+ if let Either :: Left ( mplace) = op. as_mplace_or_imm ( )
1480
+ && let ty:: Array ( ty, _const) = mplace. layout . ty . kind ( )
1481
+ {
1475
1482
// ignore nested arrays
1476
- Value :: Aggregate ( AggregateTy :: Array , _, fields) => {
1477
- for f in fields {
1478
- if let Value :: Constant { value : Const :: Val ( const_, _) , .. } = self . get ( * f)
1479
- && let ConstValue :: Indirect { .. } = const_
1480
- {
1481
- return None ;
1482
- }
1483
- }
1483
+ if ty. is_array ( ) {
1484
+ return None ;
1484
1485
}
1485
1486
// ignore promoted arrays
1486
- Value :: Projection ( index, ProjectionElem :: Deref ) => {
1487
- if let Value :: Constant { value : Const :: Val ( const_, ty) , .. } = self . get ( * index)
1488
- && let ConstValue :: Scalar ( Scalar :: Ptr ( ..) ) = const_
1489
- && let ty:: Ref ( region, ty, _mutability) = ty. kind ( )
1490
- && region. is_erased ( )
1491
- && ty. is_array ( )
1492
- {
1493
- return None ;
1494
- }
1487
+ else if let Value :: Projection ( _index, ProjectionElem :: Deref ) = value {
1488
+ return None ;
1495
1489
}
1496
- _ => { }
1497
1490
}
1498
1491
1499
- let op = self . evaluated [ index] . as_ref ( ) ?;
1500
-
1501
1492
let value = op_to_prop_const ( & mut self . ecx , op) ?;
1502
1493
1503
1494
// Check that we do not leak a pointer.
0 commit comments