@@ -202,7 +202,7 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi) -> Conv {
202202fn fn_abi_of_fn_ptr < ' tcx > (
203203 tcx : TyCtxt < ' tcx > ,
204204 query : ty:: ParamEnvAnd < ' tcx , ( ty:: PolyFnSig < ' tcx > , & ' tcx ty:: List < Ty < ' tcx > > ) > ,
205- ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
205+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , & ' tcx FnAbiError < ' tcx > > {
206206 let ( param_env, ( sig, extra_args) ) = query. into_parts ( ) ;
207207
208208 let cx = LayoutCx { tcx, param_env } ;
@@ -212,7 +212,7 @@ fn fn_abi_of_fn_ptr<'tcx>(
212212fn fn_abi_of_instance < ' tcx > (
213213 tcx : TyCtxt < ' tcx > ,
214214 query : ty:: ParamEnvAnd < ' tcx , ( ty:: Instance < ' tcx > , & ' tcx ty:: List < Ty < ' tcx > > ) > ,
215- ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
215+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , & ' tcx FnAbiError < ' tcx > > {
216216 let ( param_env, ( instance, extra_args) ) = query. into_parts ( ) ;
217217
218218 let sig = fn_sig_for_fn_abi ( tcx, instance, param_env) ;
@@ -331,7 +331,7 @@ fn fn_abi_new_uncached<'tcx>(
331331 fn_def_id : Option < DefId > ,
332332 // FIXME(eddyb) replace this with something typed, like an `enum`.
333333 force_thin_self_ptr : bool ,
334- ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
334+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , & ' tcx FnAbiError < ' tcx > > {
335335 let sig = cx. tcx . normalize_erasing_late_bound_regions ( cx. param_env , sig) ;
336336
337337 let conv = conv_from_spec_abi ( cx. tcx ( ) , sig. abi ) ;
@@ -376,7 +376,7 @@ fn fn_abi_new_uncached<'tcx>(
376376 let is_drop_in_place =
377377 fn_def_id. is_some ( ) && fn_def_id == cx. tcx . lang_items ( ) . drop_in_place_fn ( ) ;
378378
379- let arg_of = |ty : Ty < ' tcx > , arg_idx : Option < usize > | -> Result < _ , FnAbiError < ' tcx > > {
379+ let arg_of = |ty : Ty < ' tcx > , arg_idx : Option < usize > | -> Result < _ , & ' tcx FnAbiError < ' tcx > > {
380380 let span = tracing:: debug_span!( "arg_of" ) ;
381381 let _entered = span. enter ( ) ;
382382 let is_return = arg_idx. is_none ( ) ;
@@ -386,7 +386,8 @@ fn fn_abi_new_uncached<'tcx>(
386386 _ => bug ! ( "argument to drop_in_place is not a raw ptr: {:?}" , ty) ,
387387 } ) ;
388388
389- let layout = cx. layout_of ( ty) . map_err ( |err| * err) ?;
389+ let layout =
390+ cx. layout_of ( ty) . map_err ( |err| & * cx. tcx . arena . alloc ( FnAbiError :: Layout ( * err) ) ) ?;
390391 let layout = if force_thin_self_ptr && arg_idx == Some ( 0 ) {
391392 // Don't pass the vtable, it's not an argument of the virtual fn.
392393 // Instead, pass just the data pointer, but give it the type `*const/mut dyn Trait`
@@ -454,7 +455,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
454455 fn_abi : & mut FnAbi < ' tcx , Ty < ' tcx > > ,
455456 abi : SpecAbi ,
456457 fn_def_id : Option < DefId > ,
457- ) -> Result < ( ) , FnAbiError < ' tcx > > {
458+ ) -> Result < ( ) , & ' tcx FnAbiError < ' tcx > > {
458459 if abi == SpecAbi :: Unadjusted {
459460 return Ok ( ( ) ) ;
460461 }
@@ -548,7 +549,9 @@ fn fn_abi_adjust_for_abi<'tcx>(
548549 fixup ( arg, Some ( arg_idx) ) ;
549550 }
550551 } else {
551- fn_abi. adjust_for_foreign_abi ( cx, abi) ?;
552+ fn_abi
553+ . adjust_for_foreign_abi ( cx, abi)
554+ . map_err ( |err| & * cx. tcx . arena . alloc ( FnAbiError :: AdjustForForeignAbi ( err) ) ) ?;
552555 }
553556
554557 Ok ( ( ) )
0 commit comments