diff options
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/errors.rs | 9 |
2 files changed, 11 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 05fa87c8094..07c46e93632 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -1,7 +1,7 @@ use crate::base; use crate::common::{self, CodegenCx}; use crate::debuginfo; -use crate::errors::InvalidMinimumAlignment; +use crate::errors::{InvalidMinimumAlignment, LinkageConstOrMutType}; use crate::llvm::{self, True}; use crate::llvm_util; use crate::type_::Type; @@ -147,9 +147,7 @@ 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().emit_err(InvalidMinimumAlignment { - err, - }); + cx.sess().emit_err(InvalidMinimumAlignment { err }); } } } @@ -177,10 +175,7 @@ fn check_and_apply_linkage<'ll, 'tcx>( let llty2 = if let ty::RawPtr(ref mt) = ty.kind() { cx.layout_of(mt.ty).llvm_type(cx) } else { - cx.sess().span_fatal( - cx.tcx.def_span(def_id), - "must have type `*const T` or `*mut T` due to `#[linkage]` attribute", - ) + cx.sess().emit_fatal(LinkageConstOrMutType { span: cx.tcx.def_span(def_id) }) }; unsafe { // Declare a symbol `foo` with the desired linkage. diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index 8c87d9eb1fb..2661bd3cb99 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -71,5 +71,12 @@ pub(crate) struct LayoutSizeOverflow { #[derive(SessionDiagnostic)] #[diag(codegen_llvm::invalid_minimum_alignment)] pub(crate) struct InvalidMinimumAlignment { - pub err: String + pub err: String, +} + +#[derive(SessionDiagnostic)] +#[diag(codegen_llvm::linkage_const_or_mut_type)] +pub(crate) struct LinkageConstOrMutType { + #[primary_span] + pub span: Span, } |
