Skip to content

Commit 7e00a48

Browse files
committed
Add LinkageConstOrMutType
1 parent 9363f0f commit 7e00a48

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

compiler/rustc_codegen_gcc/src/consts.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRan
1414

1515
use crate::base;
1616
use crate::context::CodegenCx;
17+
use crate::errors::LinkageConstOrMutType;
1718
use crate::type_of::LayoutGccExt;
1819

1920
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
@@ -368,10 +369,7 @@ fn check_and_apply_linkage<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, attrs: &Codeg
368369
cx.layout_of(mt.ty).gcc_type(cx, true)
369370
}
370371
else {
371-
cx.sess().span_fatal(
372-
span,
373-
"must have type `*const T` or `*mut T` due to `#[linkage]` attribute",
374-
)
372+
cx.sess().emit_fatal(LinkageConstOrMutType { span: span })
375373
};
376374
// Declare a symbol `foo` with the desired linkage.
377375
let global1 = cx.declare_global_with_linkage(&sym, llty2, base::global_linkage_to_gcc(linkage));
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
use rustc_macros::SessionDiagnostic;
2+
use rustc_span::Span;
23

34
#[derive(SessionDiagnostic)]
45
#[diag(codegen_gcc::ranlib_failure)]
56
pub(crate) struct RanlibFailure {
67
pub exit_code: Option<i32>
78
}
9+
10+
#[derive(SessionDiagnostic)]
11+
#[diag(codegen_gcc::linkage_const_or_mut_type)]
12+
pub(crate) struct LinkageConstOrMutType {
13+
#[primary_span]
14+
pub span: Span
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
codegen_gcc_ranlib_failure =
22
Ranlib exited with code {$exit_code}
3+
4+
codegen_gcc_linkage_const_or_mut_type =
5+
must have type `*const T` or `*mut T` due to `#[linkage]` attribute

0 commit comments

Comments
 (0)