@@ -456,17 +456,32 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
456456 fn fold_const ( & mut self , mut ct : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
457457 match ct. kind ( ) {
458458 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+
459474 // We need to canonicalize the *root* of our const var.
460475 // This is so that our canonical response correctly reflects
461476 // 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) ;
463478 if root_vid != vid {
464479 ct = ty:: Const :: new_var ( self . tcx , root_vid, ct. ty ( ) ) ;
465480 vid = root_vid;
466481 }
467482
468483 debug ! ( "canonical: const var found with vid {:?}" , vid) ;
469- match self . infcx . unwrap ( ) . probe_const_var ( vid) {
484+ match infcx. probe_const_var ( vid) {
470485 Ok ( c) => {
471486 debug ! ( "(resolved to {:?})" , c) ;
472487 return self . fold_const ( c) ;
@@ -487,7 +502,19 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
487502 }
488503 }
489504 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) {
491518 Some ( value) => return self . fold_const ( value) ,
492519 None => {
493520 return self . canonicalize_const_var (
0 commit comments