Skip to content

Commit 5e0c53a

Browse files
committed
Add LayoutSizeOverflow
1 parent d0b7e71 commit 5e0c53a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Diff for: compiler/rustc_codegen_gcc/src/context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDat
1818
use rustc_target::spec::{HasTargetSpec, Target, TlsModel};
1919

2020
use crate::callee::get_fn;
21+
use crate::errors::LayoutSizeOverflow;
2122

2223
#[derive(Clone)]
2324
pub struct FuncSig<'gcc> {
@@ -477,7 +478,7 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
477478
#[inline]
478479
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
479480
if let LayoutError::SizeOverflow(_) = err {
480-
self.sess().span_fatal(span, &err.to_string())
481+
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
481482
} else {
482483
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
483484
}
@@ -495,7 +496,7 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
495496
fn_abi_request: FnAbiRequest<'tcx>,
496497
) -> ! {
497498
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
498-
self.sess().span_fatal(span, &err.to_string())
499+
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
499500
} else {
500501
match fn_abi_request {
501502
FnAbiRequest::OfFnPtr { sig, extra_args } => {

Diff for: compiler/rustc_codegen_gcc/src/errors.rs

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ pub(crate) struct RanlibFailure {
77
pub exit_code: Option<i32>
88
}
99

10+
#[derive(SessionDiagnostic)]
11+
#[diag(codegen_gcc::layout_size_overflow)]
12+
pub(crate) struct LayoutSizeOverflow {
13+
#[primary_span]
14+
pub span: Span,
15+
pub error: String,
16+
}
17+
1018
#[derive(SessionDiagnostic)]
1119
#[diag(codegen_gcc::linkage_const_or_mut_type)]
1220
pub(crate) struct LinkageConstOrMutType {

Diff for: compiler/rustc_error_messages/locales/en-US/codegen_gcc.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
codegen_gcc_ranlib_failure =
22
Ranlib exited with code {$exit_code}
33
4+
codegen_gcc_layout_size_overflow =
5+
{$error}
6+
47
codegen_gcc_linkage_const_or_mut_type =
58
must have type `*const T` or `*mut T` due to `#[linkage]` attribute
69

0 commit comments

Comments
 (0)