diff options
| author | Xiretza <xiretza@xiretza.xyz> | 2022-09-22 18:39:17 +0200 |
|---|---|---|
| committer | Xiretza <xiretza@xiretza.xyz> | 2022-09-27 20:29:19 +0200 |
| commit | d7c64574e03f1d44c0a9e200b7dbeba98c50d8b3 (patch) | |
| tree | 8919fb00645f33b14da43004f27e50a70b65de78 /compiler/rustc_errors | |
| parent | 37fdcb4b364aeb8164a21a39dac984eb1e772872 (diff) | |
| download | rust-d7c64574e03f1d44c0a9e200b7dbeba98c50d8b3.tar.gz rust-d7c64574e03f1d44c0a9e200b7dbeba98c50d8b3.zip | |
Implement IntoDiagnosticArg for rustc_ast::token::Token(Kind)
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index fb409c578f6..5520e22e476 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -183,6 +183,18 @@ impl IntoDiagnosticArg for ast::Path { } } +impl IntoDiagnosticArg for ast::token::Token { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(pprust::token_to_string(&self)) + } +} + +impl IntoDiagnosticArg for ast::token::TokenKind { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(pprust::token_kind_to_string(&self)) + } +} + /// Trait implemented by error types. This should not be implemented manually. Instead, use /// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic]. #[cfg_attr(bootstrap, rustc_diagnostic_item = "AddSubdiagnostic")] |
