@@ -154,19 +154,25 @@ impl<'tcx> crate::MirPass<'tcx> for GVN {
154154}
155155
156156newtype_index ! {
157+ /// This represents a `Value` in the symbolic execution.
157158 #[ debug_format = "_v{}" ]
158159 struct VnIndex { }
159160}
160161
162+ /// Marker type to forbid hashing and comparing opaque values.
163+ /// This struct should only be constructed by `ValueSet::insert_unique` to ensure we use that
164+ /// method to create non-unifiable values. It will ICE if used in `ValueSet::insert`.
161165#[ derive( Copy , Clone , Debug , Eq ) ]
162166struct VnOpaque ;
163167impl PartialEq for VnOpaque {
164168 fn eq ( & self , _: & VnOpaque ) -> bool {
169+ // ICE if we try to compare unique values
165170 unreachable ! ( )
166171 }
167172}
168173impl Hash for VnOpaque {
169174 fn hash < T : Hasher > ( & self , _: & mut T ) {
175+ // ICE if we try to hash unique values
170176 unreachable ! ( )
171177 }
172178}
@@ -191,6 +197,8 @@ enum Value<'tcx> {
191197 // `disambiguator` is `None` iff the constant is deterministic.
192198 disambiguator : Option < VnOpaque > ,
193199 } ,
200+
201+ // Aggregates.
194202 /// An aggregate value, either tuple/closure/struct/enum.
195203 /// This does not contain unions, as we cannot reason with the value.
196204 Aggregate ( VariantIdx , Vec < VnIndex > ) ,
@@ -252,6 +260,7 @@ impl<'tcx> ValueSet<'tcx> {
252260 }
253261
254262 /// Insert a `(Value, Ty)` pair without hashing or deduplication.
263+ /// This always creates a new `VnIndex`.
255264 #[ inline]
256265 fn insert_unique (
257266 & mut self ,
0 commit comments