@@ -21,10 +21,10 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
21
21
use rustc_middle:: span_bug;
22
22
use rustc_middle:: mir:: mono:: CodegenUnit ;
23
23
use rustc_middle:: ty:: { self , Instance , ParamEnv , PolyExistentialTraitRef , Ty , TyCtxt } ;
24
- use rustc_middle:: ty:: layout:: { HasParamEnv , HasTyCtxt , LayoutError , TyAndLayout , LayoutOfHelpers } ;
24
+ use rustc_middle:: ty:: layout:: { FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasParamEnv , HasTyCtxt , LayoutError , TyAndLayout , LayoutOfHelpers } ;
25
25
use rustc_session:: Session ;
26
26
use rustc_span:: { Span , Symbol } ;
27
- use rustc_target:: abi:: { HasDataLayout , PointeeInfo , Size , TargetDataLayout , VariantIdx } ;
27
+ use rustc_target:: abi:: { call :: FnAbi , HasDataLayout , PointeeInfo , Size , TargetDataLayout , VariantIdx } ;
28
28
use rustc_target:: spec:: { HasTargetSpec , Target , TlsModel } ;
29
29
30
30
use crate :: callee:: get_fn;
@@ -401,6 +401,43 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
401
401
}
402
402
}
403
403
404
+ impl < ' gcc , ' tcx > FnAbiOfHelpers < ' tcx > for CodegenCx < ' gcc , ' tcx > {
405
+ type FnAbiOfResult = & ' tcx FnAbi < ' tcx , Ty < ' tcx > > ;
406
+
407
+ #[ inline]
408
+ fn handle_fn_abi_err (
409
+ & self ,
410
+ err : FnAbiError < ' tcx > ,
411
+ span : Span ,
412
+ fn_abi_request : FnAbiRequest < ' tcx > ,
413
+ ) -> ! {
414
+ if let FnAbiError :: Layout ( LayoutError :: SizeOverflow ( _) ) = err {
415
+ self . sess ( ) . span_fatal ( span, & err. to_string ( ) )
416
+ } else {
417
+ match fn_abi_request {
418
+ FnAbiRequest :: OfFnPtr { sig, extra_args } => {
419
+ span_bug ! (
420
+ span,
421
+ "`fn_abi_of_fn_ptr({}, {:?})` failed: {}" ,
422
+ sig,
423
+ extra_args,
424
+ err
425
+ ) ;
426
+ }
427
+ FnAbiRequest :: OfInstance { instance, extra_args } => {
428
+ span_bug ! (
429
+ span,
430
+ "`fn_abi_of_instance({}, {:?})` failed: {}" ,
431
+ instance,
432
+ extra_args,
433
+ err
434
+ ) ;
435
+ }
436
+ }
437
+ }
438
+ }
439
+ }
440
+
404
441
impl < ' tcx , ' gcc > HasParamEnv < ' tcx > for CodegenCx < ' gcc , ' tcx > {
405
442
fn param_env ( & self ) -> ParamEnv < ' tcx > {
406
443
ParamEnv :: reveal_all ( )
0 commit comments