@@ -456,17 +456,32 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
456
456
fn fold_const ( & mut self , mut ct : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
457
457
match ct. kind ( ) {
458
458
ty:: ConstKind :: Infer ( InferConst :: Var ( mut vid) ) => {
459
+ let Some ( infcx) = self . infcx else {
460
+ // FIXME(with_negative_coherence): the infcx has constraints from equating
461
+ // the impl headers in `impl_intersection_has_negative_obligation`.
462
+ // We should use these constraints as assumptions.
463
+ assert ! ( self . tcx. features( ) . with_negative_coherence) ;
464
+ debug ! ( "canonicalizing `ConstKind::Infer` without an `infcx`?" ) ;
465
+ assert ! ( !self . canonicalize_mode. preserve_universes( ) ) ;
466
+ return self . canonicalize_const_var (
467
+ CanonicalVarInfo {
468
+ kind : CanonicalVarKind :: Const ( ty:: UniverseIndex :: ROOT , ct. ty ( ) ) ,
469
+ } ,
470
+ ct,
471
+ ) ;
472
+ } ;
473
+
459
474
// We need to canonicalize the *root* of our const var.
460
475
// This is so that our canonical response correctly reflects
461
476
// any equated inference vars correctly!
462
- let root_vid = self . infcx . unwrap ( ) . root_const_var ( vid) ;
477
+ let root_vid = infcx. root_const_var ( vid) ;
463
478
if root_vid != vid {
464
479
ct = ty:: Const :: new_var ( self . tcx , root_vid, ct. ty ( ) ) ;
465
480
vid = root_vid;
466
481
}
467
482
468
483
debug ! ( "canonical: const var found with vid {:?}" , vid) ;
469
- match self . infcx . unwrap ( ) . probe_const_var ( vid) {
484
+ match infcx. probe_const_var ( vid) {
470
485
Ok ( c) => {
471
486
debug ! ( "(resolved to {:?})" , c) ;
472
487
return self . fold_const ( c) ;
@@ -487,7 +502,19 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
487
502
}
488
503
}
489
504
ty:: ConstKind :: Infer ( InferConst :: EffectVar ( vid) ) => {
490
- match self . infcx . unwrap ( ) . probe_effect_var ( vid) {
505
+ let Some ( infcx) = self . infcx else {
506
+ // FIXME(with_negative_coherence): the infcx has constraints from equating
507
+ // the impl headers in `impl_intersection_has_negative_obligation`.
508
+ // We should use these constraints as assumptions.
509
+ assert ! ( self . tcx. features( ) . with_negative_coherence) ;
510
+ debug ! ( "canonicalizing `ConstKind::Infer` without an `infcx`?" ) ;
511
+ return self . canonicalize_const_var (
512
+ CanonicalVarInfo { kind : CanonicalVarKind :: Effect } ,
513
+ ct,
514
+ ) ;
515
+ } ;
516
+
517
+ match infcx. probe_effect_var ( vid) {
491
518
Some ( value) => return self . fold_const ( value) ,
492
519
None => {
493
520
return self . canonicalize_const_var (
0 commit comments