Skip to content

Commit 39d363f

Browse files
committed
Port layout size overflow
1 parent f031823 commit 39d363f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

compiler/rustc_codegen_llvm/src/context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::callee::get_fn;
44
use crate::coverageinfo;
55
use crate::debuginfo;
66
use crate::errors::BranchProtectionRequiresAArch64;
7+
use crate::errors::LayoutSizeOverflow;
78
use crate::llvm;
89
use crate::llvm_util;
910
use crate::type_::Type;
@@ -952,7 +953,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
952953
#[inline]
953954
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
954955
if let LayoutError::SizeOverflow(_) = err {
955-
self.sess().span_fatal(span, &err.to_string())
956+
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
956957
} else {
957958
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
958959
}
@@ -970,7 +971,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
970971
fn_abi_request: FnAbiRequest<'tcx>,
971972
) -> ! {
972973
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
973-
self.sess().span_fatal(span, &err.to_string())
974+
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
974975
} else {
975976
match fn_abi_request {
976977
FnAbiRequest::OfFnPtr { sig, extra_args } => {

compiler/rustc_codegen_llvm/src/errors.rs

+8
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,11 @@ pub(crate) struct SymbolAlreadyDefined<'a> {
5959
#[derive(SessionDiagnostic)]
6060
#[diag(codegen_llvm::branch_protection_requires_aarch64)]
6161
pub(crate) struct BranchProtectionRequiresAArch64;
62+
63+
#[derive(SessionDiagnostic)]
64+
#[diag(codegen_llvm::layout_size_overflow)]
65+
pub(crate) struct LayoutSizeOverflow {
66+
#[primary_span]
67+
pub span: Span,
68+
pub error: String,
69+
}

compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ codegen_llvm_symbol_already_defined =
2424
2525
codegen_llvm_branch_protection_requires_aarch64 =
2626
-Zbranch-protection is only supported on aarch64
27+
28+
codegen_llvm_layout_size_overflow =
29+
{$error}

0 commit comments

Comments
 (0)