@@ -337,51 +337,49 @@ TrivialTypeTraversalAndLiftImpls! {
337337}
338338
339339impl < ' tcx > CanonicalVarValues < ' tcx > {
340- /// Creates dummy var values which should not be used in a
341- /// canonical response.
342- pub fn dummy ( ) -> CanonicalVarValues < ' tcx > {
343- CanonicalVarValues { var_values : ty:: List :: empty ( ) }
344- }
345-
346- #[ inline]
347- pub fn len ( & self ) -> usize {
348- self . var_values . len ( )
349- }
350-
351- /// Makes an identity substitution from this one: each bound var
352- /// is matched to the same bound var, preserving the original kinds.
353- /// For example, if we have:
354- /// `self.var_values == [Type(u32), Lifetime('a), Type(u64)]`
355- /// we'll return a substitution `subst` with:
356- /// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`.
357- pub fn make_identity ( & self , tcx : TyCtxt < ' tcx > ) -> Self {
358- use crate :: ty:: subst:: GenericArgKind ;
359-
340+ // Given a list of canonical variables, construct a set of values which are
341+ // the identity response.
342+ pub fn make_identity (
343+ tcx : TyCtxt < ' tcx > ,
344+ infos : CanonicalVarInfos < ' tcx > ,
345+ ) -> CanonicalVarValues < ' tcx > {
360346 CanonicalVarValues {
361- var_values : tcx. mk_substs ( self . var_values . iter ( ) . enumerate ( ) . map (
362- |( i, kind ) | -> ty:: GenericArg < ' tcx > {
363- match kind . unpack ( ) {
364- GenericArgKind :: Type ( .. ) => tcx
347+ var_values : tcx. mk_substs ( infos . iter ( ) . enumerate ( ) . map (
348+ |( i, info ) | -> ty:: GenericArg < ' tcx > {
349+ match info . kind {
350+ CanonicalVarKind :: Ty ( _ ) | CanonicalVarKind :: PlaceholderTy ( _ ) => tcx
365351 . mk_ty ( ty:: Bound ( ty:: INNERMOST , ty:: BoundVar :: from_usize ( i) . into ( ) ) )
366352 . into ( ) ,
367- GenericArgKind :: Lifetime ( .. ) => {
353+ CanonicalVarKind :: Region ( _ ) | CanonicalVarKind :: PlaceholderRegion ( _ ) => {
368354 let br = ty:: BoundRegion {
369355 var : ty:: BoundVar :: from_usize ( i) ,
370356 kind : ty:: BrAnon ( i as u32 , None ) ,
371357 } ;
372358 tcx. mk_region ( ty:: ReLateBound ( ty:: INNERMOST , br) ) . into ( )
373359 }
374- GenericArgKind :: Const ( ct) => tcx
360+ CanonicalVarKind :: Const ( _, ty)
361+ | CanonicalVarKind :: PlaceholderConst ( _, ty) => tcx
375362 . mk_const (
376363 ty:: ConstKind :: Bound ( ty:: INNERMOST , ty:: BoundVar :: from_usize ( i) ) ,
377- ct . ty ( ) ,
364+ ty ,
378365 )
379366 . into ( ) ,
380367 }
381368 } ,
382369 ) ) ,
383370 }
384371 }
372+
373+ /// Creates dummy var values which should not be used in a
374+ /// canonical response.
375+ pub fn dummy ( ) -> CanonicalVarValues < ' tcx > {
376+ CanonicalVarValues { var_values : ty:: List :: empty ( ) }
377+ }
378+
379+ #[ inline]
380+ pub fn len ( & self ) -> usize {
381+ self . var_values . len ( )
382+ }
385383}
386384
387385impl < ' a , ' tcx > IntoIterator for & ' a CanonicalVarValues < ' tcx > {
0 commit comments