@@ -2839,7 +2839,7 @@ pub fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi) -> Conv {
28392839}
28402840
28412841/// Error produced by attempting to compute or adjust a `FnAbi`.
2842- #[ derive( Clone , Debug , HashStable ) ]
2842+ #[ derive( Copy , Clone , Debug , HashStable ) ]
28432843pub enum FnAbiError < ' tcx > {
28442844 /// Error produced by a `layout_of` call, while computing `FnAbi` initially.
28452845 Layout ( LayoutError < ' tcx > ) ,
@@ -2893,7 +2893,7 @@ pub trait FnAbiOfHelpers<'tcx>: LayoutOfHelpers<'tcx> {
28932893 /// (and any `FnAbiError`s are turned into fatal errors or ICEs).
28942894 fn handle_fn_abi_err (
28952895 & self ,
2896- err : & ' tcx FnAbiError < ' tcx > ,
2896+ err : FnAbiError < ' tcx > ,
28972897 span : Span ,
28982898 fn_abi_request : FnAbiRequest < ' tcx > ,
28992899 ) -> <Self :: FnAbiOfResult as MaybeResult < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > > >:: Error ;
@@ -2915,11 +2915,9 @@ pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
29152915 let span = self . layout_tcx_at_span ( ) ;
29162916 let tcx = self . tcx ( ) . at ( span) ;
29172917
2918- MaybeResult :: from (
2919- tcx. fn_abi_of_fn_ptr ( self . param_env ( ) . and ( ( sig, extra_args) ) ) . as_ref ( ) . map_err ( |err| {
2920- self . handle_fn_abi_err ( err, span, FnAbiRequest :: OfFnPtr { sig, extra_args } )
2921- } ) ,
2922- )
2918+ MaybeResult :: from ( tcx. fn_abi_of_fn_ptr ( self . param_env ( ) . and ( ( sig, extra_args) ) ) . map_err (
2919+ |err| self . handle_fn_abi_err ( err, span, FnAbiRequest :: OfFnPtr { sig, extra_args } ) ,
2920+ ) )
29232921 }
29242922
29252923 /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
@@ -2938,21 +2936,14 @@ pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
29382936 let tcx = self . tcx ( ) . at ( span) ;
29392937
29402938 MaybeResult :: from (
2941- tcx. fn_abi_of_instance ( self . param_env ( ) . and ( ( instance, extra_args) ) ) . as_ref ( ) . map_err (
2942- |err| {
2943- // HACK(eddyb) at least for definitions of/calls to `Instance`s,
2944- // we can get some kind of span even if one wasn't provided.
2945- // However, we don't do this early in order to avoid calling
2946- // `def_span` unconditionally (which may have a perf penalty).
2947- let span =
2948- if !span. is_dummy ( ) { span } else { tcx. def_span ( instance. def_id ( ) ) } ;
2949- self . handle_fn_abi_err (
2950- err,
2951- span,
2952- FnAbiRequest :: OfInstance { instance, extra_args } ,
2953- )
2954- } ,
2955- ) ,
2939+ tcx. fn_abi_of_instance ( self . param_env ( ) . and ( ( instance, extra_args) ) ) . map_err ( |err| {
2940+ // HACK(eddyb) at least for definitions of/calls to `Instance`s,
2941+ // we can get some kind of span even if one wasn't provided.
2942+ // However, we don't do this early in order to avoid calling
2943+ // `def_span` unconditionally (which may have a perf penalty).
2944+ let span = if !span. is_dummy ( ) { span } else { tcx. def_span ( instance. def_id ( ) ) } ;
2945+ self . handle_fn_abi_err ( err, span, FnAbiRequest :: OfInstance { instance, extra_args } )
2946+ } ) ,
29562947 )
29572948 }
29582949}
@@ -2962,7 +2953,7 @@ impl<'tcx, C: FnAbiOfHelpers<'tcx>> FnAbiOf<'tcx> for C {}
29622953fn fn_abi_of_fn_ptr < ' tcx > (
29632954 tcx : TyCtxt < ' tcx > ,
29642955 query : ty:: ParamEnvAnd < ' tcx , ( ty:: PolyFnSig < ' tcx > , & ' tcx ty:: List < Ty < ' tcx > > ) > ,
2965- ) -> Result < FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
2956+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
29662957 let ( param_env, ( sig, extra_args) ) = query. into_parts ( ) ;
29672958
29682959 LayoutCx { tcx, param_env } . fn_abi_new_uncached (
@@ -2977,7 +2968,7 @@ fn fn_abi_of_fn_ptr<'tcx>(
29772968fn fn_abi_of_instance < ' tcx > (
29782969 tcx : TyCtxt < ' tcx > ,
29792970 query : ty:: ParamEnvAnd < ' tcx , ( ty:: Instance < ' tcx > , & ' tcx ty:: List < Ty < ' tcx > > ) > ,
2980- ) -> Result < FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
2971+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
29812972 let ( param_env, ( instance, extra_args) ) = query. into_parts ( ) ;
29822973
29832974 let sig = instance. fn_sig_for_fn_abi ( tcx, param_env) ;
@@ -3010,7 +3001,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
30103001 codegen_fn_attr_flags : CodegenFnAttrFlags ,
30113002 // FIXME(eddyb) replace this with something typed, like an `enum`.
30123003 force_thin_self_ptr : bool ,
3013- ) -> Result < FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
3004+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
30143005 debug ! ( "fn_abi_new_uncached({:?}, {:?})" , sig, extra_args) ;
30153006
30163007 let sig = self . tcx . normalize_erasing_late_bound_regions ( self . param_env , sig) ;
@@ -3174,7 +3165,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
31743165 } ;
31753166 self . fn_abi_adjust_for_abi ( & mut fn_abi, sig. abi ) ?;
31763167 debug ! ( "fn_abi_new_uncached = {:?}" , fn_abi) ;
3177- Ok ( fn_abi)
3168+ Ok ( self . tcx . arena . alloc ( fn_abi) )
31783169 }
31793170
31803171 fn fn_abi_adjust_for_abi (
0 commit comments