summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_symbol_mangling/src/errors.rs
blob: 664d2543f1fdb384d475df29125b86fb21924230 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! Errors emitted by symbol_mangling.

use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
use rustc_macros::SessionDiagnostic;
use rustc_span::Span;

#[derive(SessionDiagnostic)]
#[diag(symbol_mangling::test_output)]
pub struct TestOutput {
    #[primary_span]
    pub span: Span,
    pub kind: Kind,
    pub content: String,
}

pub enum Kind {
    SymbolName,
    Demangling,
    DemanglingAlt,
    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",
        }
        .into();
        DiagnosticArgValue::Str(kind)
    }
}