@@ -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:: Symbol ;
20
20
21
21
use std:: iter:: repeat;
22
22
@@ -234,11 +234,11 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
234
234
}
235
235
}
236
236
237
- fn insert ( & mut self , span : Span , hir_id : HirId , node : Node < ' hir > ) {
238
- self . insert_with_hash ( span , hir_id, node, Fingerprint :: ZERO )
237
+ fn insert ( & mut self , hir_id : HirId , node : Node < ' hir > ) {
238
+ self . insert_with_hash ( hir_id, node, Fingerprint :: ZERO )
239
239
}
240
240
241
- fn insert_with_hash ( & mut self , span : Span , hir_id : HirId , node : Node < ' hir > , hash : Fingerprint ) {
241
+ fn insert_with_hash ( & mut self , hir_id : HirId , node : Node < ' hir > , hash : Fingerprint ) {
242
242
let entry = Entry { parent : self . parent_node , node } ;
243
243
244
244
// Make sure that the DepNode of some node coincides with the HirId
@@ -250,6 +250,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
250
250
None => format ! ( "{:?}" , node) ,
251
251
} ;
252
252
253
+ let span = self . krate . spans [ hir_id] ;
253
254
span_bug ! (
254
255
span,
255
256
"inconsistent DepNode at `{:?}` for `{}`: \
@@ -331,7 +332,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
331
332
332
333
fn visit_param ( & mut self , param : & ' hir Param < ' hir > ) {
333
334
let node = Node :: Param ( param) ;
334
- self . insert ( param. pat . span , param . hir_id , node) ;
335
+ self . insert ( param. hir_id , node) ;
335
336
self . with_parent ( param. hir_id , |this| {
336
337
intravisit:: walk_param ( this, param) ;
337
338
} ) ;
@@ -344,12 +345,13 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
344
345
self . definitions. opt_hir_id_to_local_def_id( i. hir_id) . unwrap( )
345
346
) ;
346
347
self . with_dep_node_owner ( i. hir_id . owner , i, |this, hash| {
347
- this. insert_with_hash ( i. span , i. hir_id , Node :: Item ( i) , hash) ;
348
+ this. insert_with_hash ( i. hir_id , Node :: Item ( i) , hash) ;
349
+
348
350
this. with_parent ( i. hir_id , |this| {
349
351
if let ItemKind :: Struct ( ref struct_def, _) = i. kind {
350
352
// If this is a tuple or unit-like struct, register the constructor.
351
353
if let Some ( ctor_hir_id) = struct_def. ctor_hir_id ( ) {
352
- this. insert ( i . span , ctor_hir_id, Node :: Ctor ( struct_def) ) ;
354
+ this. insert ( ctor_hir_id, Node :: Ctor ( struct_def) ) ;
353
355
}
354
356
}
355
357
intravisit:: walk_item ( this, i) ;
@@ -363,7 +365,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
363
365
self . definitions. opt_hir_id_to_local_def_id( fi. hir_id) . unwrap( )
364
366
) ;
365
367
self . with_dep_node_owner ( fi. hir_id . owner , fi, |this, hash| {
366
- this. insert_with_hash ( fi. span , fi . hir_id , Node :: ForeignItem ( fi) , hash) ;
368
+ this. insert_with_hash ( fi. hir_id , Node :: ForeignItem ( fi) , hash) ;
367
369
368
370
this. with_parent ( fi. hir_id , |this| {
369
371
intravisit:: walk_foreign_item ( this, fi) ;
@@ -382,14 +384,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
382
384
self . definitions. opt_hir_id_to_local_def_id( param. hir_id) . unwrap( )
383
385
) ;
384
386
self . with_dep_node_owner ( param. hir_id . owner , param, |this, hash| {
385
- this. insert_with_hash ( param. span , param . hir_id , Node :: GenericParam ( param) , hash) ;
387
+ this. insert_with_hash ( param. hir_id , Node :: GenericParam ( param) , hash) ;
386
388
387
389
this. with_parent ( param. hir_id , |this| {
388
390
intravisit:: walk_generic_param ( this, param) ;
389
391
} ) ;
390
392
} ) ;
391
393
} else {
392
- self . insert ( param. span , param . hir_id , Node :: GenericParam ( param) ) ;
394
+ self . insert ( param. hir_id , Node :: GenericParam ( param) ) ;
393
395
intravisit:: walk_generic_param ( self , param) ;
394
396
}
395
397
}
@@ -400,7 +402,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
400
402
self . definitions. opt_hir_id_to_local_def_id( ti. hir_id) . unwrap( )
401
403
) ;
402
404
self . with_dep_node_owner ( ti. hir_id . owner , ti, |this, hash| {
403
- this. insert_with_hash ( ti. span , ti . hir_id , Node :: TraitItem ( ti) , hash) ;
405
+ this. insert_with_hash ( ti. hir_id , Node :: TraitItem ( ti) , hash) ;
404
406
405
407
this. with_parent ( ti. hir_id , |this| {
406
408
intravisit:: walk_trait_item ( this, ti) ;
@@ -414,7 +416,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
414
416
self . definitions. opt_hir_id_to_local_def_id( ii. hir_id) . unwrap( )
415
417
) ;
416
418
self . with_dep_node_owner ( ii. hir_id . owner , ii, |this, hash| {
417
- this. insert_with_hash ( ii. span , ii . hir_id , Node :: ImplItem ( ii) , hash) ;
419
+ this. insert_with_hash ( ii. hir_id , Node :: ImplItem ( ii) , hash) ;
418
420
419
421
this. with_parent ( ii. hir_id , |this| {
420
422
intravisit:: walk_impl_item ( this, ii) ;
@@ -425,7 +427,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
425
427
fn visit_pat ( & mut self , pat : & ' hir Pat < ' hir > ) {
426
428
let node =
427
429
if let PatKind :: Binding ( ..) = pat. kind { Node :: Binding ( pat) } else { Node :: Pat ( pat) } ;
428
- self . insert ( pat. span , pat . hir_id , node) ;
430
+ self . insert ( pat. hir_id , node) ;
429
431
430
432
self . with_parent ( pat. hir_id , |this| {
431
433
intravisit:: walk_pat ( this, pat) ;
@@ -435,31 +437,31 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
435
437
fn visit_arm ( & mut self , arm : & ' hir Arm < ' hir > ) {
436
438
let node = Node :: Arm ( arm) ;
437
439
438
- self . insert ( arm. span , arm . hir_id , node) ;
440
+ self . insert ( arm. hir_id , node) ;
439
441
440
442
self . with_parent ( arm. hir_id , |this| {
441
443
intravisit:: walk_arm ( this, arm) ;
442
444
} ) ;
443
445
}
444
446
445
447
fn visit_anon_const ( & mut self , constant : & ' hir AnonConst ) {
446
- self . insert ( DUMMY_SP , constant. hir_id , Node :: AnonConst ( constant) ) ;
448
+ self . insert ( constant. hir_id , Node :: AnonConst ( constant) ) ;
447
449
448
450
self . with_parent ( constant. hir_id , |this| {
449
451
intravisit:: walk_anon_const ( this, constant) ;
450
452
} ) ;
451
453
}
452
454
453
455
fn visit_expr ( & mut self , expr : & ' hir Expr < ' hir > ) {
454
- self . insert ( expr. span , expr . hir_id , Node :: Expr ( expr) ) ;
456
+ self . insert ( expr. hir_id , Node :: Expr ( expr) ) ;
455
457
456
458
self . with_parent ( expr. hir_id , |this| {
457
459
intravisit:: walk_expr ( this, expr) ;
458
460
} ) ;
459
461
}
460
462
461
463
fn visit_stmt ( & mut self , stmt : & ' hir Stmt < ' hir > ) {
462
- self . insert ( stmt. span , stmt . hir_id , Node :: Stmt ( stmt) ) ;
464
+ self . insert ( stmt. hir_id , Node :: Stmt ( stmt) ) ;
463
465
464
466
self . with_parent ( stmt. hir_id , |this| {
465
467
intravisit:: walk_stmt ( this, stmt) ;
@@ -468,21 +470,21 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
468
470
469
471
fn visit_path_segment ( & mut self , path_segment : & ' hir PathSegment < ' hir > ) {
470
472
if let Some ( hir_id) = path_segment. hir_id {
471
- self . insert ( DUMMY_SP , hir_id, Node :: PathSegment ( path_segment) ) ;
473
+ self . insert ( hir_id, Node :: PathSegment ( path_segment) ) ;
472
474
}
473
475
intravisit:: walk_path_segment ( self , path_segment) ;
474
476
}
475
477
476
478
fn visit_ty ( & mut self , ty : & ' hir Ty < ' hir > ) {
477
- self . insert ( ty. span , ty . hir_id , Node :: Ty ( ty) ) ;
479
+ self . insert ( ty. hir_id , Node :: Ty ( ty) ) ;
478
480
479
481
self . with_parent ( ty. hir_id , |this| {
480
482
intravisit:: walk_ty ( this, ty) ;
481
483
} ) ;
482
484
}
483
485
484
486
fn visit_trait_ref ( & mut self , tr : & ' hir TraitRef < ' hir > ) {
485
- self . insert ( tr. path . span , tr . hir_ref_id , Node :: TraitRef ( tr) ) ;
487
+ self . insert ( tr. hir_ref_id , Node :: TraitRef ( tr) ) ;
486
488
487
489
self . with_parent ( tr. hir_ref_id , |this| {
488
490
intravisit:: walk_trait_ref ( this, tr) ;
@@ -501,26 +503,26 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
501
503
}
502
504
503
505
fn visit_block ( & mut self , block : & ' hir Block < ' hir > ) {
504
- self . insert ( block. span , block . hir_id , Node :: Block ( block) ) ;
506
+ self . insert ( block. hir_id , Node :: Block ( block) ) ;
505
507
self . with_parent ( block. hir_id , |this| {
506
508
intravisit:: walk_block ( this, block) ;
507
509
} ) ;
508
510
}
509
511
510
512
fn visit_local ( & mut self , l : & ' hir Local < ' hir > ) {
511
- self . insert ( l. span , l . hir_id , Node :: Local ( l) ) ;
513
+ self . insert ( l. hir_id , Node :: Local ( l) ) ;
512
514
self . with_parent ( l. hir_id , |this| intravisit:: walk_local ( this, l) )
513
515
}
514
516
515
517
fn visit_lifetime ( & mut self , lifetime : & ' hir Lifetime ) {
516
- self . insert ( lifetime. span , lifetime . hir_id , Node :: Lifetime ( lifetime) ) ;
518
+ self . insert ( lifetime. hir_id , Node :: Lifetime ( lifetime) ) ;
517
519
}
518
520
519
521
fn visit_vis ( & mut self , visibility : & ' hir Visibility < ' hir > ) {
520
522
match visibility. node {
521
523
VisibilityKind :: Public | VisibilityKind :: Crate ( _) | VisibilityKind :: Inherited => { }
522
524
VisibilityKind :: Restricted { hir_id, .. } => {
523
- self . insert ( visibility . span , hir_id, Node :: Visibility ( visibility) ) ;
525
+ self . insert ( hir_id, Node :: Visibility ( visibility) ) ;
524
526
self . with_parent ( hir_id, |this| {
525
527
intravisit:: walk_vis ( this, visibility) ;
526
528
} ) ;
@@ -538,29 +540,24 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
538
540
} ) ;
539
541
self . with_parent ( parent, |this| {
540
542
this. with_dep_node_owner ( macro_def. hir_id . owner , macro_def, |this, hash| {
541
- this. insert_with_hash (
542
- macro_def. span ,
543
- macro_def. hir_id ,
544
- Node :: MacroDef ( macro_def) ,
545
- hash,
546
- ) ;
543
+ this. insert_with_hash ( macro_def. hir_id , Node :: MacroDef ( macro_def) , hash) ;
547
544
} )
548
545
} ) ;
549
546
}
550
547
551
548
fn visit_variant ( & mut self , v : & ' hir Variant < ' hir > , g : & ' hir Generics < ' hir > , item_id : HirId ) {
552
- self . insert ( v. span , v . id , Node :: Variant ( v) ) ;
549
+ self . insert ( v. id , Node :: Variant ( v) ) ;
553
550
self . with_parent ( v. id , |this| {
554
551
// Register the constructor of this variant.
555
552
if let Some ( ctor_hir_id) = v. data . ctor_hir_id ( ) {
556
- this. insert ( v . span , ctor_hir_id, Node :: Ctor ( & v. data ) ) ;
553
+ this. insert ( ctor_hir_id, Node :: Ctor ( & v. data ) ) ;
557
554
}
558
555
intravisit:: walk_variant ( this, v, g, item_id) ;
559
556
} ) ;
560
557
}
561
558
562
559
fn visit_struct_field ( & mut self , field : & ' hir StructField < ' hir > ) {
563
- self . insert ( field. span , field . hir_id , Node :: Field ( field) ) ;
560
+ self . insert ( field. hir_id , Node :: Field ( field) ) ;
564
561
self . with_parent ( field. hir_id , |this| {
565
562
intravisit:: walk_struct_field ( this, field) ;
566
563
} ) ;
0 commit comments