@@ -102,48 +102,6 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
102
102
Some ( write ( ) )
103
103
}
104
104
105
- fn debug_application_ty (
106
- application_ty : & chalk_ir:: ApplicationTy < Self > ,
107
- fmt : & mut fmt:: Formatter < ' _ > ,
108
- ) -> Option < fmt:: Result > {
109
- match application_ty. name {
110
- chalk_ir:: TypeName :: Ref ( mutbl) => {
111
- let data = application_ty. substitution . interned ( ) ;
112
- match ( & * * data[ 0 ] . interned ( ) , & * * data[ 1 ] . interned ( ) ) {
113
- (
114
- chalk_ir:: GenericArgData :: Lifetime ( lifetime) ,
115
- chalk_ir:: GenericArgData :: Ty ( ty) ,
116
- ) => Some ( match mutbl {
117
- chalk_ir:: Mutability :: Not => write ! ( fmt, "(&{:?} {:?})" , lifetime, ty) ,
118
- chalk_ir:: Mutability :: Mut => write ! ( fmt, "(&{:?} mut {:?})" , lifetime, ty) ,
119
- } ) ,
120
- _ => unreachable ! ( ) ,
121
- }
122
- }
123
- chalk_ir:: TypeName :: Array => {
124
- let data = application_ty. substitution . interned ( ) ;
125
- match ( & * * data[ 0 ] . interned ( ) , & * * data[ 1 ] . interned ( ) ) {
126
- ( chalk_ir:: GenericArgData :: Ty ( ty) , chalk_ir:: GenericArgData :: Const ( len) ) => {
127
- Some ( write ! ( fmt, "[{:?}; {:?}]" , ty, len) )
128
- }
129
- _ => unreachable ! ( ) ,
130
- }
131
- }
132
- chalk_ir:: TypeName :: Slice => {
133
- let data = application_ty. substitution . interned ( ) ;
134
- let ty = match & * * data[ 0 ] . interned ( ) {
135
- chalk_ir:: GenericArgData :: Ty ( t) => t,
136
- _ => unreachable ! ( ) ,
137
- } ;
138
- Some ( write ! ( fmt, "[{:?}]" , ty) )
139
- }
140
- _ => {
141
- let chalk_ir:: ApplicationTy { name, substitution } = application_ty;
142
- Some ( write ! ( fmt, "{:?}{:?}" , name, chalk_ir:: debug:: Angle ( substitution. interned( ) ) ) )
143
- }
144
- }
145
- }
146
-
147
105
fn debug_substitution (
148
106
substitution : & chalk_ir:: Substitution < Self > ,
149
107
fmt : & mut fmt:: Formatter < ' _ > ,
@@ -174,6 +132,32 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
174
132
Some ( write ! ( fmt, "{:?}" , clauses. interned( ) ) )
175
133
}
176
134
135
+ fn debug_ty ( ty : & chalk_ir:: Ty < Self > , fmt : & mut fmt:: Formatter < ' _ > ) -> Option < fmt:: Result > {
136
+ match & ty. interned ( ) . kind {
137
+ chalk_ir:: TyKind :: Ref ( chalk_ir:: Mutability :: Not , lifetime, ty) => {
138
+ Some ( write ! ( fmt, "(&{:?} {:?})" , lifetime, ty) )
139
+ }
140
+ chalk_ir:: TyKind :: Ref ( chalk_ir:: Mutability :: Mut , lifetime, ty) => {
141
+ Some ( write ! ( fmt, "(&{:?} mut {:?})" , lifetime, ty) )
142
+ }
143
+ chalk_ir:: TyKind :: Array ( ty, len) => Some ( write ! ( fmt, "[{:?}; {:?}]" , ty, len) ) ,
144
+ chalk_ir:: TyKind :: Slice ( ty) => Some ( write ! ( fmt, "[{:?}]" , ty) ) ,
145
+ chalk_ir:: TyKind :: Tuple ( len, substs) => Some ( ( || {
146
+ write ! ( fmt, "(" ) ?;
147
+ for ( idx, substitution) in substs. interned ( ) . iter ( ) . enumerate ( ) {
148
+ if idx == * len && * len != 1 {
149
+ // Don't add a trailing comma if the tuple has more than one element
150
+ write ! ( fmt, "{:?}" , substitution) ?;
151
+ } else {
152
+ write ! ( fmt, "{:?}," , substitution) ?;
153
+ }
154
+ }
155
+ write ! ( fmt, ")" )
156
+ } ) ( ) ) ,
157
+ _ => None ,
158
+ }
159
+ }
160
+
177
161
fn debug_alias (
178
162
alias_ty : & chalk_ir:: AliasTy < Self > ,
179
163
fmt : & mut fmt:: Formatter < ' _ > ,
0 commit comments