@@ -27,7 +27,7 @@ use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
2727use rustc_target:: spec:: abi:: { self , Abi } ;
2828use std:: borrow:: Cow ;
2929use std:: cmp:: Ordering ;
30- use std:: fmt:: { self , Display } ;
30+ use std:: fmt;
3131use std:: marker:: PhantomData ;
3232use std:: ops:: { ControlFlow , Deref , Range } ;
3333use ty:: util:: IntTypeExt ;
@@ -878,6 +878,12 @@ impl<'tcx> PolyTraitRef<'tcx> {
878878 }
879879}
880880
881+ impl < ' tcx > IntoDiagnosticArg for TraitRef < ' tcx > {
882+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
883+ self . to_string ( ) . into_diagnostic_arg ( )
884+ }
885+ }
886+
881887/// An existential reference to a trait, where `Self` is erased.
882888/// For example, the trait object `Trait<'a, 'b, X, Y>` is:
883889/// ```ignore (illustrative)
@@ -918,6 +924,12 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
918924 }
919925}
920926
927+ impl < ' tcx > IntoDiagnosticArg for ExistentialTraitRef < ' tcx > {
928+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
929+ self . to_string ( ) . into_diagnostic_arg ( )
930+ }
931+ }
932+
921933pub type PolyExistentialTraitRef < ' tcx > = Binder < ' tcx , ExistentialTraitRef < ' tcx > > ;
922934
923935impl < ' tcx > PolyExistentialTraitRef < ' tcx > {
@@ -1150,10 +1162,10 @@ impl<'tcx, T: IntoIterator> Binder<'tcx, T> {
11501162
11511163impl < ' tcx , T > IntoDiagnosticArg for Binder < ' tcx , T >
11521164where
1153- Binder < ' tcx , T > : Display ,
1165+ T : IntoDiagnosticArg ,
11541166{
11551167 fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
1156- self . to_string ( ) . into_diagnostic_arg ( )
1168+ self . 0 . into_diagnostic_arg ( )
11571169 }
11581170}
11591171
@@ -1373,6 +1385,12 @@ impl<'tcx> FnSig<'tcx> {
13731385 }
13741386}
13751387
1388+ impl < ' tcx > IntoDiagnosticArg for FnSig < ' tcx > {
1389+ fn into_diagnostic_arg ( self ) -> DiagnosticArgValue < ' static > {
1390+ self . to_string ( ) . into_diagnostic_arg ( )
1391+ }
1392+ }
1393+
13761394pub type PolyFnSig < ' tcx > = Binder < ' tcx , FnSig < ' tcx > > ;
13771395
13781396impl < ' tcx > PolyFnSig < ' tcx > {
0 commit comments