@@ -14,7 +14,7 @@ use rustc_middle::mir::mono::CodegenUnit;
14
14
use rustc_middle:: ty:: { self , Instance , ParamEnv , PolyExistentialTraitRef , Ty , TyCtxt } ;
15
15
use rustc_middle:: ty:: layout:: { FnAbiError , FnAbiOf , FnAbiOfHelpers , FnAbiRequest , HasParamEnv , HasTyCtxt , LayoutError , TyAndLayout , LayoutOfHelpers } ;
16
16
use rustc_session:: Session ;
17
- use rustc_span:: Span ;
17
+ use rustc_span:: { Span , source_map :: respan } ;
18
18
use rustc_target:: abi:: { call:: FnAbi , HasDataLayout , PointeeInfo , Size , TargetDataLayout , VariantIdx } ;
19
19
use rustc_target:: spec:: { HasTargetSpec , Target , TlsModel } ;
20
20
@@ -493,6 +493,23 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
493
493
#[ inline]
494
494
fn handle_layout_err ( & self , err : LayoutError < ' tcx > , span : Span , ty : Ty < ' tcx > ) -> ! {
495
495
if let LayoutError :: SizeOverflow ( _) = err {
496
+ let _ = respan ( span, err) ;
497
+ // error: lifetime may not live long enough
498
+ // --> src/context.rs:483:13
499
+ // |
500
+ // 475 | impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
501
+ // | ---- ---- lifetime `'tcx` defined here
502
+ // | |
503
+ // | lifetime `'gcc` defined here
504
+ // ...
505
+ // 483 | self.sess().emit_fatal(respan(span, err))
506
+ // | ^^^^^^^^^^^ argument requires that `'gcc` must outlive `'tcx`
507
+ // |
508
+ // = help: consider adding the following bound: `'gcc: 'tcx`
509
+ // = note: requirement occurs because of the type `CodegenCx<'_, '_>`, which makes the generic argument `'_` invariant
510
+ // = note: the struct `CodegenCx<'gcc, 'tcx>` is invariant over the parameter `'gcc`
511
+ // = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
512
+ // self.sess().emit_fatal(respan(span, err))
496
513
self . sess ( ) . emit_fatal ( LayoutSizeOverflow { span, error : err. to_string ( ) } )
497
514
} else {
498
515
span_bug ! ( span, "failed to get layout for `{}`: {}" , ty, err)
0 commit comments