@@ -21,10 +21,10 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
2121use rustc_middle:: span_bug;
2222use rustc_middle:: mir:: mono:: CodegenUnit ;
2323use 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 } ;
2525use rustc_session:: Session ;
2626use 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 } ;
2828use rustc_target:: spec:: { HasTargetSpec , Target , TlsModel } ;
2929
3030use crate :: callee:: get_fn;
@@ -401,6 +401,43 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
401401 }
402402}
403403
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+
404441impl < ' tcx , ' gcc > HasParamEnv < ' tcx > for CodegenCx < ' gcc , ' tcx > {
405442 fn param_env ( & self ) -> ParamEnv < ' tcx > {
406443 ParamEnv :: reveal_all ( )
0 commit comments