@@ -204,6 +204,7 @@ enum Value<'tcx> {
204
204
value : Const < ' tcx > ,
205
205
/// Some constants do not have a deterministic value. To avoid merging two instances of the
206
206
/// same `Const`, we assign them an additional integer index.
207
+ // `disambiguator` is 0 iff the constant is deterministic.
207
208
disambiguator : usize ,
208
209
} ,
209
210
/// An aggregate value, either tuple/closure/struct/enum.
@@ -288,7 +289,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
288
289
rev_locals : IndexVec :: with_capacity ( num_values) ,
289
290
values : FxIndexSet :: with_capacity_and_hasher ( num_values, Default :: default ( ) ) ,
290
291
evaluated : IndexVec :: with_capacity ( num_values) ,
291
- next_opaque : Some ( 0 ) ,
292
+ next_opaque : Some ( 1 ) ,
292
293
feature_unsized_locals : tcx. features ( ) . unsized_locals ,
293
294
ssa,
294
295
dominators,
@@ -360,6 +361,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
360
361
let next_opaque = self . next_opaque . as_mut ( ) ?;
361
362
let disambiguator = * next_opaque;
362
363
* next_opaque += 1 ;
364
+ assert_ne ! ( disambiguator, 0 ) ;
363
365
disambiguator
364
366
} ;
365
367
Some ( self . insert ( Value :: Constant { value, disambiguator } ) )
@@ -1447,12 +1449,11 @@ impl<'tcx> VnState<'_, 'tcx> {
1447
1449
1448
1450
/// If `index` is a `Value::Constant`, return the `Constant` to be put in the MIR.
1449
1451
fn try_as_constant ( & mut self , index : VnIndex ) -> Option < ConstOperand < ' tcx > > {
1450
- // This was already constant in MIR, do not change it.
1451
- if let Value :: Constant { value, disambiguator : _ } = * self . get ( index)
1452
- // If the constant is not deterministic, adding an additional mention of it in MIR will
1453
- // not give the same value as the former mention.
1454
- && value. is_deterministic ( )
1455
- {
1452
+ // This was already constant in MIR, do not change it. If the constant is not
1453
+ // deterministic, adding an additional mention of it in MIR will not give the same value as
1454
+ // the former mention.
1455
+ if let Value :: Constant { value, disambiguator : 0 } = * self . get ( index) {
1456
+ assert ! ( value. is_deterministic( ) ) ;
1456
1457
return Some ( ConstOperand { span : DUMMY_SP , user_ty : None , const_ : value } ) ;
1457
1458
}
1458
1459
0 commit comments