diff options
| author | Nikita Tomashevich <quant3234@gmail.com> | 2022-09-02 16:05:00 +0300 |
|---|---|---|
| committer | Nikita Tomashevich <quant3234@gmail.com> | 2022-09-06 18:41:08 +0300 |
| commit | e750d7faa7e18fb3af51de96b35baebcce4123a2 (patch) | |
| tree | a522b380a0536aa3ddfedab6248cb5ef08671925 | |
| parent | 3190522294dac32db63b11b579f6b75a4f2f7d8e (diff) | |
| download | rust-e750d7faa7e18fb3af51de96b35baebcce4123a2.tar.gz rust-e750d7faa7e18fb3af51de96b35baebcce4123a2.zip | |
Remove a comment and use IntoDiagnosticArg instead of add_to() where feasible
| -rw-r--r-- | compiler/rustc_infer/src/errors/note_and_explain.rs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/compiler/rustc_infer/src/errors/note_and_explain.rs b/compiler/rustc_infer/src/errors/note_and_explain.rs index c9df277c744..6f1f9522c86 100644 --- a/compiler/rustc_infer/src/errors/note_and_explain.rs +++ b/compiler/rustc_infer/src/errors/note_and_explain.rs @@ -1,5 +1,5 @@ use crate::infer::error_reporting::nice_region_error::find_anon_type; -use rustc_errors::{self, fluent, AddSubdiagnostic}; +use rustc_errors::{self, fluent, AddSubdiagnostic, IntoDiagnosticArg}; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::{symbol::kw, Span}; @@ -29,7 +29,6 @@ impl<'a> DescriptionCtx<'a> { ty::ReEmpty(ty::UniverseIndex::ROOT) => me.kind = "reempty", - // uh oh, hope no user ever sees THIS ty::ReEmpty(ui) => { me.kind = "reemptyuni"; me.arg = format!("{:?}", ui); @@ -128,19 +127,23 @@ pub enum SuffixKind { Continues, } -impl PrefixKind { - fn add_to(self, diag: &mut rustc_errors::Diagnostic) { - match self { - Self::Empty => diag.set_arg("pref_kind", "empty"), - }; +impl IntoDiagnosticArg for PrefixKind { + fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { + let kind = match self { + Self::Empty => "empty", + } + .into(); + rustc_errors::DiagnosticArgValue::Str(kind) } } -impl SuffixKind { - fn add_to(self, diag: &mut rustc_errors::Diagnostic) { - match self { - Self::Continues => diag.set_arg("suff_kind", "continues"), - }; +impl IntoDiagnosticArg for SuffixKind { + fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { + let kind = match self { + Self::Continues => "continues", + } + .into(); + rustc_errors::DiagnosticArgValue::Str(kind) } } @@ -170,7 +173,7 @@ impl AddSubdiagnostic for RegionExplanation<'_> { diag.note(fluent::infer::region_explanation); } self.desc.add_to(diag); - self.prefix.add_to(diag); - self.suffix.add_to(diag); + diag.set_arg("pref_kind", self.prefix); + diag.set_arg("suff_kind", self.suffix); } } |
