... and make the latter mandatory to implement.
///////////////////////////////////////////////////////////////////////////
// Nested items.
- /// The default versions of the `visit_nested_XXX` routines invoke
- /// this method to get a map to use; if they get back `None`, they
- /// just skip nested things. Otherwise, they will lookup the
- /// nested item-like things in the map and visit it. So the best
- /// way to implement a nested visitor is to override this method
- /// to return a `Map`; one advantage of this is that if we add
- /// more types of nested things in the future, they will
- /// automatically work.
+ /// The default versions of the `visit_nested_XXX` routines invoke this
+ /// method to get a map to use; if they get back `None`, they just skip
+ /// nested things. Otherwise, they will lookup the nested thing in the map
+ /// and visit it depending on what `nested_visit_mode` returns. So the best
+ /// way to implement a nested visitor is to override this method to return a
+ /// `Map`; one advantage of this is that if we add more types of nested
+ /// things in the future, they will automatically work.
///
/// **If for some reason you want the nested behavior, but don't
/// have a `Map` are your disposal:** then you should override the
/// `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>, NestedVisitMode)> {
- None
+ 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
}
/// Invoked when a nested item is encountered. By default does
}
fn map_for_body<'v, V: Visitor<'v>>(visitor: &mut V) -> Option<&Map<'v>> {
- visitor.nested_visit_map().map(|(map, _mode)| map)
+ visitor.nested_visit_map()
}
fn map_for_item<'v, V: Visitor<'v>>(visitor: &mut V) -> Option<&Map<'v>> {
- visitor.nested_visit_map().and_then(|(map, mode)| {
- match mode {
- NestedVisitMode::OnlyBodies => None,
- NestedVisitMode::All => Some(map)
- }
- })
+ 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>) {
}
impl<'a, 'ast> Visitor<'ast> for IdRangeComputingVisitor<'a, 'ast> {
- fn nested_visit_map(&mut self) -> Option<(&Map<'ast>, NestedVisitMode)> {
- Some((&self.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&Map<'ast>> {
+ Some(&self.map)
}
fn visit_id(&mut self, id: NodeId) {
use super::*;
-use hir::intravisit::{Visitor, NestedVisitMode};
+use hir::intravisit::Visitor;
use hir::def_id::DefId;
use middle::cstore::InlinedItem;
use std::iter::repeat;
/// 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>, NestedVisitMode)> {
+ fn nested_visit_map(&mut self) -> Option<&map::Map<'ast>> {
panic!("visit_nested_xxx must be manually implemented in this visitor")
}
// 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
+ }
+
fn visit_body(&mut self, id: hir::ExprId) {
if let Some(krate) = self.hir_crate {
self.visit_expr(krate.expr(id));
/// 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>, hir_visit::NestedVisitMode)> {
- Some((&self.tcx.map, hir_visit::NestedVisitMode::All))
+ 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 visit_item(&mut self, it: &'tcx hir::Item) {
// 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>, hir_visit::NestedVisitMode)> {
- Some((&self.cx.tcx.map, hir_visit::NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.cx.tcx.map)
}
fn visit_id(&mut self, id: ast::NodeId) {
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 visit_pat(&mut self, p: &hir::Pat) {
self.index.entry(p.id).or_insert(vec![]).push(self.entry);
intravisit::walk_pat(self, p)
}
impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name,
/// 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>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::All))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&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(
use syntax_pos::Span;
use hir::{self, PatKind};
use hir::def::Def;
-use hir::intravisit::{self, FnKind, Visitor, NestedVisitMode};
+use hir::intravisit::{self, FnKind, Visitor};
#[derive(Copy, Clone)]
struct UnsafeContext {
}
impl<'a, 'tcx> Visitor<'tcx> for EffectCheckVisitor<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_fn(&mut self, fn_kind: FnKind<'tcx>, fn_decl: &'tcx hir::FnDecl,
use syntax::abi::Abi::RustIntrinsic;
use syntax::ast;
use syntax_pos::Span;
-use hir::intravisit::{self, Visitor, FnKind, NestedVisitMode};
+use hir::intravisit::{self, Visitor, FnKind};
use hir;
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
}
impl<'a, 'tcx> Visitor<'tcx> for ItemVisitor<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
// const, static and N in [T; N].
}
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for ExprVisitor<'a, 'gcx, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'gcx>, NestedVisitMode)> {
- Some((&self.infcx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
+ Some(&self.infcx.tcx.map)
}
fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
use hir::Expr;
use hir;
use hir::print::{expr_to_string, block_to_string};
-use hir::intravisit::{self, Visitor, FnKind, NestedVisitMode};
+use hir::intravisit::{self, Visitor, FnKind};
/// For use with `propagate_through_loop`.
enum LoopKind<'a> {
}
impl<'a, 'tcx> Visitor<'tcx> for IrMaps<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
b: hir::ExprId, s: Span, id: NodeId) {
}
impl<'a, 'tcx> Visitor<'tcx> for Liveness<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.ir.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.ir.tcx.map)
}
fn visit_fn(&mut self, _: FnKind<'tcx>, _: &'tcx hir::FnDecl,
_: hir::ExprId, _: Span, _: NodeId) {
use syntax::ast;
use syntax::attr;
use hir;
-use hir::intravisit::{Visitor, NestedVisitMode};
+use hir::intravisit::{Visitor};
use hir::itemlikevisit::ItemLikeVisitor;
use hir::intravisit;
}
impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
use syntax_pos::Span;
use hir;
-use hir::intravisit::{self, Visitor, FnKind, NestedVisitMode};
+use hir::intravisit::{self, Visitor, FnKind};
use hir::{Block, Item, FnDecl, Arm, Pat, PatKind, Stmt, Expr, Local};
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, RustcEncodable,
}
impl<'ast, 'a> Visitor<'ast> for RegionResolutionVisitor<'ast, 'a> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'ast>, NestedVisitMode)> {
- Some((&self.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
+ Some(&self.map)
}
fn visit_block(&mut self, b: &'ast Block) {
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>, NestedVisitMode)> {
- Some((&self.hir_map, NestedVisitMode::All))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&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![]);
return;
impl<'v, 'a> Visitor<'v> for GatherLabels<'a> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
+
fn visit_expr(&mut self, ex: &'v hir::Expr) {
// do not recurse into closures defined in the block
// since they are treated as separate fns from the POV of
}
impl<'v> Visitor<'v> for ConstrainedCollector {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
+
fn visit_ty(&mut self, ty: &'v hir::Ty) {
match ty.node {
hir::TyPath(hir::QPath::Resolved(Some(_), _)) |
}
impl<'v> Visitor<'v> for AllCollector {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
+
fn visit_lifetime(&mut self, lifetime_ref: &'v hir::Lifetime) {
self.regions.insert(lifetime_ref.name);
}
/// 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>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::All))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&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;
}
impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&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(_) => {
}
impl<'a, 'v> Visitor<'v> for Context<'a> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
+
fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {
if let Some(lang_item) = lang_items::extract(&i.attrs) {
self.register(&lang_item.as_str(), i.span);
use rustc::hir;
use rustc::hir::Expr;
use rustc::hir::intravisit;
-use rustc::hir::intravisit::{Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{Visitor};
use self::restrictions::RestrictionResult;
}
impl<'a, 'tcx> Visitor<'tcx> for StaticInitializerCtxt<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.bccx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.bccx.tcx.map)
}
fn visit_expr(&mut self, ex: &'tcx Expr) {
use errors::DiagnosticBuilder;
use rustc::hir;
-use rustc::hir::intravisit::{self, Visitor, FnKind, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor, FnKind};
pub mod check_loans;
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>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_fn(&mut self, fk: FnKind<'tcx>, fd: &'tcx hir::FnDecl,
use rustc_errors::DiagnosticBuilder;
use rustc::hir::def::*;
-use rustc::hir::intravisit::{self, Visitor, FnKind, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor, FnKind};
use rustc::hir::print::pat_to_string;
use rustc::hir::{self, Pat, PatKind};
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 visit_expr(&mut self, _expr: &'tcx hir::Expr) {
return // const, static and N in [T; N] - shouldn't contain anything
}
}
impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
}
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 visit_pat(&mut self, pat: &Pat) {
match pat.node {
PatKind::Binding(.., ref subpat) => {
impl<'a, 'tcx> Visitor<'tcx> for HashItemsVisitor<'a, 'tcx> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> { None }
+
fn visit_item(&mut self, item: &'tcx hir::Item) {
self.calculate_node_id(item.id, |v| v.visit_item(item));
visit::walk_item(self, item);
}
impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'hash, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, visit::NestedVisitMode)> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
if self.hash_bodies {
- Some((&self.tcx.map, visit::NestedVisitMode::OnlyBodies))
+ Some(&self.tcx.map)
} else {
None
}
use rustc::hir;
use rustc::hir::map as ast_map;
-use rustc::hir::intravisit::{Visitor, IdRangeComputingVisitor, IdRange, NestedVisitMode};
+use rustc::hir::intravisit::{Visitor, IdRangeComputingVisitor, IdRange};
use cstore::CrateMetadata;
use encoder::EncodeContext;
}
impl<'a, 'b, 'tcx> Visitor<'tcx> for SideTableEncodingIdVisitor<'a, 'b, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.ecx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.ecx.tcx.map)
}
fn visit_id(&mut self, id: ast::NodeId) {
use rustc::hir::{self, PatKind};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
-use rustc::hir::intravisit::{Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{Visitor};
use rustc::hir::intravisit;
use super::index_builder::{FromId, IndexBuilder, Untracked};
}
impl<'a, 'b, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.index.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.index.tcx.map)
}
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
intravisit::walk_expr(self, ex);
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::subst::Substs;
use rustc::hir;
-use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, FnKind, Visitor};
use syntax::abi::Abi;
use syntax::ast;
use syntax_pos::Span;
}
impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
// Const and static items.
use rustc::hir::{self, PatKind};
use syntax::ast;
use syntax_pos::Span;
-use rustc::hir::intravisit::{self, FnKind, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, FnKind, Visitor};
use std::collections::hash_map::Entry;
use std::cmp::Ordering;
}
impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_item(&mut self, i: &'tcx hir::Item) {
}
impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'v>, hir_visit::NestedVisitMode)> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> {
panic!("visit_nested_xxx must be manually implemented in this visitor")
}
use rustc::dep_graph::DepNode;
use rustc::hir::map::Map;
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use rustc::hir;
use syntax::ast;
use syntax_pos::Span;
}
impl<'a, 'ast> Visitor<'ast> for CheckLoopVisitor<'a, 'ast> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'ast>, NestedVisitMode)> {
- Some((&self.hir_map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
+ Some(&self.map)
}
fn visit_item(&mut self, i: &'ast hir::Item) {
use rustc::traits::Reveal;
use rustc::hir;
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use syntax::ast;
use syntax_pos::Span;
}
impl<'a, 'tcx> Visitor<'tcx> for RvalueContext<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.tcx.map)
}
fn visit_fn(&mut self,
use syntax::ast;
use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax_pos::Span;
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use rustc::hir;
use std::cell::RefCell;
}
impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> { None }
+
fn visit_item(&mut self, it: &'ast hir::Item) {
match it.node {
hir::ItemStatic(..) |
}
impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'ast>, NestedVisitMode)> {
- Some((&self.ast_map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'ast>> {
+ Some(&self.ast_map)
}
fn visit_item(&mut self, it: &'ast hir::Item) {
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>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::All))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&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
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>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::All))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&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);
}
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 visit_ty(&mut self, ty: &hir::Ty) {
if let hir::TyPath(hir::QPath::Resolved(_, ref path)) = ty.node {
if self.inner.path_is_private_type(path) {
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>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::All))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&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
}
impl<'a, 'tcx> Visitor<'tcx> for SymbolNamesTest<'a, 'tcx> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> { None }
+
fn visit_item(&mut self, item: &'tcx hir::Item) {
self.process_attrs(item.id);
intravisit::walk_item(self, item);
use syntax::util::lev_distance::find_best_match_for_name;
use syntax_pos::{self, BytePos, Span};
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir::{self, PatKind};
use rustc::hir::print as pprust;
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>, NestedVisitMode)> {
- Some((&self.ccx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.ccx.tcx.map)
}
fn visit_item(&mut self, i: &'tcx hir::Item) {
}
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for GatherLocalsVisitor<'a, 'gcx, 'tcx> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> { None }
+
// Add explicitly-declared locals.
fn visit_local(&mut self, local: &'gcx hir::Local) {
let o_ty = match local.ty {
use std::ops::Deref;
use syntax::ast;
use syntax_pos::Span;
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use rustc::hir::{self, PatKind};
use self::SubjectNode::Subject;
// 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>, NestedVisitMode)> {
- Some((&self.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
+ Some(&self.tcx.map)
}
fn visit_fn(&mut self, _fk: intravisit::FnKind<'gcx>, fd: &'gcx hir::FnDecl,
use syntax::ast;
use syntax_pos::Span;
use rustc::hir;
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use rustc::util::nodemap::NodeMap;
///////////////////////////////////////////////////////////////////////////
}
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for SeedBorrowKind<'a, 'gcx, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'gcx>, NestedVisitMode)> {
- Some((&self.fcx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
+ Some(&self.fcx.tcx.map)
}
fn visit_expr(&mut self, expr: &'gcx hir::Expr) {
}
impl<'a, 'gcx, 'tcx> Visitor<'gcx> for AdjustBorrowKind<'a, 'gcx, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'gcx>, NestedVisitMode)> {
- Some((&self.fcx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
+ Some(&self.fcx.tcx.map)
}
fn visit_fn(&mut self,
}
impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'v>> { None }
+
fn visit_item(&mut self, i: &hir::Item) {
debug!("visit_item: {:?}", i);
self.check_item_well_formed(i);
use syntax_pos::{DUMMY_SP, Span};
use rustc::hir::print::pat_to_string;
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use rustc::hir::{self, PatKind};
///////////////////////////////////////////////////////////////////////////
// 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>, NestedVisitMode)> {
- Some((&self.fcx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'gcx>> {
+ Some(&self.fcx.tcx.map)
}
fn visit_stmt(&mut self, s: &'gcx hir::Stmt) {
use syntax_pos::Span;
use rustc::hir::{self, map as hir_map, print as pprust};
-use rustc::hir::intravisit::{self, Visitor, NestedVisitMode};
+use rustc::hir::intravisit::{self, Visitor};
use rustc::hir::def::{Def, CtorKind};
use rustc::hir::def_id::DefId;
}
impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> {
- fn nested_visit_map(&mut self) -> Option<(&hir::map::Map<'tcx>, NestedVisitMode)> {
- Some((&self.ccx.tcx.map, NestedVisitMode::OnlyBodies))
+ fn nested_visit_map(&mut self) -> Option<&hir::map::Map<'tcx>> {
+ Some(&self.ccx.tcx.map)
}
fn visit_item(&mut self, item: &'tcx hir::Item) {