@@ -173,8 +173,10 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
173
173
match r. kind ( ) {
174
174
ty:: ReLateParam ( _) | ty:: ReErased | ty:: ReStatic | ty:: ReEarlyParam ( ..) => r,
175
175
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
+ ) ,
178
180
179
181
ty:: ReVar ( vid) => {
180
182
let universe = infcx
@@ -288,7 +290,7 @@ struct Canonicalizer<'cx, 'tcx> {
288
290
/// Set to `None` to disable the resolution of inference variables.
289
291
infcx : Option < & ' cx InferCtxt < ' tcx > > ,
290
292
tcx : TyCtxt < ' tcx > ,
291
- variables : SmallVec < [ CanonicalVarKind < ' tcx > ; 8 ] > ,
293
+ variables : SmallVec < [ CanonicalVarKind ; 8 ] > ,
292
294
query_state : & ' cx mut OriginalQueryValues < ' tcx > ,
293
295
// Note that indices is only used once `var_values` is big enough to be
294
296
// heap-allocated.
@@ -390,11 +392,13 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
390
392
bug ! ( "encountered a fresh type during canonicalization" )
391
393
}
392
394
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)
398
402
}
399
403
400
404
ty:: Bound ( debruijn, _) => {
@@ -481,8 +485,13 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
481
485
}
482
486
}
483
487
ty:: ConstKind :: Placeholder ( placeholder) => {
488
+ let universe = if self . canonicalize_mode . preserve_universes ( ) {
489
+ placeholder. universe
490
+ } else {
491
+ ty:: UniverseIndex :: ROOT
492
+ } ;
484
493
return self
485
- . canonicalize_const_var ( CanonicalVarKind :: PlaceholderConst ( placeholder ) , ct) ;
494
+ . canonicalize_const_var ( CanonicalVarKind :: PlaceholderConst ( universe ) , ct) ;
486
495
}
487
496
_ => { }
488
497
}
@@ -588,7 +597,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
588
597
/// or returns an existing variable if `kind` has already been
589
598
/// seen. `kind` is expected to be an unbound variable (or
590
599
/// 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 {
592
601
let Canonicalizer { variables, query_state, indices, .. } = self ;
593
602
594
603
let var_values = & mut query_state. var_values ;
@@ -651,7 +660,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
651
660
/// Replaces the universe indexes used in `var_values` with their index in
652
661
/// `query_state.universe_map`. This minimizes the maximum universe used in
653
662
/// the canonicalized value.
654
- fn universe_canonicalized_variables ( self ) -> SmallVec < [ CanonicalVarKind < ' tcx > ; 8 ] > {
663
+ fn universe_canonicalized_variables ( self ) -> SmallVec < [ CanonicalVarKind ; 8 ] > {
655
664
if self . query_state . universe_map . len ( ) == 1 {
656
665
return self . variables ;
657
666
}
@@ -675,23 +684,14 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
675
684
}
676
685
CanonicalVarKind :: Region ( u) => CanonicalVarKind :: Region ( reverse_universe_map[ & u] ) ,
677
686
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] )
683
689
}
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] )
689
692
}
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] )
695
695
}
696
696
} )
697
697
. collect ( )
@@ -721,7 +721,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
721
721
/// representing the region `r`; return a region referencing it.
722
722
fn canonical_var_for_region (
723
723
& mut self ,
724
- info : CanonicalVarKind < ' tcx > ,
724
+ info : CanonicalVarKind ,
725
725
r : ty:: Region < ' tcx > ,
726
726
) -> ty:: Region < ' tcx > {
727
727
let var = self . canonical_var ( info, r. into ( ) ) ;
@@ -733,10 +733,10 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
733
733
/// if `ty_var` is bound to anything; if so, canonicalize
734
734
/// *that*. Otherwise, create a new canonical variable for
735
735
/// `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 > {
737
737
debug_assert ! ( !self . infcx. is_some_and( |infcx| ty_var != infcx. shallow_resolve( ty_var) ) ) ;
738
738
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 ) )
740
740
}
741
741
742
742
/// Given a type variable `const_var` of the given kind, first check
@@ -745,7 +745,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
745
745
/// `const_var`.
746
746
fn canonicalize_const_var (
747
747
& mut self ,
748
- info : CanonicalVarKind < ' tcx > ,
748
+ info : CanonicalVarKind ,
749
749
const_var : ty:: Const < ' tcx > ,
750
750
) -> ty:: Const < ' tcx > {
751
751
debug_assert ! (
0 commit comments