22//! `ty` form from the HIR.
33
44use rustc_hir:: LangItem ;
5+ use rustc_middle:: ty:: Binder ;
56use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt } ;
67use rustc_span:: Span ;
78
@@ -23,52 +24,58 @@ use rustc_span::Span;
2324/// include the self type (e.g., `trait_bounds`) but in others we do not
2425#[ derive( Default , PartialEq , Eq , Clone , Debug ) ]
2526pub struct Bounds < ' tcx > {
26- pub predicates : Vec < ( ty:: Predicate < ' tcx > , Span ) > ,
27+ pub predicates : Vec < ( Binder < ' tcx , ty:: Clause < ' tcx > > , Span ) > ,
2728}
2829
2930impl < ' tcx > Bounds < ' tcx > {
3031 pub fn push_region_bound (
3132 & mut self ,
32- tcx : TyCtxt < ' tcx > ,
33+ _tcx : TyCtxt < ' tcx > ,
3334 region : ty:: PolyTypeOutlivesPredicate < ' tcx > ,
3435 span : Span ,
3536 ) {
36- self . predicates . push ( ( region. to_predicate ( tcx ) , span) ) ;
37+ self . predicates . push ( ( region. map_bound ( |p| ty :: Clause :: TypeOutlives ( p ) ) , span) ) ;
3738 }
3839
3940 pub fn push_trait_bound (
4041 & mut self ,
41- tcx : TyCtxt < ' tcx > ,
42+ _tcx : TyCtxt < ' tcx > ,
4243 trait_ref : ty:: PolyTraitRef < ' tcx > ,
4344 span : Span ,
4445 constness : ty:: BoundConstness ,
4546 polarity : ty:: ImplPolarity ,
4647 ) {
4748 self . predicates . push ( (
48- trait_ref
49- . map_bound ( |trait_ref| ty:: TraitPredicate { trait_ref, constness, polarity } )
50- . to_predicate ( tcx ) ,
49+ trait_ref. map_bound ( |trait_ref| {
50+ ty :: Clause :: Trait ( ty:: TraitPredicate { trait_ref, constness, polarity } )
51+ } ) ,
5152 span,
5253 ) ) ;
5354 }
5455
5556 pub fn push_projection_bound (
5657 & mut self ,
57- tcx : TyCtxt < ' tcx > ,
58+ _tcx : TyCtxt < ' tcx > ,
5859 projection : ty:: PolyProjectionPredicate < ' tcx > ,
5960 span : Span ,
6061 ) {
61- self . predicates . push ( ( projection. to_predicate ( tcx ) , span) ) ;
62+ self . predicates . push ( ( projection. map_bound ( |proj| ty :: Clause :: Projection ( proj ) ) , span) ) ;
6263 }
6364
6465 pub fn push_sized ( & mut self , tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , span : Span ) {
6566 let sized_def_id = tcx. require_lang_item ( LangItem :: Sized , Some ( span) ) ;
6667 let trait_ref = ty:: TraitRef :: new ( tcx, sized_def_id, [ ty] ) ;
6768 // Preferable to put this obligation first, since we report better errors for sized ambiguity.
68- self . predicates . insert ( 0 , ( trait_ref. without_const ( ) . to_predicate ( tcx) , span) ) ;
69+ self . predicates . insert (
70+ 0 ,
71+ (
72+ ty:: Binder :: dummy ( ty:: Clause :: Trait ( trait_ref. without_const ( ) . to_predicate ( tcx) ) ) ,
73+ span,
74+ ) ,
75+ ) ;
6976 }
7077
71- pub fn predicates ( & self ) -> impl Iterator < Item = ( ty:: Predicate < ' tcx > , Span ) > + ' _ {
78+ pub fn predicates ( & self ) -> impl Iterator < Item = ( Binder < ' tcx , ty:: Clause < ' tcx > > , Span ) > + ' _ {
7279 self . predicates . iter ( ) . cloned ( )
7380 }
7481}
0 commit comments