about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-10-14 12:53:18 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-10-25 06:46:48 +0000
commitf6aa3ee7e8a6c28199ebf09810b330b46adf8610 (patch)
treeef96f5ee3feea625c9b92f8b4b546b353c2dc709
parent5e78b9cdb39f2cd47a0518ba568e7bfd0d1f8d95 (diff)
downloadrust-f6aa3ee7e8a6c28199ebf09810b330b46adf8610.tar.gz
rust-f6aa3ee7e8a6c28199ebf09810b330b46adf8610.zip
Complete comments.
-rw-r--r--compiler/rustc_middle/src/mir/consts.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs
index 375870a4fb5..d427b4ec3f4 100644
--- a/compiler/rustc_middle/src/mir/consts.rs
+++ b/compiler/rustc_middle/src/mir/consts.rs
@@ -498,7 +498,8 @@ impl<'tcx> Const<'tcx> {
         }
     }
 
-    /// Return true if any evaluation of this constant returns the same value.
+    /// Return true if any evaluation of this constant always returns the same value,
+    /// taking into account even pointer identity tests.
     pub fn is_deterministic(&self) -> bool {
         // Some constants may contain pointers. We need to preserve the provenance of these
         // pointers, but not all constants guarantee this:
@@ -506,14 +507,10 @@ impl<'tcx> Const<'tcx> {
         // - ConstValue::Slice does not either.
         match self {
             Const::Ty(c) => match c.kind() {
-                ty::ConstKind::Value(valtree) => match valtree {
-                    // This is just an integer, keep it.
-                    ty::ValTree::Leaf(_) => true,
-                    // This branch may be a reference. Valtree references correspond to a
-                    // different allocation each time they are evaluated.
-                    ty::ValTree::Branch(_) => false,
-                },
                 ty::ConstKind::Param(..) => true,
+                // A valtree may be a reference. Valtree references correspond to a
+                // different allocation each time they are evaluated.
+                ty::ConstKind::Value(_) => false,
                 ty::ConstKind::Unevaluated(..) | ty::ConstKind::Expr(..) => false,
                 // Should not appear in runtime MIR.
                 ty::ConstKind::Infer(..)