]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_middle/src/traits/structural_impls.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_middle / src / traits / structural_impls.rs
CommitLineData
9fa01778 1use crate::traits;
e9174d1e
SL
2
3use std::fmt;
4
dc9dc135 5// Structural impls for the structs in `traits`.
e9174d1e 6
f035d41b 7impl<'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
6a06907d
XL
22 super::ImplSource::Pointee(ref d) => write!(f, "{:?}", d),
23
1b1a35ee 24 super::ImplSource::Object(ref d) => write!(f, "{:?}", d),
e9174d1e 25
fc512014
XL
26 super::ImplSource::Param(ref n, ct) => {
27 write!(f, "ImplSourceParamData({:?}, {:?})", n, ct)
28 }
e9174d1e 29
1b1a35ee 30 super::ImplSource::Builtin(ref d) => write!(f, "{:?}", d),
a1dfa0c6 31
1b1a35ee 32 super::ImplSource::TraitAlias(ref d) => write!(f, "{:?}", d),
94222f64
XL
33
34 super::ImplSource::TraitUpcasting(ref d) => write!(f, "{:?}", d),
c295e0f8 35
5e7ed085 36 super::ImplSource::ConstDestruct(ref d) => write!(f, "{:?}", d),
e9174d1e
SL
37 }
38 }
39}
40
f035d41b 41impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceUserDefinedData<'tcx, N> {
0bf4aa26 42 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94b46f34
XL
43 write!(
44 f,
f035d41b 45 "ImplSourceUserDefinedData(impl_def_id={:?}, substs={:?}, nested={:?})",
94b46f34
XL
46 self.impl_def_id, self.substs, self.nested
47 )
e9174d1e
SL
48 }
49}
50
f035d41b 51impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceGeneratorData<'tcx, N> {
0bf4aa26 52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94b46f34
XL
53 write!(
54 f,
f035d41b 55 "ImplSourceGeneratorData(generator_def_id={:?}, substs={:?}, nested={:?})",
94b46f34
XL
56 self.generator_def_id, self.substs, self.nested
57 )
ea8adc8c
XL
58 }
59}
60
f035d41b 61impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceClosureData<'tcx, N> {
0bf4aa26 62 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94b46f34
XL
63 write!(
64 f,
f035d41b 65 "ImplSourceClosureData(closure_def_id={:?}, substs={:?}, nested={:?})",
94b46f34
XL
66 self.closure_def_id, self.substs, self.nested
67 )
e9174d1e
SL
68 }
69}
70
f035d41b 71impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceBuiltinData<N> {
0bf4aa26 72 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f035d41b 73 write!(f, "ImplSourceBuiltinData(nested={:?})", self.nested)
e9174d1e
SL
74 }
75}
76
a2a8927a 77impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitUpcastingData<'tcx, N> {
94222f64
XL
78 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
79 write!(
80 f,
81 "ImplSourceTraitUpcastingData(upcast={:?}, vtable_vptr_slot={:?}, nested={:?})",
82 self.upcast_trait_ref, self.vtable_vptr_slot, self.nested
83 )
84 }
85}
86
f035d41b 87impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceAutoImplData<N> {
0bf4aa26 88 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94b46f34
XL
89 write!(
90 f,
f035d41b 91 "ImplSourceAutoImplData(trait_def_id={:?}, nested={:?})",
94b46f34
XL
92 self.trait_def_id, self.nested
93 )
e9174d1e
SL
94 }
95}
96
f035d41b 97impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceObjectData<'tcx, N> {
0bf4aa26 98 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94b46f34
XL
99 write!(
100 f,
f035d41b 101 "ImplSourceObjectData(upcast={:?}, vtable_base={}, nested={:?})",
94b46f34
XL
102 self.upcast_trait_ref, self.vtable_base, self.nested
103 )
a7813a04
XL
104 }
105}
106
f035d41b 107impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceFnPointerData<'tcx, N> {
0bf4aa26 108 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f035d41b 109 write!(f, "ImplSourceFnPointerData(fn_ty={:?}, nested={:?})", self.fn_ty, self.nested)
e9174d1e
SL
110 }
111}
112
f035d41b 113impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitAliasData<'tcx, N> {
a1dfa0c6
XL
114 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
115 write!(
116 f,
1b1a35ee 117 "ImplSourceTraitAliasData(alias_def_id={:?}, substs={:?}, nested={:?})",
a1dfa0c6
XL
118 self.alias_def_id, self.substs, self.nested
119 )
120 }
121}
122
5e7ed085 123impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceConstDestructData<N> {
5099ac24 124 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5e7ed085 125 write!(f, "ImplSourceConstDestructData(nested={:?})", self.nested)
5099ac24
FG
126 }
127}
128
a7813a04
XL
129///////////////////////////////////////////////////////////////////////////
130// Lift implementations
131
fc512014 132TrivialTypeFoldableAndLiftImpls! {
3dfed10e
XL
133 super::IfExpressionCause,
134 super::ImplSourceDiscriminantKindData,
6a06907d 135 super::ImplSourcePointeeData,
a7813a04 136}