@@ -29,7 +29,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
2929 /// The crate
3030 krate : & ' hir Crate ,
3131 /// The node map
32- map : Vec < EntryKind < ' hir > > ,
32+ map : Vec < Option < Entry < ' hir > > > ,
3333 /// The parent of this node
3434 parent_node : NodeId ,
3535
@@ -114,7 +114,11 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
114114 hcx,
115115 hir_body_nodes,
116116 } ;
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+ } ) ;
118122
119123 collector
120124 }
@@ -124,9 +128,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
124128 cstore : & dyn CrateStore ,
125129 source_map : & SourceMap ,
126130 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
130133 . sort_unstable_by ( |& ( ref d1, _) , & ( ref d2, _) | d1. cmp ( d2) ) ;
131134
132135 let node_hashes = self
@@ -178,44 +181,24 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
178181 ( self . map , svh)
179182 }
180183
181- fn insert_entry ( & mut self , id : NodeId , entry : EntryKind < ' hir > ) {
184+ fn insert_entry ( & mut self , id : NodeId , entry : Entry < ' hir > ) {
182185 debug ! ( "hir_map: {:?} => {:?}" , id, entry) ;
183186 let len = self . map . len ( ) ;
184187 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 ) ) ;
186189 }
187- self . map [ id. as_usize ( ) ] = entry;
190+ self . map [ id. as_usize ( ) ] = Some ( entry) ;
188191 }
189192
190193 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,
219202 } ;
220203
221204 // Make sure that the DepNode of some node coincides with the HirId
0 commit comments