|
1 | 1 | use crate::infer::error_reporting::nice_region_error::find_anon_type; |
2 | | -use rustc_errors::{self, fluent, AddSubdiagnostic}; |
| 2 | +use rustc_errors::{self, fluent, AddSubdiagnostic, IntoDiagnosticArg}; |
3 | 3 | use rustc_middle::ty::{self, TyCtxt}; |
4 | 4 | use rustc_span::{symbol::kw, Span}; |
5 | 5 |
|
@@ -29,7 +29,6 @@ impl<'a> DescriptionCtx<'a> { |
29 | 29 |
|
30 | 30 | ty::ReEmpty(ty::UniverseIndex::ROOT) => me.kind = "reempty", |
31 | 31 |
|
32 | | - // uh oh, hope no user ever sees THIS |
33 | 32 | ty::ReEmpty(ui) => { |
34 | 33 | me.kind = "reemptyuni"; |
35 | 34 | me.arg = format!("{:?}", ui); |
@@ -128,19 +127,23 @@ pub enum SuffixKind { |
128 | 127 | Continues, |
129 | 128 | } |
130 | 129 |
|
131 | | -impl PrefixKind { |
132 | | - fn add_to(self, diag: &mut rustc_errors::Diagnostic) { |
133 | | - match self { |
134 | | - Self::Empty => diag.set_arg("pref_kind", "empty"), |
135 | | - }; |
| 130 | +impl IntoDiagnosticArg for PrefixKind { |
| 131 | + fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { |
| 132 | + let kind = match self { |
| 133 | + Self::Empty => "empty", |
| 134 | + } |
| 135 | + .into(); |
| 136 | + rustc_errors::DiagnosticArgValue::Str(kind) |
136 | 137 | } |
137 | 138 | } |
138 | 139 |
|
139 | | -impl SuffixKind { |
140 | | - fn add_to(self, diag: &mut rustc_errors::Diagnostic) { |
141 | | - match self { |
142 | | - Self::Continues => diag.set_arg("suff_kind", "continues"), |
143 | | - }; |
| 140 | +impl IntoDiagnosticArg for SuffixKind { |
| 141 | + fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> { |
| 142 | + let kind = match self { |
| 143 | + Self::Continues => "continues", |
| 144 | + } |
| 145 | + .into(); |
| 146 | + rustc_errors::DiagnosticArgValue::Str(kind) |
144 | 147 | } |
145 | 148 | } |
146 | 149 |
|
@@ -170,7 +173,7 @@ impl AddSubdiagnostic for RegionExplanation<'_> { |
170 | 173 | diag.note(fluent::infer::region_explanation); |
171 | 174 | } |
172 | 175 | self.desc.add_to(diag); |
173 | | - self.prefix.add_to(diag); |
174 | | - self.suffix.add_to(diag); |
| 176 | + diag.set_arg("pref_kind", self.prefix); |
| 177 | + diag.set_arg("suff_kind", self.suffix); |
175 | 178 | } |
176 | 179 | } |
0 commit comments