about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform
diff options
context:
space:
mode:
authorCamille Gillot <gillot.camille@gmail.com>2025-09-14 13:18:19 +0000
committerCamille Gillot <gillot.camille@gmail.com>2025-09-14 13:23:32 +0000
commitdf04be8cf744b500b5972fdc76898a96067d5517 (patch)
tree253613d4b0702aa01d7c0d0af76a2dc51b4cee5d /compiler/rustc_mir_transform
parent0a911ec97f9ce39eb52dd3e5da6232e733cdee47 (diff)
downloadrust-df04be8cf744b500b5972fdc76898a96067d5517.tar.gz
rust-df04be8cf744b500b5972fdc76898a96067d5517.zip
Comment.
Diffstat (limited to 'compiler/rustc_mir_transform')
-rw-r--r--compiler/rustc_mir_transform/src/gvn.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs
index f8b3e5c6f87..fc0a03b1aab 100644
--- a/compiler/rustc_mir_transform/src/gvn.rs
+++ b/compiler/rustc_mir_transform/src/gvn.rs
@@ -154,19 +154,25 @@ impl<'tcx> crate::MirPass<'tcx> for GVN {
 }
 
 newtype_index! {
+    /// This represents a `Value` in the symbolic execution.
     #[debug_format = "_v{}"]
     struct VnIndex {}
 }
 
+/// Marker type to forbid hashing and comparing opaque values.
+/// This struct should only be constructed by `ValueSet::insert_unique` to ensure we use that
+/// method to create non-unifiable values. It will ICE if used in `ValueSet::insert`.
 #[derive(Copy, Clone, Debug, Eq)]
 struct VnOpaque;
 impl PartialEq for VnOpaque {
     fn eq(&self, _: &VnOpaque) -> bool {
+        // ICE if we try to compare unique values
         unreachable!()
     }
 }
 impl Hash for VnOpaque {
     fn hash<T: Hasher>(&self, _: &mut T) {
+        // ICE if we try to hash unique values
         unreachable!()
     }
 }
@@ -191,6 +197,8 @@ enum Value<'tcx> {
         // `disambiguator` is `None` iff the constant is deterministic.
         disambiguator: Option<VnOpaque>,
     },
+
+    // Aggregates.
     /// An aggregate value, either tuple/closure/struct/enum.
     /// This does not contain unions, as we cannot reason with the value.
     Aggregate(VariantIdx, Vec<VnIndex>),
@@ -252,6 +260,7 @@ impl<'tcx> ValueSet<'tcx> {
     }
 
     /// Insert a `(Value, Ty)` pair without hashing or deduplication.
+    /// This always creates a new `VnIndex`.
     #[inline]
     fn insert_unique(
         &mut self,