@@ -498,22 +498,19 @@ impl<'tcx> Const<'tcx> {
498
498
}
499
499
}
500
500
501
- /// Return true if any evaluation of this constant returns the same value.
501
+ /// Return true if any evaluation of this constant always returns the same value,
502
+ /// taking into account even pointer identity tests.
502
503
pub fn is_deterministic ( & self ) -> bool {
503
504
// Some constants may contain pointers. We need to preserve the provenance of these
504
505
// pointers, but not all constants guarantee this:
505
506
// - valtrees purposefully do not;
506
507
// - ConstValue::Slice does not either.
507
508
match self {
508
509
Const :: Ty ( c) => match c. kind ( ) {
509
- ty:: ConstKind :: Value ( valtree) => match valtree {
510
- // This is just an integer, keep it.
511
- ty:: ValTree :: Leaf ( _) => true ,
512
- // This branch may be a reference. Valtree references correspond to a
513
- // different allocation each time they are evaluated.
514
- ty:: ValTree :: Branch ( _) => false ,
515
- } ,
516
510
ty:: ConstKind :: Param ( ..) => true ,
511
+ // A valtree may be a reference. Valtree references correspond to a
512
+ // different allocation each time they are evaluated.
513
+ ty:: ConstKind :: Value ( _) => false ,
517
514
ty:: ConstKind :: Unevaluated ( ..) | ty:: ConstKind :: Expr ( ..) => false ,
518
515
// Should not appear in runtime MIR.
519
516
ty:: ConstKind :: Infer ( ..)
0 commit comments