Skip to content

Commit d07b1cd

Browse files
committed
Call into_diagnostic_arg on Binder's contained value directly.
1 parent 3fb6d6b commit d07b1cd

File tree

1 file changed

+21
-3
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+21
-3
lines changed

compiler/rustc_middle/src/ty/sty.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
2727
use rustc_target::spec::abi::{self, Abi};
2828
use std::borrow::Cow;
2929
use std::cmp::Ordering;
30-
use std::fmt::{self, Display};
30+
use std::fmt;
3131
use std::marker::PhantomData;
3232
use std::ops::{ControlFlow, Deref, Range};
3333
use 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+
921933
pub type PolyExistentialTraitRef<'tcx> = Binder<'tcx, ExistentialTraitRef<'tcx>>;
922934

923935
impl<'tcx> PolyExistentialTraitRef<'tcx> {
@@ -1150,10 +1162,10 @@ impl<'tcx, T: IntoIterator> Binder<'tcx, T> {
11501162

11511163
impl<'tcx, T> IntoDiagnosticArg for Binder<'tcx, T>
11521164
where
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+
13761394
pub type PolyFnSig<'tcx> = Binder<'tcx, FnSig<'tcx>>;
13771395

13781396
impl<'tcx> PolyFnSig<'tcx> {

0 commit comments

Comments
 (0)