Skip to content

Commit df04be8

Browse files
committed
Comment.
1 parent 0a911ec commit df04be8

File tree

1 file changed

+9
-0
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+9
-0
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,25 @@ impl<'tcx> crate::MirPass<'tcx> for GVN {
154154
}
155155

156156
newtype_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)]
162166
struct VnOpaque;
163167
impl PartialEq for VnOpaque {
164168
fn eq(&self, _: &VnOpaque) -> bool {
169+
// ICE if we try to compare unique values
165170
unreachable!()
166171
}
167172
}
168173
impl 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

Comments
 (0)