// may need to be marked as live.
fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
node_id: ast::NodeId) -> bool {
- match tcx.hir.find(node_id) {
+ match tcx.hir().find(node_id) {
Some(Node::Item(..)) |
Some(Node::ImplItem(..)) |
Some(Node::ForeignItem(..)) |
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
fn check_def_id(&mut self, def_id: DefId) {
- if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
+ if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
if should_explore(self.tcx, node_id) {
self.worklist.push(node_id);
}
}
fn insert_def_id(&mut self, def_id: DefId) {
- if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) {
+ if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
debug_assert!(!should_explore(self.tcx, node_id));
self.live_symbols.insert(node_id);
}
self.check_def_id(def.def_id());
}
_ if self.in_pat => (),
- Def::PrimTy(..) | Def::SelfTy(..) |
+ Def::PrimTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) |
Def::Local(..) | Def::Upvar(..) => {}
Def::Variant(variant_id) | Def::VariantCtor(variant_id, ..) => {
if let Some(enum_id) = self.tcx.parent_def_id(variant_id) {
continue
}
- if let Some(ref node) = self.tcx.hir.find(id) {
+ if let Some(ref node) = self.tcx.hir().find(id) {
self.live_symbols.insert(id);
self.visit_node(node);
}
Node::Item(item) => {
match item.node {
hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => {
- let def_id = self.tcx.hir.local_def_id(item.id);
+ let def_id = self.tcx.hir().local_def_id(item.id);
let def = self.tcx.adt_def(def_id);
self.repr_has_repr_c = def.repr.c();
hir::ItemKind::Fn(..)
| hir::ItemKind::Ty(..)
| hir::ItemKind::Static(..)
+ | hir::ItemKind::Existential(..)
| hir::ItemKind::Const(..) => {
intravisit::walk_item(self, &item);
}
fn visit_nested_body(&mut self, body: hir::BodyId) {
let old_tables = self.tables;
self.tables = self.tcx.body_tables(body);
- let body = self.tcx.hir.body(body);
+ let body = self.tcx.hir().body(body);
self.visit_body(body);
self.tables = old_tables;
}
return true;
}
- let def_id = tcx.hir.local_def_id(id);
+ let def_id = tcx.hir().local_def_id(id);
let cg_attrs = tcx.codegen_fn_attrs(def_id);
// #[used], #[no_mangle], #[export_name], etc also keeps the item alive
- // forcefully, e.g. for placing it in a specific section.
+ // forcefully, e.g., for placing it in a specific section.
if cg_attrs.contains_extern_indicator() ||
cg_attrs.flags.contains(CodegenFnAttrFlags::USED) {
return true;
}
fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
- let field_type = self.tcx.type_of(self.tcx.hir.local_def_id(field.id));
+ let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
!field.is_positional()
&& !self.symbol_is_live(field.id, None)
&& !field_type.is_phantom_data()
// This is done to handle the case where, for example, the static
// method of a private type is used, but the type itself is never
// called directly.
- let def_id = self.tcx.hir.local_def_id(id);
+ let def_id = self.tcx.hir().local_def_id(id);
let inherent_impls = self.tcx.inherent_impls(def_id);
for &impl_did in inherent_impls.iter() {
for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
- if let Some(item_node_id) = self.tcx.hir.as_local_node_id(item_did) {
+ if let Some(item_node_id) = self.tcx.hir().as_local_node_id(item_did) {
if self.live_symbols.contains(&item_node_id) {
return true;
}
/// an error. We could do this also by checking the parents, but
/// this is how the code is setup and it seems harmless enough.
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.tcx.hir)
+ NestedVisitorMap::All(&self.tcx.hir())
}
fn visit_item(&mut self, item: &'tcx hir::Item) {
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
- let krate = tcx.hir.krate();
+ let krate = tcx.hir().krate();
let live_symbols = find_live(tcx, access_levels, krate);
let mut visitor = DeadVisitor {
tcx,