@@ -204,6 +204,7 @@ enum Value<'tcx> {
204204 value : Const < ' tcx > ,
205205 /// Some constants do not have a deterministic value. To avoid merging two instances of the
206206 /// same `Const`, we assign them an additional integer index.
207+ // `disambiguator` is 0 iff the constant is deterministic.
207208 disambiguator : usize ,
208209 } ,
209210 /// An aggregate value, either tuple/closure/struct/enum.
@@ -288,7 +289,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
288289 rev_locals : IndexVec :: with_capacity ( num_values) ,
289290 values : FxIndexSet :: with_capacity_and_hasher ( num_values, Default :: default ( ) ) ,
290291 evaluated : IndexVec :: with_capacity ( num_values) ,
291- next_opaque : Some ( 0 ) ,
292+ next_opaque : Some ( 1 ) ,
292293 feature_unsized_locals : tcx. features ( ) . unsized_locals ,
293294 ssa,
294295 dominators,
@@ -360,6 +361,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
360361 let next_opaque = self . next_opaque . as_mut ( ) ?;
361362 let disambiguator = * next_opaque;
362363 * next_opaque += 1 ;
364+ assert_ne ! ( disambiguator, 0 ) ;
363365 disambiguator
364366 } ;
365367 Some ( self . insert ( Value :: Constant { value, disambiguator } ) )
@@ -1447,12 +1449,11 @@ impl<'tcx> VnState<'_, 'tcx> {
14471449
14481450 /// If `index` is a `Value::Constant`, return the `Constant` to be put in the MIR.
14491451 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( ) ) ;
14561457 return Some ( ConstOperand { span : DUMMY_SP , user_ty : None , const_ : value } ) ;
14571458 }
14581459
0 commit comments