2
2
//! `ty` form from the HIR.
3
3
4
4
use rustc_hir:: LangItem ;
5
- use rustc_middle:: ty:: Binder ;
6
5
use rustc_middle:: ty:: { self , ToPredicate , Ty , TyCtxt } ;
7
6
use rustc_span:: Span ;
8
7
@@ -24,62 +23,58 @@ use rustc_span::Span;
24
23
/// include the self type (e.g., `trait_bounds`) but in others we do not
25
24
#[ derive( Default , PartialEq , Eq , Clone , Debug ) ]
26
25
pub struct Bounds < ' tcx > {
27
- pub predicates : Vec < ( Binder < ' tcx , ty:: Clause < ' tcx > > , Span ) > ,
26
+ pub predicates : Vec < ( ty:: Clause < ' tcx > , Span ) > ,
28
27
}
29
28
30
29
impl < ' tcx > Bounds < ' tcx > {
31
30
pub fn push_region_bound (
32
31
& mut self ,
33
- _tcx : TyCtxt < ' tcx > ,
32
+ tcx : TyCtxt < ' tcx > ,
34
33
region : ty:: PolyTypeOutlivesPredicate < ' tcx > ,
35
34
span : Span ,
36
35
) {
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) ) ;
38
38
}
39
39
40
40
pub fn push_trait_bound (
41
41
& mut self ,
42
- _tcx : TyCtxt < ' tcx > ,
42
+ tcx : TyCtxt < ' tcx > ,
43
43
trait_ref : ty:: PolyTraitRef < ' tcx > ,
44
44
span : Span ,
45
45
constness : ty:: BoundConstness ,
46
46
polarity : ty:: ImplPolarity ,
47
47
) {
48
48
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) ,
52
54
span,
53
55
) ) ;
54
56
}
55
57
56
58
pub fn push_projection_bound (
57
59
& mut self ,
58
- _tcx : TyCtxt < ' tcx > ,
60
+ tcx : TyCtxt < ' tcx > ,
59
61
projection : ty:: PolyProjectionPredicate < ' tcx > ,
60
62
span : Span ,
61
63
) {
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
+ ) ) ;
63
68
}
64
69
65
70
pub fn push_sized ( & mut self , tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , span : Span ) {
66
71
let sized_def_id = tcx. require_lang_item ( LangItem :: Sized , Some ( span) ) ;
67
72
let trait_ref = ty:: TraitRef :: new ( tcx, sized_def_id, [ ty] ) ;
68
73
// 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) ) ;
80
75
}
81
76
82
77
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 ( )
84
79
}
85
80
}
0 commit comments