Skip to content

Commit 925b11e

Browse files
ellishgantoyo
authored andcommitted
fix lifetime error
1 parent 9bbb491 commit 925b11e

File tree

2 files changed

+3
-29
lines changed

2 files changed

+3
-29
lines changed

src/context.rs

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDat
1919
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
2020

2121
use crate::callee::get_fn;
22-
use crate::errors::LayoutSizeOverflow;
2322

2423
#[derive(Clone)]
2524
pub struct FuncSig<'gcc> {
@@ -299,7 +298,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
299298
self.is_native_int_type(typ) || self.is_non_native_int_type(typ) || typ.is_compatible_with(self.bool_type)
300299
}
301300

302-
pub fn sess(&self) -> &Session {
301+
pub fn sess(&self) -> &'tcx Session {
303302
&self.tcx.sess
304303
}
305304

@@ -493,24 +492,7 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
493492
#[inline]
494493
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
495494
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))
513-
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
495+
self.sess().emit_fatal(respan(span, err))
514496
} else {
515497
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
516498
}
@@ -528,7 +510,7 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
528510
fn_abi_request: FnAbiRequest<'tcx>,
529511
) -> ! {
530512
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
531-
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
513+
self.sess().emit_fatal(respan(span, err))
532514
} else {
533515
match fn_abi_request {
534516
FnAbiRequest::OfFnPtr { sig, extra_args } => {

src/errors.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,6 @@ pub(crate) struct InvalidMonomorphizationUnsupportedOperation<'a> {
225225
pub in_elem: Ty<'a>,
226226
}
227227

228-
#[derive(Diagnostic)]
229-
#[diag(codegen_gcc::layout_size_overflow)]
230-
pub(crate) struct LayoutSizeOverflow {
231-
#[primary_span]
232-
pub span: Span,
233-
pub error: String,
234-
}
235-
236228
#[derive(Diagnostic)]
237229
#[diag(codegen_gcc::linkage_const_or_mut_type)]
238230
pub(crate) struct LinkageConstOrMutType {

0 commit comments

Comments
 (0)