11//! Things related to IR printing in the next-trait-solver.
22
3- use std:: any:: type_name_of_val;
4-
53use rustc_type_ir:: { self as ty, ir_print:: IrPrint } ;
64
75use super :: SolverDefId ;
@@ -82,7 +80,10 @@ impl<'db> IrPrint<ty::TraitPredicate<Self>> for DbInterner<'db> {
8280 t : & ty:: TraitPredicate < Self > ,
8381 fmt : & mut std:: fmt:: Formatter < ' _ > ,
8482 ) -> std:: fmt:: Result {
85- fmt. write_str ( & format ! ( "TODO: {:?}" , type_name_of_val( t) ) )
83+ match t. polarity {
84+ ty:: PredicatePolarity :: Positive => write ! ( fmt, "{:?}" , t. trait_ref) ,
85+ ty:: PredicatePolarity :: Negative => write ! ( fmt, "!{:?}" , t. trait_ref) ,
86+ }
8687 }
8788}
8889impl < ' db > IrPrint < rustc_type_ir:: HostEffectPredicate < Self > > for DbInterner < ' db > {
@@ -97,7 +98,11 @@ impl<'db> IrPrint<rustc_type_ir::HostEffectPredicate<Self>> for DbInterner<'db>
9798 t : & rustc_type_ir:: HostEffectPredicate < Self > ,
9899 fmt : & mut std:: fmt:: Formatter < ' _ > ,
99100 ) -> std:: fmt:: Result {
100- fmt. write_str ( & format ! ( "TODO: {:?}" , type_name_of_val( t) ) )
101+ let prefix = match t. constness {
102+ ty:: BoundConstness :: Const => "const" ,
103+ ty:: BoundConstness :: Maybe => "[const]" ,
104+ } ;
105+ write ! ( fmt, "{prefix} {:?}" , t. trait_ref)
101106 }
102107}
103108impl < ' db > IrPrint < ty:: ExistentialTraitRef < Self > > for DbInterner < ' db > {
@@ -183,7 +188,7 @@ impl<'db> IrPrint<ty::NormalizesTo<Self>> for DbInterner<'db> {
183188 t : & ty:: NormalizesTo < Self > ,
184189 fmt : & mut std:: fmt:: Formatter < ' _ > ,
185190 ) -> std:: fmt:: Result {
186- fmt . write_str ( & format ! ( "TODO: {:?}", type_name_of_val ( t ) ) )
191+ write ! ( fmt , "NormalizesTo({} -> {:?}) ", t . alias , t . term )
187192 }
188193}
189194impl < ' db > IrPrint < ty:: SubtypePredicate < Self > > for DbInterner < ' db > {
@@ -198,7 +203,7 @@ impl<'db> IrPrint<ty::SubtypePredicate<Self>> for DbInterner<'db> {
198203 t : & ty:: SubtypePredicate < Self > ,
199204 fmt : & mut std:: fmt:: Formatter < ' _ > ,
200205 ) -> std:: fmt:: Result {
201- fmt . write_str ( & format ! ( "TODO: {:?}", type_name_of_val ( t ) ) )
206+ write ! ( fmt , "{:?} <: {:?}", t . a , t . b )
202207 }
203208}
204209impl < ' db > IrPrint < ty:: CoercePredicate < Self > > for DbInterner < ' db > {
@@ -210,7 +215,7 @@ impl<'db> IrPrint<ty::CoercePredicate<Self>> for DbInterner<'db> {
210215 t : & ty:: CoercePredicate < Self > ,
211216 fmt : & mut std:: fmt:: Formatter < ' _ > ,
212217 ) -> std:: fmt:: Result {
213- fmt . write_str ( & format ! ( "TODO: {:?}", type_name_of_val ( t ) ) )
218+ write ! ( fmt , "CoercePredicate({:?} -> {:?}) ", t . a , t . b )
214219 }
215220}
216221impl < ' db > IrPrint < ty:: FnSig < Self > > for DbInterner < ' db > {
@@ -219,7 +224,9 @@ impl<'db> IrPrint<ty::FnSig<Self>> for DbInterner<'db> {
219224 }
220225
221226 fn print_debug ( t : & ty:: FnSig < Self > , fmt : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
222- fmt. write_str ( & format ! ( "TODO: {:?}" , type_name_of_val( t) ) )
227+ let tys = t. inputs_and_output . as_slice ( ) ;
228+ let ( output, inputs) = tys. split_last ( ) . unwrap ( ) ;
229+ write ! ( fmt, "fn({:?}) -> {:?}" , inputs, output)
223230 }
224231}
225232
@@ -235,6 +242,10 @@ impl<'db> IrPrint<rustc_type_ir::PatternKind<DbInterner<'db>>> for DbInterner<'d
235242 t : & rustc_type_ir:: PatternKind < DbInterner < ' db > > ,
236243 fmt : & mut std:: fmt:: Formatter < ' _ > ,
237244 ) -> std:: fmt:: Result {
238- fmt. write_str ( & format ! ( "TODO: {:?}" , type_name_of_val( t) ) )
245+ match t {
246+ ty:: PatternKind :: Range { start, end } => write ! ( fmt, "{:?}..={:?}" , start, end) ,
247+ ty:: PatternKind :: Or ( list) => write ! ( fmt, "or({:?})" , list) ,
248+ ty:: PatternKind :: NotNull => fmt. write_str ( "!null" ) ,
249+ }
239250 }
240251}
0 commit comments