@@ -16,7 +16,7 @@ use rustc_hir::*;
16
16
use rustc_index:: vec:: { Idx , IndexVec } ;
17
17
use rustc_session:: { CrateDisambiguator , Session } ;
18
18
use rustc_span:: source_map:: SourceMap ;
19
- use rustc_span:: { Span , Symbol , DUMMY_SP } ;
19
+ use rustc_span:: { Span , Symbol } ;
20
20
21
21
use std:: iter:: repeat;
22
22
@@ -133,10 +133,15 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
133
133
hcx,
134
134
hir_body_nodes,
135
135
map : ( 0 ..definitions. def_index_count ( ) )
136
- . map ( |_| HirOwnerData { signature : None , with_bodies : None } )
136
+ . map ( |_| HirOwnerData {
137
+ spans : IndexVec :: new ( ) ,
138
+ signature : None ,
139
+ with_bodies : None ,
140
+ } )
137
141
. collect ( ) ,
138
142
} ;
139
143
collector. insert_entry (
144
+ krate. item . span ,
140
145
hir:: CRATE_HIR_ID ,
141
146
Entry { parent : hir:: CRATE_HIR_ID , node : Node :: Crate ( & krate. item ) } ,
142
147
hash,
@@ -196,7 +201,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
196
201
( self . map , svh)
197
202
}
198
203
199
- fn insert_entry ( & mut self , id : HirId , entry : Entry < ' hir > , hash : Fingerprint ) {
204
+ fn insert_entry ( & mut self , span : Span , id : HirId , entry : Entry < ' hir > , hash : Fingerprint ) {
200
205
let i = id. local_id . as_u32 ( ) as usize ;
201
206
202
207
let arena = self . arena ;
@@ -213,6 +218,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
213
218
214
219
let nodes = data. with_bodies . as_mut ( ) . unwrap ( ) ;
215
220
221
+ insert_vec_map ( & mut data. spans , id. local_id , span) ;
216
222
if i == 0 {
217
223
// Overwrite the dummy hash with the real HIR owner hash.
218
224
nodes. hash = hash;
@@ -262,7 +268,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
262
268
}
263
269
}
264
270
265
- self . insert_entry ( hir_id, entry, hash) ;
271
+ self . insert_entry ( span , hir_id, entry, hash) ;
266
272
}
267
273
268
274
fn with_parent < F : FnOnce ( & mut Self ) > ( & mut self , parent_node_id : HirId , f : F ) {
@@ -323,7 +329,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
323
329
324
330
fn visit_param ( & mut self , param : & ' hir Param < ' hir > ) {
325
331
let node = Node :: Param ( param) ;
326
- self . insert ( param. pat . span , param. hir_id , node) ;
332
+ self . insert ( param. span , param. hir_id , node) ;
327
333
self . with_parent ( param. hir_id , |this| {
328
334
intravisit:: walk_param ( this, param) ;
329
335
} ) ;
@@ -411,7 +417,11 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
411
417
}
412
418
413
419
fn visit_anon_const ( & mut self , constant : & ' hir AnonConst ) {
414
- self . insert ( DUMMY_SP , constant. hir_id , Node :: AnonConst ( constant) ) ;
420
+ self . insert (
421
+ self . krate . body ( constant. body ) . value . span ,
422
+ constant. hir_id ,
423
+ Node :: AnonConst ( constant) ,
424
+ ) ;
415
425
416
426
self . with_parent ( constant. hir_id , |this| {
417
427
intravisit:: walk_anon_const ( this, constant) ;
@@ -436,7 +446,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
436
446
437
447
fn visit_path_segment ( & mut self , path_span : Span , path_segment : & ' hir PathSegment < ' hir > ) {
438
448
if let Some ( hir_id) = path_segment. hir_id {
439
- self . insert ( path_span , hir_id, Node :: PathSegment ( path_segment) ) ;
449
+ self . insert ( path_segment . ident . span , hir_id, Node :: PathSegment ( path_segment) ) ;
440
450
}
441
451
intravisit:: walk_path_segment ( self , path_span, path_segment) ;
442
452
}
0 commit comments