Remove rustc_symbol_mangling/messages.ftl
.
It contains a single message that (a) doesn't contain any natural language, and (b) is only used in tests.
This commit is contained in:
parent
99592fdfa1
commit
f4a9d29c50
6 changed files with 26 additions and 24 deletions
|
@ -1,18 +1,32 @@
|
|||
//! Errors emitted by symbol_mangling.
|
||||
|
||||
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
|
||||
use rustc_macros::Diagnostic;
|
||||
use rustc_errors::{ErrorGuaranteed, IntoDiagnostic};
|
||||
use rustc_span::Span;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(symbol_mangling_test_output)]
|
||||
pub struct TestOutput {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub kind: Kind,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
// This diagnostic doesn't need translation because (a) it doesn't contain any
|
||||
// natural language, and (b) it's only used in tests. So we construct it
|
||||
// manually and avoid the fluent machinery.
|
||||
impl IntoDiagnostic<'_> for TestOutput {
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'_ rustc_errors::Handler,
|
||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||
let TestOutput { span, kind, content } = self;
|
||||
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
let mut diag = handler.struct_err(format!("{kind}({content})"));
|
||||
diag.set_span(span);
|
||||
diag
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Kind {
|
||||
SymbolName,
|
||||
Demangling,
|
||||
|
@ -20,15 +34,13 @@ pub enum Kind {
|
|||
DefPath,
|
||||
}
|
||||
|
||||
impl IntoDiagnosticArg for Kind {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
let kind = match self {
|
||||
Kind::SymbolName => "symbol-name",
|
||||
Kind::Demangling => "demangling",
|
||||
Kind::DemanglingAlt => "demangling-alt",
|
||||
Kind::DefPath => "def-path",
|
||||
impl fmt::Display for Kind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Kind::SymbolName => write!(f, "symbol-name"),
|
||||
Kind::Demangling => write!(f, "demangling"),
|
||||
Kind::DemanglingAlt => write!(f, "demangling-alt"),
|
||||
Kind::DefPath => write!(f, "def-path"),
|
||||
}
|
||||
.into();
|
||||
DiagnosticArgValue::Str(kind)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,8 +103,6 @@ extern crate rustc_middle;
|
|||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
|
||||
use rustc_fluent_macro::fluent_messages;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
|
@ -121,8 +119,6 @@ pub mod errors;
|
|||
pub mod test;
|
||||
pub mod typeid;
|
||||
|
||||
fluent_messages! { "../messages.ftl" }
|
||||
|
||||
/// This function computes the symbol name for the given `instance` and the
|
||||
/// given instantiating crate. That is, if you know that instance X is
|
||||
/// instantiated in crate Y, this is the symbol name this instance would have.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue