Port LinkageConstOrMutType error
This commit is contained in:
parent
5d79d3c4bb
commit
60ee496c74
3 changed files with 14 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
use crate::base;
|
use crate::base;
|
||||||
use crate::common::{self, CodegenCx};
|
use crate::common::{self, CodegenCx};
|
||||||
use crate::debuginfo;
|
use crate::debuginfo;
|
||||||
use crate::errors::InvalidMinimumAlignment;
|
use crate::errors::{InvalidMinimumAlignment, LinkageConstOrMutType};
|
||||||
use crate::llvm::{self, True};
|
use crate::llvm::{self, True};
|
||||||
use crate::llvm_util;
|
use crate::llvm_util;
|
||||||
use crate::type_::Type;
|
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) {
|
match Align::from_bits(min) {
|
||||||
Ok(min) => align = align.max(min),
|
Ok(min) => align = align.max(min),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
cx.sess().emit_err(InvalidMinimumAlignment {
|
cx.sess().emit_err(InvalidMinimumAlignment { err });
|
||||||
err,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,10 +175,7 @@ fn check_and_apply_linkage<'ll, 'tcx>(
|
||||||
let llty2 = if let ty::RawPtr(ref mt) = ty.kind() {
|
let llty2 = if let ty::RawPtr(ref mt) = ty.kind() {
|
||||||
cx.layout_of(mt.ty).llvm_type(cx)
|
cx.layout_of(mt.ty).llvm_type(cx)
|
||||||
} else {
|
} else {
|
||||||
cx.sess().span_fatal(
|
cx.sess().emit_fatal(LinkageConstOrMutType { span: cx.tcx.def_span(def_id) })
|
||||||
cx.tcx.def_span(def_id),
|
|
||||||
"must have type `*const T` or `*mut T` due to `#[linkage]` attribute",
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
// Declare a symbol `foo` with the desired linkage.
|
// Declare a symbol `foo` with the desired linkage.
|
||||||
|
|
|
@ -71,5 +71,12 @@ pub(crate) struct LayoutSizeOverflow {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(codegen_llvm::invalid_minimum_alignment)]
|
#[diag(codegen_llvm::invalid_minimum_alignment)]
|
||||||
pub(crate) struct InvalidMinimumAlignment {
|
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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,3 +30,6 @@ codegen_llvm_layout_size_overflow =
|
||||||
|
|
||||||
codegen_llvm_invalid_minimum_alignment =
|
codegen_llvm_invalid_minimum_alignment =
|
||||||
invalid minimum global alignment: {$err}
|
invalid minimum global alignment: {$err}
|
||||||
|
|
||||||
|
codegen_llvm_linkage_const_or_mut_type =
|
||||||
|
must have type `*const T` or `*mut T` due to `#[linkage]` attribute
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue