@@ -173,8 +173,10 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
173173 match r. kind ( ) {
174174 ty:: ReLateParam ( _) | ty:: ReErased | ty:: ReStatic | ty:: ReEarlyParam ( ..) => r,
175175
176- ty:: RePlaceholder ( placeholder) => canonicalizer
177- . canonical_var_for_region ( CanonicalVarKind :: PlaceholderRegion ( placeholder) , r) ,
176+ ty:: RePlaceholder ( placeholder) => canonicalizer. canonical_var_for_region (
177+ CanonicalVarKind :: PlaceholderRegion ( placeholder. universe ) ,
178+ r,
179+ ) ,
178180
179181 ty:: ReVar ( vid) => {
180182 let universe = infcx
@@ -288,7 +290,7 @@ struct Canonicalizer<'cx, 'tcx> {
288290 /// Set to `None` to disable the resolution of inference variables.
289291 infcx : Option < & ' cx InferCtxt < ' tcx > > ,
290292 tcx : TyCtxt < ' tcx > ,
291- variables : SmallVec < [ CanonicalVarKind < ' tcx > ; 8 ] > ,
293+ variables : SmallVec < [ CanonicalVarKind ; 8 ] > ,
292294 query_state : & ' cx mut OriginalQueryValues < ' tcx > ,
293295 // Note that indices is only used once `var_values` is big enough to be
294296 // heap-allocated.
@@ -390,11 +392,13 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
390392 bug ! ( "encountered a fresh type during canonicalization" )
391393 }
392394
393- ty:: Placeholder ( mut placeholder) => {
394- if !self . canonicalize_mode . preserve_universes ( ) {
395- placeholder. universe = ty:: UniverseIndex :: ROOT ;
396- }
397- self . canonicalize_ty_var ( CanonicalVarKind :: PlaceholderTy ( placeholder) , t)
395+ ty:: Placeholder ( placeholder) => {
396+ let universe = if self . canonicalize_mode . preserve_universes ( ) {
397+ placeholder. universe
398+ } else {
399+ ty:: UniverseIndex :: ROOT
400+ } ;
401+ self . canonicalize_ty_var ( CanonicalVarKind :: PlaceholderTy ( universe) , t)
398402 }
399403
400404 ty:: Bound ( debruijn, _) => {
@@ -481,8 +485,13 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
481485 }
482486 }
483487 ty:: ConstKind :: Placeholder ( placeholder) => {
488+ let universe = if self . canonicalize_mode . preserve_universes ( ) {
489+ placeholder. universe
490+ } else {
491+ ty:: UniverseIndex :: ROOT
492+ } ;
484493 return self
485- . canonicalize_const_var ( CanonicalVarKind :: PlaceholderConst ( placeholder ) , ct) ;
494+ . canonicalize_const_var ( CanonicalVarKind :: PlaceholderConst ( universe ) , ct) ;
486495 }
487496 _ => { }
488497 }
@@ -588,11 +597,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
588597 /// or returns an existing variable if `kind` has already been
589598 /// seen. `kind` is expected to be an unbound variable (or
590599 /// potentially a free region).
591- fn canonical_var (
592- & mut self ,
593- var_kind : CanonicalVarKind < ' tcx > ,
594- value : GenericArg < ' tcx > ,
595- ) -> BoundVar {
600+ fn canonical_var ( & mut self , var_kind : CanonicalVarKind , value : GenericArg < ' tcx > ) -> BoundVar {
596601 let Canonicalizer { variables, query_state, indices, .. } = self ;
597602
598603 let var_values = & mut query_state. var_values ;
@@ -655,7 +660,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
655660 /// Replaces the universe indexes used in `var_values` with their index in
656661 /// `query_state.universe_map`. This minimizes the maximum universe used in
657662 /// the canonicalized value.
658- fn universe_canonicalized_variables ( self ) -> SmallVec < [ CanonicalVarKind < ' tcx > ; 8 ] > {
663+ fn universe_canonicalized_variables ( self ) -> SmallVec < [ CanonicalVarKind ; 8 ] > {
659664 if self . query_state . universe_map . len ( ) == 1 {
660665 return self . variables ;
661666 }
@@ -679,23 +684,14 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
679684 }
680685 CanonicalVarKind :: Region ( u) => CanonicalVarKind :: Region ( reverse_universe_map[ & u] ) ,
681686 CanonicalVarKind :: Const ( u) => CanonicalVarKind :: Const ( reverse_universe_map[ & u] ) ,
682- CanonicalVarKind :: PlaceholderTy ( placeholder) => {
683- CanonicalVarKind :: PlaceholderTy ( ty:: Placeholder {
684- universe : reverse_universe_map[ & placeholder. universe ] ,
685- ..placeholder
686- } )
687+ CanonicalVarKind :: PlaceholderTy ( ui) => {
688+ CanonicalVarKind :: PlaceholderTy ( reverse_universe_map[ & ui] )
687689 }
688- CanonicalVarKind :: PlaceholderRegion ( placeholder) => {
689- CanonicalVarKind :: PlaceholderRegion ( ty:: Placeholder {
690- universe : reverse_universe_map[ & placeholder. universe ] ,
691- ..placeholder
692- } )
690+ CanonicalVarKind :: PlaceholderRegion ( ui) => {
691+ CanonicalVarKind :: PlaceholderRegion ( reverse_universe_map[ & ui] )
693692 }
694- CanonicalVarKind :: PlaceholderConst ( placeholder) => {
695- CanonicalVarKind :: PlaceholderConst ( ty:: Placeholder {
696- universe : reverse_universe_map[ & placeholder. universe ] ,
697- ..placeholder
698- } )
693+ CanonicalVarKind :: PlaceholderConst ( ui) => {
694+ CanonicalVarKind :: PlaceholderConst ( reverse_universe_map[ & ui] )
699695 }
700696 } )
701697 . collect ( )
@@ -725,7 +721,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
725721 /// representing the region `r`; return a region referencing it.
726722 fn canonical_var_for_region (
727723 & mut self ,
728- var_kind : CanonicalVarKind < ' tcx > ,
724+ var_kind : CanonicalVarKind ,
729725 r : ty:: Region < ' tcx > ,
730726 ) -> ty:: Region < ' tcx > {
731727 let var = self . canonical_var ( var_kind, r. into ( ) ) ;
@@ -737,14 +733,10 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
737733 /// if `ty_var` is bound to anything; if so, canonicalize
738734 /// *that*. Otherwise, create a new canonical variable for
739735 /// `ty_var`.
740- fn canonicalize_ty_var (
741- & mut self ,
742- var_kind : CanonicalVarKind < ' tcx > ,
743- ty_var : Ty < ' tcx > ,
744- ) -> Ty < ' tcx > {
736+ fn canonicalize_ty_var ( & mut self , var_kind : CanonicalVarKind , ty_var : Ty < ' tcx > ) -> Ty < ' tcx > {
745737 debug_assert ! ( !self . infcx. is_some_and( |infcx| ty_var != infcx. shallow_resolve( ty_var) ) ) ;
746738 let var = self . canonical_var ( var_kind, ty_var. into ( ) ) ;
747- Ty :: new_bound ( self . tcx , self . binder_index , var . into ( ) )
739+ Ty :: new_bound ( self . tcx , self . binder_index , ty :: BoundTy :: new_anon ( var ) )
748740 }
749741
750742 /// Given a type variable `const_var` of the given kind, first check
@@ -753,7 +745,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
753745 /// `const_var`.
754746 fn canonicalize_const_var (
755747 & mut self ,
756- var_kind : CanonicalVarKind < ' tcx > ,
748+ var_kind : CanonicalVarKind ,
757749 ct_var : ty:: Const < ' tcx > ,
758750 ) -> ty:: Const < ' tcx > {
759751 debug_assert ! (
0 commit comments