Skip to content

Commit a8a8055

Browse files
committed
Use LayoutError's implementation of IntoDiagnostic
1 parent 0381e51 commit a8a8055

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

compiler/rustc_codegen_llvm/src/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::callee::get_fn;
44
use crate::coverageinfo;
55
use crate::debuginfo;
66
use crate::errors::BranchProtectionRequiresAArch64;
7-
use crate::errors::LayoutSizeOverflow;
87
use crate::llvm;
98
use crate::llvm_util;
109
use crate::type_::Type;
@@ -28,6 +27,7 @@ use rustc_session::config::{BranchProtection, CFGuard, CFProtection};
2827
use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
2928
use rustc_session::Session;
3029
use rustc_span::source_map::Span;
30+
use rustc_span::source_map::Spanned;
3131
use rustc_target::abi::{
3232
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
3333
};
@@ -953,7 +953,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
953953
#[inline]
954954
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
955955
if let LayoutError::SizeOverflow(_) = err {
956-
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
956+
self.sess().emit_fatal(Spanned { span, node: err })
957957
} else {
958958
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
959959
}
@@ -971,7 +971,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
971971
fn_abi_request: FnAbiRequest<'tcx>,
972972
) -> ! {
973973
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
974-
self.sess().emit_fatal(LayoutSizeOverflow { span, error: err.to_string() })
974+
self.sess().emit_fatal(Spanned { span, node: err })
975975
} else {
976976
match fn_abi_request {
977977
FnAbiRequest::OfFnPtr { sig, extra_args } => {

compiler/rustc_codegen_llvm/src/errors.rs

-8
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,6 @@ pub(crate) struct SymbolAlreadyDefined<'a> {
5555
#[diag(codegen_llvm_branch_protection_requires_aarch64)]
5656
pub(crate) struct BranchProtectionRequiresAArch64;
5757

58-
#[derive(Diagnostic)]
59-
#[diag(codegen_llvm_layout_size_overflow)]
60-
pub(crate) struct LayoutSizeOverflow {
61-
#[primary_span]
62-
pub span: Span,
63-
pub error: String,
64-
}
65-
6658
#[derive(Diagnostic)]
6759
#[diag(codegen_llvm_invalid_minimum_alignment)]
6860
pub(crate) struct InvalidMinimumAlignment {

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

-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ codegen_llvm_symbol_already_defined =
2020
codegen_llvm_branch_protection_requires_aarch64 =
2121
-Zbranch-protection is only supported on aarch64
2222
23-
codegen_llvm_layout_size_overflow =
24-
{$error}
25-
2623
codegen_llvm_invalid_minimum_alignment =
2724
invalid minimum global alignment: {$err}
2825

compiler/rustc_middle/src/ty/layout.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ pub enum LayoutError<'tcx> {
189189
NormalizationFailure(Ty<'tcx>, NormalizationError<'tcx>),
190190
}
191191

192-
impl<'a> IntoDiagnostic<'a, !> for LayoutError<'a> {
193-
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, !> {
192+
impl IntoDiagnostic<'_, !> for LayoutError<'_> {
193+
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
194194
let mut diag = handler.struct_fatal("");
195195

196196
match self {
@@ -1126,8 +1126,8 @@ impl<'tcx> fmt::Display for FnAbiError<'tcx> {
11261126
}
11271127
}
11281128

1129-
impl<'tcx> IntoDiagnostic<'tcx, !> for FnAbiError<'tcx> {
1130-
fn into_diagnostic(self, handler: &'tcx Handler) -> DiagnosticBuilder<'tcx, !> {
1129+
impl IntoDiagnostic<'_, !> for FnAbiError<'_> {
1130+
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
11311131
handler.struct_fatal(self.to_string())
11321132
}
11331133
}

0 commit comments

Comments
 (0)