use crate::ty::query::Providers;
use crate::middle::privacy;
use crate::session::config;
-use crate::util::nodemap::{NodeSet, FxHashSet};
+use crate::util::nodemap::{HirIdSet, FxHashSet};
use rustc_target::spec::abi::Abi;
-use syntax::ast;
use crate::hir;
use crate::hir::def_id::LOCAL_CRATE;
use crate::hir::intravisit::{Visitor, NestedVisitorMap};
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
// The set of items which must be exported in the linkage sense.
- reachable_symbols: NodeSet,
+ reachable_symbols: HirIdSet,
// A worklist of item IDs. Each item ID in this worklist will be inlined
// and will be scanned for further references.
- worklist: Vec<ast::NodeId>,
+ worklist: Vec<hir::HirId>,
// Whether any output of this compilation is a library
any_library: bool,
}
match def {
Some(Def::Local(node_id)) | Some(Def::Upvar(node_id, ..)) => {
- self.reachable_symbols.insert(node_id);
+ let hir_id = self.tcx.hir().node_to_hir_id(node_id);
+ self.reachable_symbols.insert(hir_id);
}
Some(def) => {
- if let Some((node_id, def_id)) = def.opt_def_id().and_then(|def_id| {
- self.tcx.hir().as_local_node_id(def_id).map(|node_id| (node_id, def_id))
+ if let Some((hir_id, def_id)) = def.opt_def_id().and_then(|def_id| {
+ self.tcx.hir().as_local_hir_id(def_id).map(|hir_id| (hir_id, def_id))
}) {
if self.def_id_represents_local_inlined_item(def_id) {
- self.worklist.push(node_id);
+ self.worklist.push(hir_id);
} else {
match def {
// If this path leads to a constant, then we need to
// recurse into the constant to continue finding
// items that are reachable.
Def::Const(..) | Def::AssociatedConst(..) => {
- self.worklist.push(node_id);
+ self.worklist.push(hir_id);
}
// If this wasn't a static, then the destination is
// surely reachable.
_ => {
- self.reachable_symbols.insert(node_id);
+ self.reachable_symbols.insert(hir_id);
}
}
}
continue
}
- if let Some(ref item) = self.tcx.hir().find(search_item) {
+ if let Some(ref item) = self.tcx.hir().find_by_hir_id(search_item) {
self.propagate_node(item, search_item);
}
}
}
fn propagate_node(&mut self, node: &Node<'tcx>,
- search_item: ast::NodeId) {
+ search_item: hir::HirId) {
if !self.any_library {
// If we are building an executable, only explicitly extern
// types need to be exported.
} else {
false
};
- let def_id = self.tcx.hir().local_def_id(item.id);
+ let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
let is_extern = codegen_attrs.contains_extern_indicator();
let std_internal = codegen_attrs.flags.contains(
Node::Item(item) => {
match item.node {
hir::ItemKind::Fn(.., body) => {
- let def_id = self.tcx.hir().local_def_id(item.id);
+ let def_id = self.tcx.hir().local_def_id_from_hir_id(item.hir_id);
if item_might_be_inlined(self.tcx,
&item,
self.tcx.codegen_fn_attrs(def_id)) {
self.visit_nested_body(body);
}
hir::ImplItemKind::Method(_, body) => {
- let did = self.tcx.hir().get_parent_did(search_item);
+ let did = self.tcx.hir().get_parent_did_by_hir_id(search_item);
if method_might_be_inlined(self.tcx, impl_item, did) {
self.visit_nested_body(body)
}
_ => {
bug!(
"found unexpected node kind in worklist: {} ({:?})",
- self.tcx.hir().node_to_string(search_item),
+ self.tcx.hir().hir_to_string(search_item),
node,
);
}
struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
access_levels: &'a privacy::AccessLevels,
- worklist: &'a mut Vec<ast::NodeId>,
+ worklist: &'a mut Vec<hir::HirId>,
}
impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx> {
let codegen_attrs = self.tcx.codegen_fn_attrs(def_id);
if codegen_attrs.contains_extern_indicator() ||
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) {
- self.worklist.push(item.id);
+ self.worklist.push(item.hir_id);
}
// We need only trait impls here, not inherent impls, and only non-exported ones
if let hir::ItemKind::Impl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node {
- if !self.access_levels.is_reachable(item.id) {
- self.worklist.extend(impl_item_refs.iter().map(|r| r.id.node_id));
+ let node_id = self.tcx.hir().hir_to_node_id(item.hir_id);
+ if !self.access_levels.is_reachable(node_id) {
+ // FIXME(@ljedrz): rework back to a nice extend when item Ids contain HirId
+ for impl_item_ref in impl_item_refs {
+ let hir_id = self.tcx.hir().node_to_hir_id(impl_item_ref.id.node_id);
+ self.worklist.push(hir_id);
+ }
let trait_def_id = match trait_ref.path.def {
Def::Trait(def_id) => def_id,
let provided_trait_methods = self.tcx.provided_trait_methods(trait_def_id);
self.worklist.reserve(provided_trait_methods.len());
for default_method in provided_trait_methods {
- let node_id = self.tcx
- .hir()
- .as_local_node_id(default_method.def_id)
- .unwrap();
- self.worklist.push(node_id);
+ let hir_id = self.tcx
+ .hir()
+ .as_local_hir_id(default_method.def_id)
+ .unwrap();
+ self.worklist.push(hir_id);
}
}
}
// We introduce a new-type here, so we can have a specialized HashStable
// implementation for it.
#[derive(Clone)]
-pub struct ReachableSet(pub Lrc<NodeSet>);
+pub struct ReachableSet(pub Lrc<HirIdSet>);
fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> ReachableSet {
debug_assert!(crate_num == LOCAL_CRATE);
// If other crates link to us, they're going to expect to be able to
// use the lang items, so we need to be sure to mark them as
// exported.
- reachable_context.worklist.extend(access_levels.map.iter().map(|(id, _)| *id));
+ reachable_context.worklist.extend(
+ access_levels.map.iter().map(|(id, _)| tcx.hir().node_to_hir_id(*id)));
for item in tcx.lang_items().items().iter() {
if let Some(did) = *item {
- if let Some(node_id) = tcx.hir().as_local_node_id(did) {
- reachable_context.worklist.push(node_id);
+ if let Some(hir_id) = tcx.hir().as_local_hir_id(did) {
+ reachable_context.worklist.push(hir_id);
}
}
}
use rustc::util::nodemap::HirIdSet;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
-use syntax::ast::{self, DUMMY_NODE_ID, Ident};
+use syntax::ast::Ident;
use syntax::attr;
use syntax::symbol::keywords;
use syntax_pos::Span;
// Returns an over-approximation (`skip_assoc_tys` = true) of visibility due to
// associated types for which we can't determine visibility precisely.
- fn of_impl<'a, 'tcx>(node_id: ast::NodeId, tcx: TyCtxt<'a, 'tcx, 'tcx>,
+ fn of_impl<'a, 'tcx>(hir_id: hir::HirId, tcx: TyCtxt<'a, 'tcx, 'tcx>,
access_levels: &'a AccessLevels) -> Self {
let mut find = FindMin { tcx, access_levels, min: Self::MAX };
- let def_id = tcx.hir().local_def_id(node_id);
+ let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
find.visit(tcx.type_of(def_id));
if let Some(trait_ref) = tcx.impl_trait_ref(def_id) {
find.visit_trait(trait_ref);
}
impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
- fn get(&self, id: ast::NodeId) -> Option<AccessLevel> {
- self.access_levels.map.get(&id).cloned()
+ fn get(&self, id: hir::HirId) -> Option<AccessLevel> {
+ let node_id = self.tcx.hir().hir_to_node_id(id);
+ self.access_levels.map.get(&node_id).cloned()
}
// Updates node level and returns the updated level.
- fn update(&mut self, id: ast::NodeId, level: Option<AccessLevel>) -> Option<AccessLevel> {
+ fn update(&mut self, id: hir::HirId, level: Option<AccessLevel>) -> Option<AccessLevel> {
let old_level = self.get(id);
// Accessibility levels can only grow.
if level > old_level {
- self.access_levels.map.insert(id, level.unwrap());
+ let node_id = self.tcx.hir().hir_to_node_id(id);
+ self.access_levels.map.insert(node_id, level.unwrap());
self.changed = true;
level
} else {
}
}
- fn reach(&mut self, item_id: ast::NodeId, access_level: Option<AccessLevel>)
+ fn reach(&mut self, item_id: hir::HirId, access_level: Option<AccessLevel>)
-> ReachEverythingInTheInterfaceVisitor<'_, 'a, 'tcx> {
ReachEverythingInTheInterfaceVisitor {
access_level: cmp::min(access_level, Some(AccessLevel::Reachable)),
- item_def_id: self.tcx.hir().local_def_id(item_id),
+ item_def_id: self.tcx.hir().local_def_id_from_hir_id(item_id),
ev: self,
}
}
let def_id = self.tcx.hir().local_def_id(item_id.id);
if !self.tcx.hygienic_eq(segment.ident, item.ident, def_id) { continue; }
if let hir::ItemKind::Use(..) = item.node {
- self.update(item.id, Some(AccessLevel::Exported));
+ self.update(item.hir_id, Some(AccessLevel::Exported));
}
}
}
fn visit_item(&mut self, item: &'tcx hir::Item) {
let inherited_item_level = match item.node {
hir::ItemKind::Impl(..) =>
- Option::<AccessLevel>::of_impl(item.id, self.tcx, &self.access_levels),
+ Option::<AccessLevel>::of_impl(item.hir_id, self.tcx, &self.access_levels),
// Foreign modules inherit level from parents.
hir::ItemKind::ForeignMod(..) => self.prev_level,
// Other `pub` items inherit levels from parents.
};
// Update level of the item itself.
- let item_level = self.update(item.id, inherited_item_level);
+ let item_level = self.update(item.hir_id, inherited_item_level);
// Update levels of nested things.
match item.node {
hir::ItemKind::Enum(ref def, _) => {
for variant in &def.variants {
- let variant_level = self.update(variant.node.data.id(), item_level);
+ let variant_level = self.update(variant.node.data.hir_id(), item_level);
for field in variant.node.data.fields() {
- self.update(field.id, variant_level);
+ self.update(field.hir_id, variant_level);
}
}
}
hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => {
for impl_item_ref in impl_item_refs {
if trait_ref.is_some() || impl_item_ref.vis.node.is_pub() {
- self.update(impl_item_ref.id.node_id, item_level);
+ let hir_id = self.tcx.hir().node_to_hir_id(impl_item_ref.id.node_id);
+ self.update(hir_id, item_level);
}
}
}
hir::ItemKind::Trait(.., ref trait_item_refs) => {
for trait_item_ref in trait_item_refs {
- self.update(trait_item_ref.id.node_id, item_level);
+ let hir_id = self.tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
+ self.update(hir_id, item_level);
}
}
hir::ItemKind::Struct(ref def, _) | hir::ItemKind::Union(ref def, _) => {
if !def.is_struct() {
- self.update(def.id(), item_level);
+ self.update(def.hir_id(), item_level);
}
for field in def.fields() {
if field.vis.node.is_pub() {
- self.update(field.id, item_level);
+ self.update(field.hir_id, item_level);
}
}
}
hir::ItemKind::ForeignMod(ref foreign_mod) => {
for foreign_item in &foreign_mod.items {
if foreign_item.vis.node.is_pub() {
- self.update(foreign_item.id, item_level);
+ self.update(foreign_item.hir_id, item_level);
}
}
}
// in the reachability pass (`middle/reachable.rs`). Types are marked as link-time
// reachable if they are returned via `impl Trait`, even from private functions.
let exist_level = cmp::max(item_level, Some(AccessLevel::ReachableFromImplTrait));
- self.reach(item.id, exist_level).generics().predicates().ty();
+ self.reach(item.hir_id, exist_level).generics().predicates().ty();
}
// Visit everything.
hir::ItemKind::Const(..) | hir::ItemKind::Static(..) |
hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => {
if item_level.is_some() {
- self.reach(item.id, item_level).generics().predicates().ty();
+ self.reach(item.hir_id, item_level).generics().predicates().ty();
}
}
hir::ItemKind::Trait(.., ref trait_item_refs) => {
if item_level.is_some() {
- self.reach(item.id, item_level).generics().predicates();
+ self.reach(item.hir_id, item_level).generics().predicates();
for trait_item_ref in trait_item_refs {
- let mut reach = self.reach(trait_item_ref.id.node_id, item_level);
+ let hir_id = self.tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
+ let mut reach = self.reach(hir_id, item_level);
reach.generics().predicates();
if trait_item_ref.kind == AssociatedItemKind::Type &&
}
hir::ItemKind::TraitAlias(..) => {
if item_level.is_some() {
- self.reach(item.id, item_level).generics().predicates();
+ self.reach(item.hir_id, item_level).generics().predicates();
}
}
// Visit everything except for private impl items.
hir::ItemKind::Impl(.., ref impl_item_refs) => {
if item_level.is_some() {
- self.reach(item.id, item_level).generics().predicates().ty().trait_ref();
+ self.reach(item.hir_id, item_level).generics().predicates().ty().trait_ref();
for impl_item_ref in impl_item_refs {
- let impl_item_level = self.get(impl_item_ref.id.node_id);
+ let hir_id = self.tcx.hir().node_to_hir_id(impl_item_ref.id.node_id);
+ let impl_item_level = self.get(hir_id);
if impl_item_level.is_some() {
- self.reach(impl_item_ref.id.node_id, impl_item_level)
+ self.reach(hir_id, impl_item_level)
.generics().predicates().ty();
}
}
// Visit everything, but enum variants have their own levels.
hir::ItemKind::Enum(ref def, _) => {
if item_level.is_some() {
- self.reach(item.id, item_level).generics().predicates();
+ self.reach(item.hir_id, item_level).generics().predicates();
}
for variant in &def.variants {
- let variant_level = self.get(variant.node.data.id());
+ let variant_level = self.get(variant.node.data.hir_id());
if variant_level.is_some() {
for field in variant.node.data.fields() {
- self.reach(field.id, variant_level).ty();
+ self.reach(field.hir_id, variant_level).ty();
}
// Corner case: if the variant is reachable, but its
// enum is not, make the enum reachable as well.
- self.update(item.id, variant_level);
+ self.update(item.hir_id, variant_level);
}
}
}
// Visit everything, but foreign items have their own levels.
hir::ItemKind::ForeignMod(ref foreign_mod) => {
for foreign_item in &foreign_mod.items {
- let foreign_item_level = self.get(foreign_item.id);
+ let foreign_item_level = self.get(foreign_item.hir_id);
if foreign_item_level.is_some() {
- self.reach(foreign_item.id, foreign_item_level)
+ self.reach(foreign_item.hir_id, foreign_item_level)
.generics().predicates().ty();
}
}
hir::ItemKind::Struct(ref struct_def, _) |
hir::ItemKind::Union(ref struct_def, _) => {
if item_level.is_some() {
- self.reach(item.id, item_level).generics().predicates();
+ self.reach(item.hir_id, item_level).generics().predicates();
for field in struct_def.fields() {
- let field_level = self.get(field.id);
+ let field_level = self.get(field.hir_id);
if field_level.is_some() {
- self.reach(field.id, field_level).ty();
+ self.reach(field.hir_id, field_level).ty();
}
}
}
for export in exports.iter() {
if export.vis == ty::Visibility::Public {
if let Some(def_id) = export.def.opt_def_id() {
- if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
- self.update(node_id, Some(AccessLevel::Exported));
+ if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
+ self.update(hir_id, Some(AccessLevel::Exported));
}
}
}
}
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
- let node_id = self.tcx.hir().hir_to_node_id(md.hir_id);
-
if md.legacy {
- self.update(node_id, Some(AccessLevel::Public));
+ self.update(md.hir_id, Some(AccessLevel::Public));
return
}
self.tcx,
self.tcx.hir().local_def_id_from_hir_id(md.hir_id)
).unwrap();
- let mut module_id = self.tcx.hir().as_local_node_id(module_did).unwrap();
+ let mut module_id = self.tcx.hir().as_local_hir_id(module_did).unwrap();
let level = if md.vis.node.is_pub() { self.get(module_id) } else { None };
- let level = self.update(node_id, level);
+ let level = self.update(md.hir_id, level);
if level.is_none() {
return
}
loop {
- let module = if module_id == ast::CRATE_NODE_ID {
+ let module = if module_id == hir::CRATE_HIR_ID {
&self.tcx.hir().krate().module
} else if let hir::ItemKind::Mod(ref module) =
- self.tcx.hir().expect_item(module_id).node {
+ self.tcx.hir().expect_item_by_hir_id(module_id).node {
module
} else {
unreachable!()
};
for id in &module.item_ids {
- self.update(id.id, level);
+ let hir_id = self.tcx.hir().node_to_hir_id(id.id);
+ self.update(hir_id, level);
}
- let def_id = self.tcx.hir().local_def_id(module_id);
+ let def_id = self.tcx.hir().local_def_id_from_hir_id(module_id);
if let Some(exports) = self.tcx.module_exports(def_id) {
for export in exports.iter() {
- if let Some(node_id) = self.tcx.hir().as_local_node_id(export.def.def_id()) {
- self.update(node_id, level);
+ if let Some(hir_id) = self.tcx.hir().as_local_hir_id(export.def.def_id()) {
+ self.update(hir_id, level);
}
}
}
- if module_id == ast::CRATE_NODE_ID {
+ if module_id == hir::CRATE_HIR_ID {
break
}
- module_id = self.tcx.hir().get_parent_node(module_id);
+ module_id = self.tcx.hir().get_parent_node_by_hir_id(module_id);
}
}
}
impl<'a, 'tcx> DefIdVisitor<'a, 'tcx> for ReachEverythingInTheInterfaceVisitor<'_, 'a, 'tcx> {
fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { self.ev.tcx }
fn visit_def_id(&mut self, def_id: DefId, _kind: &str, _descr: &dyn fmt::Display) -> bool {
- if let Some(node_id) = self.ev.tcx.hir().as_local_node_id(def_id) {
- self.ev.update(node_id, self.access_level);
+ if let Some(hir_id) = self.ev.tcx.hir().as_local_hir_id(def_id) {
+ self.ev.update(hir_id, self.access_level);
}
false
}
struct NamePrivacyVisitor<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
- current_item: ast::NodeId,
+ current_item: hir::HirId,
empty_tables: &'a ty::TypeckTables<'tcx>,
}
def: &'tcx ty::AdtDef, // definition of the struct or enum
field: &'tcx ty::FieldDef) { // definition of the field
let ident = Ident::new(keywords::Invalid.name(), use_ctxt);
- let current_hir = self.tcx.hir().node_to_hir_id(self.current_item);
+ let current_hir = self.current_item;
let def_id = self.tcx.adjust_ident(ident, def.did, current_hir).1;
if !def.is_enum() && !field.vis.is_accessible_from(def_id, self.tcx) {
struct_span_err!(self.tcx.sess, span, E0451, "field `{}` of {} `{}` is private",
}
fn visit_item(&mut self, item: &'tcx hir::Item) {
- let orig_current_item = mem::replace(&mut self.current_item, item.id);
+ let orig_current_item = mem::replace(&mut self.current_item, item.hir_id);
let orig_tables =
mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
intravisit::walk_item(self, item);
// Check types in item interfaces.
fn visit_item(&mut self, item: &'tcx hir::Item) {
- let orig_current_item =
- mem::replace(&mut self.current_item, self.tcx.hir().local_def_id(item.id));
+ let orig_current_item = mem::replace(&mut self.current_item,
+ self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
let orig_in_body = mem::replace(&mut self.in_body, false);
let orig_tables =
mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
}
}
- fn trait_is_public(&self, trait_id: ast::NodeId) -> bool {
+ fn trait_is_public(&self, trait_id: hir::HirId) -> bool {
// FIXME: this would preferably be using `exported_items`, but all
// traits are exported currently (see `EmbargoVisitor.exported_trait`).
- self.access_levels.is_public(trait_id)
+ let node_id = self.tcx.hir().hir_to_node_id(trait_id);
+ self.access_levels.is_public(node_id)
}
fn check_generic_bound(&mut self, bound: &hir::GenericBound) {
}
}
- fn item_is_public(&self, id: &ast::NodeId, vis: &hir::Visibility) -> bool {
- self.access_levels.is_reachable(*id) || vis.node.is_pub()
+ fn item_is_public(&self, id: &hir::HirId, vis: &hir::Visibility) -> bool {
+ let node_id = self.tcx.hir().hir_to_node_id(*id);
+ self.access_levels.is_reachable(node_id) || vis.node.is_pub()
}
}
hir::ItemKind::ForeignMod(_) => {}
hir::ItemKind::Trait(.., ref bounds, _) => {
- if !self.trait_is_public(item.id) {
+ if !self.trait_is_public(item.hir_id) {
return
}
|tr| {
let did = tr.path.def.def_id();
- if let Some(node_id) = self.tcx.hir().as_local_node_id(did) {
- self.trait_is_public(node_id)
+ if let Some(hir_id) = self.tcx.hir().as_local_hir_id(did) {
+ self.trait_is_public(hir_id)
} else {
true // external traits must be public
}
match impl_item.node {
hir::ImplItemKind::Const(..) |
hir::ImplItemKind::Method(..) => {
- let node_id = self.tcx.hir().hir_to_node_id(
- impl_item.hir_id);
- self.access_levels.is_reachable(node_id)
+ self.access_levels.is_reachable(
+ impl_item_ref.id.node_id)
}
hir::ImplItemKind::Existential(..) |
hir::ImplItemKind::Type(_) => false,
// don't erroneously report errors for private
// types in private items.
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
- let node_id = self.tcx.hir().hir_to_node_id(impl_item.hir_id);
match impl_item.node {
hir::ImplItemKind::Const(..) |
hir::ImplItemKind::Method(..)
- if self.item_is_public(&node_id, &impl_item.vis) =>
+ if self.item_is_public(&impl_item.hir_id, &impl_item.vis) =>
{
intravisit::walk_impl_item(self, impl_item)
}
// methods will be visible as `Public::foo`.
let mut found_pub_static = false;
for impl_item_ref in impl_item_refs {
- if self.item_is_public(&impl_item_ref.id.node_id, &impl_item_ref.vis) {
+ let hir_id = self.tcx.hir().node_to_hir_id(impl_item_ref.id.node_id);
+ if self.item_is_public(&hir_id, &impl_item_ref.vis) {
let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
match impl_item_ref.kind {
AssociatedItemKind::Const => {
hir::ItemKind::Ty(..) => return,
// Not at all public, so we don't care.
- _ if !self.item_is_public(&item.id, &item.vis) => {
+ _ if !self.item_is_public(&item.hir_id, &item.vis) => {
return;
}
}
fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
- if self.access_levels.is_reachable(item.id) {
+ let node_id = self.tcx.hir().hir_to_node_id(item.hir_id);
+ if self.access_levels.is_reachable(node_id) {
intravisit::walk_foreign_item(self, item)
}
}
v: &'tcx hir::Variant,
g: &'tcx hir::Generics,
item_id: hir::HirId) {
- if self.access_levels.is_reachable(v.node.data.id()) {
+ let node_id = self.tcx.hir().hir_to_node_id(v.node.data.hir_id());
+ if self.access_levels.is_reachable(node_id) {
self.in_variant = true;
intravisit::walk_variant(self, v, g, item_id);
self.in_variant = false;
// A trait impl is public when both its type and its trait are public
// Subitems of trait impls have inherited publicity.
hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => {
- let impl_vis = ty::Visibility::of_impl(item.id, tcx, &Default::default());
+ let impl_vis = ty::Visibility::of_impl(item.hir_id, tcx, &Default::default());
self.check(item.hir_id, impl_vis).generics().predicates();
for impl_item_ref in impl_item_refs {
let impl_item = tcx.hir().impl_item(impl_item_ref.id);
let mut visitor = NamePrivacyVisitor {
tcx,
tables: &empty_tables,
- current_item: DUMMY_NODE_ID,
+ current_item: hir::DUMMY_HIR_ID,
empty_tables: &empty_tables,
};
let (module, span, node_id) = tcx.hir().get_module(module_def_id);
break
}
}
- visitor.update(ast::CRATE_NODE_ID, Some(AccessLevel::Public));
+ visitor.update(hir::CRATE_HIR_ID, Some(AccessLevel::Public));
{
let mut visitor = ObsoleteVisiblePrivateTypesVisitor {