@@ -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,7 +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 ( & mut self , info : CanonicalVarKind < ' tcx > , kind : GenericArg < ' tcx > ) -> BoundVar {
600+ fn canonical_var ( & mut self , info : CanonicalVarKind , kind : GenericArg < ' tcx > ) -> BoundVar {
592601 let Canonicalizer { variables, query_state, indices, .. } = self ;
593602
594603 let var_values = & mut query_state. var_values ;
@@ -651,7 +660,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
651660 /// Replaces the universe indexes used in `var_values` with their index in
652661 /// `query_state.universe_map`. This minimizes the maximum universe used in
653662 /// the canonicalized value.
654- fn universe_canonicalized_variables ( self ) -> SmallVec < [ CanonicalVarKind < ' tcx > ; 8 ] > {
663+ fn universe_canonicalized_variables ( self ) -> SmallVec < [ CanonicalVarKind ; 8 ] > {
655664 if self . query_state . universe_map . len ( ) == 1 {
656665 return self . variables ;
657666 }
@@ -675,23 +684,14 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
675684 }
676685 CanonicalVarKind :: Region ( u) => CanonicalVarKind :: Region ( reverse_universe_map[ & u] ) ,
677686 CanonicalVarKind :: Const ( u) => CanonicalVarKind :: Const ( reverse_universe_map[ & u] ) ,
678- CanonicalVarKind :: PlaceholderTy ( placeholder) => {
679- CanonicalVarKind :: PlaceholderTy ( ty:: Placeholder {
680- universe : reverse_universe_map[ & placeholder. universe ] ,
681- ..placeholder
682- } )
687+ CanonicalVarKind :: PlaceholderTy ( ui) => {
688+ CanonicalVarKind :: PlaceholderTy ( reverse_universe_map[ & ui] )
683689 }
684- CanonicalVarKind :: PlaceholderRegion ( placeholder) => {
685- CanonicalVarKind :: PlaceholderRegion ( ty:: Placeholder {
686- universe : reverse_universe_map[ & placeholder. universe ] ,
687- ..placeholder
688- } )
690+ CanonicalVarKind :: PlaceholderRegion ( ui) => {
691+ CanonicalVarKind :: PlaceholderRegion ( reverse_universe_map[ & ui] )
689692 }
690- CanonicalVarKind :: PlaceholderConst ( placeholder) => {
691- CanonicalVarKind :: PlaceholderConst ( ty:: Placeholder {
692- universe : reverse_universe_map[ & placeholder. universe ] ,
693- ..placeholder
694- } )
693+ CanonicalVarKind :: PlaceholderConst ( ui) => {
694+ CanonicalVarKind :: PlaceholderConst ( reverse_universe_map[ & ui] )
695695 }
696696 } )
697697 . collect ( )
@@ -721,7 +721,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
721721 /// representing the region `r`; return a region referencing it.
722722 fn canonical_var_for_region (
723723 & mut self ,
724- info : CanonicalVarKind < ' tcx > ,
724+ info : CanonicalVarKind ,
725725 r : ty:: Region < ' tcx > ,
726726 ) -> ty:: Region < ' tcx > {
727727 let var = self . canonical_var ( info, r. into ( ) ) ;
@@ -733,10 +733,10 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
733733 /// if `ty_var` is bound to anything; if so, canonicalize
734734 /// *that*. Otherwise, create a new canonical variable for
735735 /// `ty_var`.
736- fn canonicalize_ty_var ( & mut self , info : CanonicalVarKind < ' tcx > , ty_var : Ty < ' tcx > ) -> Ty < ' tcx > {
736+ fn canonicalize_ty_var ( & mut self , info : CanonicalVarKind , ty_var : Ty < ' tcx > ) -> Ty < ' tcx > {
737737 debug_assert ! ( !self . infcx. is_some_and( |infcx| ty_var != infcx. shallow_resolve( ty_var) ) ) ;
738738 let var = self . canonical_var ( info, ty_var. into ( ) ) ;
739- Ty :: new_bound ( self . tcx , self . binder_index , var . into ( ) )
739+ Ty :: new_bound ( self . tcx , self . binder_index , ty :: BoundTy :: new_anon ( var ) )
740740 }
741741
742742 /// Given a type variable `const_var` of the given kind, first check
@@ -745,7 +745,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
745745 /// `const_var`.
746746 fn canonicalize_const_var (
747747 & mut self ,
748- info : CanonicalVarKind < ' tcx > ,
748+ info : CanonicalVarKind ,
749749 const_var : ty:: Const < ' tcx > ,
750750 ) -> ty:: Const < ' tcx > {
751751 debug_assert ! (
0 commit comments