@@ -154,19 +154,25 @@ impl<'tcx> crate::MirPass<'tcx> for GVN {
154
154
}
155
155
156
156
newtype_index ! {
157
+ /// This represents a `Value` in the symbolic execution.
157
158
#[ debug_format = "_v{}" ]
158
159
struct VnIndex { }
159
160
}
160
161
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`.
161
165
#[ derive( Copy , Clone , Debug , Eq ) ]
162
166
struct VnOpaque ;
163
167
impl PartialEq for VnOpaque {
164
168
fn eq ( & self , _: & VnOpaque ) -> bool {
169
+ // ICE if we try to compare unique values
165
170
unreachable ! ( )
166
171
}
167
172
}
168
173
impl Hash for VnOpaque {
169
174
fn hash < T : Hasher > ( & self , _: & mut T ) {
175
+ // ICE if we try to hash unique values
170
176
unreachable ! ( )
171
177
}
172
178
}
@@ -191,6 +197,8 @@ enum Value<'tcx> {
191
197
// `disambiguator` is `None` iff the constant is deterministic.
192
198
disambiguator : Option < VnOpaque > ,
193
199
} ,
200
+
201
+ // Aggregates.
194
202
/// An aggregate value, either tuple/closure/struct/enum.
195
203
/// This does not contain unions, as we cannot reason with the value.
196
204
Aggregate ( VariantIdx , Vec < VnIndex > ) ,
@@ -252,6 +260,7 @@ impl<'tcx> ValueSet<'tcx> {
252
260
}
253
261
254
262
/// Insert a `(Value, Ty)` pair without hashing or deduplication.
263
+ /// This always creates a new `VnIndex`.
255
264
#[ inline]
256
265
fn insert_unique (
257
266
& mut self ,
0 commit comments