Skip to content

Commit 700d697

Browse files
committed
Remove Span parameter from HIR collector.
1 parent 973d19b commit 700d697

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

compiler/rustc_middle/src/hir/map/collector.rs

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_hir::*;
1616
use rustc_index::vec::{Idx, IndexVec};
1717
use rustc_session::{CrateDisambiguator, Session};
1818
use rustc_span::source_map::SourceMap;
19-
use rustc_span::{Span, Symbol, DUMMY_SP};
19+
use rustc_span::Symbol;
2020

2121
use std::iter::repeat;
2222

@@ -234,11 +234,11 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
234234
}
235235
}
236236

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)
239239
}
240240

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) {
242242
let entry = Entry { parent: self.parent_node, node };
243243

244244
// Make sure that the DepNode of some node coincides with the HirId
@@ -250,6 +250,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
250250
None => format!("{:?}", node),
251251
};
252252

253+
let span = self.krate.spans[hir_id];
253254
span_bug!(
254255
span,
255256
"inconsistent DepNode at `{:?}` for `{}`: \
@@ -331,7 +332,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
331332

332333
fn visit_param(&mut self, param: &'hir Param<'hir>) {
333334
let node = Node::Param(param);
334-
self.insert(param.pat.span, param.hir_id, node);
335+
self.insert(param.hir_id, node);
335336
self.with_parent(param.hir_id, |this| {
336337
intravisit::walk_param(this, param);
337338
});
@@ -344,12 +345,13 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
344345
self.definitions.opt_hir_id_to_local_def_id(i.hir_id).unwrap()
345346
);
346347
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+
348350
this.with_parent(i.hir_id, |this| {
349351
if let ItemKind::Struct(ref struct_def, _) = i.kind {
350352
// If this is a tuple or unit-like struct, register the constructor.
351353
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));
353355
}
354356
}
355357
intravisit::walk_item(this, i);
@@ -363,7 +365,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
363365
self.definitions.opt_hir_id_to_local_def_id(fi.hir_id).unwrap()
364366
);
365367
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);
367369

368370
this.with_parent(fi.hir_id, |this| {
369371
intravisit::walk_foreign_item(this, fi);
@@ -382,14 +384,14 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
382384
self.definitions.opt_hir_id_to_local_def_id(param.hir_id).unwrap()
383385
);
384386
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);
386388

387389
this.with_parent(param.hir_id, |this| {
388390
intravisit::walk_generic_param(this, param);
389391
});
390392
});
391393
} else {
392-
self.insert(param.span, param.hir_id, Node::GenericParam(param));
394+
self.insert(param.hir_id, Node::GenericParam(param));
393395
intravisit::walk_generic_param(self, param);
394396
}
395397
}
@@ -400,7 +402,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
400402
self.definitions.opt_hir_id_to_local_def_id(ti.hir_id).unwrap()
401403
);
402404
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);
404406

405407
this.with_parent(ti.hir_id, |this| {
406408
intravisit::walk_trait_item(this, ti);
@@ -414,7 +416,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
414416
self.definitions.opt_hir_id_to_local_def_id(ii.hir_id).unwrap()
415417
);
416418
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);
418420

419421
this.with_parent(ii.hir_id, |this| {
420422
intravisit::walk_impl_item(this, ii);
@@ -425,7 +427,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
425427
fn visit_pat(&mut self, pat: &'hir Pat<'hir>) {
426428
let node =
427429
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);
429431

430432
self.with_parent(pat.hir_id, |this| {
431433
intravisit::walk_pat(this, pat);
@@ -435,31 +437,31 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
435437
fn visit_arm(&mut self, arm: &'hir Arm<'hir>) {
436438
let node = Node::Arm(arm);
437439

438-
self.insert(arm.span, arm.hir_id, node);
440+
self.insert(arm.hir_id, node);
439441

440442
self.with_parent(arm.hir_id, |this| {
441443
intravisit::walk_arm(this, arm);
442444
});
443445
}
444446

445447
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));
447449

448450
self.with_parent(constant.hir_id, |this| {
449451
intravisit::walk_anon_const(this, constant);
450452
});
451453
}
452454

453455
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));
455457

456458
self.with_parent(expr.hir_id, |this| {
457459
intravisit::walk_expr(this, expr);
458460
});
459461
}
460462

461463
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));
463465

464466
self.with_parent(stmt.hir_id, |this| {
465467
intravisit::walk_stmt(this, stmt);
@@ -468,21 +470,21 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
468470

469471
fn visit_path_segment(&mut self, path_segment: &'hir PathSegment<'hir>) {
470472
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));
472474
}
473475
intravisit::walk_path_segment(self, path_segment);
474476
}
475477

476478
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));
478480

479481
self.with_parent(ty.hir_id, |this| {
480482
intravisit::walk_ty(this, ty);
481483
});
482484
}
483485

484486
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));
486488

487489
self.with_parent(tr.hir_ref_id, |this| {
488490
intravisit::walk_trait_ref(this, tr);
@@ -501,26 +503,26 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
501503
}
502504

503505
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));
505507
self.with_parent(block.hir_id, |this| {
506508
intravisit::walk_block(this, block);
507509
});
508510
}
509511

510512
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));
512514
self.with_parent(l.hir_id, |this| intravisit::walk_local(this, l))
513515
}
514516

515517
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));
517519
}
518520

519521
fn visit_vis(&mut self, visibility: &'hir Visibility<'hir>) {
520522
match visibility.node {
521523
VisibilityKind::Public | VisibilityKind::Crate(_) | VisibilityKind::Inherited => {}
522524
VisibilityKind::Restricted { hir_id, .. } => {
523-
self.insert(visibility.span, hir_id, Node::Visibility(visibility));
525+
self.insert(hir_id, Node::Visibility(visibility));
524526
self.with_parent(hir_id, |this| {
525527
intravisit::walk_vis(this, visibility);
526528
});
@@ -538,29 +540,24 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
538540
});
539541
self.with_parent(parent, |this| {
540542
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);
547544
})
548545
});
549546
}
550547

551548
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));
553550
self.with_parent(v.id, |this| {
554551
// Register the constructor of this variant.
555552
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));
557554
}
558555
intravisit::walk_variant(this, v, g, item_id);
559556
});
560557
}
561558

562559
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));
564561
self.with_parent(field.hir_id, |this| {
565562
intravisit::walk_struct_field(this, field);
566563
});

0 commit comments

Comments
 (0)