diff options
| author | Michael Goulet <michael@errs.io> | 2022-06-28 22:09:59 -0700 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-07-08 03:47:31 +0000 |
| commit | ff9fd36aa4ed90051424560268108370bbb3749b (patch) | |
| tree | 7c75f1d0b37918f5f877f9b8efe09b884e47f739 /compiler/rustc_errors/src | |
| parent | 1c4afbd1de7a0aa548a4b8f184aede5c5954e63a (diff) | |
| download | rust-ff9fd36aa4ed90051424560268108370bbb3749b.tar.gz rust-ff9fd36aa4ed90051424560268108370bbb3749b.zip | |
Implement IntoDiagnosticArg for hir::ConstContext
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 0d1d017d874..9429ad1a897 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -5,6 +5,7 @@ use crate::{ }; use rustc_data_structures::stable_map::FxHashMap; use rustc_error_messages::FluentValue; +use rustc_hir as hir; use rustc_lint_defs::{Applicability, LintExpectationId}; use rustc_span::edition::LATEST_STABLE_EDITION; use rustc_span::symbol::{Ident, Symbol}; @@ -160,6 +161,16 @@ impl<'source> Into<FluentValue<'source>> for DiagnosticArgValue<'source> { } } +impl IntoDiagnosticArg for hir::ConstContext { + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { + DiagnosticArgValue::Str(Cow::Borrowed(match self { + hir::ConstContext::ConstFn => "constant function", + hir::ConstContext::Static(_) => "static", + hir::ConstContext::Const => "constant", + })) + } +} + /// Trait implemented by error types. This should not be implemented manually. Instead, use /// `#[derive(SessionSubdiagnostic)]` -- see [rustc_macros::SessionSubdiagnostic]. #[rustc_diagnostic_item = "AddSubdiagnostic"] |
