@@ -13,7 +13,7 @@ use rustc_middle::mir::mono::CodegenUnit;
13
13
use rustc_middle:: ty:: { self , Instance , ParamEnv , PolyExistentialTraitRef , Ty , TyCtxt } ;
14
14
use rustc_middle:: ty:: layout:: { FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasParamEnv , HasTyCtxt , LayoutError , TyAndLayout , LayoutOfHelpers } ;
15
15
use rustc_session:: Session ;
16
- use rustc_span:: Span ;
16
+ use rustc_span:: { Span , source_map :: respan } ;
17
17
use rustc_target:: abi:: { call:: FnAbi , HasDataLayout , PointeeInfo , Size , TargetDataLayout , VariantIdx } ;
18
18
use rustc_target:: spec:: { HasTargetSpec , Target , TlsModel } ;
19
19
@@ -478,6 +478,23 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
478
478
#[ inline]
479
479
fn handle_layout_err ( & self , err : LayoutError < ' tcx > , span : Span , ty : Ty < ' tcx > ) -> ! {
480
480
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))
481
498
self . sess ( ) . emit_fatal ( LayoutSizeOverflow { span, error : err. to_string ( ) } )
482
499
} else {
483
500
span_bug ! ( span, "failed to get layout for `{}`: {}" , ty, err)
0 commit comments