11use std:: collections:: VecDeque ;
2+ use std:: fmt;
23use std:: rc:: Rc ;
34
45use rustc_data_structures:: frozen:: Frozen ;
@@ -182,7 +183,7 @@ pub(crate) enum Cause {
182183/// For more information about this translation, see
183184/// `InferCtxt::process_registered_region_obligations` and
184185/// `InferCtxt::type_must_outlive` in `rustc_infer::infer::InferCtxt`.
185- #[ derive( Clone , Debug ) ]
186+ #[ derive( Clone ) ]
186187pub ( crate ) struct TypeTest < ' tcx > {
187188 /// The type `T` that must outlive the region.
188189 pub generic_kind : GenericKind < ' tcx > ,
@@ -198,6 +199,47 @@ pub(crate) struct TypeTest<'tcx> {
198199 pub verify_bound : VerifyBound < ' tcx > ,
199200}
200201
202+ impl fmt:: Debug for TypeTest < ' _ > {
203+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
204+ fn fmt_bound (
205+ f : & mut fmt:: Formatter < ' _ > ,
206+ generic_kind : GenericKind < ' _ > ,
207+ lower : RegionVid ,
208+ bound : & VerifyBound < ' _ > ,
209+ ) -> fmt:: Result {
210+ let fmt_bounds =
211+ |f : & mut fmt:: Formatter < ' _ > , bounds : & [ VerifyBound < ' _ > ] | -> fmt:: Result {
212+ let mut it = bounds. iter ( ) . peekable ( ) ;
213+ while let Some ( bound) = it. next ( ) {
214+ fmt_bound ( f, generic_kind, lower, bound) ?;
215+ if it. peek ( ) . is_some ( ) {
216+ write ! ( f, ", " ) ?
217+ }
218+ }
219+ Ok ( ( ) )
220+ } ;
221+ match bound {
222+ VerifyBound :: IfEq ( binder) => write ! ( f, "{:?} == {:?}" , generic_kind, binder) ,
223+ VerifyBound :: OutlivedBy ( region) => write ! ( f, "{region:?}: {lower:?}" ) ,
224+ VerifyBound :: AnyBound ( verify_bounds) => {
225+ write ! ( f, "Any[" ) ?;
226+ fmt_bounds ( f, verify_bounds) ?;
227+ write ! ( f, "]" )
228+ }
229+ VerifyBound :: AllBounds ( verify_bounds) => {
230+ write ! ( f, "All[" ) ?;
231+ fmt_bounds ( f, verify_bounds) ?;
232+ write ! ( f, "]" )
233+ }
234+ VerifyBound :: IsEmpty => write ! ( f, "Empty({lower:?})" ) ,
235+ }
236+ }
237+ write ! ( f, "TypeTest from {:?}[" , self . span) ?;
238+ fmt_bound ( f, self . generic_kind , self . lower_bound , & self . verify_bound ) ?;
239+ write ! ( f, "] ⊢ {:?}: {:?}" , self . generic_kind, self . lower_bound)
240+ }
241+ }
242+
201243/// When we have an unmet lifetime constraint, we try to propagate it outward (e.g. to a closure
202244/// environment). If we can't, it is an error.
203245#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
0 commit comments