@@ -13,7 +13,7 @@ use rustc_ast_ir::visit::VisitorResult;
1313use rustc_hir:: def:: Namespace ;
1414use rustc_span:: source_map:: Spanned ;
1515use rustc_target:: abi:: TyAndLayout ;
16- use rustc_type_ir:: { ConstKind , DebugWithInfcx , InferCtxtLike , WithInfcx } ;
16+ use rustc_type_ir:: ConstKind ;
1717
1818use std:: fmt:: { self , Debug } ;
1919
@@ -83,14 +83,6 @@ impl fmt::Debug for ty::LateParamRegion {
8383 }
8484}
8585
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- }
9486impl < ' tcx > fmt:: Debug for Ty < ' tcx > {
9587 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
9688 with_no_trimmed_paths ! ( fmt:: Debug :: fmt( self . kind( ) , f) )
@@ -121,91 +113,46 @@ impl<'tcx> fmt::Debug for ty::Clause<'tcx> {
121113 }
122114}
123115
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-
140116impl < ' tcx > fmt:: Debug for ty:: consts:: Expr < ' tcx > {
141117 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 {
151119 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, )
161122 }
162123 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)
165126 }
166127 ty:: ExprKind :: FunctionCall => {
167- let ( func_ty, func, args) = this . data . call_args ( ) ;
128+ let ( func_ty, func, args) = self . call_args ( ) ;
168129 let args = args. collect :: < Vec < _ > > ( ) ;
169- write ! ( f, "({:?}: {:?})(" , & this . wrap ( func) , & this . wrap ( func_ty) ) ?;
130+ write ! ( f, "({:?}: {:?})(" , func, func_ty) ?;
170131 for arg in args. iter ( ) . rev ( ) . skip ( 1 ) . rev ( ) {
171- write ! ( f, "{:?}, " , & this . wrap ( arg) ) ?;
132+ write ! ( f, "{:?}, " , arg) ?;
172133 }
173134 if let Some ( arg) = args. last ( ) {
174- write ! ( f, "{:?}" , & this . wrap ( arg) ) ?;
135+ write ! ( f, "{:?}" , arg) ?;
175136 }
176137
177138 write ! ( f, ")" )
178139 }
179140 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)
188143 }
189144 }
190145 }
191146}
192147
193148impl < ' tcx > fmt:: Debug for ty:: Const < ' tcx > {
194149 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 {
203150 // 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 ( ) {
205152 return ty:: tls:: with ( move |tcx| {
206153 // Somehow trying to lift the valtree results in lifetime errors, so we lift the
207154 // entire constant.
208- let lifted = tcx. lift ( * this . data ) . unwrap ( ) ;
155+ let lifted = tcx. lift ( * self ) . unwrap ( ) ;
209156 let ConstKind :: Value ( ty, valtree) = lifted. kind ( ) else {
210157 bug ! ( "we checked that this is a valtree" )
211158 } ;
@@ -215,7 +162,7 @@ impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::Const<'tcx> {
215162 } ) ;
216163 }
217164 // Fall back to something verbose.
218- write ! ( f, "{kind :?}" , kind = & this . map ( |data| data . kind( ) ) )
165+ write ! ( f, "{:?}" , self . kind( ) )
219166 }
220167}
221168
@@ -247,32 +194,12 @@ impl<'tcx> fmt::Debug for GenericArg<'tcx> {
247194 }
248195 }
249196}
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- }
262197
263198impl < ' tcx > fmt:: Debug for Region < ' tcx > {
264199 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
265200 write ! ( f, "{:?}" , self . kind( ) )
266201 }
267202}
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- }
276203
277204///////////////////////////////////////////////////////////////////////////
278205// Atomic structs
0 commit comments