@@ -498,22 +498,19 @@ impl<'tcx> Const<'tcx> {
498498 }
499499 }
500500
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.
502503 pub fn is_deterministic ( & self ) -> bool {
503504 // Some constants may contain pointers. We need to preserve the provenance of these
504505 // pointers, but not all constants guarantee this:
505506 // - valtrees purposefully do not;
506507 // - ConstValue::Slice does not either.
507508 match self {
508509 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- } ,
516510 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 ,
517514 ty:: ConstKind :: Unevaluated ( ..) | ty:: ConstKind :: Expr ( ..) => false ,
518515 // Should not appear in runtime MIR.
519516 ty:: ConstKind :: Infer ( ..)
0 commit comments