mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 19:43:24 +00:00
revamp Visitor
with a single method for controlling nested visits
This commit is contained in:
parent
8575184b39
commit
104125d5f7
@ -70,9 +70,42 @@ impl<'a> FnKind<'a> {
|
||||
/// Specifies what nested things a visitor wants to visit. Currently there are
|
||||
/// two modes: `OnlyBodies` descends into item bodies, but not into nested
|
||||
/// items; `All` descends into item bodies and nested items.
|
||||
pub enum NestedVisitMode {
|
||||
OnlyBodies,
|
||||
All
|
||||
pub enum NestedVisitorMap<'this, 'tcx: 'this> {
|
||||
/// Do not visit any nested things. When you add a new
|
||||
/// "non-nested" thing, you will want to audit such uses to see if
|
||||
/// they remain valid.
|
||||
None,
|
||||
|
||||
/// Do not visit nested item-like things, but visit nested things
|
||||
/// that are inside of an item-like.
|
||||
///
|
||||
/// **This is the default mode.**
|
||||
OnlyBodies(&'this Map<'tcx>),
|
||||
|
||||
/// Visit all nested things, including item-likes.
|
||||
All(&'this Map<'tcx>),
|
||||
}
|
||||
|
||||
impl<'this, 'tcx> NestedVisitorMap<'this, 'tcx> {
|
||||
/// Returns the map to use for an "intra item-like" thing (if any).
|
||||
/// e.g., function body.
|
||||
pub fn intra(self) -> Option<&'this Map<'tcx>> {
|
||||
match self {
|
||||
NestedVisitorMap::None => None,
|
||||
NestedVisitorMap::OnlyBodies(map) => Some(map),
|
||||
NestedVisitorMap::All(map) => Some(map),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the map to use for an "item-like" thing (if any).
|
||||
/// e.g., item, impl-item.
|
||||
pub fn inter(self) -> Option<&'this Map<'tcx>> {
|
||||
match self {
|
||||
NestedVisitorMap::None => None,
|
||||
NestedVisitorMap::OnlyBodies(_) => None,
|
||||
NestedVisitorMap::All(map) => Some(map),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Each method of the Visitor trait is a hook to be potentially
|
||||
@ -109,13 +142,7 @@ pub trait Visitor<'v> : Sized {
|
||||
/// `panic!()`. This way, if a new `visit_nested_XXX` variant is
|
||||
/// added in the future, we will see the panic in your code and
|
||||
/// fix it appropriately.
|
||||
fn nested_visit_map(&mut self) -> Option<&Map<'v>>;
|
||||
|
||||
/// Specifies what things nested things this visitor wants to visit. By
|
||||
/// default, bodies will be visited, but not nested items.
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode {
|
||||
NestedVisitMode::OnlyBodies
|
||||
}
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v>;
|
||||
|
||||
/// Invoked when a nested item is encountered. By default does
|
||||
/// nothing unless you override `nested_visit_map` to return
|
||||
@ -127,8 +154,7 @@ pub trait Visitor<'v> : Sized {
|
||||
/// but cannot supply a `Map`; see `nested_visit_map` for advice.
|
||||
#[allow(unused_variables)]
|
||||
fn visit_nested_item(&mut self, id: ItemId) {
|
||||
let opt_item = map_for_item(self)
|
||||
.map(|map| map.expect_item(id.id));
|
||||
let opt_item = self.nested_visit_map().inter().map(|map| map.expect_item(id.id));
|
||||
if let Some(item) = opt_item {
|
||||
self.visit_item(item);
|
||||
}
|
||||
@ -139,8 +165,7 @@ pub trait Visitor<'v> : Sized {
|
||||
/// method.
|
||||
#[allow(unused_variables)]
|
||||
fn visit_nested_impl_item(&mut self, id: ImplItemId) {
|
||||
let opt_item = map_for_item(self)
|
||||
.map(|map| map.impl_item(id));
|
||||
let opt_item = self.nested_visit_map().inter().map(|map| map.impl_item(id));
|
||||
if let Some(item) = opt_item {
|
||||
self.visit_impl_item(item);
|
||||
}
|
||||
@ -151,8 +176,7 @@ pub trait Visitor<'v> : Sized {
|
||||
/// `nested_visit_map` to return `Some(_)`, in which case it will walk the
|
||||
/// body.
|
||||
fn visit_body(&mut self, id: ExprId) {
|
||||
let opt_expr = map_for_body(self)
|
||||
.map(|map| map.expr(id));
|
||||
let opt_expr = self.nested_visit_map().intra().map(|map| map.expr(id));
|
||||
if let Some(expr) = opt_expr {
|
||||
self.visit_expr(expr);
|
||||
}
|
||||
@ -302,18 +326,6 @@ pub trait Visitor<'v> : Sized {
|
||||
}
|
||||
}
|
||||
|
||||
fn map_for_body<'v, V: Visitor<'v>>(visitor: &mut V) -> Option<&Map<'v>> {
|
||||
visitor.nested_visit_map()
|
||||
}
|
||||
|
||||
fn map_for_item<'v, V: Visitor<'v>>(visitor: &mut V) -> Option<&Map<'v>> {
|
||||
match visitor.nested_visit_mode() {
|
||||
NestedVisitMode::OnlyBodies => None,
|
||||
NestedVisitMode::All => Some(visitor.nested_visit_map()
|
||||
.expect("NestedVisitMode::All without nested_visit_map"))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_opt_name<'v, V: Visitor<'v>>(visitor: &mut V, span: Span, opt_name: Option<Name>) {
|
||||
if let Some(name) = opt_name {
|
||||
visitor.visit_name(span, name);
|
||||
@ -1061,8 +1073,8 @@ impl<'a, 'ast> IdRangeComputingVisitor<'a, 'ast> {
|
||||
}
|
||||
|
||||
impl<'a, 'ast> Visitor<'ast> for IdRangeComputingVisitor<'a, 'ast> {
|
||||
fn nested_visit_map(&mut self) -> Option<&Map<'ast>> {
|
||||
Some(&self.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
NestedVisitorMap::OnlyBodies(&self.map)
|
||||
}
|
||||
|
||||
fn visit_id(&mut self, id: NodeId) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
use hir::intravisit::Visitor;
|
||||
use hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
use hir::def_id::DefId;
|
||||
use middle::cstore::InlinedItem;
|
||||
use std::iter::repeat;
|
||||
@ -91,7 +91,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
|
||||
/// deep walking so that we walk nested items in the context of
|
||||
/// their outer items.
|
||||
|
||||
fn nested_visit_map(&mut self) -> Option<&map::Map<'ast>> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
panic!("visit_nested_xxx must be manually implemented in this visitor")
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
use hir::map::definitions::*;
|
||||
|
||||
use hir;
|
||||
use hir::intravisit;
|
||||
use hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use hir::def_id::{CRATE_DEF_INDEX, DefId, DefIndex};
|
||||
|
||||
use middle::cstore::InlinedItem;
|
||||
@ -326,9 +326,10 @@ impl<'a> visit::Visitor for DefCollector<'a> {
|
||||
}
|
||||
|
||||
// We walk the HIR rather than the AST when reading items from metadata.
|
||||
impl<'ast> intravisit::Visitor<'ast> for DefCollector<'ast> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
|
||||
None
|
||||
impl<'ast> Visitor<'ast> for DefCollector<'ast> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
// note however that we override `visit_body` below
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_body(&mut self, id: hir::ExprId) {
|
||||
|
@ -791,12 +791,8 @@ impl<'a, 'tcx> hir_visit::Visitor<'tcx> for LateContext<'a, 'tcx> {
|
||||
/// Because lints are scoped lexically, we want to walk nested
|
||||
/// items in the context of the outer item, so enable
|
||||
/// deep-walking.
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> hir_visit::NestedVisitMode {
|
||||
hir_visit::NestedVisitMode::All
|
||||
fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'tcx> {
|
||||
hir_visit::NestedVisitorMap::All(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, it: &'tcx hir::Item) {
|
||||
@ -1113,8 +1109,8 @@ struct IdVisitor<'a, 'b: 'a, 'tcx: 'a+'b> {
|
||||
|
||||
// Output any lints that were previously added to the session.
|
||||
impl<'a, 'b, 'tcx> hir_visit::Visitor<'tcx> for IdVisitor<'a, 'b, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.cx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'tcx> {
|
||||
hir_visit::NestedVisitorMap::OnlyBodies(&self.cx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_id(&mut self, id: ast::NodeId) {
|
||||
|
@ -193,7 +193,9 @@ fn build_nodeid_to_index(decl: Option<&hir::FnDecl>,
|
||||
let mut formals = Formals { entry: entry, index: index };
|
||||
intravisit::walk_fn_decl(&mut formals, decl);
|
||||
impl<'a, 'v> intravisit::Visitor<'v> for Formals<'a> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'v> {
|
||||
panic!("should not encounter fn bodies or items")
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, p: &hir::Pat) {
|
||||
self.index.entry(p.id).or_insert(vec![]).push(self.entry);
|
||||
|
@ -15,7 +15,7 @@
|
||||
use dep_graph::DepNode;
|
||||
use hir::map as ast_map;
|
||||
use hir::{self, PatKind};
|
||||
use hir::intravisit::{self, Visitor, NestedVisitMode};
|
||||
use hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use hir::itemlikevisit::ItemLikeVisitor;
|
||||
|
||||
use middle::privacy;
|
||||
@ -221,8 +221,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name,
|
||||
@ -510,12 +510,10 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> {
|
||||
/// on inner functions when the outer function is already getting
|
||||
/// 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(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode { NestedVisitMode::All }
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
if self.should_warn_about_item(item) {
|
||||
self.warn_dead_code(
|
||||
|
@ -21,7 +21,7 @@ use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use hir::{self, PatKind};
|
||||
use hir::def::Def;
|
||||
use hir::intravisit::{self, FnKind, Visitor};
|
||||
use hir::intravisit::{self, FnKind, Visitor, NestedVisitorMap};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct UnsafeContext {
|
||||
@ -93,8 +93,8 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fn_kind: FnKind<'tcx>, fn_decl: &'tcx hir::FnDecl,
|
||||
|
@ -19,7 +19,7 @@ use ty::layout::{LayoutError, Pointer, SizeSkeleton};
|
||||
use syntax::abi::Abi::RustIntrinsic;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use hir::intravisit::{self, Visitor, FnKind};
|
||||
use hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap};
|
||||
use hir;
|
||||
|
||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
@ -117,8 +117,8 @@ impl<'a, 'gcx, 'tcx> ExprVisitor<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
// const, static and N in [T; N].
|
||||
@ -163,8 +163,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for ExprVisitor<'a, 'gcx, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
|
||||
Some(&self.infcx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.infcx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
|
||||
|
@ -128,7 +128,7 @@ use syntax_pos::Span;
|
||||
use hir::Expr;
|
||||
use hir;
|
||||
use hir::print::{expr_to_string, block_to_string};
|
||||
use hir::intravisit::{self, Visitor, FnKind};
|
||||
use hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap};
|
||||
|
||||
/// For use with `propagate_through_loop`.
|
||||
enum LoopKind<'a> {
|
||||
@ -183,9 +183,10 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt) -> String {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
|
||||
b: hir::ExprId, s: Span, id: NodeId) {
|
||||
visit_fn(self, fk, fd, b, s, id);
|
||||
@ -352,9 +353,10 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.ir.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.ir.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, _: FnKind<'tcx>, _: &'tcx hir::FnDecl,
|
||||
_: hir::ExprId, _: Span, _: NodeId) {
|
||||
// do not check contents of nested fns
|
||||
|
@ -28,7 +28,7 @@ use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use hir;
|
||||
use hir::intravisit::{Visitor};
|
||||
use hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
use hir::itemlikevisit::ItemLikeVisitor;
|
||||
use hir::intravisit;
|
||||
|
||||
@ -89,8 +89,8 @@ struct ReachableContext<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
|
@ -31,7 +31,7 @@ use syntax::ast::{self, NodeId};
|
||||
use syntax_pos::Span;
|
||||
|
||||
use hir;
|
||||
use hir::intravisit::{self, Visitor, FnKind};
|
||||
use hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap};
|
||||
use hir::{Block, Item, FnDecl, Arm, Pat, PatKind, Stmt, Expr, Local};
|
||||
|
||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
|
||||
@ -1170,8 +1170,8 @@ impl<'ast, 'a> RegionResolutionVisitor<'ast, 'a> {
|
||||
}
|
||||
|
||||
impl<'ast, 'a> Visitor<'ast> for RegionResolutionVisitor<'ast, 'a> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
|
||||
Some(&self.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
NestedVisitorMap::OnlyBodies(&self.map)
|
||||
}
|
||||
|
||||
fn visit_block(&mut self, b: &'ast Block) {
|
||||
|
@ -34,7 +34,7 @@ use util::nodemap::NodeMap;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use hir;
|
||||
use hir::print::lifetime_to_string;
|
||||
use hir::intravisit::{self, Visitor, FnKind, NestedVisitMode};
|
||||
use hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub enum DefRegion {
|
||||
@ -132,12 +132,10 @@ pub fn krate(sess: &Session,
|
||||
impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
// Override the nested functions -- lifetimes follow lexical scope,
|
||||
// so it's convenient to walk the tree in lexical order.
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.hir_map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.hir_map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode { NestedVisitMode::All }
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
// Save labels for nested items.
|
||||
let saved_labels_in_fn = replace(&mut self.labels_in_fn, vec![]);
|
||||
@ -425,7 +423,9 @@ fn extract_labels(ctxt: &mut LifetimeContext, b: hir::ExprId) {
|
||||
return;
|
||||
|
||||
impl<'v, 'a> Visitor<'v> for GatherLabels<'a> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &'v hir::Expr) {
|
||||
// do not recurse into closures defined in the block
|
||||
@ -942,7 +942,9 @@ fn insert_late_bound_lifetimes(map: &mut NamedRegionMap,
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for ConstrainedCollector {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &'v hir::Ty) {
|
||||
match ty.node {
|
||||
@ -981,7 +983,9 @@ fn insert_late_bound_lifetimes(map: &mut NamedRegionMap,
|
||||
}
|
||||
|
||||
impl<'v> Visitor<'v> for AllCollector {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_lifetime(&mut self, lifetime_ref: &'v hir::Lifetime) {
|
||||
self.regions.insert(lifetime_ref.name);
|
||||
|
@ -30,8 +30,7 @@ use util::nodemap::{DefIdMap, FxHashSet, FxHashMap};
|
||||
|
||||
use hir;
|
||||
use hir::{Item, Generics, StructField, Variant};
|
||||
use hir::intravisit::{self, Visitor, NestedVisitMode};
|
||||
use hir::itemlikevisit::DeepVisitor;
|
||||
use hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
|
||||
use std::mem::replace;
|
||||
use std::cmp::Ordering;
|
||||
@ -234,12 +233,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
|
||||
/// Because stability levels are scoped lexically, we want to walk
|
||||
/// nested items in the context of the outer item, so enable
|
||||
/// deep-walking.
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode { NestedVisitMode::All }
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
let orig_in_trait_impl = self.in_trait_impl;
|
||||
let mut kind = AnnotationKind::Required;
|
||||
@ -329,8 +326,8 @@ impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx Item) {
|
||||
@ -431,8 +428,7 @@ impl<'a, 'tcx> Index<'tcx> {
|
||||
/// features and possibly prints errors.
|
||||
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let mut checker = Checker { tcx: tcx };
|
||||
tcx.visit_all_item_likes_in_krate(DepNode::StabilityCheck,
|
||||
&mut DeepVisitor::new(&mut checker));
|
||||
tcx.visit_all_item_likes_in_krate(DepNode::StabilityCheck, &mut checker.as_deep_visitor());
|
||||
}
|
||||
|
||||
struct Checker<'a, 'tcx: 'a> {
|
||||
@ -540,12 +536,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
/// Because stability levels are scoped lexically, we want to walk
|
||||
/// nested items in the context of the outer item, so enable
|
||||
/// deep-walking.
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode { NestedVisitMode::OnlyBodies }
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
hir::ItemExternCrate(_) => {
|
||||
@ -653,7 +650,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
};
|
||||
missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span);
|
||||
intravisit::walk_crate(&mut missing, krate);
|
||||
krate.visit_all_item_likes(&mut DeepVisitor::new(&mut missing));
|
||||
krate.visit_all_item_likes(&mut missing.as_deep_visitor());
|
||||
}
|
||||
|
||||
let ref declared_lib_features = sess.features.borrow().declared_lib_features;
|
||||
|
@ -18,7 +18,7 @@ use rustc_back::PanicStrategy;
|
||||
use syntax::ast;
|
||||
use syntax::symbol::Symbol;
|
||||
use syntax_pos::Span;
|
||||
use hir::intravisit::Visitor;
|
||||
use hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
use hir::intravisit;
|
||||
use hir;
|
||||
|
||||
@ -125,7 +125,9 @@ impl<'a> Context<'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for Context<'a> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {
|
||||
if let Some(lang_item) = lang_items::extract(&i.attrs) {
|
||||
|
@ -30,7 +30,7 @@ use syntax_pos::Span;
|
||||
use rustc::hir;
|
||||
use rustc::hir::Expr;
|
||||
use rustc::hir::intravisit;
|
||||
use rustc::hir::intravisit::{Visitor};
|
||||
use rustc::hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
|
||||
use self::restrictions::RestrictionResult;
|
||||
|
||||
@ -521,8 +521,8 @@ struct StaticInitializerCtxt<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for StaticInitializerCtxt<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.bccx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.bccx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &'tcx Expr) {
|
||||
|
@ -47,7 +47,7 @@ use syntax_pos::{MultiSpan, Span};
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{self, Visitor, FnKind};
|
||||
use rustc::hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap};
|
||||
|
||||
pub mod check_loans;
|
||||
|
||||
@ -63,8 +63,8 @@ pub struct LoanDataFlowOperator;
|
||||
pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator>;
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for BorrowckCtxt<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
|
||||
|
@ -29,7 +29,7 @@ use rustc::ty::{self, TyCtxt};
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
|
||||
use rustc::hir::def::*;
|
||||
use rustc::hir::intravisit::{self, Visitor, FnKind};
|
||||
use rustc::hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap};
|
||||
use rustc::hir::print::pat_to_string;
|
||||
use rustc::hir::{self, Pat, PatKind};
|
||||
|
||||
@ -42,7 +42,9 @@ use syntax_pos::Span;
|
||||
struct OuterVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> }
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, _expr: &'tcx hir::Expr) {
|
||||
return // const, static and N in [T; N] - shouldn't contain anything
|
||||
@ -93,8 +95,8 @@ struct MatchVisitor<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
|
||||
@ -563,7 +565,9 @@ struct AtBindingPatternVisitor<'a, 'b:'a, 'tcx:'b> {
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, pat: &Pat) {
|
||||
match pat.node {
|
||||
|
@ -34,7 +34,7 @@ use rustc::dep_graph::DepNode;
|
||||
use rustc::hir;
|
||||
use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
|
||||
use rustc::hir::intravisit as visit;
|
||||
use rustc::hir::intravisit::Visitor;
|
||||
use rustc::hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc::util::common::record_time;
|
||||
@ -224,7 +224,9 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
|
||||
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for HashItemsVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.calculate_node_id(item.id, |v| v.visit_item(item));
|
||||
|
@ -513,11 +513,11 @@ macro_rules! hash_span {
|
||||
}
|
||||
|
||||
impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'hash, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> visit::NestedVisitorMap<'this, 'tcx> {
|
||||
if self.hash_bodies {
|
||||
Some(&self.tcx.map)
|
||||
visit::NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
} else {
|
||||
None
|
||||
visit::NestedVisitorMap::None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,9 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::map as ast_map;
|
||||
|
||||
use rustc::hir::intravisit::{Visitor, IdRangeComputingVisitor, IdRange};
|
||||
use rustc::hir::intravisit::{Visitor, IdRangeComputingVisitor, IdRange, NestedVisitorMap};
|
||||
|
||||
use cstore::CrateMetadata;
|
||||
use encoder::EncodeContext;
|
||||
@ -75,8 +74,8 @@ struct SideTableEncodingIdVisitor<'a, 'b: 'a, 'tcx: 'b> {
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx> Visitor<'tcx> for SideTableEncodingIdVisitor<'a, 'b, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.ecx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.ecx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_id(&mut self, id: ast::NodeId) {
|
||||
|
@ -39,7 +39,7 @@ use syntax_pos;
|
||||
|
||||
use rustc::hir::{self, PatKind};
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc::hir::intravisit::{Visitor};
|
||||
use rustc::hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
use rustc::hir::intravisit;
|
||||
|
||||
use super::index_builder::{FromId, IndexBuilder, Untracked};
|
||||
@ -983,8 +983,8 @@ struct EncodeVisitor<'a, 'b: 'a, 'tcx: 'b> {
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.index.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.index.tcx.map)
|
||||
}
|
||||
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
|
||||
intravisit::walk_expr(self, ex);
|
||||
|
@ -30,7 +30,7 @@ use rustc::traits::Reveal;
|
||||
use rustc::ty::{self, Ty, TyCtxt};
|
||||
use rustc::ty::subst::Substs;
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor};
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitorMap};
|
||||
use syntax::abi::Abi;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
@ -144,8 +144,8 @@ impl<'a, 'gcx> BuildMir<'a, 'gcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
// Const and static items.
|
||||
|
@ -48,7 +48,7 @@ use rustc::lint::builtin::CONST_ERR;
|
||||
use rustc::hir::{self, PatKind};
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor};
|
||||
use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitorMap};
|
||||
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::cmp::Ordering;
|
||||
@ -233,8 +233,8 @@ impl<'a, 'gcx> CheckCrateVisitor<'a, 'gcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
|
@ -106,7 +106,7 @@ impl<'k> StatCollector<'k> {
|
||||
}
|
||||
|
||||
impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> {
|
||||
fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, 'v> {
|
||||
panic!("visit_nested_xxx must be manually implemented in this visitor")
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ use rustc::session::Session;
|
||||
|
||||
use rustc::dep_graph::DepNode;
|
||||
use rustc::hir::map::Map;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
@ -60,8 +60,8 @@ pub fn check_crate(sess: &Session, map: &Map) {
|
||||
}
|
||||
|
||||
impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
|
||||
Some(&self.hir_map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
NestedVisitorMap::OnlyBodies(&self.hir_map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'ast hir::Item) {
|
||||
|
@ -18,7 +18,7 @@ use rustc::ty::{self, TyCtxt, ParameterEnvironment};
|
||||
use rustc::traits::Reveal;
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
|
||||
@ -32,8 +32,8 @@ struct RvalueContext<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for RvalueContext<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
|
@ -20,7 +20,7 @@ use rustc::util::nodemap::NodeMap;
|
||||
use syntax::ast;
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir;
|
||||
|
||||
use std::cell::RefCell;
|
||||
@ -36,7 +36,9 @@ struct CheckCrateVisitor<'a, 'ast: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, it: &'ast hir::Item) {
|
||||
match it.node {
|
||||
@ -202,8 +204,8 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
|
||||
}
|
||||
|
||||
impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
|
||||
Some(&self.ast_map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'ast> {
|
||||
NestedVisitorMap::OnlyBodies(&self.ast_map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, it: &'ast hir::Item) {
|
||||
|
@ -30,7 +30,7 @@ use rustc::dep_graph::DepNode;
|
||||
use rustc::hir::{self, PatKind};
|
||||
use rustc::hir::def::{self, Def, CtorKind};
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir::itemlikevisit::DeepVisitor;
|
||||
use rustc::hir::pat_util::EnumerateAndAdjustIterator;
|
||||
use rustc::lint;
|
||||
@ -120,12 +120,10 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||
/// We want to visit items in the context of their containing
|
||||
/// module and so forth, so supply a crate for doing a deep walk.
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode { NestedVisitMode::All }
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let inherited_item_level = match item.node {
|
||||
// Impls inherit level from their types and traits
|
||||
@ -434,12 +432,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for PrivacyVisitor<'a, 'tcx> {
|
||||
/// We want to visit items in the context of their containing
|
||||
/// module and so forth, so supply a crate for doing a deep walk.
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode { NestedVisitMode::All }
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
let orig_curitem = replace(&mut self.curitem, item.id);
|
||||
intravisit::walk_item(self, item);
|
||||
@ -619,7 +615,9 @@ impl<'a, 'tcx> ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, ty: &hir::Ty) {
|
||||
if let hir::TyPath(hir::QPath::Resolved(_, ref path)) = ty.node {
|
||||
@ -646,12 +644,10 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for ObsoleteCheckTypeForPrivatenessVisitor<'a
|
||||
impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
/// We want to visit items in the context of their containing
|
||||
/// module and so forth, so supply a crate for doing a deep walk.
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::All(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn nested_visit_mode(&mut self) -> NestedVisitMode { NestedVisitMode::All }
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
match item.node {
|
||||
// contents of a private mod can be reexported, so we need
|
||||
@ -1068,8 +1064,8 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
//! paths etc in all kinds of annoying scenarios.
|
||||
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use syntax::ast;
|
||||
|
||||
use common::SharedCrateContext;
|
||||
@ -67,7 +67,9 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for SymbolNamesTest<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.process_attrs(item.id);
|
||||
|
@ -119,7 +119,7 @@ use syntax::symbol::{Symbol, InternedString, keywords};
|
||||
use syntax::util::lev_distance::find_best_match_for_name;
|
||||
use syntax_pos::{self, BytePos, Span};
|
||||
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc::hir::{self, PatKind};
|
||||
use rustc::hir::print as pprust;
|
||||
@ -538,8 +538,8 @@ struct CheckItemTypesVisitor<'a, 'tcx: 'a> { ccx: &'a CrateCtxt<'a, 'tcx> }
|
||||
struct CheckItemBodiesVisitor<'a, 'tcx: 'a> { ccx: &'a CrateCtxt<'a, 'tcx> }
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.ccx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.ccx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
@ -700,7 +700,9 @@ impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
// Add explicitly-declared locals.
|
||||
fn visit_local(&mut self, local: &'gcx hir::Local) {
|
||||
|
@ -99,7 +99,7 @@ use std::mem;
|
||||
use std::ops::Deref;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir::{self, PatKind};
|
||||
|
||||
use self::SubjectNode::Subject;
|
||||
@ -480,8 +480,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for RegionCtxt<'a, 'gcx, 'tcx> {
|
||||
// hierarchy, and in particular the relationships between free
|
||||
// regions, until regionck, as described in #3238.
|
||||
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
|
||||
Some(&self.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, _fk: intravisit::FnKind<'gcx>, fd: &'gcx hir::FnDecl,
|
||||
|
@ -50,7 +50,7 @@ use rustc::infer::UpvarRegion;
|
||||
use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use rustc::hir;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::util::nodemap::NodeMap;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -78,8 +78,8 @@ struct SeedBorrowKind<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for SeedBorrowKind<'a, 'gcx, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
|
||||
Some(&self.fcx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.fcx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
|
||||
@ -490,8 +490,8 @@ impl<'a, 'gcx, 'tcx> AdjustBorrowKind<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for AdjustBorrowKind<'a, 'gcx, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
|
||||
Some(&self.fcx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.fcx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
|
@ -23,7 +23,7 @@ use syntax::ast;
|
||||
use syntax_pos::Span;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir;
|
||||
|
||||
pub struct CheckTypeWellFormedVisitor<'ccx, 'tcx:'ccx> {
|
||||
@ -609,7 +609,9 @@ fn reject_shadowing_type_parameters(tcx: TyCtxt, span: Span, def_id: DefId) {
|
||||
}
|
||||
|
||||
impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
|
||||
NestedVisitorMap::None
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
debug!("visit_item: {:?}", i);
|
||||
|
@ -27,7 +27,7 @@ use syntax::ast;
|
||||
use syntax_pos::{DUMMY_SP, Span};
|
||||
|
||||
use rustc::hir::print::pat_to_string;
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir::{self, PatKind};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -187,8 +187,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
|
||||
// traffic in node-ids or update tables in the type context etc.
|
||||
|
||||
impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
|
||||
Some(&self.fcx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'gcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.fcx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, s: &'gcx hir::Stmt) {
|
||||
|
@ -83,7 +83,7 @@ use syntax::symbol::{Symbol, keywords};
|
||||
use syntax_pos::Span;
|
||||
|
||||
use rustc::hir::{self, map as hir_map, print as pprust};
|
||||
use rustc::hir::intravisit::{self, Visitor};
|
||||
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
|
||||
use rustc::hir::def::{Def, CtorKind};
|
||||
use rustc::hir::def_id::DefId;
|
||||
|
||||
@ -178,8 +178,8 @@ impl<'a, 'tcx> CollectItemTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||
fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
|
||||
Some(&self.ccx.tcx.map)
|
||||
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
|
||||
NestedVisitorMap::OnlyBodies(&self.ccx.tcx.map)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
|
Loading…
Reference in New Issue
Block a user