Port layout size overflow

This commit is contained in:
SLASHLogin 2022-08-26 10:14:15 +02:00
parent f031823ecd
commit 39d363fd58
3 changed files with 14 additions and 2 deletions

View File

@ -4,6 +4,7 @@ use crate::callee::get_fn;
use crate::coverageinfo;
use crate::debuginfo;
use crate::errors::BranchProtectionRequiresAArch64;
use crate::errors::LayoutSizeOverflow;
use crate::llvm;
use crate::llvm_util;
use crate::type_::Type;
@ -952,7 +953,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
#[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
if let LayoutError::SizeOverflow(_) = err {
self.sess().span_fatal(span, &err.to_string())
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
} else {
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
}
@ -970,7 +971,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
fn_abi_request: FnAbiRequest<'tcx>,
) -> ! {
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
self.sess().span_fatal(span, &err.to_string())
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
} else {
match fn_abi_request {
FnAbiRequest::OfFnPtr { sig, extra_args } => {

View File

@ -59,3 +59,11 @@ pub(crate) struct SymbolAlreadyDefined<'a> {
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::branch_protection_requires_aarch64)]
pub(crate) struct BranchProtectionRequiresAArch64;
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::layout_size_overflow)]
pub(crate) struct LayoutSizeOverflow {
#[primary_span]
pub span: Span,
pub error: String,
}

View File

@ -24,3 +24,6 @@ codegen_llvm_symbol_already_defined =
codegen_llvm_branch_protection_requires_aarch64 =
-Zbranch-protection is only supported on aarch64
codegen_llvm_layout_size_overflow =
{$error}