@@ -220,6 +220,55 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ClosureSubsts<'a> {
220220 }
221221}
222222
223+ impl < ' a , ' tcx > Lift < ' tcx > for ty:: adjustment:: Adjustment < ' a > {
224+ type Lifted = ty:: adjustment:: Adjustment < ' tcx > ;
225+ fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < Self :: Lifted > {
226+ tcx. lift ( & self . kind ) . and_then ( |kind| {
227+ tcx. lift ( & self . target ) . map ( |target| {
228+ ty:: adjustment:: Adjustment { kind, target }
229+ } )
230+ } )
231+ }
232+ }
233+
234+ impl < ' a , ' tcx > Lift < ' tcx > for ty:: adjustment:: Adjust < ' a > {
235+ type Lifted = ty:: adjustment:: Adjust < ' tcx > ;
236+ fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < Self :: Lifted > {
237+ match * self {
238+ ty:: adjustment:: Adjust :: NeverToAny =>
239+ Some ( ty:: adjustment:: Adjust :: NeverToAny ) ,
240+ ty:: adjustment:: Adjust :: ReifyFnPointer =>
241+ Some ( ty:: adjustment:: Adjust :: ReifyFnPointer ) ,
242+ ty:: adjustment:: Adjust :: UnsafeFnPointer =>
243+ Some ( ty:: adjustment:: Adjust :: UnsafeFnPointer ) ,
244+ ty:: adjustment:: Adjust :: ClosureFnPointer =>
245+ Some ( ty:: adjustment:: Adjust :: ClosureFnPointer ) ,
246+ ty:: adjustment:: Adjust :: MutToConstPointer =>
247+ Some ( ty:: adjustment:: Adjust :: MutToConstPointer ) ,
248+ ty:: adjustment:: Adjust :: DerefRef { ref autoderefs, ref autoref, unsize } => {
249+ tcx. lift ( autoderefs) . and_then ( |autoderefs| {
250+ tcx. lift ( autoref) . map ( |autoref| {
251+ ty:: adjustment:: Adjust :: DerefRef { autoderefs, autoref, unsize }
252+ } )
253+ } )
254+ }
255+ }
256+ }
257+ }
258+
259+ impl < ' a , ' tcx > Lift < ' tcx > for ty:: adjustment:: OverloadedDeref < ' a > {
260+ type Lifted = ty:: adjustment:: OverloadedDeref < ' tcx > ;
261+ fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < Self :: Lifted > {
262+ tcx. lift ( & ( self . region , self . target ) ) . map ( |( region, target) | {
263+ ty:: adjustment:: OverloadedDeref {
264+ region,
265+ mutbl : self . mutbl ,
266+ target,
267+ }
268+ } )
269+ }
270+ }
271+
223272impl < ' a , ' tcx > Lift < ' tcx > for ty:: adjustment:: AutoBorrow < ' a > {
224273 type Lifted = ty:: adjustment:: AutoBorrow < ' tcx > ;
225274 fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < Self :: Lifted > {
@@ -631,6 +680,65 @@ impl<'tcx> TypeFoldable<'tcx> for ty::ClosureSubsts<'tcx> {
631680 }
632681}
633682
683+ impl < ' tcx > TypeFoldable < ' tcx > for ty:: adjustment:: Adjustment < ' tcx > {
684+ fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
685+ ty:: adjustment:: Adjustment {
686+ kind : self . kind . fold_with ( folder) ,
687+ target : self . target . fold_with ( folder) ,
688+ }
689+ }
690+
691+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
692+ self . kind . visit_with ( visitor) || self . target . visit_with ( visitor)
693+ }
694+ }
695+
696+ impl < ' tcx > TypeFoldable < ' tcx > for ty:: adjustment:: Adjust < ' tcx > {
697+ fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
698+ match * self {
699+ ty:: adjustment:: Adjust :: NeverToAny |
700+ ty:: adjustment:: Adjust :: ReifyFnPointer |
701+ ty:: adjustment:: Adjust :: UnsafeFnPointer |
702+ ty:: adjustment:: Adjust :: ClosureFnPointer |
703+ ty:: adjustment:: Adjust :: MutToConstPointer => self . clone ( ) ,
704+ ty:: adjustment:: Adjust :: DerefRef { ref autoderefs, ref autoref, unsize } => {
705+ ty:: adjustment:: Adjust :: DerefRef {
706+ autoderefs : autoderefs. fold_with ( folder) ,
707+ autoref : autoref. fold_with ( folder) ,
708+ unsize,
709+ }
710+ }
711+ }
712+ }
713+
714+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
715+ match * self {
716+ ty:: adjustment:: Adjust :: NeverToAny |
717+ ty:: adjustment:: Adjust :: ReifyFnPointer |
718+ ty:: adjustment:: Adjust :: UnsafeFnPointer |
719+ ty:: adjustment:: Adjust :: ClosureFnPointer |
720+ ty:: adjustment:: Adjust :: MutToConstPointer => false ,
721+ ty:: adjustment:: Adjust :: DerefRef { ref autoderefs, ref autoref, unsize : _ } => {
722+ autoderefs. visit_with ( visitor) || autoref. visit_with ( visitor)
723+ }
724+ }
725+ }
726+ }
727+
728+ impl < ' tcx > TypeFoldable < ' tcx > for ty:: adjustment:: OverloadedDeref < ' tcx > {
729+ fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
730+ ty:: adjustment:: OverloadedDeref {
731+ region : self . region . fold_with ( folder) ,
732+ mutbl : self . mutbl ,
733+ target : self . target . fold_with ( folder) ,
734+ }
735+ }
736+
737+ fn super_visit_with < V : TypeVisitor < ' tcx > > ( & self , visitor : & mut V ) -> bool {
738+ self . region . visit_with ( visitor) || self . target . visit_with ( visitor)
739+ }
740+ }
741+
634742impl < ' tcx > TypeFoldable < ' tcx > for ty:: adjustment:: AutoBorrow < ' tcx > {
635743 fn super_fold_with < ' gcx : ' tcx , F : TypeFolder < ' gcx , ' tcx > > ( & self , folder : & mut F ) -> Self {
636744 match * self {
0 commit comments