Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operate on HirId instead of NodeId in hir::Pat::each_binding, and consequences of that #50929

Merged
merged 3 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,6 @@ impl Definitions {
self.node_to_hir_id[node_id]
}

pub fn find_node_for_hir_id(&self, hir_id: hir::HirId) -> ast::NodeId {
self.node_to_hir_id
.iter()
.position(|x| *x == hir_id)
.map(|idx| ast::NodeId::new(idx))
.unwrap()
}

#[inline]
pub fn def_index_to_hir_id(&self, def_index: DefIndex) -> hir::HirId {
let space_index = def_index.address_space().index();
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use hir::def::Def;
use hir::def_id::DefId;
use hir::{self, PatKind};
use hir::{self, HirId, PatKind};
use syntax::ast;
use syntax::codemap::Spanned;
use syntax_pos::Span;
Expand Down Expand Up @@ -91,11 +91,11 @@ impl hir::Pat {
/// Call `f` on every "binding" in a pattern, e.g., on `a` in
/// `match foo() { Some(a) => (), None => () }`
pub fn each_binding<F>(&self, mut f: F)
where F: FnMut(hir::BindingAnnotation, ast::NodeId, Span, &Spanned<ast::Name>),
where F: FnMut(hir::BindingAnnotation, HirId, Span, &Spanned<ast::Name>),
{
self.walk(|p| {
if let PatKind::Binding(binding_mode, _, ref pth, _) = p.node {
f(binding_mode, p.id, p.span, pth);
f(binding_mode, p.hir_id, p.span, pth);
}
true
});
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,9 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
fn walk_local(&mut self, local: &hir::Local) {
match local.init {
None => {
let delegate = &mut self.delegate;
local.pat.each_binding(|_, id, span, _| {
delegate.decl_without_init(id, span);
local.pat.each_binding(|_, hir_id, span, _| {
let node_id = self.mc.tcx.hir.hir_to_node_id(hir_id);
self.delegate.decl_without_init(node_id, span);
})
}

Expand Down
Loading