From 5d79d3c4bb8768b4e8ee2b243a625bbfd740a696 Mon Sep 17 00:00:00 2001 From: SLASHLogin Date: Fri, 26 Aug 2022 10:30:43 +0200 Subject: [PATCH] Port InvalidMinimumAlignment --- compiler/rustc_codegen_llvm/src/consts.rs | 5 ++++- compiler/rustc_codegen_llvm/src/errors.rs | 6 ++++++ .../rustc_error_messages/locales/en-US/codegen_llvm.ftl | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index bf5ac4e503e..05fa87c8094 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -1,6 +1,7 @@ use crate::base; use crate::common::{self, CodegenCx}; use crate::debuginfo; +use crate::errors::InvalidMinimumAlignment; use crate::llvm::{self, True}; use crate::llvm_util; use crate::type_::Type; @@ -146,7 +147,9 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: match Align::from_bits(min) { Ok(min) => align = align.max(min), Err(err) => { - cx.sess().err(&format!("invalid minimum global alignment: {}", err)); + cx.sess().emit_err(InvalidMinimumAlignment { + err, + }); } } } diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index 95a12d98d5c..8c87d9eb1fb 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -67,3 +67,9 @@ pub(crate) struct LayoutSizeOverflow { pub span: Span, pub error: String, } + +#[derive(SessionDiagnostic)] +#[diag(codegen_llvm::invalid_minimum_alignment)] +pub(crate) struct InvalidMinimumAlignment { + pub err: String +} diff --git a/compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl b/compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl index 75c6547a444..1c38bbdce16 100644 --- a/compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl +++ b/compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl @@ -27,3 +27,6 @@ codegen_llvm_branch_protection_requires_aarch64 = codegen_llvm_layout_size_overflow = {$error} + +codegen_llvm_invalid_minimum_alignment = + invalid minimum global alignment: {$err}