rustc_infer/traits/
structural_impls.rs

1use std::fmt;
2
3use rustc_middle::ty;
4
5use crate::traits;
6use crate::traits::project::Normalized;
7
8// Structural impls for the structs in `traits`.
9
10impl<'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)
13    }
14}
15
16impl<'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_internals()) {
19            write!(
20                f,
21                "Obligation(predicate={:?}, cause={:?}, param_env={:?}, depth={})",
22                self.predicate, self.cause, self.param_env, self.recursion_depth
23            )
24        } else {
25            write!(f, "Obligation(predicate={:?}, depth={})", self.predicate, self.recursion_depth)
26        }
27    }
28}
29
30impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        write!(f, "MismatchedProjectionTypes({:?})", self.err)
33    }
34}