@@ -2839,7 +2839,7 @@ pub fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi) -> Conv {
2839
2839
}
2840
2840
2841
2841
/// Error produced by attempting to compute or adjust a `FnAbi`.
2842
- #[ derive( Clone , Debug , HashStable ) ]
2842
+ #[ derive( Copy , Clone , Debug , HashStable ) ]
2843
2843
pub enum FnAbiError < ' tcx > {
2844
2844
/// Error produced by a `layout_of` call, while computing `FnAbi` initially.
2845
2845
Layout ( LayoutError < ' tcx > ) ,
@@ -2893,7 +2893,7 @@ pub trait FnAbiOfHelpers<'tcx>: LayoutOfHelpers<'tcx> {
2893
2893
/// (and any `FnAbiError`s are turned into fatal errors or ICEs).
2894
2894
fn handle_fn_abi_err (
2895
2895
& self ,
2896
- err : & ' tcx FnAbiError < ' tcx > ,
2896
+ err : FnAbiError < ' tcx > ,
2897
2897
span : Span ,
2898
2898
fn_abi_request : FnAbiRequest < ' tcx > ,
2899
2899
) -> <Self :: FnAbiOfResult as MaybeResult < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > > >:: Error ;
@@ -2915,11 +2915,9 @@ pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
2915
2915
let span = self . layout_tcx_at_span ( ) ;
2916
2916
let tcx = self . tcx ( ) . at ( span) ;
2917
2917
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
+ ) )
2923
2921
}
2924
2922
2925
2923
/// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
@@ -2938,21 +2936,14 @@ pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
2938
2936
let tcx = self . tcx ( ) . at ( span) ;
2939
2937
2940
2938
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
+ } ) ,
2956
2947
)
2957
2948
}
2958
2949
}
@@ -2962,7 +2953,7 @@ impl<'tcx, C: FnAbiOfHelpers<'tcx>> FnAbiOf<'tcx> for C {}
2962
2953
fn fn_abi_of_fn_ptr < ' tcx > (
2963
2954
tcx : TyCtxt < ' tcx > ,
2964
2955
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 > > {
2966
2957
let ( param_env, ( sig, extra_args) ) = query. into_parts ( ) ;
2967
2958
2968
2959
LayoutCx { tcx, param_env } . fn_abi_new_uncached (
@@ -2977,7 +2968,7 @@ fn fn_abi_of_fn_ptr<'tcx>(
2977
2968
fn fn_abi_of_instance < ' tcx > (
2978
2969
tcx : TyCtxt < ' tcx > ,
2979
2970
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 > > {
2981
2972
let ( param_env, ( instance, extra_args) ) = query. into_parts ( ) ;
2982
2973
2983
2974
let sig = instance. fn_sig_for_fn_abi ( tcx, param_env) ;
@@ -3010,7 +3001,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
3010
3001
codegen_fn_attr_flags : CodegenFnAttrFlags ,
3011
3002
// FIXME(eddyb) replace this with something typed, like an `enum`.
3012
3003
force_thin_self_ptr : bool ,
3013
- ) -> Result < FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
3004
+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
3014
3005
debug ! ( "fn_abi_new_uncached({:?}, {:?})" , sig, extra_args) ;
3015
3006
3016
3007
let sig = self . tcx . normalize_erasing_late_bound_regions ( self . param_env , sig) ;
@@ -3174,7 +3165,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
3174
3165
} ;
3175
3166
self . fn_abi_adjust_for_abi ( & mut fn_abi, sig. abi ) ?;
3176
3167
debug ! ( "fn_abi_new_uncached = {:?}" , fn_abi) ;
3177
- Ok ( fn_abi)
3168
+ Ok ( self . tcx . arena . alloc ( fn_abi) )
3178
3169
}
3179
3170
3180
3171
fn fn_abi_adjust_for_abi (
0 commit comments