@@ -19,7 +19,9 @@ use hir;
19
19
use util:: nodemap:: FxHashMap ;
20
20
21
21
/// A trait's definition with type information.
22
- pub struct TraitDef < ' tcx > {
22
+ pub struct TraitDef {
23
+ pub def_id : DefId ,
24
+
23
25
pub unsafety : hir:: Unsafety ,
24
26
25
27
/// If `true`, then this trait had the `#[rustc_paren_sugar]`
@@ -28,15 +30,6 @@ pub struct TraitDef<'tcx> {
28
30
/// be usable with the sugar (or without it).
29
31
pub paren_sugar : bool ,
30
32
31
- /// Generic type definitions. Note that `Self` is listed in here
32
- /// as having a single bound, the trait itself (e.g., in the trait
33
- /// `Eq`, there is a single bound `Self : Eq`). This is so that
34
- /// default methods get to assume that the `Self` parameters
35
- /// implements the trait.
36
- pub generics : & ' tcx ty:: Generics < ' tcx > ,
37
-
38
- pub trait_ref : ty:: TraitRef < ' tcx > ,
39
-
40
33
// Impls of a trait. To allow for quicker lookup, the impls are indexed by a
41
34
// simplified version of their `Self` type: impls with a simplifiable `Self`
42
35
// are stored in `nonblanket_impls` keyed by it, while all other impls are
@@ -72,18 +65,16 @@ pub struct TraitDef<'tcx> {
72
65
pub def_path_hash : u64 ,
73
66
}
74
67
75
- impl < ' a , ' gcx , ' tcx > TraitDef < ' tcx > {
76
- pub fn new ( unsafety : hir:: Unsafety ,
68
+ impl < ' a , ' gcx , ' tcx > TraitDef {
69
+ pub fn new ( def_id : DefId ,
70
+ unsafety : hir:: Unsafety ,
77
71
paren_sugar : bool ,
78
- generics : & ' tcx ty:: Generics < ' tcx > ,
79
- trait_ref : ty:: TraitRef < ' tcx > ,
80
72
def_path_hash : u64 )
81
- -> TraitDef < ' tcx > {
73
+ -> TraitDef {
82
74
TraitDef {
75
+ def_id : def_id,
83
76
paren_sugar : paren_sugar,
84
77
unsafety : unsafety,
85
- generics : generics,
86
- trait_ref : trait_ref,
87
78
nonblanket_impls : RefCell :: new ( FxHashMap ( ) ) ,
88
79
blanket_impls : RefCell :: new ( vec ! [ ] ) ,
89
80
flags : Cell :: new ( ty:: TraitFlags :: NO_TRAIT_FLAGS ) ,
@@ -92,10 +83,6 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
92
83
}
93
84
}
94
85
95
- pub fn def_id ( & self ) -> DefId {
96
- self . trait_ref . def_id
97
- }
98
-
99
86
// returns None if not yet calculated
100
87
pub fn object_safety ( & self ) -> Option < bool > {
101
88
if self . flags . get ( ) . intersects ( TraitFlags :: OBJECT_SAFETY_VALID ) {
@@ -117,11 +104,11 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
117
104
}
118
105
119
106
fn write_trait_impls ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) {
120
- tcx. dep_graph . write ( DepNode :: TraitImpls ( self . trait_ref . def_id ) ) ;
107
+ tcx. dep_graph . write ( DepNode :: TraitImpls ( self . def_id ) ) ;
121
108
}
122
109
123
110
fn read_trait_impls ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) {
124
- tcx. dep_graph . read ( DepNode :: TraitImpls ( self . trait_ref . def_id ) ) ;
111
+ tcx. dep_graph . read ( DepNode :: TraitImpls ( self . def_id ) ) ;
125
112
}
126
113
127
114
/// Records a basic trait-to-implementation mapping.
@@ -203,13 +190,13 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
203
190
. insert ( tcx, impl_def_id)
204
191
}
205
192
206
- pub fn ancestors ( & ' a self , of_impl : DefId ) -> specialization_graph:: Ancestors < ' a , ' tcx > {
193
+ pub fn ancestors ( & ' a self , of_impl : DefId ) -> specialization_graph:: Ancestors < ' a > {
207
194
specialization_graph:: ancestors ( self , of_impl)
208
195
}
209
196
210
197
pub fn for_each_impl < F : FnMut ( DefId ) > ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > , mut f : F ) {
211
198
self . read_trait_impls ( tcx) ;
212
- tcx. populate_implementations_for_trait_if_necessary ( self . trait_ref . def_id ) ;
199
+ tcx. populate_implementations_for_trait_if_necessary ( self . def_id ) ;
213
200
214
201
for & impl_def_id in self . blanket_impls . borrow ( ) . iter ( ) {
215
202
f ( impl_def_id) ;
@@ -231,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
231
218
{
232
219
self . read_trait_impls ( tcx) ;
233
220
234
- tcx. populate_implementations_for_trait_if_necessary ( self . trait_ref . def_id ) ;
221
+ tcx. populate_implementations_for_trait_if_necessary ( self . def_id ) ;
235
222
236
223
for & impl_def_id in self . blanket_impls . borrow ( ) . iter ( ) {
237
224
f ( impl_def_id) ;
0 commit comments