Skip to content

Commit 5d79d3c

Browse files
committed
Port InvalidMinimumAlignment
1 parent 39d363f commit 5d79d3c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::base;
22
use crate::common::{self, CodegenCx};
33
use crate::debuginfo;
4+
use crate::errors::InvalidMinimumAlignment;
45
use crate::llvm::{self, True};
56
use crate::llvm_util;
67
use crate::type_::Type;
@@ -146,7 +147,9 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align:
146147
match Align::from_bits(min) {
147148
Ok(min) => align = align.max(min),
148149
Err(err) => {
149-
cx.sess().err(&format!("invalid minimum global alignment: {}", err));
150+
cx.sess().emit_err(InvalidMinimumAlignment {
151+
err,
152+
});
150153
}
151154
}
152155
}

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ pub(crate) struct LayoutSizeOverflow {
6767
pub span: Span,
6868
pub error: String,
6969
}
70+
71+
#[derive(SessionDiagnostic)]
72+
#[diag(codegen_llvm::invalid_minimum_alignment)]
73+
pub(crate) struct InvalidMinimumAlignment {
74+
pub err: String
75+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ codegen_llvm_branch_protection_requires_aarch64 =
2727
2828
codegen_llvm_layout_size_overflow =
2929
{$error}
30+
31+
codegen_llvm_invalid_minimum_alignment =
32+
invalid minimum global alignment: {$err}

0 commit comments

Comments
 (0)