2 use crate::traits
::project
::Normalized
;
4 use rustc_middle
::ty
::fold
::{TypeFoldable, TypeFolder, TypeVisitor}
;
8 // Structural impls for the structs in `traits`.
10 impl<'tcx
, T
: fmt
::Debug
> fmt
::Debug
for Normalized
<'tcx
, T
> {
11 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
12 write
!(f
, "Normalized({:?}, {:?})", self.value
, self.obligations
)
16 impl<'tcx
, O
: fmt
::Debug
> fmt
::Debug
for traits
::Obligation
<'tcx
, O
> {
17 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
18 if ty
::tls
::with(|tcx
| tcx
.sess
.verbose()) {
21 "Obligation(predicate={:?}, cause={:?}, param_env={:?}, depth={})",
22 self.predicate
, self.cause
, self.param_env
, self.recursion_depth
25 write
!(f
, "Obligation(predicate={:?}, depth={})", self.predicate
, self.recursion_depth
)
30 impl<'tcx
> fmt
::Debug
for traits
::FulfillmentError
<'tcx
> {
31 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
32 write
!(f
, "FulfillmentError({:?},{:?})", self.obligation
, self.code
)
36 impl<'tcx
> fmt
::Debug
for traits
::FulfillmentErrorCode
<'tcx
> {
37 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
39 super::CodeSelectionError(ref e
) => write
!(f
, "{:?}", e
),
40 super::CodeProjectionError(ref e
) => write
!(f
, "{:?}", e
),
41 super::CodeSubtypeError(ref a
, ref b
) => {
42 write
!(f
, "CodeSubtypeError({:?}, {:?})", a
, b
)
44 super::CodeConstEquateError(ref a
, ref b
) => {
45 write
!(f
, "CodeConstEquateError({:?}, {:?})", a
, b
)
47 super::CodeAmbiguity
=> write
!(f
, "Ambiguity"),
52 impl<'tcx
> fmt
::Debug
for traits
::MismatchedProjectionTypes
<'tcx
> {
53 fn fmt(&self, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
{
54 write
!(f
, "MismatchedProjectionTypes({:?})", self.err
)
58 ///////////////////////////////////////////////////////////////////////////
59 // TypeFoldable implementations.
61 impl<'tcx
, O
: TypeFoldable
<'tcx
>> TypeFoldable
<'tcx
> for traits
::Obligation
<'tcx
, O
> {
62 fn super_fold_with
<F
: TypeFolder
<'tcx
>>(&self, folder
: &mut F
) -> Self {
64 cause
: self.cause
.clone(),
65 recursion_depth
: self.recursion_depth
,
66 predicate
: self.predicate
.fold_with(folder
),
67 param_env
: self.param_env
.fold_with(folder
),
71 fn super_visit_with
<V
: TypeVisitor
<'tcx
>>(&self, visitor
: &mut V
) -> bool
{
72 self.predicate
.visit_with(visitor
)