22//! `ty` form from the HIR.
33
44use rustc_hir:: LangItem ;
5- use rustc_middle:: ty:: Binder ;
65use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt } ;
76use rustc_span:: Span ;
87
@@ -24,62 +23,58 @@ use rustc_span::Span;
2423/// include the self type (e.g., `trait_bounds`) but in others we do not
2524#[ derive( Default , PartialEq , Eq , Clone , Debug ) ]
2625pub struct Bounds < ' tcx > {
27- pub predicates : Vec < ( Binder < ' tcx , ty:: Clause < ' tcx > > , Span ) > ,
26+ pub predicates : Vec < ( ty:: Clause < ' tcx > , Span ) > ,
2827}
2928
3029impl < ' tcx > Bounds < ' tcx > {
3130 pub fn push_region_bound (
3231 & mut self ,
33- _tcx : TyCtxt < ' tcx > ,
32+ tcx : TyCtxt < ' tcx > ,
3433 region : ty:: PolyTypeOutlivesPredicate < ' tcx > ,
3534 span : Span ,
3635 ) {
37- self . predicates . push ( ( region. map_bound ( |p| ty:: Clause :: TypeOutlives ( p) ) , span) ) ;
36+ self . predicates
37+ . push ( ( region. map_bound ( |p| ty:: ClauseKind :: TypeOutlives ( p) ) . to_predicate ( tcx) , span) ) ;
3838 }
3939
4040 pub fn push_trait_bound (
4141 & mut self ,
42- _tcx : TyCtxt < ' tcx > ,
42+ tcx : TyCtxt < ' tcx > ,
4343 trait_ref : ty:: PolyTraitRef < ' tcx > ,
4444 span : Span ,
4545 constness : ty:: BoundConstness ,
4646 polarity : ty:: ImplPolarity ,
4747 ) {
4848 self . predicates . push ( (
49- trait_ref. map_bound ( |trait_ref| {
50- ty:: Clause :: Trait ( ty:: TraitPredicate { trait_ref, constness, polarity } )
51- } ) ,
49+ trait_ref
50+ . map_bound ( |trait_ref| {
51+ ty:: ClauseKind :: Trait ( ty:: TraitPredicate { trait_ref, constness, polarity } )
52+ } )
53+ . to_predicate ( tcx) ,
5254 span,
5355 ) ) ;
5456 }
5557
5658 pub fn push_projection_bound (
5759 & mut self ,
58- _tcx : TyCtxt < ' tcx > ,
60+ tcx : TyCtxt < ' tcx > ,
5961 projection : ty:: PolyProjectionPredicate < ' tcx > ,
6062 span : Span ,
6163 ) {
62- self . predicates . push ( ( projection. map_bound ( |proj| ty:: Clause :: Projection ( proj) ) , span) ) ;
64+ self . predicates . push ( (
65+ projection. map_bound ( |proj| ty:: ClauseKind :: Projection ( proj) ) . to_predicate ( tcx) ,
66+ span,
67+ ) ) ;
6368 }
6469
6570 pub fn push_sized ( & mut self , tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , span : Span ) {
6671 let sized_def_id = tcx. require_lang_item ( LangItem :: Sized , Some ( span) ) ;
6772 let trait_ref = ty:: TraitRef :: new ( tcx, sized_def_id, [ ty] ) ;
6873 // Preferable to put this obligation first, since we report better errors for sized ambiguity.
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- ) ;
76- }
77-
78- pub fn predicates ( & self ) -> impl Iterator < Item = ( Binder < ' tcx , ty:: Clause < ' tcx > > , Span ) > + ' _ {
79- self . predicates . iter ( ) . cloned ( )
74+ self . predicates . insert ( 0 , ( trait_ref. to_predicate ( tcx) , span) ) ;
8075 }
8176
8277 pub fn clauses ( & self ) -> impl Iterator < Item = ( ty:: Clause < ' tcx > , Span ) > + ' _ {
83- self . predicates . iter ( ) . cloned ( ) . map ( | ( pred , span ) | ( pred . as_clause ( ) . unwrap ( ) , span ) )
78+ self . predicates . iter ( ) . cloned ( )
8479 }
8580}
0 commit comments