rustc_symbol_mangling/
errors.rs1use std::fmt;
4
5use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
6use rustc_span::Span;
7
8pub struct TestOutput {
9 pub span: Span,
10 pub kind: Kind,
11 pub content: String,
12}
13
14impl<G: EmissionGuarantee> Diagnostic<'_, G> for TestOutput {
18 fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
19 let TestOutput { span, kind, content } = self;
20
21 Diag::new(dcx, level, ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0}({1})", kind, content))
})format!("{kind}({content})")).with_span(span)
22 }
23}
24
25pub enum Kind {
26 SymbolName,
27 Demangling,
28 DemanglingAlt,
29 DefPath,
30}
31
32impl fmt::Display for Kind {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 match self {
35 Kind::SymbolName => f.write_fmt(format_args!("symbol-name"))write!(f, "symbol-name"),
36 Kind::Demangling => f.write_fmt(format_args!("demangling"))write!(f, "demangling"),
37 Kind::DemanglingAlt => f.write_fmt(format_args!("demangling-alt"))write!(f, "demangling-alt"),
38 Kind::DefPath => f.write_fmt(format_args!("def-path"))write!(f, "def-path"),
39 }
40 }
41}