Skip to content

HirId-ify intravisit #58232

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

Merged
merged 7 commits into from
Feb 24, 2019
Merged
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
133 changes: 66 additions & 67 deletions src/librustc/hir/intravisit.rs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
@@ -3301,7 +3301,9 @@ impl<'a> LoweringContext<'a> {
let mut path = path.clone();
for seg in path.segments.iter_mut() {
if seg.id.is_some() {
seg.id = Some(self.next_id().node_id);
let next_id = self.next_id();
seg.id = Some(next_id.node_id);
seg.hir_id = Some(next_id.hir_id);
}
}
path
114 changes: 59 additions & 55 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
@@ -27,9 +27,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
/// The node map
map: Vec<Option<Entry<'hir>>>,
/// The parent of this node
parent_node: NodeId,

parent_hir: hir::HirId,
parent_node: hir::HirId,

// These fields keep track of the currently relevant DepNodes during
// the visitor's traversal.
@@ -40,6 +38,7 @@ pub(super) struct NodeCollector<'a, 'hir> {

dep_graph: &'a DepGraph,
definitions: &'a definitions::Definitions,
hir_to_node_id: &'a FxHashMap<HirId, NodeId>,

hcx: StableHashingContext<'a>,

@@ -100,6 +99,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
krate: &'hir Crate,
dep_graph: &'a DepGraph,
definitions: &'a definitions::Definitions,
hir_to_node_id: &'a FxHashMap<HirId, NodeId>,
mut hcx: StableHashingContext<'a>)
-> NodeCollector<'a, 'hir> {
let root_mod_def_path_hash = definitions.def_path_hash(CRATE_DEF_INDEX);
@@ -147,14 +147,14 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
krate,
source_map: sess.source_map(),
map: repeat(None).take(sess.current_node_id_count()).collect(),
parent_node: CRATE_NODE_ID,
parent_hir: hir::CRATE_HIR_ID,
parent_node: hir::CRATE_HIR_ID,
current_signature_dep_index: root_mod_sig_dep_index,
current_full_dep_index: root_mod_full_dep_index,
current_dep_node_owner: CRATE_DEF_INDEX,
currently_in_body: false,
dep_graph,
definitions,
hir_to_node_id,
hcx,
hir_body_nodes,
};
@@ -228,10 +228,10 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
self.map[id.as_usize()] = Some(entry);
}

fn insert(&mut self, span: Span, id: NodeId, node: Node<'hir>) {
fn insert(&mut self, span: Span, hir_id: HirId, node: Node<'hir>) {
let entry = Entry {
parent: self.parent_node,
parent_hir: self.parent_hir,
parent: self.hir_to_node_id[&self.parent_node],
parent_hir: self.parent_node,
dep_node: if self.currently_in_body {
self.current_full_dep_index
} else {
@@ -240,21 +240,23 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
node,
};

let node_id = self.hir_to_node_id[&hir_id];

// Make sure that the DepNode of some node coincides with the HirId
// owner of that node.
if cfg!(debug_assertions) {
let hir_id = self.definitions.node_to_hir_id(id);
assert_eq!(self.definitions.node_to_hir_id(node_id), hir_id);

if hir_id.owner != self.current_dep_node_owner {
let node_str = match self.definitions.opt_def_index(id) {
let node_str = match self.definitions.opt_def_index(node_id) {
Some(def_index) => {
self.definitions.def_path(def_index).to_string_no_crate()
}
None => format!("{:?}", node)
};

let forgot_str = if hir_id == crate::hir::DUMMY_HIR_ID {
format!("\nMaybe you forgot to lower the node id {:?}?", id)
format!("\nMaybe you forgot to lower the node id {:?}?", node_id)
} else {
String::new()
};
@@ -276,12 +278,16 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
}
}

self.insert_entry(id, entry);
self.insert_entry(node_id, entry);
}

fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_id: NodeId, f: F) {
fn with_parent<F: FnOnce(&mut Self)>(
&mut self,
parent_node_id: HirId,
f: F,
) {
let parent_node = self.parent_node;
self.parent_node = parent_id;
self.parent_node = parent_node_id;
f(self);
self.parent_node = parent_node;
}
@@ -352,12 +358,12 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
debug_assert_eq!(i.hir_id.owner,
self.definitions.opt_def_index(i.id).unwrap());
self.with_dep_node_owner(i.hir_id.owner, i, |this| {
this.insert(i.span, i.id, Node::Item(i));
this.with_parent(i.id, |this| {
this.insert(i.span, i.hir_id, Node::Item(i));
this.with_parent(i.hir_id, |this| {
if let ItemKind::Struct(ref struct_def, _) = i.node {
// If this is a tuple-like struct, register the constructor.
if !struct_def.is_struct() {
this.insert(i.span, struct_def.id(), Node::StructCtor(struct_def));
this.insert(i.span, struct_def.hir_id(), Node::StructCtor(struct_def));
}
}
intravisit::walk_item(this, i);
@@ -366,25 +372,25 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
}

fn visit_foreign_item(&mut self, foreign_item: &'hir ForeignItem) {
self.insert(foreign_item.span, foreign_item.id, Node::ForeignItem(foreign_item));
self.insert(foreign_item.span, foreign_item.hir_id, Node::ForeignItem(foreign_item));

self.with_parent(foreign_item.id, |this| {
self.with_parent(foreign_item.hir_id, |this| {
intravisit::walk_foreign_item(this, foreign_item);
});
}

fn visit_generic_param(&mut self, param: &'hir GenericParam) {
self.insert(param.span, param.id, Node::GenericParam(param));
self.insert(param.span, param.hir_id, Node::GenericParam(param));
intravisit::walk_generic_param(self, param);
}

fn visit_trait_item(&mut self, ti: &'hir TraitItem) {
debug_assert_eq!(ti.hir_id.owner,
self.definitions.opt_def_index(ti.id).unwrap());
self.with_dep_node_owner(ti.hir_id.owner, ti, |this| {
this.insert(ti.span, ti.id, Node::TraitItem(ti));
this.insert(ti.span, ti.hir_id, Node::TraitItem(ti));

this.with_parent(ti.id, |this| {
this.with_parent(ti.hir_id, |this| {
intravisit::walk_trait_item(this, ti);
});
});
@@ -394,9 +400,9 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
debug_assert_eq!(ii.hir_id.owner,
self.definitions.opt_def_index(ii.id).unwrap());
self.with_dep_node_owner(ii.hir_id.owner, ii, |this| {
this.insert(ii.span, ii.id, Node::ImplItem(ii));
this.insert(ii.span, ii.hir_id, Node::ImplItem(ii));

this.with_parent(ii.id, |this| {
this.with_parent(ii.hir_id, |this| {
intravisit::walk_impl_item(this, ii);
});
});
@@ -408,93 +414,92 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
} else {
Node::Pat(pat)
};
self.insert(pat.span, pat.id, node);
self.insert(pat.span, pat.hir_id, node);

self.with_parent(pat.id, |this| {
self.with_parent(pat.hir_id, |this| {
intravisit::walk_pat(this, pat);
});
}

fn visit_anon_const(&mut self, constant: &'hir AnonConst) {
self.insert(DUMMY_SP, constant.id, Node::AnonConst(constant));
self.insert(DUMMY_SP, constant.hir_id, Node::AnonConst(constant));

self.with_parent(constant.id, |this| {
self.with_parent(constant.hir_id, |this| {
intravisit::walk_anon_const(this, constant);
});
}

fn visit_expr(&mut self, expr: &'hir Expr) {
self.insert(expr.span, expr.id, Node::Expr(expr));
self.insert(expr.span, expr.hir_id, Node::Expr(expr));

self.with_parent(expr.id, |this| {
self.with_parent(expr.hir_id, |this| {
intravisit::walk_expr(this, expr);
});
}

fn visit_stmt(&mut self, stmt: &'hir Stmt) {
let id = stmt.id;
self.insert(stmt.span, id, Node::Stmt(stmt));
self.insert(stmt.span, stmt.hir_id, Node::Stmt(stmt));

self.with_parent(id, |this| {
self.with_parent(stmt.hir_id, |this| {
intravisit::walk_stmt(this, stmt);
});
}

fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment) {
if let Some(id) = path_segment.id {
self.insert(path_span, id, Node::PathSegment(path_segment));
if let Some(hir_id) = path_segment.hir_id {
self.insert(path_span, hir_id, Node::PathSegment(path_segment));
}
intravisit::walk_path_segment(self, path_span, path_segment);
}

fn visit_ty(&mut self, ty: &'hir Ty) {
self.insert(ty.span, ty.id, Node::Ty(ty));
self.insert(ty.span, ty.hir_id, Node::Ty(ty));

self.with_parent(ty.id, |this| {
self.with_parent(ty.hir_id, |this| {
intravisit::walk_ty(this, ty);
});
}

fn visit_trait_ref(&mut self, tr: &'hir TraitRef) {
self.insert(tr.path.span, tr.ref_id, Node::TraitRef(tr));
self.insert(tr.path.span, tr.hir_ref_id, Node::TraitRef(tr));

self.with_parent(tr.ref_id, |this| {
self.with_parent(tr.hir_ref_id, |this| {
intravisit::walk_trait_ref(this, tr);
});
}

fn visit_fn(&mut self, fk: intravisit::FnKind<'hir>, fd: &'hir FnDecl,
b: BodyId, s: Span, id: NodeId) {
b: BodyId, s: Span, id: HirId) {
assert_eq!(self.parent_node, id);
intravisit::walk_fn(self, fk, fd, b, s, id);
}

fn visit_block(&mut self, block: &'hir Block) {
self.insert(block.span, block.id, Node::Block(block));
self.with_parent(block.id, |this| {
self.insert(block.span, block.hir_id, Node::Block(block));
self.with_parent(block.hir_id, |this| {
intravisit::walk_block(this, block);
});
}

fn visit_local(&mut self, l: &'hir Local) {
self.insert(l.span, l.id, Node::Local(l));
self.with_parent(l.id, |this| {
self.insert(l.span, l.hir_id, Node::Local(l));
self.with_parent(l.hir_id, |this| {
intravisit::walk_local(this, l)
})
}

fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) {
self.insert(lifetime.span, lifetime.id, Node::Lifetime(lifetime));
self.insert(lifetime.span, lifetime.hir_id, Node::Lifetime(lifetime));
}

fn visit_vis(&mut self, visibility: &'hir Visibility) {
match visibility.node {
VisibilityKind::Public |
VisibilityKind::Crate(_) |
VisibilityKind::Inherited => {}
VisibilityKind::Restricted { id, .. } => {
self.insert(visibility.span, id, Node::Visibility(visibility));
self.with_parent(id, |this| {
VisibilityKind::Restricted { hir_id, .. } => {
self.insert(visibility.span, hir_id, Node::Visibility(visibility));
self.with_parent(hir_id, |this| {
intravisit::walk_vis(this, visibility);
});
}
@@ -505,21 +510,20 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
let def_index = self.definitions.opt_def_index(macro_def.id).unwrap();

self.with_dep_node_owner(def_index, macro_def, |this| {
this.insert(macro_def.span, macro_def.id, Node::MacroDef(macro_def));
this.insert(macro_def.span, macro_def.hir_id, Node::MacroDef(macro_def));
});
}

fn visit_variant(&mut self, v: &'hir Variant, g: &'hir Generics, item_id: NodeId) {
let id = v.node.data.id();
self.insert(v.span, id, Node::Variant(v));
self.with_parent(id, |this| {
fn visit_variant(&mut self, v: &'hir Variant, g: &'hir Generics, item_id: HirId) {
self.insert(v.span, v.node.data.hir_id(), Node::Variant(v));
self.with_parent(v.node.data.hir_id(), |this| {
intravisit::walk_variant(this, v, g, item_id);
});
}

fn visit_struct_field(&mut self, field: &'hir StructField) {
self.insert(field.span, field.id, Node::Field(field));
self.with_parent(field.id, |this| {
self.insert(field.span, field.hir_id, Node::Field(field));
self.with_parent(field.hir_id, |this| {
intravisit::walk_struct_field(this, field);
});
}
53 changes: 23 additions & 30 deletions src/librustc/hir/map/hir_id_validator.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX};
use crate::hir::{self, intravisit, HirId, ItemLocalId};
use syntax::ast::NodeId;
use crate::hir::itemlikevisit::ItemLikeVisitor;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::{Lock, ParallelIterator, par_iter};

pub fn check_crate<'hir>(hir_map: &hir::map::Map<'hir>) {
@@ -30,7 +30,7 @@ pub fn check_crate<'hir>(hir_map: &hir::map::Map<'hir>) {
struct HirIdValidator<'a, 'hir: 'a> {
hir_map: &'a hir::map::Map<'hir>,
owner_def_index: Option<DefIndex>,
hir_ids_seen: FxHashMap<ItemLocalId, NodeId>,
hir_ids_seen: FxHashSet<ItemLocalId>,
errors: &'a Lock<Vec<String>>,
}

@@ -55,17 +55,17 @@ impl<'a, 'hir: 'a> OuterVisitor<'a, 'hir> {
impl<'a, 'hir: 'a> ItemLikeVisitor<'hir> for OuterVisitor<'a, 'hir> {
fn visit_item(&mut self, i: &'hir hir::Item) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.id, |this| intravisit::walk_item(this, i));
inner_visitor.check(i.hir_id, |this| intravisit::walk_item(this, i));
}

fn visit_trait_item(&mut self, i: &'hir hir::TraitItem) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.id, |this| intravisit::walk_trait_item(this, i));
inner_visitor.check(i.hir_id, |this| intravisit::walk_trait_item(this, i));
}

fn visit_impl_item(&mut self, i: &'hir hir::ImplItem) {
let mut inner_visitor = self.new_inner_visitor(self.hir_map);
inner_visitor.check(i.id, |this| intravisit::walk_impl_item(this, i));
inner_visitor.check(i.hir_id, |this| intravisit::walk_impl_item(this, i));
}
}

@@ -77,10 +77,10 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
}

fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self,
node_id: NodeId,
hir_id: HirId,
walk: F) {
assert!(self.owner_def_index.is_none());
let owner_def_index = self.hir_map.local_def_id(node_id).index;
let owner_def_index = self.hir_map.local_def_id_from_hir_id(hir_id).index;
self.owner_def_index = Some(owner_def_index);
walk(self);

@@ -90,15 +90,15 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {

// There's always at least one entry for the owning item itself
let max = self.hir_ids_seen
.keys()
.iter()
.map(|local_id| local_id.as_usize())
.max()
.expect("owning item has no entry");

if max != self.hir_ids_seen.len() - 1 {
// Collect the missing ItemLocalIds
let missing: Vec<_> = (0 ..= max as u32)
.filter(|&i| !self.hir_ids_seen.contains_key(&ItemLocalId::from_u32(i)))
.filter(|&i| !self.hir_ids_seen.contains(&ItemLocalId::from_u32(i)))
.collect();

// Try to map those to something more useful
@@ -133,8 +133,12 @@ impl<'a, 'hir: 'a> HirIdValidator<'a, 'hir> {
max,
missing_items,
self.hir_ids_seen
.values()
.map(|n| format!("({:?} {})", n, self.hir_map.node_to_string(*n)))
.iter()
.map(|&local_id| HirId {
owner: owner_def_index,
local_id,
})
.map(|h| format!("({:?} {})", h, self.hir_map.hir_to_string(h)))
.collect::<Vec<_>>()));
}
}
@@ -147,35 +151,24 @@ impl<'a, 'hir: 'a> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
intravisit::NestedVisitorMap::OnlyBodies(self.hir_map)
}

fn visit_id(&mut self, node_id: NodeId) {
fn visit_id(&mut self, hir_id: HirId) {
let owner = self.owner_def_index.expect("no owner_def_index");
let stable_id = self.hir_map.definitions().node_to_hir_id[node_id];

if stable_id == hir::DUMMY_HIR_ID {
self.error(|| format!("HirIdValidator: No HirId assigned for NodeId {}: {:?}",
node_id,
self.hir_map.node_to_string(node_id)));
if hir_id == hir::DUMMY_HIR_ID {
self.error(|| format!("HirIdValidator: HirId {:?} is invalid",
self.hir_map.hir_to_string(hir_id)));
return;
}

if owner != stable_id.owner {
if owner != hir_id.owner {
self.error(|| format!(
"HirIdValidator: The recorded owner of {} is {} instead of {}",
self.hir_map.node_to_string(node_id),
self.hir_map.def_path(DefId::local(stable_id.owner)).to_string_no_crate(),
self.hir_map.hir_to_string(hir_id),
self.hir_map.def_path(DefId::local(hir_id.owner)).to_string_no_crate(),
self.hir_map.def_path(DefId::local(owner)).to_string_no_crate()));
}

if let Some(prev) = self.hir_ids_seen.insert(stable_id.local_id, node_id) {
if prev != node_id {
self.error(|| format!(
"HirIdValidator: Same HirId {}/{} assigned for nodes {} and {}",
self.hir_map.def_path(DefId::local(stable_id.owner)).to_string_no_crate(),
stable_id.local_id.as_usize(),
self.hir_map.node_to_string(prev),
self.hir_map.node_to_string(node_id)));
}
}
self.hir_ids_seen.insert(hir_id.local_id);
}

fn visit_impl_item_ref(&mut self, _: &'hir hir::ImplItemRef) {
14 changes: 7 additions & 7 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ use crate::middle::cstore::CrateStoreDyn;

use rustc_target::spec::abi::Abi;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::join;
use syntax::ast::{self, Name, NodeId, CRATE_NODE_ID};
use syntax::source_map::Spanned;
use syntax::ext::base::MacroKind;
@@ -1242,13 +1241,18 @@ pub fn map_crate<'hir>(sess: &crate::session::Session,
forest: &'hir Forest,
definitions: &'hir Definitions)
-> Map<'hir> {
let ((map, crate_hash), hir_to_node_id) = join(|| {
// Build the reverse mapping of `node_to_hir_id`.
let hir_to_node_id = definitions.node_to_hir_id.iter_enumerated()
.map(|(node_id, &hir_id)| (hir_id, node_id)).collect();

let (map, crate_hash) = {
let hcx = crate::ich::StableHashingContext::new(sess, &forest.krate, definitions, cstore);

let mut collector = NodeCollector::root(sess,
&forest.krate,
&forest.dep_graph,
&definitions,
&hir_to_node_id,
hcx);
intravisit::walk_crate(&mut collector, &forest.krate);

@@ -1259,11 +1263,7 @@ pub fn map_crate<'hir>(sess: &crate::session::Session,
cstore,
cmdline_args
)
}, || {
// Build the reverse mapping of `node_to_hir_id`.
definitions.node_to_hir_id.iter_enumerated()
.map(|(node_id, &hir_id)| (hir_id, node_id)).collect()
});
};

if log_enabled!(::log::Level::Debug) {
// This only makes sense for ordered stores; note the
53 changes: 28 additions & 25 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
@@ -519,7 +519,7 @@ pub struct LateContext<'a, 'tcx: 'a> {
/// The store of registered lints and the lint levels.
lint_sess: LintSession<'tcx, LateLintPassObject>,

last_ast_node_with_lint_attrs: ast::NodeId,
last_node_with_lint_attrs: hir::HirId,

/// Generic type parameters in scope for the item we are in.
pub generics: Option<&'tcx hir::Generics>,
@@ -564,7 +564,6 @@ impl LintPassObject for EarlyLintPassObject {}

impl LintPassObject for LateLintPassObject {}


pub trait LintContext<'tcx>: Sized {
type PassObject: LintPassObject;

@@ -725,10 +724,14 @@ impl<'a, 'tcx> LintContext<'tcx> for LateContext<'a, 'tcx> {
span: Option<S>,
msg: &str)
-> DiagnosticBuilder<'_> {
let id = self.last_ast_node_with_lint_attrs;
let hir_id = self.last_node_with_lint_attrs;

match span {
Some(s) => self.tcx.struct_span_lint_node(lint, id, s, msg),
None => self.tcx.struct_lint_node(lint, id, msg),
Some(s) => self.tcx.struct_span_lint_hir(lint, hir_id, s, msg),
None => {
let node_id = self.tcx.hir().hir_to_node_id(hir_id); // FIXME(@ljedrz): remove later
self.tcx.struct_lint_node(lint, node_id, msg)
},
}
}
}
@@ -767,17 +770,17 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
/// current lint context, call the provided function, then reset the
/// lints in effect to their previous state.
fn with_lint_attrs<F>(&mut self,
id: ast::NodeId,
id: hir::HirId,
attrs: &'tcx [ast::Attribute],
f: F)
where F: FnOnce(&mut Self)
{
let prev = self.last_ast_node_with_lint_attrs;
self.last_ast_node_with_lint_attrs = id;
let prev = self.last_node_with_lint_attrs;
self.last_node_with_lint_attrs = id;
self.enter_attrs(attrs);
f(self);
self.exit_attrs(attrs);
self.last_ast_node_with_lint_attrs = prev;
self.last_node_with_lint_attrs = prev;
}

fn enter_attrs(&mut self, attrs: &'tcx [ast::Attribute]) {
@@ -798,8 +801,8 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
f(self);
self.param_env = old_param_env;
}
pub fn current_lint_root(&self) -> ast::NodeId {
self.last_ast_node_with_lint_attrs
pub fn current_lint_root(&self) -> hir::HirId {
self.last_node_with_lint_attrs
}
}

@@ -837,7 +840,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
fn visit_item(&mut self, it: &'tcx hir::Item) {
let generics = self.generics.take();
self.generics = it.node.generics();
self.with_lint_attrs(it.id, &it.attrs, |cx| {
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
cx.with_param_env(it.id, |cx| {
run_lints!(cx, check_item, it);
hir_visit::walk_item(cx, it);
@@ -848,7 +851,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
}

fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
self.with_lint_attrs(it.id, &it.attrs, |cx| {
self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
cx.with_param_env(it.id, |cx| {
run_lints!(cx, check_foreign_item, it);
hir_visit::walk_foreign_item(cx, it);
@@ -863,7 +866,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
}

fn visit_expr(&mut self, e: &'tcx hir::Expr) {
self.with_lint_attrs(e.id, &e.attrs, |cx| {
self.with_lint_attrs(e.hir_id, &e.attrs, |cx| {
run_lints!(cx, check_expr, e);
hir_visit::walk_expr(cx, e);
run_lints!(cx, check_expr_post, e);
@@ -881,7 +884,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
}

fn visit_fn(&mut self, fk: hir_visit::FnKind<'tcx>, decl: &'tcx hir::FnDecl,
body_id: hir::BodyId, span: Span, id: ast::NodeId) {
body_id: hir::BodyId, span: Span, id: hir::HirId) {
// Wrap in tables here, not just in visit_nested_body,
// in order for `check_fn` to be able to use them.
let old_tables = self.tables;
@@ -897,15 +900,15 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
s: &'tcx hir::VariantData,
name: ast::Name,
g: &'tcx hir::Generics,
item_id: ast::NodeId,
item_id: hir::HirId,
_: Span) {
run_lints!(self, check_struct_def, s, name, g, item_id);
hir_visit::walk_struct_def(self, s);
run_lints!(self, check_struct_def_post, s, name, g, item_id);
}

fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
self.with_lint_attrs(s.id, &s.attrs, |cx| {
self.with_lint_attrs(s.hir_id, &s.attrs, |cx| {
run_lints!(cx, check_struct_field, s);
hir_visit::walk_struct_field(cx, s);
})
@@ -914,8 +917,8 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
fn visit_variant(&mut self,
v: &'tcx hir::Variant,
g: &'tcx hir::Generics,
item_id: ast::NodeId) {
self.with_lint_attrs(v.node.data.id(), &v.node.attrs, |cx| {
item_id: hir::HirId) {
self.with_lint_attrs(v.node.data.hir_id(), &v.node.attrs, |cx| {
run_lints!(cx, check_variant, v, g);
hir_visit::walk_variant(cx, v, g, item_id);
run_lints!(cx, check_variant_post, v, g);
@@ -931,14 +934,14 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
run_lints!(self, check_name, sp, name);
}

fn visit_mod(&mut self, m: &'tcx hir::Mod, s: Span, n: ast::NodeId) {
fn visit_mod(&mut self, m: &'tcx hir::Mod, s: Span, n: hir::HirId) {
run_lints!(self, check_mod, m, s, n);
hir_visit::walk_mod(self, m, n);
run_lints!(self, check_mod_post, m, s, n);
}

fn visit_local(&mut self, l: &'tcx hir::Local) {
self.with_lint_attrs(l.id, &l.attrs, |cx| {
self.with_lint_attrs(l.hir_id, &l.attrs, |cx| {
run_lints!(cx, check_local, l);
hir_visit::walk_local(cx, l);
})
@@ -979,7 +982,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
let generics = self.generics.take();
self.generics = Some(&trait_item.generics);
self.with_lint_attrs(trait_item.id, &trait_item.attrs, |cx| {
self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |cx| {
cx.with_param_env(trait_item.id, |cx| {
run_lints!(cx, check_trait_item, trait_item);
hir_visit::walk_trait_item(cx, trait_item);
@@ -992,7 +995,7 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
let generics = self.generics.take();
self.generics = Some(&impl_item.generics);
self.with_lint_attrs(impl_item.id, &impl_item.attrs, |cx| {
self.with_lint_attrs(impl_item.hir_id, &impl_item.attrs, |cx| {
cx.with_param_env(impl_item.id, |cx| {
run_lints!(cx, check_impl_item, impl_item);
hir_visit::walk_impl_item(cx, impl_item);
@@ -1219,12 +1222,12 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
passes,
lints: tcx.sess.lint_store.borrow(),
},
last_ast_node_with_lint_attrs: ast::CRATE_NODE_ID,
last_node_with_lint_attrs: hir::CRATE_HIR_ID,
generics: None,
};

// Visit the whole crate.
cx.with_lint_attrs(ast::CRATE_NODE_ID, &krate.attrs, |cx| {
cx.with_lint_attrs(hir::CRATE_HIR_ID, &krate.attrs, |cx| {
// since the root module isn't visited as an item (because it isn't an
// item), warn for it here.
run_lints!(cx, check_crate, krate);
14 changes: 7 additions & 7 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
@@ -182,8 +182,8 @@ macro_rules! late_lint_methods {
fn check_name(a: Span, b: ast::Name);
fn check_crate(a: &$hir hir::Crate);
fn check_crate_post(a: &$hir hir::Crate);
fn check_mod(a: &$hir hir::Mod, b: Span, c: ast::NodeId);
fn check_mod_post(a: &$hir hir::Mod, b: Span, c: ast::NodeId);
fn check_mod(a: &$hir hir::Mod, b: Span, c: hir::HirId);
fn check_mod_post(a: &$hir hir::Mod, b: Span, c: hir::HirId);
fn check_foreign_item(a: &$hir hir::ForeignItem);
fn check_foreign_item_post(a: &$hir hir::ForeignItem);
fn check_item(a: &$hir hir::Item);
@@ -206,13 +206,13 @@ macro_rules! late_lint_methods {
b: &$hir hir::FnDecl,
c: &$hir hir::Body,
d: Span,
e: ast::NodeId);
e: hir::HirId);
fn check_fn_post(
a: hir::intravisit::FnKind<$hir>,
b: &$hir hir::FnDecl,
c: &$hir hir::Body,
d: Span,
e: ast::NodeId
e: hir::HirId
);
fn check_trait_item(a: &$hir hir::TraitItem);
fn check_trait_item_post(a: &$hir hir::TraitItem);
@@ -222,13 +222,13 @@ macro_rules! late_lint_methods {
a: &$hir hir::VariantData,
b: ast::Name,
c: &$hir hir::Generics,
d: ast::NodeId
d: hir::HirId
);
fn check_struct_def_post(
a: &$hir hir::VariantData,
b: ast::Name,
c: &$hir hir::Generics,
d: ast::NodeId
d: hir::HirId
);
fn check_struct_field(a: &$hir hir::StructField);
fn check_variant(a: &$hir hir::Variant, b: &$hir hir::Generics);
@@ -781,7 +781,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'a, 'tcx> {
fn visit_variant(&mut self,
v: &'tcx hir::Variant,
g: &'tcx hir::Generics,
item_id: ast::NodeId) {
item_id: hir::HirId) {
self.with_lint_attrs(v.node.data.id(), &v.node.attrs, |builder| {
intravisit::walk_variant(builder, v, g, item_id);
})
4 changes: 2 additions & 2 deletions src/librustc/middle/dead.rs
Original file line number Diff line number Diff line change
@@ -211,7 +211,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
}

fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name,
_: &hir::Generics, _: ast::NodeId, _: syntax_pos::Span) {
_: &hir::Generics, _: hir::HirId, _: syntax_pos::Span) {
let has_repr_c = self.repr_has_repr_c;
let inherited_pub_visibility = self.inherited_pub_visibility;
let live_fields = def.fields().iter().filter(|f| {
@@ -570,7 +570,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
fn visit_variant(&mut self,
variant: &'tcx hir::Variant,
g: &'tcx hir::Generics,
id: ast::NodeId) {
id: hir::HirId) {
if self.should_warn_about_variant(&variant.node) {
self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.ident.name,
"variant", "constructed");
8 changes: 4 additions & 4 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
}

fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
b: hir::BodyId, s: Span, id: NodeId) {
b: hir::BodyId, s: Span, id: HirId) {
visit_fn(self, fk, fd, b, s, id);
}

@@ -358,16 +358,16 @@ fn visit_fn<'a, 'tcx: 'a>(ir: &mut IrMaps<'a, 'tcx>,
decl: &'tcx hir::FnDecl,
body_id: hir::BodyId,
sp: Span,
id: ast::NodeId) {
id: hir::HirId) {
debug!("visit_fn");

// swap in a new set of IR maps for this function body:
let mut fn_maps = IrMaps::new(ir.tcx);

// Don't run unused pass for #[derive()]
if let FnKind::Method(..) = fk {
let parent = ir.tcx.hir().get_parent(id);
if let Some(Node::Item(i)) = ir.tcx.hir().find(parent) {
let parent = ir.tcx.hir().get_parent_item(id);
if let Some(Node::Item(i)) = ir.tcx.hir().find_by_hir_id(parent) {
if i.attrs.iter().any(|a| a.check_name("automatically_derived")) {
return;
}
4 changes: 2 additions & 2 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
});
}

fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: NodeId) {
fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: HirId) {
self.annotate(var.node.data.id(), &var.node.attrs, var.span, AnnotationKind::Required, |v| {
intravisit::walk_variant(v, var, g, item_id);
})
@@ -369,7 +369,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
intravisit::walk_impl_item(self, ii);
}

fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: NodeId) {
fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: HirId) {
self.check_missing_stability(var.node.data.id(), var.span, "variant");
intravisit::walk_variant(self, var, g, item_id);
}
3 changes: 1 addition & 2 deletions src/librustc_borrowck/borrowck/gather_loans/move_error.rs
Original file line number Diff line number Diff line change
@@ -88,8 +88,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &[MoveErr
}
}
if let NoteClosureEnv(upvar_id) = error.move_from.note {
let var_node_id = bccx.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
err.span_label(bccx.tcx.hir().span(var_node_id),
err.span_label(bccx.tcx.hir().span_by_hir_id(upvar_id.var_path.hir_id),
"captured outer variable");
}
err.emit();
26 changes: 13 additions & 13 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
@@ -703,20 +703,20 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {

// Get type of value and span where it was previously
// moved.
let node_id = self.tcx.hir().hir_to_node_id(hir::HirId {
let hir_id = hir::HirId {
owner: self.body.value.hir_id.owner,
local_id: the_move.id
});
};
let (move_span, move_note) = match the_move.kind {
move_data::Declared => {
unreachable!();
}

move_data::MoveExpr |
move_data::MovePat => (self.tcx.hir().span(node_id), ""),
move_data::MovePat => (self.tcx.hir().span_by_hir_id(hir_id), ""),

move_data::Captured =>
(match self.tcx.hir().expect_expr(node_id).node {
(match self.tcx.hir().expect_expr_by_hir_id(hir_id).node {
hir::ExprKind::Closure(.., fn_decl_span, _) => fn_decl_span,
ref r => bug!("Captured({:?}) maps to non-closure: {:?}",
the_move.id, r),
@@ -828,8 +828,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
MutabilityViolation => {
let mut db = self.cannot_assign(error_span, &descr, Origin::Ast);
if let mc::NoteClosureEnv(upvar_id) = err.cmt.note {
let node_id = self.tcx.hir().hir_to_node_id(upvar_id.var_path.hir_id);
let sp = self.tcx.hir().span(node_id);
let hir_id = upvar_id.var_path.hir_id;
let sp = self.tcx.hir().span_by_hir_id(hir_id);
let fn_closure_msg = "`Fn` closures cannot capture their enclosing \
environment for modifications";
match (self.tcx.sess.source_map().span_to_snippet(sp), &err.cmt.cat) {
@@ -1120,8 +1120,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
} else {
"consider changing this closure to take self by mutable reference"
};
let node_id = self.tcx.hir().local_def_id_to_node_id(id);
let help_span = self.tcx.hir().span(node_id);
let hir_id = self.tcx.hir().local_def_id_to_hir_id(id);
let help_span = self.tcx.hir().span_by_hir_id(hir_id);
self.cannot_act_on_capture_in_sharable_fn(span,
prefix,
(help_span, help_msg),
@@ -1362,9 +1362,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
_ => bug!()
};
if *kind == ty::ClosureKind::Fn {
let closure_node_id =
self.tcx.hir().local_def_id_to_node_id(upvar_id.closure_expr_id);
db.span_help(self.tcx.hir().span(closure_node_id),
let closure_hir_id =
self.tcx.hir().local_def_id_to_hir_id(upvar_id.closure_expr_id);
db.span_help(self.tcx.hir().span_by_hir_id(closure_hir_id),
"consider changing this closure to take \
self by mutable reference");
}
@@ -1397,8 +1397,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
loan_path: &LoanPath<'tcx>,
out: &mut String) {
match loan_path.kind {
LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id}, closure_expr_id: _ }) => {
out.push_str(&self.tcx.hir().name(self.tcx.hir().hir_to_node_id(id)).as_str());
LpUpvar(ty::UpvarId { var_path: ty::UpvarPath { hir_id: id }, closure_expr_id: _ }) => {
out.push_str(&self.tcx.hir().name_by_hir_id(id).as_str());
}
LpVar(id) => {
out.push_str(&self.tcx.hir().name(id).as_str());
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
@@ -499,7 +499,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {

fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem) {
// If the method is an impl for a trait, don't doc.
if method_context(cx, impl_item.id) == MethodLateContext::TraitImpl {
if method_context(cx, impl_item.hir_id) == MethodLateContext::TraitImpl {
return;
}

8 changes: 4 additions & 4 deletions src/librustc_lint/nonstandard_style.rs
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ pub enum MethodLateContext {
PlainImpl,
}

pub fn method_context(cx: &LateContext<'_, '_>, id: ast::NodeId) -> MethodLateContext {
let def_id = cx.tcx.hir().local_def_id(id);
pub fn method_context(cx: &LateContext<'_, '_>, id: hir::HirId) -> MethodLateContext {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(id);
let item = cx.tcx.associated_item(def_id);
match item.container {
ty::TraitContainer(..) => MethodLateContext::TraitAutoImpl,
@@ -317,7 +317,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
_: &hir::FnDecl,
_: &hir::Body,
_: Span,
id: ast::NodeId,
id: hir::HirId,
) {
match &fk {
FnKind::Method(ident, ..) => {
@@ -369,7 +369,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
s: &hir::VariantData,
_: ast::Name,
_: &hir::Generics,
_: ast::NodeId,
_: hir::HirId,
) {
for sf in s.fields() {
self.check_snake_case(cx, "structure field", &sf.ident);
2 changes: 1 addition & 1 deletion src/librustc_metadata/encoder.rs
Original file line number Diff line number Diff line change
@@ -1663,7 +1663,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
fn visit_variant(&mut self,
v: &'tcx hir::Variant,
g: &'tcx hir::Generics,
id: ast::NodeId) {
id: hir::HirId) {
intravisit::walk_variant(self, v, g, id);

if let Some(ref discr) = v.node.disr_expr {
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/mod.rs
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ fn mir_keys<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: CrateNum)
v: &'tcx hir::VariantData,
_: ast::Name,
_: &'tcx hir::Generics,
_: ast::NodeId,
_: hir::HirId,
_: Span) {
if let hir::VariantData::Tuple(_, node_id, _) = *v {
self.set.insert(self.tcx.hir().local_def_id(node_id));
6 changes: 3 additions & 3 deletions src/librustc_passes/hir_stats.rs
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
hir_visit::walk_item(self, i)
}

fn visit_mod(&mut self, m: &'v hir::Mod, _s: Span, n: NodeId) {
fn visit_mod(&mut self, m: &'v hir::Mod, _s: Span, n: hir::HirId) {
self.record("Mod", Id::None, m);
hir_visit::walk_mod(self, m, n)
}
@@ -173,7 +173,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
fd: &'v hir::FnDecl,
b: hir::BodyId,
s: Span,
id: NodeId) {
id: hir::HirId) {
self.record("FnDecl", Id::None, fd);
hir_visit::walk_fn(self, fk, fd, b, s, id)
}
@@ -206,7 +206,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
fn visit_variant(&mut self,
v: &'v hir::Variant,
g: &'v hir::Generics,
item_id: NodeId) {
item_id: hir::HirId) {
self.record("Variant", Id::None, v);
hir_visit::walk_variant(self, v, g, item_id)
}
19 changes: 10 additions & 9 deletions src/librustc_privacy/lib.rs
Original file line number Diff line number Diff line change
@@ -454,8 +454,8 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
if let Some([module, segment]) = segments.rchunks_exact(2).next() {
if let Some(item) = module.def
.and_then(|def| def.mod_def_id())
.and_then(|def_id| self.tcx.hir().as_local_node_id(def_id))
.map(|module_node_id| self.tcx.hir().expect_item(module_node_id))
.and_then(|def_id| self.tcx.hir().as_local_hir_id(def_id))
.map(|module_hir_id| self.tcx.hir().expect_item_by_hir_id(module_hir_id))
{
if let hir::ItemKind::Mod(m) = &item.node {
for item_id in m.item_ids.as_ref() {
@@ -673,11 +673,11 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
self.prev_level = orig_level;
}

fn visit_mod(&mut self, m: &'tcx hir::Mod, _sp: Span, id: ast::NodeId) {
fn visit_mod(&mut self, m: &'tcx hir::Mod, _sp: Span, id: hir::HirId) {
// This code is here instead of in visit_item so that the
// crate module gets processed as well.
if self.prev_level.is_some() {
let def_id = self.tcx.hir().local_def_id(id);
let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
if let Some(exports) = self.tcx.module_exports(def_id) {
for export in exports.iter() {
if export.vis == ty::Visibility::Public {
@@ -823,7 +823,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NamePrivacyVisitor<'a, 'tcx> {
NestedVisitorMap::All(&self.tcx.hir())
}

fn visit_mod(&mut self, _m: &'tcx hir::Mod, _s: Span, _n: ast::NodeId) {
fn visit_mod(&mut self, _m: &'tcx hir::Mod, _s: Span, _n: hir::HirId) {
// Don't visit nested modules, since we run a separate visitor walk
// for each module in `privacy_access_levels`
}
@@ -963,7 +963,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypePrivacyVisitor<'a, 'tcx> {
NestedVisitorMap::All(&self.tcx.hir())
}

fn visit_mod(&mut self, _m: &'tcx hir::Mod, _s: Span, _n: ast::NodeId) {
fn visit_mod(&mut self, _m: &'tcx hir::Mod, _s: Span, _n: hir::HirId) {
// Don't visit nested modules, since we run a separate visitor walk
// for each module in `privacy_access_levels`
}
@@ -1461,7 +1461,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
fn visit_variant(&mut self,
v: &'tcx hir::Variant,
g: &'tcx hir::Generics,
item_id: ast::NodeId) {
item_id: hir::HirId) {
if self.access_levels.is_reachable(v.node.data.id()) {
self.in_variant = true;
intravisit::walk_variant(self, v, g, item_id);
@@ -1769,7 +1769,8 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
empty_tables: &empty_tables,
};
let (module, span, node_id) = tcx.hir().get_module(module_def_id);
intravisit::walk_mod(&mut visitor, module, node_id);
let hir_id = tcx.hir().node_to_hir_id(node_id);
intravisit::walk_mod(&mut visitor, module, hir_id);

// Check privacy of explicitly written types and traits as well as
// inferred types of expressions and patterns.
@@ -1781,7 +1782,7 @@ fn check_mod_privacy<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
span,
empty_tables: &empty_tables,
};
intravisit::walk_mod(&mut visitor, module, node_id);
intravisit::walk_mod(&mut visitor, module, hir_id);
}

fn privacy_access_levels<'tcx>(
12 changes: 6 additions & 6 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
@@ -501,7 +501,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
mut msg: String,
candidates: Vec<DefId>) {
let module_did = self.tcx.hir().get_module_parent_by_hir_id(self.body_id);
let module_id = self.tcx.hir().as_local_node_id(module_did).unwrap();
let module_id = self.tcx.hir().as_local_hir_id(module_did).unwrap();
let krate = self.tcx.hir().krate();
let (span, found_use) = UsePlacementFinder::check(self.tcx, krate, module_id);
if let Some(span) = span {
@@ -787,7 +787,7 @@ pub fn provide(providers: &mut ty::query::Providers) {
}

struct UsePlacementFinder<'a, 'tcx: 'a, 'gcx: 'tcx> {
target_module: ast::NodeId,
target_module: hir::HirId,
span: Option<Span>,
found_use: bool,
tcx: TyCtxt<'a, 'gcx, 'tcx>
@@ -797,7 +797,7 @@ impl<'a, 'tcx, 'gcx> UsePlacementFinder<'a, 'tcx, 'gcx> {
fn check(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
krate: &'tcx hir::Crate,
target_module: ast::NodeId,
target_module: hir::HirId,
) -> (Option<Span>, bool) {
let mut finder = UsePlacementFinder {
target_module,
@@ -815,13 +815,13 @@ impl<'a, 'tcx, 'gcx> hir::intravisit::Visitor<'tcx> for UsePlacementFinder<'a, '
&mut self,
module: &'tcx hir::Mod,
_: Span,
node_id: ast::NodeId,
hir_id: hir::HirId,
) {
if self.span.is_some() {
return;
}
if node_id != self.target_module {
hir::intravisit::walk_mod(self, module, node_id);
if hir_id != self.target_module {
hir::intravisit::walk_mod(self, module, hir_id);
return;
}
// Find a `use` statement.
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
@@ -1024,7 +1024,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {

// Don't descend into the bodies of nested closures
fn visit_fn(&mut self, _: intravisit::FnKind<'gcx>, _: &'gcx hir::FnDecl,
_: hir::BodyId, _: Span, _: ast::NodeId) { }
_: hir::BodyId, _: Span, _: hir::HirId) { }
}

/// When `check_fn` is invoked on a generator (i.e., a body that
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/regionck.rs
Original file line number Diff line number Diff line change
@@ -456,7 +456,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> {
_: &'gcx hir::FnDecl,
body_id: hir::BodyId,
span: Span,
id: ast::NodeId,
hir_id: hir::HirId,
) {
assert!(
match fk {
@@ -473,7 +473,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> {
let env_snapshot = self.outlives_environment.push_snapshot_pre_closure();

let body = self.tcx.hir().body(body_id);
let hir_id = self.tcx.hir().node_to_hir_id(id);
self.visit_fn_body(hir_id, body, span);

// Restore state from previous function.
8 changes: 4 additions & 4 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
@@ -296,8 +296,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
}
}

let for_ = if let Some(nodeid) = tcx.hir().as_local_node_id(did) {
match tcx.hir().expect_item(nodeid).node {
let for_ = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
match tcx.hir().expect_item_by_hir_id(hir_id).node {
hir::ItemKind::Impl(.., ref t, _) => {
t.clean(cx)
}
@@ -318,8 +318,8 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
}

let predicates = tcx.predicates_of(did);
let (trait_items, generics) = if let Some(nodeid) = tcx.hir().as_local_node_id(did) {
match tcx.hir().expect_item(nodeid).node {
let (trait_items, generics) = if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
match tcx.hir().expect_item_by_hir_id(hir_id).node {
hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => {
(
item_ids.iter()
4 changes: 2 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
@@ -2562,9 +2562,9 @@ impl Clean<Type> for hir::Ty {
let mut alias = None;
if let Def::TyAlias(def_id) = path.def {
// Substitute private type aliases
if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) {
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
alias = Some(&cx.tcx.hir().expect_item(node_id).node);
alias = Some(&cx.tcx.hir().expect_item_by_hir_id(hir_id).node);
}
}
};
2 changes: 1 addition & 1 deletion src/librustdoc/test.rs
Original file line number Diff line number Diff line change
@@ -893,7 +893,7 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> {
fn visit_variant(&mut self,
v: &'hir hir::Variant,
g: &'hir hir::Generics,
item_id: ast::NodeId) {
item_id: hir::HirId) {
self.visit_testable(v.node.ident.to_string(), &v.node.attrs, |this| {
intravisit::walk_variant(this, v, g, item_id);
});
6 changes: 3 additions & 3 deletions src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs
Original file line number Diff line number Diff line change
@@ -48,11 +48,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass {
_: &'tcx hir::FnDecl,
_: &'tcx hir::Body,
span: source_map::Span,
id: ast::NodeId) {
id: hir::HirId) {

let item = match cx.tcx.hir().get(id) {
let item = match cx.tcx.hir().get_by_hir_id(id) {
Node::Item(item) => item,
_ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent(id)),
_ => cx.tcx.hir().expect_item_by_hir_id(cx.tcx.hir().get_parent_item(id)),
};

if !attr::contains_name(&item.attrs, "whitelisted_attr") {
2 changes: 1 addition & 1 deletion src/tools/clippy