@@ -13,7 +13,7 @@ use rustc_middle::mir::mono::CodegenUnit;
1313use rustc_middle:: ty:: { self , Instance , ParamEnv , PolyExistentialTraitRef , Ty , TyCtxt } ;
1414use rustc_middle:: ty:: layout:: { FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasParamEnv , HasTyCtxt , LayoutError , TyAndLayout , LayoutOfHelpers } ;
1515use rustc_session:: Session ;
16- use rustc_span:: Span ;
16+ use rustc_span:: { Span , source_map :: respan } ;
1717use rustc_target:: abi:: { call:: FnAbi , HasDataLayout , PointeeInfo , Size , TargetDataLayout , VariantIdx } ;
1818use rustc_target:: spec:: { HasTargetSpec , Target , TlsModel } ;
1919
@@ -478,6 +478,23 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
478478 #[ inline]
479479 fn handle_layout_err ( & self , err : LayoutError < ' tcx > , span : Span , ty : Ty < ' tcx > ) -> ! {
480480 if let LayoutError :: SizeOverflow ( _) = err {
481+ let _ = respan ( span, err) ;
482+ // error: lifetime may not live long enough
483+ // --> src/context.rs:483:13
484+ // |
485+ // 475 | impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
486+ // | ---- ---- lifetime `'tcx` defined here
487+ // | |
488+ // | lifetime `'gcc` defined here
489+ // ...
490+ // 483 | self.sess().emit_fatal(respan(span, err))
491+ // | ^^^^^^^^^^^ argument requires that `'gcc` must outlive `'tcx`
492+ // |
493+ // = help: consider adding the following bound: `'gcc: 'tcx`
494+ // = note: requirement occurs because of the type `CodegenCx<'_, '_>`, which makes the generic argument `'_` invariant
495+ // = note: the struct `CodegenCx<'gcc, 'tcx>` is invariant over the parameter `'gcc`
496+ // = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
497+ // self.sess().emit_fatal(respan(span, err))
481498 self . sess ( ) . emit_fatal ( LayoutSizeOverflow { span, error : err. to_string ( ) } )
482499 } else {
483500 span_bug ! ( span, "failed to get layout for `{}`: {}" , ty, err)
0 commit comments