]>
Commit | Line | Data |
---|---|---|
9fa01778 | 1 | use crate::traits; |
e9174d1e SL |
2 | |
3 | use std::fmt; | |
4 | ||
dc9dc135 | 5 | // Structural impls for the structs in `traits`. |
e9174d1e | 6 | |
f035d41b | 7 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> { |
0bf4aa26 | 8 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
e9174d1e | 9 | match *self { |
1b1a35ee | 10 | super::ImplSource::UserDefined(ref v) => write!(f, "{:?}", v), |
e9174d1e | 11 | |
1b1a35ee | 12 | super::ImplSource::AutoImpl(ref t) => write!(f, "{:?}", t), |
e9174d1e | 13 | |
1b1a35ee | 14 | super::ImplSource::Closure(ref d) => write!(f, "{:?}", d), |
e9174d1e | 15 | |
1b1a35ee | 16 | super::ImplSource::Generator(ref d) => write!(f, "{:?}", d), |
ea8adc8c | 17 | |
1b1a35ee | 18 | super::ImplSource::FnPointer(ref d) => write!(f, "({:?})", d), |
e9174d1e | 19 | |
1b1a35ee | 20 | super::ImplSource::DiscriminantKind(ref d) => write!(f, "{:?}", d), |
f9f354fc | 21 | |
1b1a35ee | 22 | super::ImplSource::Object(ref d) => write!(f, "{:?}", d), |
e9174d1e | 23 | |
fc512014 XL |
24 | super::ImplSource::Param(ref n, ct) => { |
25 | write!(f, "ImplSourceParamData({:?}, {:?})", n, ct) | |
26 | } | |
e9174d1e | 27 | |
1b1a35ee | 28 | super::ImplSource::Builtin(ref d) => write!(f, "{:?}", d), |
a1dfa0c6 | 29 | |
1b1a35ee | 30 | super::ImplSource::TraitAlias(ref d) => write!(f, "{:?}", d), |
e9174d1e SL |
31 | } |
32 | } | |
33 | } | |
34 | ||
f035d41b | 35 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceUserDefinedData<'tcx, N> { |
0bf4aa26 | 36 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
94b46f34 XL |
37 | write!( |
38 | f, | |
f035d41b | 39 | "ImplSourceUserDefinedData(impl_def_id={:?}, substs={:?}, nested={:?})", |
94b46f34 XL |
40 | self.impl_def_id, self.substs, self.nested |
41 | ) | |
e9174d1e SL |
42 | } |
43 | } | |
44 | ||
f035d41b | 45 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceGeneratorData<'tcx, N> { |
0bf4aa26 | 46 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
94b46f34 XL |
47 | write!( |
48 | f, | |
f035d41b | 49 | "ImplSourceGeneratorData(generator_def_id={:?}, substs={:?}, nested={:?})", |
94b46f34 XL |
50 | self.generator_def_id, self.substs, self.nested |
51 | ) | |
ea8adc8c XL |
52 | } |
53 | } | |
54 | ||
f035d41b | 55 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceClosureData<'tcx, N> { |
0bf4aa26 | 56 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
94b46f34 XL |
57 | write!( |
58 | f, | |
f035d41b | 59 | "ImplSourceClosureData(closure_def_id={:?}, substs={:?}, nested={:?})", |
94b46f34 XL |
60 | self.closure_def_id, self.substs, self.nested |
61 | ) | |
e9174d1e SL |
62 | } |
63 | } | |
64 | ||
f035d41b | 65 | impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceBuiltinData<N> { |
0bf4aa26 | 66 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
f035d41b | 67 | write!(f, "ImplSourceBuiltinData(nested={:?})", self.nested) |
e9174d1e SL |
68 | } |
69 | } | |
70 | ||
f035d41b | 71 | impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceAutoImplData<N> { |
0bf4aa26 | 72 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
94b46f34 XL |
73 | write!( |
74 | f, | |
f035d41b | 75 | "ImplSourceAutoImplData(trait_def_id={:?}, nested={:?})", |
94b46f34 XL |
76 | self.trait_def_id, self.nested |
77 | ) | |
e9174d1e SL |
78 | } |
79 | } | |
80 | ||
f035d41b | 81 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceObjectData<'tcx, N> { |
0bf4aa26 | 82 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
94b46f34 XL |
83 | write!( |
84 | f, | |
f035d41b | 85 | "ImplSourceObjectData(upcast={:?}, vtable_base={}, nested={:?})", |
94b46f34 XL |
86 | self.upcast_trait_ref, self.vtable_base, self.nested |
87 | ) | |
a7813a04 XL |
88 | } |
89 | } | |
90 | ||
f035d41b | 91 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceFnPointerData<'tcx, N> { |
0bf4aa26 | 92 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
f035d41b | 93 | write!(f, "ImplSourceFnPointerData(fn_ty={:?}, nested={:?})", self.fn_ty, self.nested) |
e9174d1e SL |
94 | } |
95 | } | |
96 | ||
f035d41b | 97 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitAliasData<'tcx, N> { |
a1dfa0c6 XL |
98 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
99 | write!( | |
100 | f, | |
1b1a35ee | 101 | "ImplSourceTraitAliasData(alias_def_id={:?}, substs={:?}, nested={:?})", |
a1dfa0c6 XL |
102 | self.alias_def_id, self.substs, self.nested |
103 | ) | |
104 | } | |
105 | } | |
106 | ||
a7813a04 XL |
107 | /////////////////////////////////////////////////////////////////////////// |
108 | // Lift implementations | |
109 | ||
fc512014 | 110 | TrivialTypeFoldableAndLiftImpls! { |
3dfed10e XL |
111 | super::IfExpressionCause, |
112 | super::ImplSourceDiscriminantKindData, | |
a7813a04 | 113 | } |