Call into_diagnostic_arg on Binder's contained value directly.

This commit is contained in:
IQuant 2023-04-10 18:08:35 +03:00
parent 3fb6d6b2f4
commit d07b1cd4a8

View File

@ -27,7 +27,7 @@ use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
use rustc_target::spec::abi::{self, Abi}; use rustc_target::spec::abi::{self, Abi};
use std::borrow::Cow; use std::borrow::Cow;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::fmt::{self, Display}; use std::fmt;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::ops::{ControlFlow, Deref, Range}; use std::ops::{ControlFlow, Deref, Range};
use ty::util::IntTypeExt; use ty::util::IntTypeExt;
@ -878,6 +878,12 @@ impl<'tcx> PolyTraitRef<'tcx> {
} }
} }
impl<'tcx> IntoDiagnosticArg for TraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
self.to_string().into_diagnostic_arg()
}
}
/// An existential reference to a trait, where `Self` is erased. /// An existential reference to a trait, where `Self` is erased.
/// For example, the trait object `Trait<'a, 'b, X, Y>` is: /// For example, the trait object `Trait<'a, 'b, X, Y>` is:
/// ```ignore (illustrative) /// ```ignore (illustrative)
@ -918,6 +924,12 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
} }
} }
impl<'tcx> IntoDiagnosticArg for ExistentialTraitRef<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
self.to_string().into_diagnostic_arg()
}
}
pub type PolyExistentialTraitRef<'tcx> = Binder<'tcx, ExistentialTraitRef<'tcx>>; pub type PolyExistentialTraitRef<'tcx> = Binder<'tcx, ExistentialTraitRef<'tcx>>;
impl<'tcx> PolyExistentialTraitRef<'tcx> { impl<'tcx> PolyExistentialTraitRef<'tcx> {
@ -1150,10 +1162,10 @@ impl<'tcx, T: IntoIterator> Binder<'tcx, T> {
impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T> impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
where where
Binder<'tcx, T>: Display, T: IntoDiagnosticArg,
{ {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
self.to_string().into_diagnostic_arg() self.0.into_diagnostic_arg()
} }
} }
@ -1373,6 +1385,12 @@ impl<'tcx> FnSig<'tcx> {
} }
} }
impl<'tcx> IntoDiagnosticArg for FnSig<'tcx> {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
self.to_string().into_diagnostic_arg()
}
}
pub type PolyFnSig<'tcx> = Binder<'tcx, FnSig<'tcx>>; pub type PolyFnSig<'tcx> = Binder<'tcx, FnSig<'tcx>>;
impl<'tcx> PolyFnSig<'tcx> { impl<'tcx> PolyFnSig<'tcx> {