@@ -13,7 +13,7 @@ use rustc_ast_ir::visit::VisitorResult;
13
13
use rustc_hir:: def:: Namespace ;
14
14
use rustc_span:: source_map:: Spanned ;
15
15
use rustc_target:: abi:: TyAndLayout ;
16
- use rustc_type_ir:: { ConstKind , DebugWithInfcx , InferCtxtLike , WithInfcx } ;
16
+ use rustc_type_ir:: ConstKind ;
17
17
18
18
use std:: fmt:: { self , Debug } ;
19
19
@@ -83,14 +83,6 @@ impl fmt::Debug for ty::LateParamRegion {
83
83
}
84
84
}
85
85
86
- impl < ' tcx > ty:: DebugWithInfcx < TyCtxt < ' tcx > > for Ty < ' tcx > {
87
- fn fmt < Infcx : InferCtxtLike < Interner = TyCtxt < ' tcx > > > (
88
- this : WithInfcx < ' _ , Infcx , & Self > ,
89
- f : & mut core:: fmt:: Formatter < ' _ > ,
90
- ) -> core:: fmt:: Result {
91
- this. data . fmt ( f)
92
- }
93
- }
94
86
impl < ' tcx > fmt:: Debug for Ty < ' tcx > {
95
87
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
96
88
with_no_trimmed_paths ! ( fmt:: Debug :: fmt( self . kind( ) , f) )
@@ -121,91 +113,46 @@ impl<'tcx> fmt::Debug for ty::Clause<'tcx> {
121
113
}
122
114
}
123
115
124
- impl < ' tcx > DebugWithInfcx < TyCtxt < ' tcx > > for Pattern < ' tcx > {
125
- fn fmt < Infcx : InferCtxtLike < Interner = TyCtxt < ' tcx > > > (
126
- this : WithInfcx < ' _ , Infcx , & Self > ,
127
- f : & mut core:: fmt:: Formatter < ' _ > ,
128
- ) -> core:: fmt:: Result {
129
- match & * * this. data {
130
- ty:: PatternKind :: Range { start, end, include_end } => f
131
- . debug_struct ( "Pattern::Range" )
132
- . field ( "start" , start)
133
- . field ( "end" , end)
134
- . field ( "include_end" , include_end)
135
- . finish ( ) ,
136
- }
137
- }
138
- }
139
-
140
116
impl < ' tcx > fmt:: Debug for ty:: consts:: Expr < ' tcx > {
141
117
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
142
- WithInfcx :: with_no_infcx ( self ) . fmt ( f)
143
- }
144
- }
145
- impl < ' tcx > DebugWithInfcx < TyCtxt < ' tcx > > for ty:: consts:: Expr < ' tcx > {
146
- fn fmt < Infcx : InferCtxtLike < Interner = TyCtxt < ' tcx > > > (
147
- this : WithInfcx < ' _ , Infcx , & Self > ,
148
- f : & mut core:: fmt:: Formatter < ' _ > ,
149
- ) -> core:: fmt:: Result {
150
- match this. data . kind {
118
+ match self . kind {
151
119
ty:: ExprKind :: Binop ( op) => {
152
- let ( lhs_ty, rhs_ty, lhs, rhs) = this. data . binop_args ( ) ;
153
- write ! (
154
- f,
155
- "({op:?}: ({:?}: {:?}), ({:?}: {:?}))" ,
156
- & this. wrap( lhs) ,
157
- & this. wrap( lhs_ty) ,
158
- & this. wrap( rhs) ,
159
- & this. wrap( rhs_ty) ,
160
- )
120
+ let ( lhs_ty, rhs_ty, lhs, rhs) = self . binop_args ( ) ;
121
+ write ! ( f, "({op:?}: ({:?}: {:?}), ({:?}: {:?}))" , lhs, lhs_ty, rhs, rhs_ty, )
161
122
}
162
123
ty:: ExprKind :: UnOp ( op) => {
163
- let ( rhs_ty, rhs) = this . data . unop_args ( ) ;
164
- write ! ( f, "({op:?}: ({:?}: {:?}))" , & this . wrap ( rhs) , & this . wrap ( rhs_ty) )
124
+ let ( rhs_ty, rhs) = self . unop_args ( ) ;
125
+ write ! ( f, "({op:?}: ({:?}: {:?}))" , rhs, rhs_ty)
165
126
}
166
127
ty:: ExprKind :: FunctionCall => {
167
- let ( func_ty, func, args) = this . data . call_args ( ) ;
128
+ let ( func_ty, func, args) = self . call_args ( ) ;
168
129
let args = args. collect :: < Vec < _ > > ( ) ;
169
- write ! ( f, "({:?}: {:?})(" , & this . wrap ( func) , & this . wrap ( func_ty) ) ?;
130
+ write ! ( f, "({:?}: {:?})(" , func, func_ty) ?;
170
131
for arg in args. iter ( ) . rev ( ) . skip ( 1 ) . rev ( ) {
171
- write ! ( f, "{:?}, " , & this . wrap ( arg) ) ?;
132
+ write ! ( f, "{:?}, " , arg) ?;
172
133
}
173
134
if let Some ( arg) = args. last ( ) {
174
- write ! ( f, "{:?}" , & this . wrap ( arg) ) ?;
135
+ write ! ( f, "{:?}" , arg) ?;
175
136
}
176
137
177
138
write ! ( f, ")" )
178
139
}
179
140
ty:: ExprKind :: Cast ( kind) => {
180
- let ( value_ty, value, to_ty) = this. data . cast_args ( ) ;
181
- write ! (
182
- f,
183
- "({kind:?}: ({:?}: {:?}), {:?})" ,
184
- & this. wrap( value) ,
185
- & this. wrap( value_ty) ,
186
- & this. wrap( to_ty)
187
- )
141
+ let ( value_ty, value, to_ty) = self . cast_args ( ) ;
142
+ write ! ( f, "({kind:?}: ({:?}: {:?}), {:?})" , value, value_ty, to_ty)
188
143
}
189
144
}
190
145
}
191
146
}
192
147
193
148
impl < ' tcx > fmt:: Debug for ty:: Const < ' tcx > {
194
149
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
195
- WithInfcx :: with_no_infcx ( self ) . fmt ( f)
196
- }
197
- }
198
- impl < ' tcx > DebugWithInfcx < TyCtxt < ' tcx > > for ty:: Const < ' tcx > {
199
- fn fmt < Infcx : InferCtxtLike < Interner = TyCtxt < ' tcx > > > (
200
- this : WithInfcx < ' _ , Infcx , & Self > ,
201
- f : & mut core:: fmt:: Formatter < ' _ > ,
202
- ) -> core:: fmt:: Result {
203
150
// If this is a value, we spend some effort to make it look nice.
204
- if let ConstKind :: Value ( _, _) = this . data . kind ( ) {
151
+ if let ConstKind :: Value ( _, _) = self . kind ( ) {
205
152
return ty:: tls:: with ( move |tcx| {
206
153
// Somehow trying to lift the valtree results in lifetime errors, so we lift the
207
154
// entire constant.
208
- let lifted = tcx. lift ( * this . data ) . unwrap ( ) ;
155
+ let lifted = tcx. lift ( * self ) . unwrap ( ) ;
209
156
let ConstKind :: Value ( ty, valtree) = lifted. kind ( ) else {
210
157
bug ! ( "we checked that this is a valtree" )
211
158
} ;
@@ -215,7 +162,7 @@ impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::Const<'tcx> {
215
162
} ) ;
216
163
}
217
164
// Fall back to something verbose.
218
- write ! ( f, "{kind :?}" , kind = & this . map ( |data| data . kind( ) ) )
165
+ write ! ( f, "{:?}" , self . kind( ) )
219
166
}
220
167
}
221
168
@@ -247,32 +194,12 @@ impl<'tcx> fmt::Debug for GenericArg<'tcx> {
247
194
}
248
195
}
249
196
}
250
- impl < ' tcx > DebugWithInfcx < TyCtxt < ' tcx > > for GenericArg < ' tcx > {
251
- fn fmt < Infcx : InferCtxtLike < Interner = TyCtxt < ' tcx > > > (
252
- this : WithInfcx < ' _ , Infcx , & Self > ,
253
- f : & mut core:: fmt:: Formatter < ' _ > ,
254
- ) -> core:: fmt:: Result {
255
- match this. data . unpack ( ) {
256
- GenericArgKind :: Lifetime ( lt) => write ! ( f, "{:?}" , & this. wrap( lt) ) ,
257
- GenericArgKind :: Const ( ct) => write ! ( f, "{:?}" , & this. wrap( ct) ) ,
258
- GenericArgKind :: Type ( ty) => write ! ( f, "{:?}" , & this. wrap( ty) ) ,
259
- }
260
- }
261
- }
262
197
263
198
impl < ' tcx > fmt:: Debug for Region < ' tcx > {
264
199
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
265
200
write ! ( f, "{:?}" , self . kind( ) )
266
201
}
267
202
}
268
- impl < ' tcx > DebugWithInfcx < TyCtxt < ' tcx > > for Region < ' tcx > {
269
- fn fmt < Infcx : InferCtxtLike < Interner = TyCtxt < ' tcx > > > (
270
- this : WithInfcx < ' _ , Infcx , & Self > ,
271
- f : & mut core:: fmt:: Formatter < ' _ > ,
272
- ) -> core:: fmt:: Result {
273
- write ! ( f, "{:?}" , & this. map( |data| data. kind( ) ) )
274
- }
275
- }
276
203
277
204
///////////////////////////////////////////////////////////////////////////
278
205
// Atomic structs
0 commit comments