@@ -202,7 +202,7 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi) -> Conv {
202
202
fn fn_abi_of_fn_ptr < ' tcx > (
203
203
tcx : TyCtxt < ' tcx > ,
204
204
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 > > {
206
206
let ( param_env, ( sig, extra_args) ) = query. into_parts ( ) ;
207
207
208
208
let cx = LayoutCx { tcx, param_env } ;
@@ -212,7 +212,7 @@ fn fn_abi_of_fn_ptr<'tcx>(
212
212
fn fn_abi_of_instance < ' tcx > (
213
213
tcx : TyCtxt < ' tcx > ,
214
214
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 > > {
216
216
let ( param_env, ( instance, extra_args) ) = query. into_parts ( ) ;
217
217
218
218
let sig = fn_sig_for_fn_abi ( tcx, instance, param_env) ;
@@ -331,7 +331,7 @@ fn fn_abi_new_uncached<'tcx>(
331
331
fn_def_id : Option < DefId > ,
332
332
// FIXME(eddyb) replace this with something typed, like an `enum`.
333
333
force_thin_self_ptr : bool ,
334
- ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , FnAbiError < ' tcx > > {
334
+ ) -> Result < & ' tcx FnAbi < ' tcx , Ty < ' tcx > > , & ' tcx FnAbiError < ' tcx > > {
335
335
let sig = cx. tcx . normalize_erasing_late_bound_regions ( cx. param_env , sig) ;
336
336
337
337
let conv = conv_from_spec_abi ( cx. tcx ( ) , sig. abi ) ;
@@ -376,7 +376,7 @@ fn fn_abi_new_uncached<'tcx>(
376
376
let is_drop_in_place =
377
377
fn_def_id. is_some ( ) && fn_def_id == cx. tcx . lang_items ( ) . drop_in_place_fn ( ) ;
378
378
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 > > {
380
380
let span = tracing:: debug_span!( "arg_of" ) ;
381
381
let _entered = span. enter ( ) ;
382
382
let is_return = arg_idx. is_none ( ) ;
@@ -386,7 +386,8 @@ fn fn_abi_new_uncached<'tcx>(
386
386
_ => bug ! ( "argument to drop_in_place is not a raw ptr: {:?}" , ty) ,
387
387
} ) ;
388
388
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) ) ) ?;
390
391
let layout = if force_thin_self_ptr && arg_idx == Some ( 0 ) {
391
392
// Don't pass the vtable, it's not an argument of the virtual fn.
392
393
// 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>(
454
455
fn_abi : & mut FnAbi < ' tcx , Ty < ' tcx > > ,
455
456
abi : SpecAbi ,
456
457
fn_def_id : Option < DefId > ,
457
- ) -> Result < ( ) , FnAbiError < ' tcx > > {
458
+ ) -> Result < ( ) , & ' tcx FnAbiError < ' tcx > > {
458
459
if abi == SpecAbi :: Unadjusted {
459
460
return Ok ( ( ) ) ;
460
461
}
@@ -548,7 +549,9 @@ fn fn_abi_adjust_for_abi<'tcx>(
548
549
fixup ( arg, Some ( arg_idx) ) ;
549
550
}
550
551
} 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) ) ) ?;
552
555
}
553
556
554
557
Ok ( ( ) )
0 commit comments