Port symbol_already_defined
error
This commit is contained in:
parent
4c625dc682
commit
9f0c16576b
3 changed files with 13 additions and 4 deletions
|
@ -2,6 +2,7 @@ use rustc_errors::fluent;
|
|||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_macros::SessionDiagnostic;
|
||||
use rustc_session::SessionDiagnostic;
|
||||
use rustc_span::Span;
|
||||
|
||||
pub(crate) enum UnknownCTargetFeature<'a> {
|
||||
UnknownFeaturePrefix { feature: &'a str },
|
||||
|
@ -46,3 +47,11 @@ pub(crate) struct ErrorCreatingImportLibrary<'a> {
|
|||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_llvm::instrument_coverage_requires_llvm_12)]
|
||||
pub(crate) struct InstrumentCoverageRequiresLLVM12;
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[diag(codegen_llvm::SymbolAlreadyDefined)]
|
||||
pub(crate) struct SymbolAlreadyDefined<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub symbol_name: &'a str,
|
||||
}
|
||||
|
|
|
@ -25,10 +25,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> {
|
|||
let llty = self.layout_of(ty).llvm_type(self);
|
||||
|
||||
let g = self.define_global(symbol_name, llty).unwrap_or_else(|| {
|
||||
self.sess().span_fatal(
|
||||
self.tcx.def_span(def_id),
|
||||
&format!("symbol `{}` is already defined", symbol_name),
|
||||
)
|
||||
self.sess().emit_fatal(SymbolAlreadyDefined { span: self.tcx.def_span(def_id), symbol_name })
|
||||
});
|
||||
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue