Use LayoutError's implementation of IntoDiagnostic

This commit is contained in:
SLASHLogin 2022-11-04 20:08:01 +01:00
parent 0381e51822
commit a8a8055cc7
4 changed files with 7 additions and 18 deletions

View file

@ -4,7 +4,6 @@ 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;
@ -28,6 +27,7 @@ use rustc_session::config::{BranchProtection, CFGuard, CFProtection};
use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
use rustc_session::Session;
use rustc_span::source_map::Span;
use rustc_span::source_map::Spanned;
use rustc_target::abi::{
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
};
@ -953,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().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
self.sess().emit_fatal(Spanned { span, node: err })
} else {
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
}
@ -971,7 +971,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
fn_abi_request: FnAbiRequest<'tcx>,
) -> ! {
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
self.sess().emit_fatal(Spanned { span, node: err })
} else {
match fn_abi_request {
FnAbiRequest::OfFnPtr { sig, extra_args } => {