Port a bunch of code new-visitor; all of these ports were
straightforward uses of `visit_all_items`. In some cases I had to remove empty `visit_item` calls that were just to suppress visiting nested items.
This commit is contained in:
parent
e14562d515
commit
e4ff9f71db
@ -37,7 +37,7 @@ use syntax::attr;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::util::small_vector::SmallVector;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::hir;
|
||||
use log;
|
||||
|
||||
@ -53,10 +53,9 @@ pub struct CrateReader<'a> {
|
||||
foreign_item_map: FnvHashMap<String, Vec<ast::NodeId>>,
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'v> visit::Visitor<'v> for LocalCrateReader<'a, 'b> {
|
||||
fn visit_item(&mut self, a: &hir::Item) {
|
||||
impl<'a, 'b, 'hir> Visitor<'hir> for LocalCrateReader<'a, 'b> {
|
||||
fn visit_item(&mut self, a: &'hir hir::Item) {
|
||||
self.process_item(a);
|
||||
visit::walk_item(self, a);
|
||||
}
|
||||
}
|
||||
|
||||
@ -716,7 +715,7 @@ impl<'a, 'b> LocalCrateReader<'a, 'b> {
|
||||
// etc.
|
||||
pub fn read_crates(&mut self, krate: &hir::Crate) {
|
||||
self.process_crate(krate);
|
||||
visit::walk_crate(self, krate);
|
||||
krate.visit_all_items(self);
|
||||
self.creader.inject_allocator_crate();
|
||||
|
||||
if log_enabled!(log::INFO) {
|
||||
|
@ -46,8 +46,8 @@ use syntax;
|
||||
use rbml::writer::Encoder;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::intravisit;
|
||||
use front::map::{LinkedPath, PathElem, PathElems};
|
||||
use front::map as ast_map;
|
||||
|
||||
@ -431,11 +431,12 @@ fn encode_info_for_mod(ecx: &EncodeContext,
|
||||
debug!("(encoding info for module) encoding info for module ID {}", id);
|
||||
|
||||
// Encode info about all the module children.
|
||||
for item in &md.items {
|
||||
for item_id in &md.item_ids {
|
||||
rbml_w.wr_tagged_u64(tag_mod_child,
|
||||
def_to_u64(ecx.tcx.map.local_def_id(item.id)));
|
||||
def_to_u64(ecx.tcx.map.local_def_id(item_id.id)));
|
||||
|
||||
each_auxiliary_node_id(&**item, |auxiliary_node_id| {
|
||||
let item = ecx.tcx.map.expect_item(item_id.id);
|
||||
each_auxiliary_node_id(item, |auxiliary_node_id| {
|
||||
rbml_w.wr_tagged_u64(tag_mod_child,
|
||||
def_to_u64(ecx.tcx.map.local_def_id(auxiliary_node_id)));
|
||||
true
|
||||
@ -1468,25 +1469,26 @@ struct EncodeVisitor<'a, 'b:'a, 'c:'a, 'tcx:'c> {
|
||||
index: &'a mut CrateIndex<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for EncodeVisitor<'a, 'b, 'c, 'tcx> {
|
||||
fn visit_expr(&mut self, ex: &hir::Expr) {
|
||||
visit::walk_expr(self, ex);
|
||||
impl<'a, 'b, 'c, 'tcx> Visitor<'tcx> for EncodeVisitor<'a, 'b, 'c, 'tcx> {
|
||||
fn visit_expr(&mut self, ex: &'tcx hir::Expr) {
|
||||
intravisit::walk_expr(self, ex);
|
||||
my_visit_expr(ex, self.rbml_w_for_visit_item, self.ecx, self.index);
|
||||
}
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
visit::walk_item(self, i);
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
intravisit::walk_item(self, i);
|
||||
my_visit_item(i, self.rbml_w_for_visit_item, self.ecx, self.index);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, ni: &hir::ForeignItem) {
|
||||
visit::walk_foreign_item(self, ni);
|
||||
fn visit_foreign_item(&mut self, ni: &'tcx hir::ForeignItem) {
|
||||
intravisit::walk_foreign_item(self, ni);
|
||||
my_visit_foreign_item(ni, self.rbml_w_for_visit_item, self.ecx, self.index);
|
||||
}
|
||||
}
|
||||
|
||||
fn encode_info_for_items<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
||||
rbml_w: &mut Encoder,
|
||||
krate: &hir::Crate)
|
||||
rbml_w: &mut Encoder)
|
||||
-> CrateIndex<'tcx> {
|
||||
let krate = ecx.tcx.map.krate();
|
||||
|
||||
let mut index = CrateIndex {
|
||||
items: IndexData::new(ecx.tcx.map.num_local_def_ids()),
|
||||
xrefs: FnvHashMap()
|
||||
@ -1503,11 +1505,11 @@ fn encode_info_for_items<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
|
||||
syntax::parse::token::intern(&ecx.link_meta.crate_name),
|
||||
hir::Public);
|
||||
|
||||
visit::walk_crate(&mut EncodeVisitor {
|
||||
krate.visit_all_items(&mut EncodeVisitor {
|
||||
index: &mut index,
|
||||
ecx: ecx,
|
||||
rbml_w_for_visit_item: &mut *rbml_w,
|
||||
}, krate);
|
||||
});
|
||||
|
||||
rbml_w.end_tag();
|
||||
index
|
||||
@ -1735,7 +1737,7 @@ fn encode_struct_field_attrs(ecx: &EncodeContext,
|
||||
}
|
||||
|
||||
rbml_w.start_tag(tag_struct_fields);
|
||||
visit::walk_crate(&mut StructFieldVisitor { ecx: ecx, rbml_w: rbml_w }, krate);
|
||||
krate.visit_all_items(&mut StructFieldVisitor { ecx: ecx, rbml_w: rbml_w });
|
||||
rbml_w.end_tag();
|
||||
}
|
||||
|
||||
@ -1756,7 +1758,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'tcx> {
|
||||
.push(impl_id);
|
||||
}
|
||||
}
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1768,7 +1769,7 @@ fn encode_impls<'a>(ecx: &'a EncodeContext,
|
||||
tcx: ecx.tcx,
|
||||
impls: FnvHashMap()
|
||||
};
|
||||
visit::walk_crate(&mut visitor, krate);
|
||||
krate.visit_all_items(&mut visitor);
|
||||
|
||||
rbml_w.start_tag(tag_impls);
|
||||
for (trait_, trait_impls) in visitor.impls {
|
||||
@ -1787,11 +1788,12 @@ fn encode_misc_info(ecx: &EncodeContext,
|
||||
rbml_w: &mut Encoder) {
|
||||
rbml_w.start_tag(tag_misc_info);
|
||||
rbml_w.start_tag(tag_misc_info_crate_items);
|
||||
for item in &krate.module.items {
|
||||
for item_id in &krate.module.item_ids {
|
||||
rbml_w.wr_tagged_u64(tag_mod_child,
|
||||
def_to_u64(ecx.tcx.map.local_def_id(item.id)));
|
||||
def_to_u64(ecx.tcx.map.local_def_id(item_id.id)));
|
||||
|
||||
each_auxiliary_node_id(&**item, |auxiliary_node_id| {
|
||||
let item = ecx.tcx.map.expect_item(item_id.id);
|
||||
each_auxiliary_node_id(item, |auxiliary_node_id| {
|
||||
rbml_w.wr_tagged_u64(tag_mod_child,
|
||||
def_to_u64(ecx.tcx.map.local_def_id(auxiliary_node_id)));
|
||||
true
|
||||
@ -2022,7 +2024,7 @@ fn encode_metadata_inner(wr: &mut Cursor<Vec<u8>>,
|
||||
// Encode and index the items.
|
||||
rbml_w.start_tag(tag_items);
|
||||
i = rbml_w.writer.seek(SeekFrom::Current(0)).unwrap();
|
||||
let index = encode_info_for_items(&ecx, &mut rbml_w, krate);
|
||||
let index = encode_info_for_items(&ecx, &mut rbml_w);
|
||||
stats.item_bytes = rbml_w.writer.seek(SeekFrom::Current(0)).unwrap() - i;
|
||||
rbml_w.end_tag();
|
||||
|
||||
|
@ -13,7 +13,7 @@ use rustc_front::hir;
|
||||
use rustc_front::util::IdVisitor;
|
||||
use syntax::ast_util::{IdRange, IdRangeComputingVisitor, IdVisitingOperation};
|
||||
use syntax::ptr::P;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use self::InlinedItem::*;
|
||||
|
||||
/// The data we save and restore about an inlined item or method. This is not
|
||||
|
@ -389,7 +389,7 @@ fn simplify_ast(ii: InlinedItemRef) -> InlinedItem {
|
||||
match ii {
|
||||
// HACK we're not dropping items.
|
||||
InlinedItemRef::Item(i) => {
|
||||
InlinedItem::Item(fold::noop_fold_item(P(i.clone()), &mut fld))
|
||||
InlinedItem::Item(P(fold::noop_fold_item(i.clone(), &mut fld)))
|
||||
}
|
||||
InlinedItemRef::TraitItem(d, ti) => {
|
||||
InlinedItem::TraitItem(d, fold::noop_fold_trait_item(P(ti.clone()), &mut fld))
|
||||
|
@ -41,7 +41,7 @@ use rustc_front::hir;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::feature_gate::UnstableFeatures;
|
||||
use rustc_front::visit::{self, FnKind, Visitor};
|
||||
use rustc_front::intravisit::{self, FnKind, Visitor};
|
||||
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::cmp::Ordering;
|
||||
@ -81,7 +81,7 @@ bitflags! {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
enum Mode {
|
||||
Const,
|
||||
ConstFn,
|
||||
@ -190,7 +190,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
||||
|
||||
let qualif = self.with_mode(mode, |this| {
|
||||
this.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b));
|
||||
visit::walk_fn(this, fk, fd, b, s);
|
||||
intravisit::walk_fn(this, fk, fd, b, s);
|
||||
this.qualif
|
||||
});
|
||||
|
||||
@ -308,6 +308,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
debug!("visit_item(item={})", self.tcx.map.node_to_string(i.id));
|
||||
assert_eq!(self.mode, Mode::Var);
|
||||
match i.node {
|
||||
hir::ItemStatic(_, hir::MutImmutable, ref expr) => {
|
||||
self.check_static_type(&**expr);
|
||||
@ -328,7 +329,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.with_mode(Mode::Var, |v| visit::walk_item(v, i));
|
||||
intravisit::walk_item(self, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,10 +340,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
if let Some(ref expr) = *default {
|
||||
self.global_expr(Mode::Const, &*expr);
|
||||
} else {
|
||||
visit::walk_trait_item(self, t);
|
||||
intravisit::walk_trait_item(self, t);
|
||||
}
|
||||
}
|
||||
_ => self.with_mode(Mode::Var, |v| visit::walk_trait_item(v, t)),
|
||||
_ => self.with_mode(Mode::Var, |v| intravisit::walk_trait_item(v, t)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,7 +352,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
hir::ImplItemKind::Const(_, ref expr) => {
|
||||
self.global_expr(Mode::Const, &*expr);
|
||||
}
|
||||
_ => self.with_mode(Mode::Var, |v| visit::walk_impl_item(v, i)),
|
||||
_ => self.with_mode(Mode::Var, |v| intravisit::walk_impl_item(v, i)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,7 +387,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => visit::walk_pat(self, p)
|
||||
_ => intravisit::walk_pat(self, p)
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,7 +413,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
tail expressions", self.msg());
|
||||
}
|
||||
}
|
||||
visit::walk_block(self, block);
|
||||
intravisit::walk_block(self, block);
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, ex: &hir::Expr) {
|
||||
@ -464,11 +465,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
if let Some(mutbl) = borrow {
|
||||
self.record_borrow(discr.id, mutbl);
|
||||
}
|
||||
visit::walk_expr(self, ex);
|
||||
intravisit::walk_expr(self, ex);
|
||||
}
|
||||
// Division by zero and overflow checking.
|
||||
hir::ExprBinary(op, _, _) => {
|
||||
visit::walk_expr(self, ex);
|
||||
intravisit::walk_expr(self, ex);
|
||||
let div_or_rem = op.node == hir::BiDiv || op.node == hir::BiRem;
|
||||
match node_ty.sty {
|
||||
ty::TyUint(_) | ty::TyInt(_) if div_or_rem => {
|
||||
@ -487,7 +488,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
_ => visit::walk_expr(self, ex)
|
||||
_ => intravisit::walk_expr(self, ex)
|
||||
}
|
||||
|
||||
// Handle borrows on (or inside the autorefs of) this expression.
|
||||
@ -837,12 +838,12 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: &ty::ctxt) {
|
||||
visit::walk_crate(&mut CheckCrateVisitor {
|
||||
tcx.map.krate().visit_all_items(&mut CheckCrateVisitor {
|
||||
tcx: tcx,
|
||||
mode: Mode::Var,
|
||||
qualif: ConstQualif::NOT_CONST,
|
||||
rvalue_borrows: NodeMap()
|
||||
}, tcx.map.krate());
|
||||
});
|
||||
|
||||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ use self::Context::*;
|
||||
use session::Session;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
use rustc_front::hir;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
@ -28,12 +27,12 @@ struct CheckLoopVisitor<'a> {
|
||||
}
|
||||
|
||||
pub fn check_crate(sess: &Session, krate: &hir::Crate) {
|
||||
visit::walk_crate(&mut CheckLoopVisitor { sess: sess, cx: Normal }, krate)
|
||||
krate.visit_all_items(&mut CheckLoopVisitor { sess: sess, cx: Normal });
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
self.with_context(Normal, |v| visit::walk_item(v, i));
|
||||
self.with_context(Normal, |v| intravisit::walk_item(v, i));
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &hir::Expr) {
|
||||
@ -50,7 +49,7 @@ impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
|
||||
}
|
||||
hir::ExprBreak(_) => self.require_loop("break", e.span),
|
||||
hir::ExprAgain(_) => self.require_loop("continue", e.span),
|
||||
_ => visit::walk_expr(self, e)
|
||||
_ => intravisit::walk_expr(self, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ use std::iter::{FromIterator, IntoIterator, repeat};
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::hir::Pat;
|
||||
use rustc_front::visit::{self, Visitor, FnKind};
|
||||
use rustc_front::intravisit::{self, Visitor, FnKind};
|
||||
use rustc_front::util as front_util;
|
||||
use rustc_back::slice;
|
||||
|
||||
@ -155,15 +155,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: &ty::ctxt) {
|
||||
visit::walk_crate(&mut MatchCheckCtxt {
|
||||
tcx.map.krate().visit_all_items(&mut MatchCheckCtxt {
|
||||
tcx: tcx,
|
||||
param_env: tcx.empty_parameter_environment(),
|
||||
}, tcx.map.krate());
|
||||
});
|
||||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
|
||||
visit::walk_expr(cx, ex);
|
||||
intravisit::walk_expr(cx, ex);
|
||||
match ex.node {
|
||||
hir::ExprMatch(ref scrut, ref arms, source) => {
|
||||
for arm in arms {
|
||||
@ -986,7 +986,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
||||
}
|
||||
|
||||
fn check_local(cx: &mut MatchCheckCtxt, loc: &hir::Local) {
|
||||
visit::walk_local(cx, loc);
|
||||
intravisit::walk_local(cx, loc);
|
||||
|
||||
let pat = StaticInliner::new(cx.tcx, None).fold_pat(loc.pat.clone());
|
||||
check_irrefutable(cx, &pat, false);
|
||||
@ -1007,7 +1007,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
|
||||
_ => cx.param_env = ParameterEnvironment::for_item(cx.tcx, fn_id),
|
||||
}
|
||||
|
||||
visit::walk_fn(cx, kind, decl, body, sp);
|
||||
intravisit::walk_fn(cx, kind, decl, body, sp);
|
||||
|
||||
for input in &decl.inputs {
|
||||
check_irrefutable(cx, &input.pat, true);
|
||||
@ -1187,10 +1187,10 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
|
||||
hir::PatIdent(_, _, Some(_)) => {
|
||||
let bindings_were_allowed = self.bindings_allowed;
|
||||
self.bindings_allowed = false;
|
||||
visit::walk_pat(self, pat);
|
||||
intravisit::walk_pat(self, pat);
|
||||
self.bindings_allowed = bindings_were_allowed;
|
||||
}
|
||||
_ => visit::walk_pat(self, pat),
|
||||
_ => intravisit::walk_pat(self, pat),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,21 +20,21 @@ use middle::ty;
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
|
||||
pub fn check_crate(tcx: &ty::ctxt,
|
||||
krate: &hir::Crate) {
|
||||
let mut rvcx = RvalueContext { tcx: tcx };
|
||||
visit::walk_crate(&mut rvcx, krate);
|
||||
krate.visit_all_items(&mut rvcx);
|
||||
}
|
||||
|
||||
struct RvalueContext<'a, 'tcx: 'a> {
|
||||
tcx: &'a ty::ctxt<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||
fn visit_fn(&mut self,
|
||||
fk: visit::FnKind<'v>,
|
||||
fk: intravisit::FnKind<'v>,
|
||||
fd: &'v hir::FnDecl,
|
||||
b: &'v hir::Block,
|
||||
s: Span,
|
||||
@ -50,7 +50,7 @@ impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||
let mut euv = euv::ExprUseVisitor::new(&mut delegate, &infcx);
|
||||
euv.walk_fn(fd, b);
|
||||
}
|
||||
visit::walk_fn(self, fk, fd, b, s)
|
||||
intravisit::walk_fn(self, fk, fd, b, s)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,7 @@ use util::nodemap::NodeMap;
|
||||
use syntax::{ast};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::feature_gate::{GateIssue, emit_feature_err};
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
use rustc_front::hir;
|
||||
|
||||
use std::cell::RefCell;
|
||||
@ -60,7 +59,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_item(self, it)
|
||||
intravisit::walk_item(self, it)
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) {
|
||||
@ -74,7 +73,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_trait_item(self, ti)
|
||||
intravisit::walk_trait_item(self, ti)
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
|
||||
@ -86,7 +85,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_impl_item(self, ii)
|
||||
intravisit::walk_impl_item(self, ii)
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +99,7 @@ pub fn check_crate<'ast>(sess: &Session,
|
||||
ast_map: ast_map,
|
||||
discriminant_map: RefCell::new(NodeMap()),
|
||||
};
|
||||
visit::walk_crate(&mut visitor, krate);
|
||||
krate.visit_all_items(&mut visitor);
|
||||
sess.abort_if_errors();
|
||||
}
|
||||
|
||||
@ -197,13 +196,13 @@ impl<'a, 'ast: 'a> CheckItemRecursionVisitor<'a, 'ast> {
|
||||
|
||||
impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
||||
fn visit_item(&mut self, it: &'ast hir::Item) {
|
||||
self.with_item_id_pushed(it.id, |v| visit::walk_item(v, it));
|
||||
self.with_item_id_pushed(it.id, |v| intravisit::walk_item(v, it));
|
||||
}
|
||||
|
||||
fn visit_enum_def(&mut self, enum_definition: &'ast hir::EnumDef,
|
||||
generics: &'ast hir::Generics, item_id: ast::NodeId, _: Span) {
|
||||
self.populate_enum_discriminants(enum_definition);
|
||||
visit::walk_enum_def(self, enum_definition, generics, item_id);
|
||||
intravisit::walk_enum_def(self, enum_definition, generics, item_id);
|
||||
}
|
||||
|
||||
fn visit_variant(&mut self, variant: &'ast hir::Variant,
|
||||
@ -222,16 +221,16 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
||||
// If `maybe_expr` is `None`, that's because no discriminant is
|
||||
// specified that affects this variant. Thus, no risk of recursion.
|
||||
if let Some(expr) = maybe_expr {
|
||||
self.with_item_id_pushed(expr.id, |v| visit::walk_expr(v, expr));
|
||||
self.with_item_id_pushed(expr.id, |v| intravisit::walk_expr(v, expr));
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &'ast hir::TraitItem) {
|
||||
self.with_item_id_pushed(ti.id, |v| visit::walk_trait_item(v, ti));
|
||||
self.with_item_id_pushed(ti.id, |v| intravisit::walk_trait_item(v, ti));
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) {
|
||||
self.with_item_id_pushed(ii.id, |v| visit::walk_impl_item(v, ii));
|
||||
self.with_item_id_pushed(ii.id, |v| intravisit::walk_impl_item(v, ii));
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &'ast hir::Expr) {
|
||||
@ -285,6 +284,6 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
visit::walk_expr(self, e);
|
||||
intravisit::walk_expr(self, e);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ use util::nodemap::NodeMap;
|
||||
use syntax::{ast, abi};
|
||||
use rustc_front::hir::Expr;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::FnKind;
|
||||
use rustc_front::intravisit::FnKind;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::InternedString;
|
||||
use syntax::ptr::P;
|
||||
|
@ -27,7 +27,7 @@ use syntax::print::pp;
|
||||
use syntax::print::pprust::PrintState;
|
||||
use util::nodemap::NodeMap;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::print::pprust;
|
||||
|
||||
|
||||
@ -194,11 +194,11 @@ fn build_nodeid_to_index(decl: Option<&hir::FnDecl>,
|
||||
index: &'a mut NodeMap<Vec<CFGIndex>>,
|
||||
}
|
||||
let mut formals = Formals { entry: entry, index: index };
|
||||
visit::walk_fn_decl(&mut formals, decl);
|
||||
impl<'a, 'v> visit::Visitor<'v> for Formals<'a> {
|
||||
intravisit::walk_fn_decl(&mut formals, decl);
|
||||
impl<'a, 'v> intravisit::Visitor<'v> for Formals<'a> {
|
||||
fn visit_pat(&mut self, p: &hir::Pat) {
|
||||
self.index.entry(p.id).or_insert(vec![]).push(self.entry);
|
||||
visit::walk_pat(self, p)
|
||||
intravisit::walk_pat(self, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -533,7 +533,7 @@ impl<'a, 'tcx, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, 'tcx, O> {
|
||||
|
||||
fn pretty_print_to<'b>(&self, wr: Box<io::Write + 'b>,
|
||||
blk: &hir::Block) -> io::Result<()> {
|
||||
let mut ps = pprust::rust_printer_annotated(wr, self);
|
||||
let mut ps = pprust::rust_printer_annotated(wr, self, None);
|
||||
try!(ps.cbox(pprust::indent_unit));
|
||||
try!(ps.ibox(0));
|
||||
try!(ps.print_block(blk));
|
||||
|
@ -19,8 +19,8 @@ use middle::ty::MethodCall;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::{FnKind, Visitor};
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::intravisit::{FnKind, Visitor};
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct UnsafeContext {
|
||||
@ -94,7 +94,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
||||
self.unsafe_context = UnsafeContext::new(SafeContext)
|
||||
}
|
||||
|
||||
visit::walk_fn(self, fn_kind, fn_decl, block, span);
|
||||
intravisit::walk_fn(self, fn_kind, fn_decl, block, span);
|
||||
|
||||
self.unsafe_context = old_unsafe_context
|
||||
}
|
||||
@ -133,7 +133,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
||||
hir::DefaultBlock | hir::PushUnstableBlock | hir:: PopUnstableBlock => {}
|
||||
}
|
||||
|
||||
visit::walk_block(self, block);
|
||||
intravisit::walk_block(self, block);
|
||||
|
||||
self.unsafe_context = old_unsafe_context
|
||||
}
|
||||
@ -177,7 +177,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
visit::walk_expr(self, expr);
|
||||
intravisit::walk_expr(self, expr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,5 +187,5 @@ pub fn check_crate(tcx: &ty::ctxt) {
|
||||
unsafe_context: UnsafeContext::new(SafeContext),
|
||||
};
|
||||
|
||||
visit::walk_crate(&mut visitor, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut visitor);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use std::fmt;
|
||||
use syntax::abi::RustIntrinsic;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::visit::{self, Visitor, FnKind};
|
||||
use rustc_front::intravisit::{self, Visitor, FnKind};
|
||||
use rustc_front::hir;
|
||||
|
||||
pub fn check_crate(tcx: &ctxt) {
|
||||
@ -29,7 +29,7 @@ pub fn check_crate(tcx: &ctxt) {
|
||||
dummy_sized_ty: tcx.types.isize,
|
||||
dummy_unsized_ty: tcx.mk_slice(tcx.types.isize),
|
||||
};
|
||||
visit::walk_crate(&mut visitor, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut visitor);
|
||||
}
|
||||
|
||||
struct IntrinsicCheckingVisitor<'a, 'tcx: 'a> {
|
||||
@ -222,11 +222,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
FnKind::ItemFn(..) | FnKind::Method(..) => {
|
||||
let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
|
||||
self.param_envs.push(param_env);
|
||||
visit::walk_fn(self, fk, fd, b, s);
|
||||
intravisit::walk_fn(self, fk, fd, b, s);
|
||||
self.param_envs.pop();
|
||||
}
|
||||
FnKind::Closure(..) => {
|
||||
visit::walk_fn(self, fk, fd, b, s);
|
||||
intravisit::walk_fn(self, fk, fd, b, s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_expr(self, expr);
|
||||
intravisit::walk_expr(self, expr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,7 @@ use syntax::ast;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use syntax::parse::token::InternedString;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::hir;
|
||||
|
||||
use std::iter::Enumerate;
|
||||
@ -164,8 +163,6 @@ impl<'a, 'v, 'tcx> Visitor<'v> for LanguageItemCollector<'a, 'tcx> {
|
||||
self.collect_item(item_index, self.ast_map.local_def_id(item.id), item.span)
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +199,7 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn collect_local_language_items(&mut self, krate: &hir::Crate) {
|
||||
visit::walk_crate(self, krate);
|
||||
krate.visit_all_items(self);
|
||||
}
|
||||
|
||||
pub fn collect_external_language_items(&mut self) {
|
||||
|
@ -127,7 +127,7 @@ use syntax::ptr::P;
|
||||
use rustc_front::hir::Expr;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::print::pprust::{expr_to_string, block_to_string};
|
||||
use rustc_front::visit::{self, Visitor, FnKind};
|
||||
use rustc_front::intravisit::{self, Visitor, FnKind};
|
||||
|
||||
/// For use with `propagate_through_loop`.
|
||||
enum LoopKind<'a> {
|
||||
@ -192,7 +192,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IrMaps<'a, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn check_crate(tcx: &ty::ctxt) {
|
||||
visit::walk_crate(&mut IrMaps::new(tcx), tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut IrMaps::new(tcx));
|
||||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ fn visit_fn(ir: &mut IrMaps,
|
||||
|
||||
// gather up the various local variables, significant expressions,
|
||||
// and so forth:
|
||||
visit::walk_fn(&mut fn_maps, fk, decl, body, sp);
|
||||
intravisit::walk_fn(&mut fn_maps, fk, decl, body, sp);
|
||||
|
||||
// Special nodes and variables:
|
||||
// - exit_ln represents the end of the fn, either by return or panic
|
||||
@ -423,7 +423,7 @@ fn visit_local(ir: &mut IrMaps, local: &hir::Local) {
|
||||
name: name
|
||||
}));
|
||||
});
|
||||
visit::walk_local(ir, local);
|
||||
intravisit::walk_local(ir, local);
|
||||
}
|
||||
|
||||
fn visit_arm(ir: &mut IrMaps, arm: &hir::Arm) {
|
||||
@ -439,7 +439,7 @@ fn visit_arm(ir: &mut IrMaps, arm: &hir::Arm) {
|
||||
}));
|
||||
})
|
||||
}
|
||||
visit::walk_arm(ir, arm);
|
||||
intravisit::walk_arm(ir, arm);
|
||||
}
|
||||
|
||||
fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
|
||||
@ -451,7 +451,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
|
||||
if let DefLocal(..) = def {
|
||||
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
|
||||
}
|
||||
visit::walk_expr(ir, expr);
|
||||
intravisit::walk_expr(ir, expr);
|
||||
}
|
||||
hir::ExprClosure(..) => {
|
||||
// Interesting control flow (for loops can contain labeled
|
||||
@ -474,17 +474,17 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
|
||||
});
|
||||
ir.set_captures(expr.id, call_caps);
|
||||
|
||||
visit::walk_expr(ir, expr);
|
||||
intravisit::walk_expr(ir, expr);
|
||||
}
|
||||
|
||||
// live nodes required for interesting control flow:
|
||||
hir::ExprIf(..) | hir::ExprMatch(..) | hir::ExprWhile(..) | hir::ExprLoop(..) => {
|
||||
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
|
||||
visit::walk_expr(ir, expr);
|
||||
intravisit::walk_expr(ir, expr);
|
||||
}
|
||||
hir::ExprBinary(op, _, _) if ::rustc_front::util::lazy_binop(op.node) => {
|
||||
ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
|
||||
visit::walk_expr(ir, expr);
|
||||
intravisit::walk_expr(ir, expr);
|
||||
}
|
||||
|
||||
// otherwise, live nodes are not required:
|
||||
@ -497,7 +497,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
|
||||
hir::ExprStruct(..) | hir::ExprRepeat(..) |
|
||||
hir::ExprInlineAsm(..) | hir::ExprBox(..) |
|
||||
hir::ExprRange(..) => {
|
||||
visit::walk_expr(ir, expr);
|
||||
intravisit::walk_expr(ir, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1383,7 +1383,7 @@ fn check_local(this: &mut Liveness, local: &hir::Local) {
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_local(this, local);
|
||||
intravisit::walk_local(this, local);
|
||||
}
|
||||
|
||||
fn check_arm(this: &mut Liveness, arm: &hir::Arm) {
|
||||
@ -1393,7 +1393,7 @@ fn check_arm(this: &mut Liveness, arm: &hir::Arm) {
|
||||
this.arm_pats_bindings(arm.pats.first().map(|p| &**p), |this, ln, var, sp, id| {
|
||||
this.warn_about_unused(sp, id, ln, var);
|
||||
});
|
||||
visit::walk_arm(this, arm);
|
||||
intravisit::walk_arm(this, arm);
|
||||
}
|
||||
|
||||
fn check_expr(this: &mut Liveness, expr: &Expr) {
|
||||
@ -1401,13 +1401,13 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
|
||||
hir::ExprAssign(ref l, _) => {
|
||||
this.check_lvalue(&**l);
|
||||
|
||||
visit::walk_expr(this, expr);
|
||||
intravisit::walk_expr(this, expr);
|
||||
}
|
||||
|
||||
hir::ExprAssignOp(_, ref l, _) => {
|
||||
this.check_lvalue(&**l);
|
||||
|
||||
visit::walk_expr(this, expr);
|
||||
intravisit::walk_expr(this, expr);
|
||||
}
|
||||
|
||||
hir::ExprInlineAsm(ref ia) => {
|
||||
@ -1421,7 +1421,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
|
||||
this.visit_expr(&**out);
|
||||
}
|
||||
|
||||
visit::walk_expr(this, expr);
|
||||
intravisit::walk_expr(this, expr);
|
||||
}
|
||||
|
||||
// no correctness conditions related to liveness
|
||||
@ -1435,7 +1435,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
|
||||
hir::ExprStruct(..) | hir::ExprRepeat(..) |
|
||||
hir::ExprClosure(..) | hir::ExprPath(..) | hir::ExprBox(..) |
|
||||
hir::ExprRange(..) => {
|
||||
visit::walk_expr(this, expr);
|
||||
intravisit::walk_expr(this, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1532,7 +1532,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
_ => {
|
||||
// For other kinds of lvalues, no checks are required,
|
||||
// and any embedded expressions are actually rvalues
|
||||
visit::walk_expr(self, expr);
|
||||
intravisit::walk_expr(self, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ use syntax::abi;
|
||||
use syntax::ast;
|
||||
use syntax::attr;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::intravisit;
|
||||
|
||||
// Returns true if the given set of generics implies that the item it's
|
||||
// associated with must be inlined.
|
||||
@ -87,9 +87,7 @@ struct ReachableContext<'a, 'tcx: 'a> {
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
|
||||
|
||||
fn visit_expr(&mut self, expr: &hir::Expr) {
|
||||
|
||||
match expr.node {
|
||||
hir::ExprPath(..) => {
|
||||
let def = match self.tcx.def_map.borrow().get(&expr.id) {
|
||||
@ -138,12 +136,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
visit::walk_expr(self, expr)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, _item: &hir::Item) {
|
||||
// Do not recurse into items. These items will be added to the worklist
|
||||
// and recursed into manually if necessary.
|
||||
intravisit::walk_expr(self, expr)
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +253,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
match item.node {
|
||||
hir::ItemFn(_, _, _, _, _, ref search_block) => {
|
||||
if item_might_be_inlined(&*item) {
|
||||
visit::walk_block(self, &**search_block)
|
||||
intravisit::walk_block(self, &**search_block)
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +285,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
self.visit_expr(&*expr);
|
||||
}
|
||||
hir::MethodTraitItem(_, Some(ref body)) => {
|
||||
visit::walk_block(self, body);
|
||||
intravisit::walk_block(self, body);
|
||||
}
|
||||
hir::TypeTraitItem(..) => {}
|
||||
}
|
||||
@ -305,7 +298,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
hir::ImplItemKind::Method(ref sig, ref body) => {
|
||||
let did = self.tcx.map.get_parent_did(search_item);
|
||||
if method_might_be_inlined(self.tcx, sig, impl_item, did) {
|
||||
visit::walk_block(self, body)
|
||||
intravisit::walk_block(self, body)
|
||||
}
|
||||
}
|
||||
hir::ImplItemKind::Type(_) => {}
|
||||
@ -350,8 +343,6 @@ impl<'a, 'v> Visitor<'v> for CollectPrivateImplItemsVisitor<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,8 +372,7 @@ pub fn find_reachable(tcx: &ty::ctxt,
|
||||
exported_items: exported_items,
|
||||
worklist: &mut reachable_context.worklist,
|
||||
};
|
||||
|
||||
visit::walk_crate(&mut collect_private_impl_items, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut collect_private_impl_items);
|
||||
}
|
||||
|
||||
// Step 2: Mark all symbols that the symbols on the worklist touch.
|
||||
|
@ -30,7 +30,7 @@ use syntax::codemap::{self, Span};
|
||||
use syntax::ast::{self, NodeId};
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::{self, Visitor, FnKind};
|
||||
use rustc_front::intravisit::{self, Visitor, FnKind};
|
||||
use rustc_front::hir::{Block, Item, FnDecl, Arm, Pat, Stmt, Expr, Local};
|
||||
use rustc_front::util::stmt_id;
|
||||
|
||||
@ -696,7 +696,7 @@ fn resolve_block(visitor: &mut RegionResolutionVisitor, blk: &hir::Block) {
|
||||
|
||||
{
|
||||
// This block should be kept approximately in sync with
|
||||
// `visit::walk_block`. (We manually walk the block, rather
|
||||
// `intravisit::walk_block`. (We manually walk the block, rather
|
||||
// than call `walk_block`, in order to maintain precise
|
||||
// index information.)
|
||||
|
||||
@ -735,7 +735,7 @@ fn resolve_arm(visitor: &mut RegionResolutionVisitor, arm: &hir::Arm) {
|
||||
visitor.terminating_scopes.insert(expr.id);
|
||||
}
|
||||
|
||||
visit::walk_arm(visitor, arm);
|
||||
intravisit::walk_arm(visitor, arm);
|
||||
}
|
||||
|
||||
fn resolve_pat(visitor: &mut RegionResolutionVisitor, pat: &hir::Pat) {
|
||||
@ -750,7 +750,7 @@ fn resolve_pat(visitor: &mut RegionResolutionVisitor, pat: &hir::Pat) {
|
||||
_ => { }
|
||||
}
|
||||
|
||||
visit::walk_pat(visitor, pat);
|
||||
intravisit::walk_pat(visitor, pat);
|
||||
}
|
||||
|
||||
fn resolve_stmt(visitor: &mut RegionResolutionVisitor, stmt: &hir::Stmt) {
|
||||
@ -767,7 +767,7 @@ fn resolve_stmt(visitor: &mut RegionResolutionVisitor, stmt: &hir::Stmt) {
|
||||
|
||||
let prev_parent = visitor.cx.parent;
|
||||
visitor.cx.parent = stmt_extent;
|
||||
visit::walk_stmt(visitor, stmt);
|
||||
intravisit::walk_stmt(visitor, stmt);
|
||||
visitor.cx.parent = prev_parent;
|
||||
}
|
||||
|
||||
@ -844,7 +844,7 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &hir::Expr) {
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_expr(visitor, expr);
|
||||
intravisit::walk_expr(visitor, expr);
|
||||
visitor.cx = prev_cx;
|
||||
}
|
||||
|
||||
@ -935,7 +935,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &hir::Local) {
|
||||
None => { }
|
||||
}
|
||||
|
||||
visit::walk_local(visitor, local);
|
||||
intravisit::walk_local(visitor, local);
|
||||
|
||||
/// True if `pat` match the `P&` nonterminal:
|
||||
///
|
||||
@ -1080,7 +1080,7 @@ fn resolve_item(visitor: &mut RegionResolutionVisitor, item: &hir::Item) {
|
||||
var_parent: ROOT_CODE_EXTENT,
|
||||
parent: ROOT_CODE_EXTENT
|
||||
};
|
||||
visit::walk_item(visitor, item);
|
||||
intravisit::walk_item(visitor, item);
|
||||
visitor.create_item_scope_if_needed(item.id);
|
||||
visitor.cx = prev_cx;
|
||||
visitor.terminating_scopes = prev_ts;
|
||||
@ -1119,8 +1119,8 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor,
|
||||
var_parent: fn_decl_scope,
|
||||
};
|
||||
|
||||
visit::walk_fn_decl(visitor, decl);
|
||||
visit::walk_fn_kind(visitor, kind);
|
||||
intravisit::walk_fn_decl(visitor, decl);
|
||||
intravisit::walk_fn_kind(visitor, kind);
|
||||
|
||||
// The body of the every fn is a root scope.
|
||||
visitor.cx = Context {
|
||||
@ -1181,12 +1181,12 @@ impl<'a, 'v> Visitor<'v> for RegionResolutionVisitor<'a> {
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
|
||||
visit::walk_impl_item(self, ii);
|
||||
intravisit::walk_impl_item(self, ii);
|
||||
self.create_item_scope_if_needed(ii.id);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, ti: &hir::TraitItem) {
|
||||
visit::walk_trait_item(self, ti);
|
||||
intravisit::walk_trait_item(self, ti);
|
||||
self.create_item_scope_if_needed(ti.id);
|
||||
}
|
||||
|
||||
@ -1237,7 +1237,7 @@ pub fn resolve_crate(sess: &Session, krate: &hir::Crate) -> RegionMaps {
|
||||
},
|
||||
terminating_scopes: NodeSet()
|
||||
};
|
||||
visit::walk_crate(&mut visitor, krate);
|
||||
krate.visit_all_items(&mut visitor);
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ use util::nodemap::NodeMap;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::print::pprust::lifetime_to_string;
|
||||
use rustc_front::visit::{self, Visitor, FnKind};
|
||||
use rustc_front::intravisit::{self, Visitor, FnKind};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub enum DefRegion {
|
||||
@ -95,30 +95,28 @@ static ROOT_SCOPE: ScopeChain<'static> = RootScope;
|
||||
|
||||
pub fn krate(sess: &Session, krate: &hir::Crate, def_map: &DefMap) -> NamedRegionMap {
|
||||
let mut named_region_map = NodeMap();
|
||||
visit::walk_crate(&mut LifetimeContext {
|
||||
krate.visit_all_items(&mut LifetimeContext {
|
||||
sess: sess,
|
||||
named_region_map: &mut named_region_map,
|
||||
scope: &ROOT_SCOPE,
|
||||
def_map: def_map,
|
||||
trait_ref_hack: false,
|
||||
labels_in_fn: vec![],
|
||||
}, krate);
|
||||
});
|
||||
sess.abort_if_errors();
|
||||
named_region_map
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
// Items save/restore the set of labels. This way inner items
|
||||
// can freely reuse names, be they loop labels or lifetimes.
|
||||
let saved = replace(&mut self.labels_in_fn, vec![]);
|
||||
assert!(self.labels_in_fn.is_empty());
|
||||
|
||||
// Items always introduce a new root scope
|
||||
self.with(RootScope, |_, this| {
|
||||
match item.node {
|
||||
hir::ItemFn(..) => {
|
||||
// Fn lifetimes get added in visit_fn below:
|
||||
visit::walk_item(this, item);
|
||||
intravisit::walk_item(this, item);
|
||||
}
|
||||
hir::ItemExternCrate(_) |
|
||||
hir::ItemUse(_) |
|
||||
@ -128,7 +126,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
hir::ItemStatic(..) |
|
||||
hir::ItemConst(..) => {
|
||||
// These sorts of items have no lifetime parameters at all.
|
||||
visit::walk_item(this, item);
|
||||
intravisit::walk_item(this, item);
|
||||
}
|
||||
hir::ItemTy(_, ref generics) |
|
||||
hir::ItemEnum(_, ref generics) |
|
||||
@ -140,14 +138,14 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
let early_scope = EarlyScope(subst::TypeSpace, lifetimes, &ROOT_SCOPE);
|
||||
this.with(early_scope, |old_scope, this| {
|
||||
this.check_lifetime_defs(old_scope, lifetimes);
|
||||
visit::walk_item(this, item);
|
||||
intravisit::walk_item(this, item);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Done traversing the item; restore saved set of labels.
|
||||
replace(&mut self.labels_in_fn, saved);
|
||||
// Done traversing the item; remove any labels it created
|
||||
self.labels_in_fn.truncate(0);
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, item: &hir::ForeignItem) {
|
||||
@ -160,11 +158,11 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
match item.node {
|
||||
hir::ForeignItemFn(_, ref generics) => {
|
||||
this.visit_early_late(subst::FnSpace, generics, |this| {
|
||||
visit::walk_foreign_item(this, item);
|
||||
intravisit::walk_foreign_item(this, item);
|
||||
})
|
||||
}
|
||||
hir::ForeignItemStatic(..) => {
|
||||
visit::walk_foreign_item(this, item);
|
||||
intravisit::walk_foreign_item(this, item);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -199,7 +197,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
// a bare fn has no bounds, so everything
|
||||
// contained within is scoped within its binder.
|
||||
this.check_lifetime_defs(old_scope, &c.lifetimes);
|
||||
visit::walk_ty(this, ty);
|
||||
intravisit::walk_ty(this, ty);
|
||||
});
|
||||
}
|
||||
hir::TyPath(None, ref path) => {
|
||||
@ -212,12 +210,12 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
visit::walk_ty(self, ty);
|
||||
intravisit::walk_ty(self, ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
visit::walk_ty(self, ty)
|
||||
intravisit::walk_ty(self, ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,9 +228,9 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
if let hir::MethodTraitItem(ref sig, None) = trait_item.node {
|
||||
self.visit_early_late(
|
||||
subst::FnSpace, &sig.generics,
|
||||
|this| visit::walk_trait_item(this, trait_item))
|
||||
|this| intravisit::walk_trait_item(this, trait_item))
|
||||
} else {
|
||||
visit::walk_trait_item(self, trait_item);
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
replace(&mut self.labels_in_fn, saved);
|
||||
@ -241,7 +239,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
fn visit_block(&mut self, b: &hir::Block) {
|
||||
self.with(BlockScope(region::DestructionScopeData::new(b.id),
|
||||
self.scope),
|
||||
|_, this| visit::walk_block(this, b));
|
||||
|_, this| intravisit::walk_block(this, b));
|
||||
}
|
||||
|
||||
fn visit_lifetime(&mut self, lifetime_ref: &hir::Lifetime) {
|
||||
@ -317,7 +315,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
for lifetime in &trait_ref.bound_lifetimes {
|
||||
this.visit_lifetime_def(lifetime);
|
||||
}
|
||||
visit::walk_path(this, &trait_ref.trait_ref.path)
|
||||
intravisit::walk_path(this, &trait_ref.trait_ref.path)
|
||||
})
|
||||
} else {
|
||||
self.visit_trait_ref(&trait_ref.trait_ref)
|
||||
@ -417,7 +415,7 @@ fn extract_labels<'v, 'a>(ctxt: &mut LifetimeContext<'a>, b: &'v hir::Block) {
|
||||
|
||||
self.labels_in_fn.push((label, ex.span));
|
||||
}
|
||||
visit::walk_expr(self, ex)
|
||||
intravisit::walk_expr(self, ex)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, _: &hir::Item) {
|
||||
@ -463,7 +461,7 @@ fn extract_labels<'v, 'a>(ctxt: &mut LifetimeContext<'a>, b: &'v hir::Block) {
|
||||
}
|
||||
|
||||
impl<'a> LifetimeContext<'a> {
|
||||
// This is just like visit::walk_fn, except that it extracts the
|
||||
// This is just like intravisit::walk_fn, except that it extracts the
|
||||
// labels of the function body and swaps them in before visiting
|
||||
// the function body itself.
|
||||
fn walk_fn<'b>(&mut self,
|
||||
@ -473,16 +471,16 @@ impl<'a> LifetimeContext<'a> {
|
||||
_span: Span) {
|
||||
match fk {
|
||||
FnKind::ItemFn(_, generics, _, _, _, _) => {
|
||||
visit::walk_fn_decl(self, fd);
|
||||
intravisit::walk_fn_decl(self, fd);
|
||||
self.visit_generics(generics);
|
||||
}
|
||||
FnKind::Method(_, sig, _) => {
|
||||
visit::walk_fn_decl(self, fd);
|
||||
intravisit::walk_fn_decl(self, fd);
|
||||
self.visit_generics(&sig.generics);
|
||||
self.visit_explicit_self(&sig.explicit_self);
|
||||
}
|
||||
FnKind::Closure(..) => {
|
||||
visit::walk_fn_decl(self, fd);
|
||||
intravisit::walk_fn_decl(self, fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ use middle::lang_items;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::InternedString;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::hir;
|
||||
|
||||
use std::collections::HashSet;
|
||||
@ -50,7 +50,7 @@ pub fn check_crate(krate: &hir::Crate,
|
||||
|
||||
{
|
||||
let mut cx = Context { sess: sess, items: items };
|
||||
visit::walk_crate(&mut cx, krate);
|
||||
krate.visit_all_items(&mut cx);
|
||||
}
|
||||
verify(sess, items);
|
||||
}
|
||||
@ -114,7 +114,7 @@ impl<'a, 'v> Visitor<'v> for Context<'a> {
|
||||
None => {}
|
||||
Some(lang_item) => self.register(&lang_item, i.span),
|
||||
}
|
||||
visit::walk_foreign_item(self, i)
|
||||
intravisit::walk_foreign_item(self, i)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,7 @@ use syntax::ast;
|
||||
use syntax::attr;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::diagnostic;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use rustc_front::hir;
|
||||
|
||||
struct RegistrarFinder {
|
||||
@ -30,8 +29,6 @@ impl<'v> Visitor<'v> for RegistrarFinder {
|
||||
self.registrars.push((item.id, item.span));
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +37,7 @@ pub fn find_plugin_registrar(diagnostic: &diagnostic::SpanHandler,
|
||||
krate: &hir::Crate)
|
||||
-> Option<ast::NodeId> {
|
||||
let mut finder = RegistrarFinder { registrars: Vec::new() };
|
||||
visit::walk_crate(&mut finder, krate);
|
||||
krate.visit_all_items(&mut finder);
|
||||
|
||||
match finder.registrars.len() {
|
||||
0 => None,
|
||||
|
@ -21,8 +21,8 @@ use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
|
||||
// The name of the associated type for `Fn` return types
|
||||
pub const FN_OUTPUT_NAME: &'static str = "Output";
|
||||
@ -169,7 +169,7 @@ impl<'v, P> Visitor<'v> for LoopQueryVisitor<P> where P: FnMut(&hir::Expr_) -> b
|
||||
// Skip inner loops, since a break in the inner loop isn't a
|
||||
// break inside the outer loop
|
||||
hir::ExprLoop(..) | hir::ExprWhile(..) => {}
|
||||
_ => visit::walk_expr(self, e)
|
||||
_ => intravisit::walk_expr(self, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,7 +181,7 @@ pub fn loop_query<P>(b: &hir::Block, p: P) -> bool where P: FnMut(&hir::Expr_) -
|
||||
p: p,
|
||||
flag: false,
|
||||
};
|
||||
visit::walk_block(&mut v, b);
|
||||
intravisit::walk_block(&mut v, b);
|
||||
return v.flag;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ struct BlockQueryVisitor<P> where P: FnMut(&hir::Expr) -> bool {
|
||||
impl<'v, P> Visitor<'v> for BlockQueryVisitor<P> where P: FnMut(&hir::Expr) -> bool {
|
||||
fn visit_expr(&mut self, e: &hir::Expr) {
|
||||
self.flag |= (self.p)(e);
|
||||
visit::walk_expr(self, e)
|
||||
intravisit::walk_expr(self, e)
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ pub fn block_query<P>(b: &hir::Block, p: P) -> bool where P: FnMut(&hir::Expr) -
|
||||
p: p,
|
||||
flag: false,
|
||||
};
|
||||
visit::walk_block(&mut v, &*b);
|
||||
intravisit::walk_block(&mut v, &*b);
|
||||
return v.flag;
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,8 @@ use syntax::codemap::Span;
|
||||
use syntax::ast::NodeId;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::hir::{Expr, FnDecl, Block, Pat};
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
|
||||
mod lifetime;
|
||||
mod restrictions;
|
||||
@ -533,7 +533,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_expr(self, ex);
|
||||
intravisit::walk_expr(self, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ use syntax::codemap::Span;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::hir::{FnDecl, Block};
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::{Visitor, FnKind};
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::intravisit::{Visitor, FnKind};
|
||||
use rustc_front::util as hir_util;
|
||||
|
||||
pub mod check_loans;
|
||||
@ -85,14 +85,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
|
||||
if let hir::ConstTraitItem(_, Some(ref expr)) = ti.node {
|
||||
gather_loans::gather_loans_in_static_initializer(self, &*expr);
|
||||
}
|
||||
visit::walk_trait_item(self, ti);
|
||||
intravisit::walk_trait_item(self, ti);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, ii: &hir::ImplItem) {
|
||||
if let hir::ImplItemKind::Const(_, ref expr) = ii.node {
|
||||
gather_loans::gather_loans_in_static_initializer(self, &*expr);
|
||||
}
|
||||
visit::walk_impl_item(self, ii);
|
||||
intravisit::walk_impl_item(self, ii);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ pub fn check_crate(tcx: &ty::ctxt) {
|
||||
}
|
||||
};
|
||||
|
||||
visit::walk_crate(&mut bccx, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut bccx);
|
||||
|
||||
if tcx.sess.borrowck_stats() {
|
||||
println!("--- borrowck stats ---");
|
||||
@ -142,7 +142,7 @@ fn borrowck_item(this: &mut BorrowckCtxt, item: &hir::Item) {
|
||||
_ => { }
|
||||
}
|
||||
|
||||
visit::walk_item(this, item);
|
||||
intravisit::walk_item(this, item);
|
||||
}
|
||||
|
||||
/// Collection of conclusions determined via borrow checker analyses.
|
||||
@ -181,7 +181,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
|
||||
decl,
|
||||
body);
|
||||
|
||||
visit::walk_fn(this, fk, decl, body, sp);
|
||||
intravisit::walk_fn(this, fk, decl, body, sp);
|
||||
}
|
||||
|
||||
fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
|
||||
|
@ -827,7 +827,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||
|
||||
time(time_passes,
|
||||
"lint checking",
|
||||
|| lint::check_crate(tcx, krate, &exported_items));
|
||||
|| lint::check_crate(tcx, &exported_items));
|
||||
|
||||
// The above three passes generate errors w/o aborting
|
||||
tcx.sess.abort_if_errors();
|
||||
|
@ -777,7 +777,8 @@ pub fn pretty_print_input(sess: Session,
|
||||
&mut rdr,
|
||||
box out,
|
||||
annotation.pp_ann(),
|
||||
true);
|
||||
true,
|
||||
Some(ast_map.krate()));
|
||||
for node_id in uii.all_matching_node_ids(ast_map) {
|
||||
let node = ast_map.get(node_id);
|
||||
try!(pp_state.print_node(&node));
|
||||
|
@ -18,7 +18,7 @@ use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::Span;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::FnKind;
|
||||
use rustc_front::intravisit::FnKind;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum MethodLateContext {
|
||||
|
@ -46,7 +46,7 @@ use syntax::attr::{self, AttrMetaMethods};
|
||||
use syntax::codemap::{self, Span};
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::FnKind;
|
||||
use rustc_front::intravisit::FnKind;
|
||||
|
||||
use bad_style::{MethodLateContext, method_context};
|
||||
|
||||
|
@ -28,7 +28,7 @@ use syntax::feature_gate::{emit_feature_err, GateIssue};
|
||||
use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::{self, Visitor};
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
use rustc_front::util::is_shift_binop;
|
||||
|
||||
declare_lint! {
|
||||
@ -626,7 +626,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> {
|
||||
"found Rust tuple type in foreign module; \
|
||||
consider using a struct instead`")
|
||||
}
|
||||
_ => visit::walk_ty(self, ty)
|
||||
_ => intravisit::walk_ty(self, ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use syntax::ptr::P;
|
||||
|
||||
use rustc_back::slice;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::FnKind;
|
||||
use rustc_front::intravisit::FnKind;
|
||||
|
||||
declare_lint! {
|
||||
pub UNUSED_MUT,
|
||||
|
@ -33,7 +33,7 @@ use self::rustc::middle::ty::{self, Ty};
|
||||
use self::rustc::util::common::ErrorReported;
|
||||
use self::rustc::util::nodemap::NodeMap;
|
||||
use self::rustc_front::hir;
|
||||
use self::rustc_front::visit;
|
||||
use self::rustc_front::intravisit::{self, Visitor};
|
||||
use self::syntax::ast;
|
||||
use self::syntax::attr::AttrMetaMethods;
|
||||
use self::syntax::codemap::Span;
|
||||
@ -47,7 +47,7 @@ pub fn build_mir_for_crate<'tcx>(tcx: &ty::ctxt<'tcx>) -> MirMap<'tcx> {
|
||||
tcx: tcx,
|
||||
map: &mut map,
|
||||
};
|
||||
visit::walk_crate(&mut dump, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut dump);
|
||||
}
|
||||
map
|
||||
}
|
||||
@ -79,32 +79,32 @@ impl<'a, 'tcx> OuterDump<'a, 'tcx> {
|
||||
}
|
||||
|
||||
|
||||
impl<'a, 'tcx> visit::Visitor<'tcx> for OuterDump<'a, 'tcx> {
|
||||
impl<'a, 'tcx> Visitor<'tcx> for OuterDump<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'tcx hir::Item) {
|
||||
self.visit_mir(&item.attrs, |c| visit::walk_item(c, item));
|
||||
visit::walk_item(self, item);
|
||||
self.visit_mir(&item.attrs, |c| intravisit::walk_item(c, item));
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
|
||||
match trait_item.node {
|
||||
hir::MethodTraitItem(_, Some(_)) => {
|
||||
self.visit_mir(&trait_item.attrs, |c| visit::walk_trait_item(c, trait_item));
|
||||
self.visit_mir(&trait_item.attrs, |c| intravisit::walk_trait_item(c, trait_item));
|
||||
}
|
||||
hir::MethodTraitItem(_, None) |
|
||||
hir::ConstTraitItem(..) |
|
||||
hir::TypeTraitItem(..) => {}
|
||||
}
|
||||
visit::walk_trait_item(self, trait_item);
|
||||
intravisit::walk_trait_item(self, trait_item);
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
|
||||
match impl_item.node {
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
self.visit_mir(&impl_item.attrs, |c| visit::walk_impl_item(c, impl_item));
|
||||
self.visit_mir(&impl_item.attrs, |c| intravisit::walk_impl_item(c, impl_item));
|
||||
}
|
||||
hir::ImplItemKind::Const(..) | hir::ImplItemKind::Type(..) => {}
|
||||
}
|
||||
visit::walk_impl_item(self, impl_item);
|
||||
intravisit::walk_impl_item(self, impl_item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,27 +117,23 @@ struct InnerDump<'a, 'm, 'tcx: 'a + 'm> {
|
||||
attr: Option<&'a ast::Attribute>,
|
||||
}
|
||||
|
||||
impl<'a, 'm, 'tcx> visit::Visitor<'tcx> for InnerDump<'a,'m,'tcx> {
|
||||
fn visit_item(&mut self, _: &'tcx hir::Item) {
|
||||
// ignore nested items; they need their own graphviz annotation
|
||||
}
|
||||
|
||||
impl<'a, 'm, 'tcx> Visitor<'tcx> for InnerDump<'a,'m,'tcx> {
|
||||
fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) {
|
||||
// ignore nested items; they need their own graphviz annotation
|
||||
// ignore methods; the outer dump will call us for them independently
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) {
|
||||
// ignore nested items; they need their own graphviz annotation
|
||||
// ignore methods; the outer dump will call us for them independently
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
fk: visit::FnKind<'tcx>,
|
||||
fk: intravisit::FnKind<'tcx>,
|
||||
decl: &'tcx hir::FnDecl,
|
||||
body: &'tcx hir::Block,
|
||||
span: Span,
|
||||
id: ast::NodeId) {
|
||||
let (prefix, implicit_arg_tys) = match fk {
|
||||
visit::FnKind::Closure =>
|
||||
intravisit::FnKind::Closure =>
|
||||
(format!("{}-", id), vec![closure_self_ty(&self.tcx, id, body.id)]),
|
||||
_ =>
|
||||
(format!(""), vec![]),
|
||||
@ -188,7 +184,7 @@ impl<'a, 'm, 'tcx> visit::Visitor<'tcx> for InnerDump<'a,'m,'tcx> {
|
||||
Err(ErrorReported) => {}
|
||||
}
|
||||
|
||||
visit::walk_fn(self, fk, decl, body, span);
|
||||
intravisit::walk_fn(self, fk, decl, body, span);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ use syntax::codemap::{Span, DUMMY_SP};
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc_front::hir::{ViewPathGlob, ViewPathList, ViewPathSimple};
|
||||
use rustc_front::visit::{self, Visitor};
|
||||
use rustc_front::intravisit::Visitor;
|
||||
|
||||
struct UnusedImportCheckVisitor<'a, 'b: 'a, 'tcx: 'b> {
|
||||
resolver: &'a mut Resolver<'b, 'tcx>,
|
||||
@ -118,7 +118,6 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
|
||||
// because this means that they were generated in some fashion by the
|
||||
// compiler and we don't need to consider them.
|
||||
if item.vis == hir::Public || item.span == DUMMY_SP {
|
||||
visit::walk_item(self, item);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -158,12 +157,10 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_crate(resolver: &mut Resolver, krate: &hir::Crate) {
|
||||
let mut visitor = UnusedImportCheckVisitor { resolver: resolver };
|
||||
visit::walk_crate(&mut visitor, krate);
|
||||
krate.visit_all_items(&mut visitor);
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ impl Ord for TraitInfo {
|
||||
/// Retrieve all traits in this crate and any dependent crates.
|
||||
pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> {
|
||||
if ccx.all_traits.borrow().is_none() {
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
|
||||
let mut traits = vec![];
|
||||
|
||||
@ -397,7 +397,7 @@ pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> {
|
||||
map: &'a hir_map::Map<'tcx>,
|
||||
traits: &'a mut AllTraitsVec,
|
||||
}
|
||||
impl<'v, 'a, 'tcx> visit::Visitor<'v> for Visitor<'a, 'tcx> {
|
||||
impl<'v, 'a, 'tcx> intravisit::Visitor<'v> for Visitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &'v hir::Item) {
|
||||
match i.node {
|
||||
hir::ItemTrait(..) => {
|
||||
@ -406,13 +406,12 @@ pub fn all_traits<'a>(ccx: &'a CrateCtxt) -> AllTraits<'a> {
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
visit::walk_item(self, i)
|
||||
}
|
||||
}
|
||||
visit::walk_crate(&mut Visitor {
|
||||
ccx.tcx.map.krate().visit_all_items(&mut Visitor {
|
||||
map: &ccx.tcx.map,
|
||||
traits: &mut traits
|
||||
}, ccx.tcx.map.krate());
|
||||
});
|
||||
|
||||
// Cross-crate:
|
||||
let mut external_mods = FnvHashSet();
|
||||
|
@ -124,7 +124,7 @@ use syntax::owned_slice::OwnedSlice;
|
||||
use syntax::parse::token::{self, InternedString};
|
||||
use syntax::ptr::P;
|
||||
|
||||
use rustc_front::visit::{self, Visitor};
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
use rustc_front::hir;
|
||||
use rustc_front::hir::Visibility;
|
||||
use rustc_front::hir::{Item, ItemImpl};
|
||||
@ -363,7 +363,7 @@ struct CheckItemBodiesVisitor<'a, 'tcx: 'a> { ccx: &'a CrateCtxt<'a, 'tcx> }
|
||||
impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
check_item_type(self.ccx, i);
|
||||
visit::walk_item(self, i);
|
||||
intravisit::walk_item(self, i);
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: &'tcx hir::Ty) {
|
||||
@ -374,14 +374,13 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
|
||||
_ => {}
|
||||
}
|
||||
|
||||
visit::walk_ty(self, t);
|
||||
intravisit::walk_ty(self, t);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for CheckItemBodiesVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &'tcx hir::Item) {
|
||||
check_item_body(self.ccx, i);
|
||||
visit::walk_item(self, i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -393,7 +392,7 @@ pub fn check_wf_old(ccx: &CrateCtxt) {
|
||||
// comes, we run the new code and issue warnings.
|
||||
let krate = ccx.tcx.map.krate();
|
||||
let mut visit = wf::CheckTypeWellFormedVisitor::new(ccx);
|
||||
visit::walk_crate(&mut visit, krate);
|
||||
krate.visit_all_items(&mut visit);
|
||||
|
||||
// If types are not well-formed, it leads to all manner of errors
|
||||
// downstream, so stop reporting errors at this point.
|
||||
@ -403,7 +402,7 @@ pub fn check_wf_old(ccx: &CrateCtxt) {
|
||||
pub fn check_wf_new(ccx: &CrateCtxt) {
|
||||
let krate = ccx.tcx.map.krate();
|
||||
let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(ccx);
|
||||
visit::walk_crate(&mut visit, krate);
|
||||
krate.visit_all_items(&mut visit);
|
||||
|
||||
// If types are not well-formed, it leads to all manner of errors
|
||||
// downstream, so stop reporting errors at this point.
|
||||
@ -413,14 +412,14 @@ pub fn check_wf_new(ccx: &CrateCtxt) {
|
||||
pub fn check_item_types(ccx: &CrateCtxt) {
|
||||
let krate = ccx.tcx.map.krate();
|
||||
let mut visit = CheckItemTypesVisitor { ccx: ccx };
|
||||
visit::walk_crate(&mut visit, krate);
|
||||
krate.visit_all_items(&mut visit);
|
||||
ccx.tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
pub fn check_item_bodies(ccx: &CrateCtxt) {
|
||||
let krate = ccx.tcx.map.krate();
|
||||
let mut visit = CheckItemBodiesVisitor { ccx: ccx };
|
||||
visit::walk_crate(&mut visit, krate);
|
||||
krate.visit_all_items(&mut visit);
|
||||
|
||||
ccx.tcx.sess.abort_if_errors();
|
||||
}
|
||||
@ -518,7 +517,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
local.pat,
|
||||
self.fcx.infcx().ty_to_string(
|
||||
self.fcx.inh.locals.borrow().get(&local.id).unwrap().clone()));
|
||||
visit::walk_local(self, local);
|
||||
intravisit::walk_local(self, local);
|
||||
}
|
||||
|
||||
// Add pattern bindings.
|
||||
@ -537,14 +536,14 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
var_ty);
|
||||
}
|
||||
}
|
||||
visit::walk_pat(self, p);
|
||||
intravisit::walk_pat(self, p);
|
||||
}
|
||||
|
||||
fn visit_block(&mut self, b: &'tcx hir::Block) {
|
||||
// non-obvious: the `blk` variable maps to region lb, so
|
||||
// we have to keep this up-to-date. This
|
||||
// is... unfortunate. It'd be nice to not need this.
|
||||
visit::walk_block(self, b);
|
||||
intravisit::walk_block(self, b);
|
||||
}
|
||||
|
||||
// Since an expr occurs as part of the type fixed size arrays we
|
||||
@ -556,18 +555,16 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
check_expr_with_hint(self.fcx, &**count_expr, self.fcx.tcx().types.usize);
|
||||
}
|
||||
hir::TyBareFn(ref function_declaration) => {
|
||||
visit::walk_fn_decl_nopat(self, &function_declaration.decl);
|
||||
intravisit::walk_fn_decl_nopat(self, &function_declaration.decl);
|
||||
walk_list!(self, visit_lifetime_def, &function_declaration.lifetimes);
|
||||
}
|
||||
_ => visit::walk_ty(self, t)
|
||||
_ => intravisit::walk_ty(self, t)
|
||||
}
|
||||
}
|
||||
|
||||
// Don't descend into fns and items
|
||||
fn visit_fn(&mut self, _: visit::FnKind<'tcx>, _: &'tcx hir::FnDecl,
|
||||
// Don't descend into the bodies of nested closures
|
||||
fn visit_fn(&mut self, _: intravisit::FnKind<'tcx>, _: &'tcx hir::FnDecl,
|
||||
_: &'tcx hir::Block, _: Span, _: ast::NodeId) { }
|
||||
fn visit_item(&mut self, _: &hir::Item) { }
|
||||
|
||||
}
|
||||
|
||||
/// Helper used by check_bare_fn and check_expr_fn. Does the grungy work of checking a function
|
||||
|
@ -102,8 +102,7 @@ use std::mem;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
use rustc_front::hir;
|
||||
use rustc_front::util as hir_util;
|
||||
|
||||
@ -496,13 +495,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Rcx<'a, 'tcx> {
|
||||
// hierarchy, and in particular the relationships between free
|
||||
// regions, until regionck, as described in #3238.
|
||||
|
||||
fn visit_fn(&mut self, _fk: visit::FnKind<'v>, fd: &'v hir::FnDecl,
|
||||
fn visit_fn(&mut self, _fk: intravisit::FnKind<'v>, fd: &'v hir::FnDecl,
|
||||
b: &'v hir::Block, span: Span, id: ast::NodeId) {
|
||||
self.visit_fn_body(id, fd, b, span)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, i: &hir::Item) { visit_item(self, i); }
|
||||
|
||||
fn visit_expr(&mut self, ex: &hir::Expr) { visit_expr(self, ex); }
|
||||
|
||||
//visit_pat: visit_pat, // (..) see above
|
||||
@ -514,12 +511,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Rcx<'a, 'tcx> {
|
||||
fn visit_block(&mut self, b: &hir::Block) { visit_block(self, b); }
|
||||
}
|
||||
|
||||
fn visit_item(_rcx: &mut Rcx, _item: &hir::Item) {
|
||||
// Ignore items
|
||||
}
|
||||
|
||||
fn visit_block(rcx: &mut Rcx, b: &hir::Block) {
|
||||
visit::walk_block(rcx, b);
|
||||
intravisit::walk_block(rcx, b);
|
||||
}
|
||||
|
||||
fn visit_arm(rcx: &mut Rcx, arm: &hir::Arm) {
|
||||
@ -528,14 +521,14 @@ fn visit_arm(rcx: &mut Rcx, arm: &hir::Arm) {
|
||||
constrain_bindings_in_pat(&**p, rcx);
|
||||
}
|
||||
|
||||
visit::walk_arm(rcx, arm);
|
||||
intravisit::walk_arm(rcx, arm);
|
||||
}
|
||||
|
||||
fn visit_local(rcx: &mut Rcx, l: &hir::Local) {
|
||||
// see above
|
||||
constrain_bindings_in_pat(&*l.pat, rcx);
|
||||
link_local(rcx, l);
|
||||
visit::walk_local(rcx, l);
|
||||
intravisit::walk_local(rcx, l);
|
||||
}
|
||||
|
||||
fn constrain_bindings_in_pat(pat: &hir::Pat, rcx: &mut Rcx) {
|
||||
@ -700,14 +693,14 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
args.iter().map(|e| &**e), false);
|
||||
}
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
constrain_call(rcx, expr, Some(&*args[0]),
|
||||
args[1..].iter().map(|e| &**e), false);
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprAssignOp(_, ref lhs, ref rhs) => {
|
||||
@ -716,14 +709,14 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
Some(&**rhs).into_iter(), false);
|
||||
}
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprIndex(ref lhs, ref rhs) if has_method_map => {
|
||||
constrain_call(rcx, expr, Some(&**lhs),
|
||||
Some(&**rhs).into_iter(), true);
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
},
|
||||
|
||||
hir::ExprBinary(op, ref lhs, ref rhs) if has_method_map => {
|
||||
@ -736,7 +729,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
constrain_call(rcx, expr, Some(&**lhs),
|
||||
Some(&**rhs).into_iter(), implicitly_ref_args);
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprBinary(_, ref lhs, ref rhs) => {
|
||||
@ -750,7 +743,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
ty,
|
||||
expr_region);
|
||||
}
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprUnary(op, ref lhs) if has_method_map => {
|
||||
@ -760,7 +753,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
constrain_call(rcx, expr, Some(&**lhs),
|
||||
None::<hir::Expr>.iter(), implicitly_ref_args);
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprUnary(hir::UnDeref, ref base) => {
|
||||
@ -781,7 +774,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
rcx, expr.span, expr_region, *r_ptr);
|
||||
}
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprIndex(ref vec_expr, _) => {
|
||||
@ -789,7 +782,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
let vec_type = rcx.resolve_expr_type_adjusted(&**vec_expr);
|
||||
constrain_index(rcx, expr, vec_type);
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprCast(ref source, _) => {
|
||||
@ -797,7 +790,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
// instance. If so, we have to be sure that the type of
|
||||
// the source obeys the trait's region bound.
|
||||
constrain_cast(rcx, expr, &**source);
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprAddrOf(m, ref base) => {
|
||||
@ -812,13 +805,13 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
// FIXME(#6268) nested method calls requires that this rule change
|
||||
let ty0 = rcx.resolve_node_type(expr.id);
|
||||
type_must_outlive(rcx, infer::AddrOf(expr.span), ty0, expr_region);
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprMatch(ref discr, ref arms, _) => {
|
||||
link_match(rcx, &**discr, &arms[..]);
|
||||
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
|
||||
hir::ExprClosure(_, _, ref body) => {
|
||||
@ -827,7 +820,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
|
||||
hir::ExprLoop(ref body, _) => {
|
||||
let repeating_scope = rcx.set_repeating_scope(body.id);
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
rcx.set_repeating_scope(repeating_scope);
|
||||
}
|
||||
|
||||
@ -842,7 +835,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &hir::Expr) {
|
||||
}
|
||||
|
||||
_ => {
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -897,7 +890,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
|
||||
expr: &hir::Expr,
|
||||
body: &hir::Block) {
|
||||
let repeating_scope = rcx.set_repeating_scope(body.id);
|
||||
visit::walk_expr(rcx, expr);
|
||||
intravisit::walk_expr(rcx, expr);
|
||||
rcx.set_repeating_scope(repeating_scope);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ use std::collections::HashSet;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit::{self, Visitor};
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// PUBLIC ENTRY POINTS
|
||||
@ -105,11 +105,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for SeedBorrowKind<'a, 'tcx> {
|
||||
_ => { }
|
||||
}
|
||||
|
||||
visit::walk_expr(self, expr);
|
||||
intravisit::walk_expr(self, expr);
|
||||
}
|
||||
|
||||
// Skip all items; they aren't in the same context.
|
||||
fn visit_item(&mut self, _: &'v hir::Item) { }
|
||||
}
|
||||
|
||||
impl<'a,'tcx> SeedBorrowKind<'a,'tcx> {
|
||||
@ -510,18 +507,15 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> {
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for AdjustBorrowKind<'a, 'tcx> {
|
||||
fn visit_fn(&mut self,
|
||||
fn_kind: visit::FnKind<'v>,
|
||||
fn_kind: intravisit::FnKind<'v>,
|
||||
decl: &'v hir::FnDecl,
|
||||
body: &'v hir::Block,
|
||||
span: Span,
|
||||
id: ast::NodeId)
|
||||
{
|
||||
visit::walk_fn(self, fn_kind, decl, body, span);
|
||||
intravisit::walk_fn(self, fn_kind, decl, body, span);
|
||||
self.analyze_closure(id, span, decl, body);
|
||||
}
|
||||
|
||||
// Skip all items; they aren't in the same context.
|
||||
fn visit_item(&mut self, _: &'v hir::Item) { }
|
||||
}
|
||||
|
||||
impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> {
|
||||
|
@ -24,7 +24,7 @@ use syntax::ast;
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use syntax::parse::token::special_idents;
|
||||
|
||||
use rustc_front::visit::{self, Visitor, FnKind};
|
||||
use rustc_front::intravisit::{self, Visitor, FnKind};
|
||||
use rustc_front::hir;
|
||||
|
||||
pub struct CheckTypeWellFormedVisitor<'ccx, 'tcx:'ccx> {
|
||||
@ -423,7 +423,7 @@ fn reject_shadowing_type_parameters<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
self.check_item_well_formed(i);
|
||||
visit::walk_item(self, i);
|
||||
intravisit::walk_item(self, i);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
@ -440,7 +440,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
visit::walk_fn(self, fk, fd, b, span)
|
||||
intravisit::walk_fn(self, fk, fd, b, span)
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'v hir::TraitItem) {
|
||||
@ -460,7 +460,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_trait_item(self, trait_item)
|
||||
intravisit::walk_trait_item(self, trait_item)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,7 @@ use syntax::ast;
|
||||
use syntax::codemap::{Span};
|
||||
use syntax::parse::token::{special_idents};
|
||||
use syntax::ptr::P;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
use rustc_front::hir;
|
||||
|
||||
pub struct CheckTypeWellFormedVisitor<'ccx, 'tcx:'ccx> {
|
||||
@ -492,19 +491,19 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
debug!("visit_item: {:?}", i);
|
||||
self.check_item_well_formed(i);
|
||||
visit::walk_item(self, i);
|
||||
intravisit::walk_item(self, i);
|
||||
}
|
||||
|
||||
fn visit_trait_item(&mut self, trait_item: &'v hir::TraitItem) {
|
||||
debug!("visit_trait_item: {:?}", trait_item);
|
||||
self.check_trait_or_impl_item(trait_item.id, trait_item.span);
|
||||
visit::walk_trait_item(self, trait_item)
|
||||
intravisit::walk_trait_item(self, trait_item)
|
||||
}
|
||||
|
||||
fn visit_impl_item(&mut self, impl_item: &'v hir::ImplItem) {
|
||||
debug!("visit_impl_item: {:?}", impl_item);
|
||||
self.check_trait_or_impl_item(impl_item.id, impl_item.span);
|
||||
visit::walk_impl_item(self, impl_item)
|
||||
intravisit::walk_impl_item(self, impl_item)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@ use std::cell::Cell;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::{DUMMY_SP, Span};
|
||||
use rustc_front::print::pprust::pat_to_string;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit::{self, Visitor};
|
||||
use rustc_front::util as hir_util;
|
||||
use rustc_front::hir;
|
||||
|
||||
@ -153,17 +152,13 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
// traffic in node-ids or update tables in the type context etc.
|
||||
|
||||
impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
|
||||
fn visit_item(&mut self, _: &hir::Item) {
|
||||
// Ignore items
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, s: &hir::Stmt) {
|
||||
if self.fcx.writeback_errors.get() {
|
||||
return;
|
||||
}
|
||||
|
||||
self.visit_node_id(ResolvingExpr(s.span), hir_util::stmt_id(s));
|
||||
visit::walk_stmt(self, s);
|
||||
intravisit::walk_stmt(self, s);
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e: &hir::Expr) {
|
||||
@ -183,7 +178,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_expr(self, e);
|
||||
intravisit::walk_expr(self, e);
|
||||
}
|
||||
|
||||
fn visit_block(&mut self, b: &hir::Block) {
|
||||
@ -192,7 +187,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
self.visit_node_id(ResolvingExpr(b.span), b.id);
|
||||
visit::walk_block(self, b);
|
||||
intravisit::walk_block(self, b);
|
||||
}
|
||||
|
||||
fn visit_pat(&mut self, p: &hir::Pat) {
|
||||
@ -207,7 +202,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
|
||||
p.id,
|
||||
self.tcx().node_id_to_type(p.id));
|
||||
|
||||
visit::walk_pat(self, p);
|
||||
intravisit::walk_pat(self, p);
|
||||
}
|
||||
|
||||
fn visit_local(&mut self, l: &hir::Local) {
|
||||
@ -218,7 +213,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
|
||||
let var_ty = self.fcx.local_ty(l.span, l.id);
|
||||
let var_ty = self.resolve(&var_ty, ResolvingLocal(l.span));
|
||||
write_ty_to_tcx(self.tcx(), l.id, var_ty);
|
||||
visit::walk_local(self, l);
|
||||
intravisit::walk_local(self, l);
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: &hir::Ty) {
|
||||
@ -228,10 +223,10 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
|
||||
write_ty_to_tcx(self.tcx(), count_expr.id, self.tcx().types.usize);
|
||||
}
|
||||
hir::TyBareFn(ref function_declaration) => {
|
||||
visit::walk_fn_decl_nopat(self, &function_declaration.decl);
|
||||
intravisit::walk_fn_decl_nopat(self, &function_declaration.decl);
|
||||
walk_list!(self, visit_lifetime_def, &function_declaration.lifetimes);
|
||||
}
|
||||
_ => visit::walk_ty(self, t)
|
||||
_ => intravisit::walk_ty(self, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ use syntax::parse::token;
|
||||
use util::nodemap::{DefIdMap, FnvHashMap};
|
||||
use rustc::front::map as hir_map;
|
||||
use rustc::front::map::NodeItem;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::hir::{Item, ItemImpl,Crate};
|
||||
use rustc_front::hir;
|
||||
|
||||
@ -96,13 +96,11 @@ struct CoherenceCheckVisitor<'a, 'tcx: 'a> {
|
||||
cc: &'a CoherenceChecker<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
if let ItemImpl(..) = item.node {
|
||||
self.cc.check_implementation(item)
|
||||
}
|
||||
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,8 +109,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
||||
// Check implementations and traits. This populates the tables
|
||||
// containing the inherent methods and extension methods. It also
|
||||
// builds up the trait inheritance table.
|
||||
let mut visitor = CoherenceCheckVisitor { cc: self };
|
||||
visit::walk_crate(&mut visitor, krate);
|
||||
krate.visit_all_items(&mut CoherenceCheckVisitor { cc: self });
|
||||
|
||||
// Copy over the inherent impls we gathered up during the walk into
|
||||
// the tcx.
|
||||
|
@ -17,13 +17,13 @@ use middle::traits;
|
||||
use middle::ty;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::hir::{Item, ItemImpl};
|
||||
|
||||
pub fn check(tcx: &ty::ctxt) {
|
||||
let mut orphan = OrphanChecker { tcx: tcx };
|
||||
visit::walk_crate(&mut orphan, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut orphan);
|
||||
}
|
||||
|
||||
struct OrphanChecker<'cx, 'tcx:'cx> {
|
||||
@ -354,9 +354,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx,'v> visit::Visitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OrphanChecker<'cx, 'tcx> {
|
||||
fn visit_item(&mut self, item: &hir::Item) {
|
||||
self.check_item(item);
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use middle::infer::{self, new_infer_ctxt};
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
use util::nodemap::DefIdMap;
|
||||
|
||||
pub fn check(tcx: &ty::ctxt) {
|
||||
@ -28,7 +28,7 @@ pub fn check(tcx: &ty::ctxt) {
|
||||
|
||||
// this secondary walk specifically checks for some other cases,
|
||||
// like defaulted traits, for which additional overlap rules exist
|
||||
visit::walk_crate(&mut overlap, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut overlap);
|
||||
}
|
||||
|
||||
struct OverlapChecker<'cx, 'tcx:'cx> {
|
||||
@ -169,7 +169,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
|
||||
impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
match item.node {
|
||||
hir::ItemDefaultImpl(_, _) => {
|
||||
@ -226,6 +226,5 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
|
||||
_ => {
|
||||
}
|
||||
}
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,13 @@
|
||||
//! crate or pertains to a type defined in this crate.
|
||||
|
||||
use middle::ty;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::hir::{Item, ItemImpl};
|
||||
|
||||
pub fn check(tcx: &ty::ctxt) {
|
||||
let mut orphan = UnsafetyChecker { tcx: tcx };
|
||||
visit::walk_crate(&mut orphan, tcx.map.krate());
|
||||
tcx.map.krate().visit_all_items(&mut orphan);
|
||||
}
|
||||
|
||||
struct UnsafetyChecker<'cx, 'tcx:'cx> {
|
||||
@ -76,7 +76,7 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx,'v> visit::Visitor<'v> for UnsafetyChecker<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for UnsafetyChecker<'cx, 'tcx> {
|
||||
fn visit_item(&mut self, item: &'v hir::Item) {
|
||||
match item.node {
|
||||
hir::ItemDefaultImpl(unsafety, _) => {
|
||||
@ -87,7 +87,5 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for UnsafetyChecker<'cx, 'tcx> {
|
||||
}
|
||||
_ => { }
|
||||
}
|
||||
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ use syntax::codemap::Span;
|
||||
use syntax::parse::token::special_idents;
|
||||
use syntax::ptr::P;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::intravisit;
|
||||
use rustc_front::print::pprust;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -108,10 +108,10 @@ pub fn collect_item_types(tcx: &ty::ctxt) {
|
||||
let ccx = &CrateCtxt { tcx: tcx, stack: RefCell::new(Vec::new()) };
|
||||
|
||||
let mut visitor = CollectTraitDefVisitor{ ccx: ccx };
|
||||
visit::walk_crate(&mut visitor, ccx.tcx.map.krate());
|
||||
ccx.tcx.map.krate().visit_all_items(&mut visitor);
|
||||
|
||||
let mut visitor = CollectItemTypesVisitor{ ccx: ccx };
|
||||
visit::walk_crate(&mut visitor, ccx.tcx.map.krate());
|
||||
ccx.tcx.map.krate().visit_all_items(&mut visitor);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -157,7 +157,7 @@ struct CollectTraitDefVisitor<'a, 'tcx: 'a> {
|
||||
ccx: &'a CrateCtxt<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for CollectTraitDefVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for CollectTraitDefVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
match i.node {
|
||||
hir::ItemTrait(..) => {
|
||||
@ -166,8 +166,6 @@ impl<'a, 'tcx, 'v> visit::Visitor<'v> for CollectTraitDefVisitor<'a, 'tcx> {
|
||||
}
|
||||
_ => { }
|
||||
}
|
||||
|
||||
visit::walk_item(self, i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,14 +176,14 @@ struct CollectItemTypesVisitor<'a, 'tcx: 'a> {
|
||||
ccx: &'a CrateCtxt<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &hir::Item) {
|
||||
convert_item(self.ccx, i);
|
||||
visit::walk_item(self, i);
|
||||
intravisit::walk_item(self, i);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, i: &hir::ForeignItem) {
|
||||
convert_foreign_item(self.ccx, i);
|
||||
visit::walk_foreign_item(self, i);
|
||||
intravisit::walk_foreign_item(self, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,8 +276,7 @@ use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::visit;
|
||||
use rustc_front::visit::Visitor;
|
||||
use rustc_front::intravisit::Visitor;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
pub fn infer_variance(tcx: &ty::ctxt) {
|
||||
@ -383,7 +382,7 @@ fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
|
||||
})
|
||||
};
|
||||
|
||||
visit::walk_crate(&mut terms_cx, krate);
|
||||
krate.visit_all_items(&mut terms_cx);
|
||||
|
||||
terms_cx
|
||||
}
|
||||
@ -531,7 +530,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> {
|
||||
// constrained to be invariant. See `visit_item` in
|
||||
// the impl for `ConstraintContext` below.
|
||||
self.add_inferreds_for_item(item.id, true, generics);
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
|
||||
hir::ItemExternCrate(_) |
|
||||
@ -544,7 +542,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> {
|
||||
hir::ItemMod(..) |
|
||||
hir::ItemForeignMod(..) |
|
||||
hir::ItemTy(..) => {
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -591,7 +588,7 @@ fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
|
||||
bivariant: bivariant,
|
||||
constraints: Vec::new(),
|
||||
};
|
||||
visit::walk_crate(&mut constraint_cx, krate);
|
||||
krate.visit_all_items(&mut constraint_cx);
|
||||
constraint_cx
|
||||
}
|
||||
|
||||
@ -637,8 +634,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||
hir::ItemDefaultImpl(..) => {
|
||||
}
|
||||
}
|
||||
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,8 +157,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
om.vis = vis;
|
||||
om.stab = self.stability(id);
|
||||
om.id = id;
|
||||
for i in &m.items {
|
||||
self.visit_item(&**i, None, &mut om);
|
||||
for i in &m.item_ids {
|
||||
let item = self.cx.map.expect_item(i.id);
|
||||
self.visit_item(item, None, &mut om);
|
||||
}
|
||||
om
|
||||
}
|
||||
@ -224,8 +225,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||
let prev = mem::replace(&mut self.inlining_from_glob, true);
|
||||
match it.node {
|
||||
hir::ItemMod(ref m) => {
|
||||
for i in &m.items {
|
||||
self.visit_item(&**i, None, om);
|
||||
for i in &m.item_ids {
|
||||
let i = self.cx.map.expect_item(i.id);
|
||||
self.visit_item(i, None, om);
|
||||
}
|
||||
}
|
||||
hir::ItemEnum(..) => {}
|
||||
|
Loading…
Reference in New Issue
Block a user