@@ -123,7 +123,7 @@ impl<'tcx> Tables<'tcx> {
123123 rustc_internal:: fn_def ( * def_id) ,
124124 generic_args. stable ( self ) ,
125125 ) ) ,
126- ty:: FnPtr ( _ ) => todo ! ( ) ,
126+ ty:: FnPtr ( poly_fn_sig ) => TyKind :: RigidTy ( RigidTy :: FnPtr ( poly_fn_sig . stable ( self ) ) ) ,
127127 ty:: Dynamic ( _, _, _) => todo ! ( ) ,
128128 ty:: Closure ( def_id, generic_args) => TyKind :: RigidTy ( RigidTy :: Closure (
129129 rustc_internal:: closure_def ( * def_id) ,
@@ -581,3 +581,98 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
581581 )
582582 }
583583}
584+
585+ impl < ' tcx > Stable < ' tcx > for ty:: PolyFnSig < ' tcx > {
586+ type T = stable_mir:: ty:: PolyFnSig ;
587+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
588+ use stable_mir:: ty:: Binder ;
589+
590+ Binder {
591+ value : self . skip_binder ( ) . stable ( tables) ,
592+ bound_vars : self
593+ . bound_vars ( )
594+ . iter ( )
595+ . map ( |bound_var| bound_var. stable ( tables) )
596+ . collect ( ) ,
597+ }
598+ }
599+ }
600+
601+ impl < ' tcx > Stable < ' tcx > for ty:: FnSig < ' tcx > {
602+ type T = stable_mir:: ty:: FnSig ;
603+ fn stable ( & self , tables : & mut Tables < ' tcx > ) -> Self :: T {
604+ use rustc_target:: spec:: abi;
605+ use stable_mir:: ty:: { Abi , FnSig , Unsafety } ;
606+
607+ FnSig {
608+ inputs_and_output : self
609+ . inputs_and_output
610+ . iter ( )
611+ . map ( |ty| tables. intern_ty ( ty) )
612+ . collect ( ) ,
613+ c_variadic : self . c_variadic ,
614+ unsafety : match self . unsafety {
615+ hir:: Unsafety :: Normal => Unsafety :: Normal ,
616+ hir:: Unsafety :: Unsafe => Unsafety :: Unsafe ,
617+ } ,
618+ abi : match self . abi {
619+ abi:: Abi :: Rust => Abi :: Rust ,
620+ abi:: Abi :: C { unwind } => Abi :: C { unwind } ,
621+ abi:: Abi :: Cdecl { unwind } => Abi :: Cdecl { unwind } ,
622+ abi:: Abi :: Stdcall { unwind } => Abi :: Stdcall { unwind } ,
623+ abi:: Abi :: Fastcall { unwind } => Abi :: Fastcall { unwind } ,
624+ abi:: Abi :: Vectorcall { unwind } => Abi :: Vectorcall { unwind } ,
625+ abi:: Abi :: Thiscall { unwind } => Abi :: Thiscall { unwind } ,
626+ abi:: Abi :: Aapcs { unwind } => Abi :: Aapcs { unwind } ,
627+ abi:: Abi :: Win64 { unwind } => Abi :: Win64 { unwind } ,
628+ abi:: Abi :: SysV64 { unwind } => Abi :: SysV64 { unwind } ,
629+ abi:: Abi :: PtxKernel => Abi :: PtxKernel ,
630+ abi:: Abi :: Msp430Interrupt => Abi :: Msp430Interrupt ,
631+ abi:: Abi :: X86Interrupt => Abi :: X86Interrupt ,
632+ abi:: Abi :: AmdGpuKernel => Abi :: AmdGpuKernel ,
633+ abi:: Abi :: EfiApi => Abi :: EfiApi ,
634+ abi:: Abi :: AvrInterrupt => Abi :: AvrInterrupt ,
635+ abi:: Abi :: AvrNonBlockingInterrupt => Abi :: AvrNonBlockingInterrupt ,
636+ abi:: Abi :: CCmseNonSecureCall => Abi :: CCmseNonSecureCall ,
637+ abi:: Abi :: Wasm => Abi :: Wasm ,
638+ abi:: Abi :: System { unwind } => Abi :: System { unwind } ,
639+ abi:: Abi :: RustIntrinsic => Abi :: RustIntrinsic ,
640+ abi:: Abi :: RustCall => Abi :: RustCall ,
641+ abi:: Abi :: PlatformIntrinsic => Abi :: PlatformIntrinsic ,
642+ abi:: Abi :: Unadjusted => Abi :: Unadjusted ,
643+ abi:: Abi :: RustCold => Abi :: RustCold ,
644+ } ,
645+ }
646+ }
647+ }
648+
649+ impl < ' tcx > Stable < ' tcx > for ty:: BoundVariableKind {
650+ type T = stable_mir:: ty:: BoundVariableKind ;
651+ fn stable ( & self , _: & mut Tables < ' tcx > ) -> Self :: T {
652+ use stable_mir:: ty:: { BoundRegionKind , BoundTyKind , BoundVariableKind } ;
653+
654+ match self {
655+ ty:: BoundVariableKind :: Ty ( bound_ty_kind) => {
656+ BoundVariableKind :: Ty ( match bound_ty_kind {
657+ ty:: BoundTyKind :: Anon => BoundTyKind :: Anon ,
658+ ty:: BoundTyKind :: Param ( def_id, symbol) => {
659+ BoundTyKind :: Param ( rustc_internal:: param_def ( * def_id) , symbol. to_string ( ) )
660+ }
661+ } )
662+ }
663+ ty:: BoundVariableKind :: Region ( bound_region_kind) => {
664+ BoundVariableKind :: Region ( match bound_region_kind {
665+ ty:: BoundRegionKind :: BrAnon ( option_span) => {
666+ BoundRegionKind :: BrAnon ( option_span. map ( |span| opaque ( & span) ) )
667+ }
668+ ty:: BoundRegionKind :: BrNamed ( def_id, symbol) => BoundRegionKind :: BrNamed (
669+ rustc_internal:: br_named_def ( * def_id) ,
670+ symbol. to_string ( ) ,
671+ ) ,
672+ ty:: BoundRegionKind :: BrEnv => BoundRegionKind :: BrEnv ,
673+ } )
674+ }
675+ ty:: BoundVariableKind :: Const => BoundVariableKind :: Const ,
676+ }
677+ }
678+ }
0 commit comments