@@ -17,8 +17,7 @@ use tracing::debug;
1717
1818use  crate :: infer:: InferCtxt ; 
1919use  crate :: infer:: canonical:: { 
20-     Canonical ,  CanonicalQueryInput ,  CanonicalTyVarKind ,  CanonicalVarInfo ,  CanonicalVarKind , 
21-     OriginalQueryValues , 
20+     Canonical ,  CanonicalQueryInput ,  CanonicalTyVarKind ,  CanonicalVarKind ,  OriginalQueryValues , 
2221} ; 
2322
2423impl < ' tcx >  InferCtxt < ' tcx >  { 
@@ -174,10 +173,8 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
174173        match  r. kind ( )  { 
175174            ty:: ReLateParam ( _)  | ty:: ReErased  | ty:: ReStatic  | ty:: ReEarlyParam ( ..)  => r, 
176175
177-             ty:: RePlaceholder ( placeholder)  => canonicalizer. canonical_var_for_region ( 
178-                 CanonicalVarInfo  {  kind :  CanonicalVarKind :: PlaceholderRegion ( placeholder)  } , 
179-                 r, 
180-             ) , 
176+             ty:: RePlaceholder ( placeholder)  => canonicalizer
177+                 . canonical_var_for_region ( CanonicalVarKind :: PlaceholderRegion ( placeholder) ,  r) , 
181178
182179            ty:: ReVar ( vid)  => { 
183180                let  universe = infcx
@@ -186,10 +183,7 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
186183                    . unwrap_region_constraints ( ) 
187184                    . probe_value ( vid) 
188185                    . unwrap_err ( ) ; 
189-                 canonicalizer. canonical_var_for_region ( 
190-                     CanonicalVarInfo  {  kind :  CanonicalVarKind :: Region ( universe)  } , 
191-                     r, 
192-                 ) 
186+                 canonicalizer. canonical_var_for_region ( CanonicalVarKind :: Region ( universe) ,  r) 
193187            } 
194188
195189            _ => { 
@@ -294,7 +288,7 @@ struct Canonicalizer<'cx, 'tcx> {
294288    /// Set to `None` to disable the resolution of inference variables. 
295289     infcx :  Option < & ' cx  InferCtxt < ' tcx > > , 
296290    tcx :  TyCtxt < ' tcx > , 
297-     variables :  SmallVec < [ CanonicalVarInfo < ' tcx > ;  8 ] > , 
291+     variables :  SmallVec < [ CanonicalVarKind < ' tcx > ;  8 ] > , 
298292    query_state :  & ' cx  mut  OriginalQueryValues < ' tcx > , 
299293    // Note that indices is only used once `var_values` is big enough to be 
300294    // heap-allocated. 
@@ -368,9 +362,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
368362                            ui = ty:: UniverseIndex :: ROOT ; 
369363                        } 
370364                        self . canonicalize_ty_var ( 
371-                             CanonicalVarInfo  { 
372-                                 kind :  CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( ui) ) , 
373-                             } , 
365+                             CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( ui) ) , 
374366                            t, 
375367                        ) 
376368                    } 
@@ -382,21 +374,15 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
382374                if  nt != t { 
383375                    return  self . fold_ty ( nt) ; 
384376                }  else  { 
385-                     self . canonicalize_ty_var ( 
386-                         CanonicalVarInfo  {  kind :  CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Int )  } , 
387-                         t, 
388-                     ) 
377+                     self . canonicalize_ty_var ( CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Int ) ,  t) 
389378                } 
390379            } 
391380            ty:: Infer ( ty:: FloatVar ( vid) )  => { 
392381                let  nt = self . infcx . unwrap ( ) . opportunistic_resolve_float_var ( vid) ; 
393382                if  nt != t { 
394383                    return  self . fold_ty ( nt) ; 
395384                }  else  { 
396-                     self . canonicalize_ty_var ( 
397-                         CanonicalVarInfo  {  kind :  CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Float )  } , 
398-                         t, 
399-                     ) 
385+                     self . canonicalize_ty_var ( CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Float ) ,  t) 
400386                } 
401387            } 
402388
@@ -408,10 +394,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
408394                if  !self . canonicalize_mode . preserve_universes ( )  { 
409395                    placeholder. universe  = ty:: UniverseIndex :: ROOT ; 
410396                } 
411-                 self . canonicalize_ty_var ( 
412-                     CanonicalVarInfo  {  kind :  CanonicalVarKind :: PlaceholderTy ( placeholder)  } , 
413-                     t, 
414-                 ) 
397+                 self . canonicalize_ty_var ( CanonicalVarKind :: PlaceholderTy ( placeholder) ,  t) 
415398            } 
416399
417400            ty:: Bound ( debruijn,  _)  => { 
@@ -483,10 +466,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
483466                            // FIXME: perf problem described in #55921. 
484467                            ui = ty:: UniverseIndex :: ROOT ; 
485468                        } 
486-                         return  self . canonicalize_const_var ( 
487-                             CanonicalVarInfo  {  kind :  CanonicalVarKind :: Const ( ui)  } , 
488-                             ct, 
489-                         ) ; 
469+                         return  self . canonicalize_const_var ( CanonicalVarKind :: Const ( ui) ,  ct) ; 
490470                    } 
491471                } 
492472            } 
@@ -501,10 +481,8 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
501481                } 
502482            } 
503483            ty:: ConstKind :: Placeholder ( placeholder)  => { 
504-                 return  self . canonicalize_const_var ( 
505-                     CanonicalVarInfo  {  kind :  CanonicalVarKind :: PlaceholderConst ( placeholder)  } , 
506-                     ct, 
507-                 ) ; 
484+                 return  self 
485+                     . canonicalize_const_var ( CanonicalVarKind :: PlaceholderConst ( placeholder) ,  ct) ; 
508486            } 
509487            _ => { } 
510488        } 
@@ -595,7 +573,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
595573        debug_assert ! ( !out_value. has_infer( )  && !out_value. has_placeholders( ) ) ; 
596574
597575        let  canonical_variables =
598-             tcx. mk_canonical_var_infos ( & canonicalizer. universe_canonicalized_variables ( ) ) ; 
576+             tcx. mk_canonical_var_kinds ( & canonicalizer. universe_canonicalized_variables ( ) ) ; 
599577
600578        let  max_universe = canonical_variables
601579            . iter ( ) 
@@ -610,7 +588,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
610588     /// or returns an existing variable if `kind` has already been 
611589     /// seen. `kind` is expected to be an unbound variable (or 
612590     /// potentially a free region). 
613-      fn  canonical_var ( & mut  self ,  info :  CanonicalVarInfo < ' tcx > ,  kind :  GenericArg < ' tcx > )  -> BoundVar  { 
591+      fn  canonical_var ( & mut  self ,  info :  CanonicalVarKind < ' tcx > ,  kind :  GenericArg < ' tcx > )  -> BoundVar  { 
614592        let  Canonicalizer  {  variables,  query_state,  indices,  .. }  = self ; 
615593
616594        let  var_values = & mut  query_state. var_values ; 
@@ -673,7 +651,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
673651    /// Replaces the universe indexes used in `var_values` with their index in 
674652     /// `query_state.universe_map`. This minimizes the maximum universe used in 
675653     /// the canonicalized value. 
676-      fn  universe_canonicalized_variables ( self )  -> SmallVec < [ CanonicalVarInfo < ' tcx > ;  8 ] >  { 
654+      fn  universe_canonicalized_variables ( self )  -> SmallVec < [ CanonicalVarKind < ' tcx > ;  8 ] >  { 
677655        if  self . query_state . universe_map . len ( )  == 1  { 
678656            return  self . variables ; 
679657        } 
@@ -688,37 +666,33 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
688666
689667        self . variables 
690668            . iter ( ) 
691-             . map ( |v| CanonicalVarInfo  { 
692-                 kind :  match  v. kind  { 
693-                     CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Int  | CanonicalTyVarKind :: Float )  => { 
694-                         return  * v; 
695-                     } 
696-                     CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( u) )  => { 
697-                         CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( reverse_universe_map[ & u] ) ) 
698-                     } 
699-                     CanonicalVarKind :: Region ( u)  => { 
700-                         CanonicalVarKind :: Region ( reverse_universe_map[ & u] ) 
701-                     } 
702-                     CanonicalVarKind :: Const ( u)  => CanonicalVarKind :: Const ( reverse_universe_map[ & u] ) , 
703-                     CanonicalVarKind :: PlaceholderTy ( placeholder)  => { 
704-                         CanonicalVarKind :: PlaceholderTy ( ty:: Placeholder  { 
705-                             universe :  reverse_universe_map[ & placeholder. universe ] , 
706-                             ..placeholder
707-                         } ) 
708-                     } 
709-                     CanonicalVarKind :: PlaceholderRegion ( placeholder)  => { 
710-                         CanonicalVarKind :: PlaceholderRegion ( ty:: Placeholder  { 
711-                             universe :  reverse_universe_map[ & placeholder. universe ] , 
712-                             ..placeholder
713-                         } ) 
714-                     } 
715-                     CanonicalVarKind :: PlaceholderConst ( placeholder)  => { 
716-                         CanonicalVarKind :: PlaceholderConst ( ty:: Placeholder  { 
717-                             universe :  reverse_universe_map[ & placeholder. universe ] , 
718-                             ..placeholder
719-                         } ) 
720-                     } 
721-                 } , 
669+             . map ( |& kind| match  kind { 
670+                 CanonicalVarKind :: Ty ( CanonicalTyVarKind :: Int  | CanonicalTyVarKind :: Float )  => { 
671+                     return  kind; 
672+                 } 
673+                 CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( u) )  => { 
674+                     CanonicalVarKind :: Ty ( CanonicalTyVarKind :: General ( reverse_universe_map[ & u] ) ) 
675+                 } 
676+                 CanonicalVarKind :: Region ( u)  => CanonicalVarKind :: Region ( reverse_universe_map[ & u] ) , 
677+                 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+                     } ) 
683+                 } 
684+                 CanonicalVarKind :: PlaceholderRegion ( placeholder)  => { 
685+                     CanonicalVarKind :: PlaceholderRegion ( ty:: Placeholder  { 
686+                         universe :  reverse_universe_map[ & placeholder. universe ] , 
687+                         ..placeholder
688+                     } ) 
689+                 } 
690+                 CanonicalVarKind :: PlaceholderConst ( placeholder)  => { 
691+                     CanonicalVarKind :: PlaceholderConst ( ty:: Placeholder  { 
692+                         universe :  reverse_universe_map[ & placeholder. universe ] , 
693+                         ..placeholder
694+                     } ) 
695+                 } 
722696            } ) 
723697            . collect ( ) 
724698    } 
@@ -740,17 +714,14 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
740714        & mut  self , 
741715        r :  ty:: Region < ' tcx > , 
742716    )  -> ty:: Region < ' tcx >  { 
743-         self . canonical_var_for_region ( 
744-             CanonicalVarInfo  {  kind :  CanonicalVarKind :: Region ( ty:: UniverseIndex :: ROOT )  } , 
745-             r, 
746-         ) 
717+         self . canonical_var_for_region ( CanonicalVarKind :: Region ( ty:: UniverseIndex :: ROOT ) ,  r) 
747718    } 
748719
749720    /// Creates a canonical variable (with the given `info`) 
750721     /// representing the region `r`; return a region referencing it. 
751722     fn  canonical_var_for_region ( 
752723        & mut  self , 
753-         info :  CanonicalVarInfo < ' tcx > , 
724+         info :  CanonicalVarKind < ' tcx > , 
754725        r :  ty:: Region < ' tcx > , 
755726    )  -> ty:: Region < ' tcx >  { 
756727        let  var = self . canonical_var ( info,  r. into ( ) ) ; 
@@ -762,7 +733,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
762733     /// if `ty_var` is bound to anything; if so, canonicalize 
763734     /// *that*. Otherwise, create a new canonical variable for 
764735     /// `ty_var`. 
765-      fn  canonicalize_ty_var ( & mut  self ,  info :  CanonicalVarInfo < ' tcx > ,  ty_var :  Ty < ' tcx > )  -> Ty < ' tcx >  { 
736+      fn  canonicalize_ty_var ( & mut  self ,  info :  CanonicalVarKind < ' tcx > ,  ty_var :  Ty < ' tcx > )  -> Ty < ' tcx >  { 
766737        debug_assert ! ( !self . infcx. is_some_and( |infcx| ty_var != infcx. shallow_resolve( ty_var) ) ) ; 
767738        let  var = self . canonical_var ( info,  ty_var. into ( ) ) ; 
768739        Ty :: new_bound ( self . tcx ,  self . binder_index ,  var. into ( ) ) 
@@ -774,7 +745,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
774745     /// `const_var`. 
775746     fn  canonicalize_const_var ( 
776747        & mut  self , 
777-         info :  CanonicalVarInfo < ' tcx > , 
748+         info :  CanonicalVarKind < ' tcx > , 
778749        const_var :  ty:: Const < ' tcx > , 
779750    )  -> ty:: Const < ' tcx >  { 
780751        debug_assert ! ( 
0 commit comments