Skip to content

Commit e750d7f

Browse files
committed
Remove a comment and use IntoDiagnosticArg instead of add_to() where feasible
1 parent 3190522 commit e750d7f

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

compiler/rustc_infer/src/errors/note_and_explain.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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};
33
use rustc_middle::ty::{self, TyCtxt};
44
use rustc_span::{symbol::kw, Span};
55

@@ -29,7 +29,6 @@ impl<'a> DescriptionCtx<'a> {
2929

3030
ty::ReEmpty(ty::UniverseIndex::ROOT) => me.kind = "reempty",
3131

32-
// uh oh, hope no user ever sees THIS
3332
ty::ReEmpty(ui) => {
3433
me.kind = "reemptyuni";
3534
me.arg = format!("{:?}", ui);
@@ -128,19 +127,23 @@ pub enum SuffixKind {
128127
Continues,
129128
}
130129

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)
136137
}
137138
}
138139

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)
144147
}
145148
}
146149

@@ -170,7 +173,7 @@ impl AddSubdiagnostic for RegionExplanation<'_> {
170173
diag.note(fluent::infer::region_explanation);
171174
}
172175
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);
175178
}
176179
}

0 commit comments

Comments
 (0)