@@ -202,6 +202,7 @@ enum Value<'tcx> {
202
202
value : Const < ' tcx > ,
203
203
/// Some constants do not have a deterministic value. To avoid merging two instances of the
204
204
/// same `Const`, we assign them an additional integer index.
205
+ // `disambiguator` is 0 iff the constant is deterministic.
205
206
disambiguator : usize ,
206
207
} ,
207
208
/// An aggregate value, either tuple/closure/struct/enum.
@@ -286,7 +287,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
286
287
rev_locals : IndexVec :: with_capacity ( num_values) ,
287
288
values : FxIndexSet :: with_capacity_and_hasher ( num_values, Default :: default ( ) ) ,
288
289
evaluated : IndexVec :: with_capacity ( num_values) ,
289
- next_opaque : Some ( 0 ) ,
290
+ next_opaque : Some ( 1 ) ,
290
291
feature_unsized_locals : tcx. features ( ) . unsized_locals ,
291
292
ssa,
292
293
dominators,
@@ -358,6 +359,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
358
359
let next_opaque = self . next_opaque . as_mut ( ) ?;
359
360
let disambiguator = * next_opaque;
360
361
* next_opaque += 1 ;
362
+ assert_ne ! ( disambiguator, 0 ) ;
361
363
disambiguator
362
364
} ;
363
365
Some ( self . insert ( Value :: Constant { value, disambiguator } ) )
@@ -1385,12 +1387,11 @@ impl<'tcx> VnState<'_, 'tcx> {
1385
1387
1386
1388
/// If `index` is a `Value::Constant`, return the `Constant` to be put in the MIR.
1387
1389
fn try_as_constant ( & mut self , index : VnIndex ) -> Option < ConstOperand < ' tcx > > {
1388
- // This was already constant in MIR, do not change it.
1389
- if let Value :: Constant { value, disambiguator : _ } = * self . get ( index)
1390
- // If the constant is not deterministic, adding an additional mention of it in MIR will
1391
- // not give the same value as the former mention.
1392
- && value. is_deterministic ( )
1393
- {
1390
+ // This was already constant in MIR, do not change it. If the constant is not
1391
+ // deterministic, adding an additional mention of it in MIR will not give the same value as
1392
+ // the former mention.
1393
+ if let Value :: Constant { value, disambiguator : 0 } = * self . get ( index) {
1394
+ assert ! ( value. is_deterministic( ) ) ;
1394
1395
return Some ( ConstOperand { span : DUMMY_SP , user_ty : None , const_ : value } ) ;
1395
1396
}
1396
1397
0 commit comments