@@ -29,7 +29,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
29
29
/// The crate
30
30
krate : & ' hir Crate ,
31
31
/// The node map
32
- map : Vec < EntryKind < ' hir > > ,
32
+ map : Vec < Option < Entry < ' hir > > > ,
33
33
/// The parent of this node
34
34
parent_node : NodeId ,
35
35
@@ -114,7 +114,11 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
114
114
hcx,
115
115
hir_body_nodes,
116
116
} ;
117
- collector. insert_entry ( CRATE_NODE_ID , EntryKind :: RootCrate ( root_mod_sig_dep_index) ) ;
117
+ collector. insert_entry ( CRATE_NODE_ID , Entry {
118
+ parent : ast:: DUMMY_NODE_ID ,
119
+ dep_node : root_mod_sig_dep_index,
120
+ node : NodeKind :: Crate ,
121
+ } ) ;
118
122
119
123
collector
120
124
}
@@ -124,9 +128,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
124
128
cstore : & dyn CrateStore ,
125
129
source_map : & SourceMap ,
126
130
commandline_args_hash : u64 )
127
- -> ( Vec < EntryKind < ' hir > > , Svh ) {
128
- self
129
- . hir_body_nodes
131
+ -> ( Vec < Option < Entry < ' hir > > > , Svh ) {
132
+ self . hir_body_nodes
130
133
. sort_unstable_by ( |& ( ref d1, _) , & ( ref d2, _) | d1. cmp ( d2) ) ;
131
134
132
135
let node_hashes = self
@@ -178,44 +181,24 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
178
181
( self . map , svh)
179
182
}
180
183
181
- fn insert_entry ( & mut self , id : NodeId , entry : EntryKind < ' hir > ) {
184
+ fn insert_entry ( & mut self , id : NodeId , entry : Entry < ' hir > ) {
182
185
debug ! ( "hir_map: {:?} => {:?}" , id, entry) ;
183
186
let len = self . map . len ( ) ;
184
187
if id. as_usize ( ) >= len {
185
- self . map . extend ( repeat ( EntryKind :: NotPresent ) . take ( id. as_usize ( ) - len + 1 ) ) ;
188
+ self . map . extend ( repeat ( None ) . take ( id. as_usize ( ) - len + 1 ) ) ;
186
189
}
187
- self . map [ id. as_usize ( ) ] = entry;
190
+ self . map [ id. as_usize ( ) ] = Some ( entry) ;
188
191
}
189
192
190
193
fn insert ( & mut self , id : NodeId , node : NodeKind < ' hir > ) {
191
- let parent = self . parent_node ;
192
- let dep_node_index = if self . currently_in_body {
193
- self . current_full_dep_index
194
- } else {
195
- self . current_signature_dep_index
196
- } ;
197
-
198
- let entry = match node {
199
- NodeKind :: Item ( n) => EntryKind :: Item ( parent, dep_node_index, n) ,
200
- NodeKind :: ForeignItem ( n) => EntryKind :: ForeignItem ( parent, dep_node_index, n) ,
201
- NodeKind :: TraitItem ( n) => EntryKind :: TraitItem ( parent, dep_node_index, n) ,
202
- NodeKind :: ImplItem ( n) => EntryKind :: ImplItem ( parent, dep_node_index, n) ,
203
- NodeKind :: Variant ( n) => EntryKind :: Variant ( parent, dep_node_index, n) ,
204
- NodeKind :: Field ( n) => EntryKind :: Field ( parent, dep_node_index, n) ,
205
- NodeKind :: AnonConst ( n) => EntryKind :: AnonConst ( parent, dep_node_index, n) ,
206
- NodeKind :: Expr ( n) => EntryKind :: Expr ( parent, dep_node_index, n) ,
207
- NodeKind :: Stmt ( n) => EntryKind :: Stmt ( parent, dep_node_index, n) ,
208
- NodeKind :: Ty ( n) => EntryKind :: Ty ( parent, dep_node_index, n) ,
209
- NodeKind :: TraitRef ( n) => EntryKind :: TraitRef ( parent, dep_node_index, n) ,
210
- NodeKind :: Binding ( n) => EntryKind :: Binding ( parent, dep_node_index, n) ,
211
- NodeKind :: Pat ( n) => EntryKind :: Pat ( parent, dep_node_index, n) ,
212
- NodeKind :: Block ( n) => EntryKind :: Block ( parent, dep_node_index, n) ,
213
- NodeKind :: StructCtor ( n) => EntryKind :: StructCtor ( parent, dep_node_index, n) ,
214
- NodeKind :: Lifetime ( n) => EntryKind :: Lifetime ( parent, dep_node_index, n) ,
215
- NodeKind :: GenericParam ( n) => EntryKind :: GenericParam ( parent, dep_node_index, n) ,
216
- NodeKind :: Visibility ( n) => EntryKind :: Visibility ( parent, dep_node_index, n) ,
217
- NodeKind :: Local ( n) => EntryKind :: Local ( parent, dep_node_index, n) ,
218
- NodeKind :: MacroDef ( n) => EntryKind :: MacroDef ( dep_node_index, n) ,
194
+ let entry = Entry {
195
+ parent : self . parent_node ,
196
+ dep_node : if self . currently_in_body {
197
+ self . current_full_dep_index
198
+ } else {
199
+ self . current_signature_dep_index
200
+ } ,
201
+ node,
219
202
} ;
220
203
221
204
// Make sure that the DepNode of some node coincides with the HirId
0 commit comments