Skip to content

Commit 5bf68db

Browse files
committed
Auto merge of #50929 - zackmdavis:hiridification_initiative, r=michaelwoerister
operate on `HirId` instead of `NodeId` in `hir::Pat::each_binding`, and consequences of that See #50928 for motivation. Questions— * Is #50928 actually a good idea as a plan of record, or is there some reason to keep `NodeId`s? * Are the uses of `find_node_for_hir_id` in this initial submission OK (see the FIXME comments)? * Can we bikeshed a better method names `struct_span_lint_hir` _&c._? (Coined in analogy to the `struct_span_lint_node` and `NodeId`, but it feels kind of semantically clunky.) r? @michaelwoerister
2 parents 2612bbc + 1b7488d commit 5bf68db

File tree

13 files changed

+146
-136
lines changed

13 files changed

+146
-136
lines changed

src/librustc/hir/map/definitions.rs

-8
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,6 @@ impl Definitions {
487487
self.node_to_hir_id[node_id]
488488
}
489489

490-
pub fn find_node_for_hir_id(&self, hir_id: hir::HirId) -> ast::NodeId {
491-
self.node_to_hir_id
492-
.iter()
493-
.position(|x| *x == hir_id)
494-
.map(|idx| ast::NodeId::new(idx))
495-
.unwrap()
496-
}
497-
498490
#[inline]
499491
pub fn def_index_to_hir_id(&self, def_index: DefIndex) -> hir::HirId {
500492
let space_index = def_index.address_space().index();

src/librustc/hir/pat_util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use hir::def::Def;
1212
use hir::def_id::DefId;
13-
use hir::{self, PatKind};
13+
use hir::{self, HirId, PatKind};
1414
use syntax::ast;
1515
use syntax::codemap::Spanned;
1616
use syntax_pos::Span;
@@ -91,11 +91,11 @@ impl hir::Pat {
9191
/// Call `f` on every "binding" in a pattern, e.g., on `a` in
9292
/// `match foo() { Some(a) => (), None => () }`
9393
pub fn each_binding<F>(&self, mut f: F)
94-
where F: FnMut(hir::BindingAnnotation, ast::NodeId, Span, &Spanned<ast::Name>),
94+
where F: FnMut(hir::BindingAnnotation, HirId, Span, &Spanned<ast::Name>),
9595
{
9696
self.walk(|p| {
9797
if let PatKind::Binding(binding_mode, _, ref pth, _) = p.node {
98-
f(binding_mode, p.id, p.span, pth);
98+
f(binding_mode, p.hir_id, p.span, pth);
9999
}
100100
true
101101
});

src/librustc/middle/expr_use_visitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,9 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
608608
fn walk_local(&mut self, local: &hir::Local) {
609609
match local.init {
610610
None => {
611-
let delegate = &mut self.delegate;
612-
local.pat.each_binding(|_, id, span, _| {
613-
delegate.decl_without_init(id, span);
611+
local.pat.each_binding(|_, hir_id, span, _| {
612+
let node_id = self.mc.tcx.hir.hir_to_node_id(hir_id);
613+
self.delegate.decl_without_init(node_id, span);
614614
})
615615
}
616616

0 commit comments

Comments
 (0)