1
Fork 0

Remove a comment and use IntoDiagnosticArg instead of add_to() where feasible

This commit is contained in:
Nikita Tomashevich 2022-09-02 16:05:00 +03:00
parent 3190522294
commit e750d7faa7
No known key found for this signature in database
GPG key ID: B29791D4D878E345

View file

@ -1,5 +1,5 @@
use crate::infer::error_reporting::nice_region_error::find_anon_type; 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_middle::ty::{self, TyCtxt};
use rustc_span::{symbol::kw, Span}; use rustc_span::{symbol::kw, Span};
@ -29,7 +29,6 @@ impl<'a> DescriptionCtx<'a> {
ty::ReEmpty(ty::UniverseIndex::ROOT) => me.kind = "reempty", ty::ReEmpty(ty::UniverseIndex::ROOT) => me.kind = "reempty",
// uh oh, hope no user ever sees THIS
ty::ReEmpty(ui) => { ty::ReEmpty(ui) => {
me.kind = "reemptyuni"; me.kind = "reemptyuni";
me.arg = format!("{:?}", ui); me.arg = format!("{:?}", ui);
@ -128,19 +127,23 @@ pub enum SuffixKind {
Continues, Continues,
} }
impl PrefixKind { impl IntoDiagnosticArg for PrefixKind {
fn add_to(self, diag: &mut rustc_errors::Diagnostic) { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
match self { let kind = match self {
Self::Empty => diag.set_arg("pref_kind", "empty"), Self::Empty => "empty",
}; }
.into();
rustc_errors::DiagnosticArgValue::Str(kind)
} }
} }
impl SuffixKind { impl IntoDiagnosticArg for SuffixKind {
fn add_to(self, diag: &mut rustc_errors::Diagnostic) { fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
match self { let kind = match self {
Self::Continues => diag.set_arg("suff_kind", "continues"), Self::Continues => "continues",
}; }
.into();
rustc_errors::DiagnosticArgValue::Str(kind)
} }
} }
@ -170,7 +173,7 @@ impl AddSubdiagnostic for RegionExplanation<'_> {
diag.note(fluent::infer::region_explanation); diag.note(fluent::infer::region_explanation);
} }
self.desc.add_to(diag); self.desc.add_to(diag);
self.prefix.add_to(diag); diag.set_arg("pref_kind", self.prefix);
self.suffix.add_to(diag); diag.set_arg("suff_kind", self.suffix);
} }
} }