@@ -19,7 +19,9 @@ use hir;
1919use util:: nodemap:: FxHashMap ;
2020
2121/// A trait's definition with type information.
22- pub struct TraitDef < ' tcx > {
22+ pub struct TraitDef {
23+ pub def_id : DefId ,
24+
2325 pub unsafety : hir:: Unsafety ,
2426
2527 /// If `true`, then this trait had the `#[rustc_paren_sugar]`
@@ -28,15 +30,6 @@ pub struct TraitDef<'tcx> {
2830 /// be usable with the sugar (or without it).
2931 pub paren_sugar : bool ,
3032
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-
4033 // Impls of a trait. To allow for quicker lookup, the impls are indexed by a
4134 // simplified version of their `Self` type: impls with a simplifiable `Self`
4235 // are stored in `nonblanket_impls` keyed by it, while all other impls are
@@ -72,18 +65,16 @@ pub struct TraitDef<'tcx> {
7265 pub def_path_hash : u64 ,
7366}
7467
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 ,
7771 paren_sugar : bool ,
78- generics : & ' tcx ty:: Generics < ' tcx > ,
79- trait_ref : ty:: TraitRef < ' tcx > ,
8072 def_path_hash : u64 )
81- -> TraitDef < ' tcx > {
73+ -> TraitDef {
8274 TraitDef {
75+ def_id : def_id,
8376 paren_sugar : paren_sugar,
8477 unsafety : unsafety,
85- generics : generics,
86- trait_ref : trait_ref,
8778 nonblanket_impls : RefCell :: new ( FxHashMap ( ) ) ,
8879 blanket_impls : RefCell :: new ( vec ! [ ] ) ,
8980 flags : Cell :: new ( ty:: TraitFlags :: NO_TRAIT_FLAGS ) ,
@@ -92,10 +83,6 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
9283 }
9384 }
9485
95- pub fn def_id ( & self ) -> DefId {
96- self . trait_ref . def_id
97- }
98-
9986 // returns None if not yet calculated
10087 pub fn object_safety ( & self ) -> Option < bool > {
10188 if self . flags . get ( ) . intersects ( TraitFlags :: OBJECT_SAFETY_VALID ) {
@@ -117,11 +104,11 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
117104 }
118105
119106 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 ) ) ;
121108 }
122109
123110 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 ) ) ;
125112 }
126113
127114 /// Records a basic trait-to-implementation mapping.
@@ -203,13 +190,13 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
203190 . insert ( tcx, impl_def_id)
204191 }
205192
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 > {
207194 specialization_graph:: ancestors ( self , of_impl)
208195 }
209196
210197 pub fn for_each_impl < F : FnMut ( DefId ) > ( & self , tcx : TyCtxt < ' a , ' gcx , ' tcx > , mut f : F ) {
211198 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 ) ;
213200
214201 for & impl_def_id in self . blanket_impls . borrow ( ) . iter ( ) {
215202 f ( impl_def_id) ;
@@ -231,7 +218,7 @@ impl<'a, 'gcx, 'tcx> TraitDef<'tcx> {
231218 {
232219 self . read_trait_impls ( tcx) ;
233220
234- tcx. populate_implementations_for_trait_if_necessary ( self . trait_ref . def_id ) ;
221+ tcx. populate_implementations_for_trait_if_necessary ( self . def_id ) ;
235222
236223 for & impl_def_id in self . blanket_impls . borrow ( ) . iter ( ) {
237224 f ( impl_def_id) ;
0 commit comments