@@ -64,7 +64,6 @@ use rustc::ty::{ToPredicate, ReprOptions};
64
64
use rustc:: ty:: { self , AdtKind , ToPolyTraitRef , Ty , TyCtxt } ;
65
65
use rustc:: ty:: maps:: Providers ;
66
66
use rustc:: ty:: util:: IntTypeExt ;
67
- use rustc:: dep_graph:: DepNode ;
68
67
use util:: nodemap:: { NodeMap , FxHashMap } ;
69
68
70
69
use rustc_const_math:: ConstInt ;
@@ -87,7 +86,7 @@ use rustc::hir::def_id::DefId;
87
86
88
87
pub fn collect_item_types < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) {
89
88
let mut visitor = CollectItemTypesVisitor { tcx : tcx } ;
90
- tcx. visit_all_item_likes_in_krate ( DepNode :: CollectItem , & mut visitor. as_deep_visitor ( ) ) ;
89
+ tcx. hir . krate ( ) . visit_all_item_likes ( & mut visitor. as_deep_visitor ( ) ) ;
91
90
}
92
91
93
92
pub fn provide ( providers : & mut Providers ) {
@@ -126,57 +125,13 @@ struct CollectItemTypesVisitor<'a, 'tcx: 'a> {
126
125
tcx : TyCtxt < ' a , ' tcx , ' tcx >
127
126
}
128
127
129
- impl < ' a , ' tcx > CollectItemTypesVisitor < ' a , ' tcx > {
130
- /// Collect item types is structured into two tasks. The outer
131
- /// task, `CollectItem`, walks the entire content of an item-like
132
- /// thing, including its body. It also spawns an inner task,
133
- /// `CollectItemSig`, which walks only the signature. This inner
134
- /// task is the one that writes the item-type into the various
135
- /// maps. This setup ensures that the item body is never
136
- /// accessible to the task that computes its signature, so that
137
- /// changes to the body don't affect the signature.
138
- ///
139
- /// Consider an example function `foo` that also has a closure in its body:
140
- ///
141
- /// ```
142
- /// fn foo(<sig>) {
143
- /// ...
144
- /// let bar = || ...; // we'll label this closure as "bar" below
145
- /// }
146
- /// ```
147
- ///
148
- /// This results in a dep-graph like so. I've labeled the edges to
149
- /// document where they arise.
150
- ///
151
- /// ```
152
- /// [HirBody(foo)] -2--> [CollectItem(foo)] -4-> [ItemSignature(bar)]
153
- /// ^ ^
154
- /// 1 3
155
- /// [Hir(foo)] -----------+-6-> [CollectItemSig(foo)] -5-> [ItemSignature(foo)]
156
- /// ```
157
- ///
158
- /// 1. This is added by the `visit_all_item_likes_in_krate`.
159
- /// 2. This is added when we fetch the item body.
160
- /// 3. This is added because `CollectItem` launches `CollectItemSig`.
161
- /// - it is arguably false; if we refactor the `with_task` system;
162
- /// we could get probably rid of it, but it is also harmless enough.
163
- /// 4. This is added by the code in `visit_expr` when we write to `item_types`.
164
- /// 5. This is added by the code in `convert_item` when we write to `item_types`;
165
- /// note that this write occurs inside the `CollectItemSig` task.
166
- /// 6. Added by reads from within `op`.
167
- fn with_collect_item_sig ( & self , id : ast:: NodeId , op : fn ( TyCtxt < ' a , ' tcx , ' tcx > , ast:: NodeId ) ) {
168
- let def_id = self . tcx . hir . local_def_id ( id) ;
169
- self . tcx . dep_graph . with_task ( DepNode :: CollectItemSig ( def_id) , self . tcx , id, op) ;
170
- }
171
- }
172
-
173
128
impl < ' a , ' tcx > Visitor < ' tcx > for CollectItemTypesVisitor < ' a , ' tcx > {
174
129
fn nested_visit_map < ' this > ( & ' this mut self ) -> NestedVisitorMap < ' this , ' tcx > {
175
130
NestedVisitorMap :: OnlyBodies ( & self . tcx . hir )
176
131
}
177
132
178
133
fn visit_item ( & mut self , item : & ' tcx hir:: Item ) {
179
- self . with_collect_item_sig ( item. id , convert_item ) ;
134
+ convert_item ( self . tcx , item. id ) ;
180
135
intravisit:: walk_item ( self , item) ;
181
136
}
182
137
@@ -209,12 +164,12 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
209
164
}
210
165
211
166
fn visit_trait_item ( & mut self , trait_item : & ' tcx hir:: TraitItem ) {
212
- self . with_collect_item_sig ( trait_item. id , convert_trait_item ) ;
167
+ convert_trait_item ( self . tcx , trait_item. id ) ;
213
168
intravisit:: walk_trait_item ( self , trait_item) ;
214
169
}
215
170
216
171
fn visit_impl_item ( & mut self , impl_item : & ' tcx hir:: ImplItem ) {
217
- self . with_collect_item_sig ( impl_item. id , convert_impl_item ) ;
172
+ convert_impl_item ( self . tcx , impl_item. id ) ;
218
173
intravisit:: walk_impl_item ( self , impl_item) ;
219
174
}
220
175
}
0 commit comments