Track the visited AST's lifetime throughout Visitor.
This commit is contained in:
parent
a09dbf28e6
commit
7ef6ff0669
47 changed files with 288 additions and 302 deletions
|
|
@ -143,7 +143,7 @@ impl<'a> Context<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Visitor for Context<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for Context<'a> {
|
||||
fn visit_ident(&mut self, sp: Span, id: ast::Ident) {
|
||||
if !token::get_ident(id).get().is_ascii() {
|
||||
self.gate_feature("non_ascii_idents", sp,
|
||||
|
|
@ -386,13 +386,13 @@ impl<'a> Visitor for Context<'a> {
|
|||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
fn_kind: &visit::FnKind,
|
||||
fn_decl: &ast::FnDecl,
|
||||
block: &ast::Block,
|
||||
fn_kind: visit::FnKind<'v>,
|
||||
fn_decl: &'v ast::FnDecl,
|
||||
block: &'v ast::Block,
|
||||
span: Span,
|
||||
_: NodeId) {
|
||||
match *fn_kind {
|
||||
visit::FkItemFn(_, _, _, ref abi) if *abi == RustIntrinsic => {
|
||||
match fn_kind {
|
||||
visit::FkItemFn(_, _, _, abi) if abi == RustIntrinsic => {
|
||||
self.gate_feature("intrinsics",
|
||||
span,
|
||||
"intrinsics are subject to change")
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ struct ShowSpanVisitor<'a> {
|
|||
sess: &'a Session
|
||||
}
|
||||
|
||||
impl<'a> Visitor for ShowSpanVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for ShowSpanVisitor<'a> {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
self.sess.span_note(e.span, "expression");
|
||||
visit::walk_expr(self, e);
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ impl<'a, 'tcx> CTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for CTypesVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CTypesVisitor<'a, 'tcx> {
|
||||
fn visit_ty(&mut self, ty: &ast::Ty) {
|
||||
match ty.node {
|
||||
ast::TyPath(_, _, id) => self.check_def(ty.span, ty.id, id),
|
||||
|
|
@ -500,7 +500,7 @@ struct RawPtrDerivingVisitor<'a, 'tcx: 'a> {
|
|||
cx: &'a Context<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for RawPtrDerivingVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for RawPtrDerivingVisitor<'a, 'tcx> {
|
||||
fn visit_ty(&mut self, ty: &ast::Ty) {
|
||||
static MSG: &'static str = "use of `#[deriving]` with a raw pointer";
|
||||
match ty.node {
|
||||
|
|
@ -908,9 +908,9 @@ impl LintPass for NonSnakeCase {
|
|||
}
|
||||
|
||||
fn check_fn(&mut self, cx: &Context,
|
||||
fk: &visit::FnKind, _: &ast::FnDecl,
|
||||
fk: visit::FnKind, _: &ast::FnDecl,
|
||||
_: &ast::Block, span: Span, _: ast::NodeId) {
|
||||
match *fk {
|
||||
match fk {
|
||||
visit::FkMethod(ident, _, m) => match method_context(cx, m) {
|
||||
PlainImpl
|
||||
=> self.check_snake_case(cx, "method", ident, span),
|
||||
|
|
@ -1218,7 +1218,7 @@ impl LintPass for UnusedMut {
|
|||
}
|
||||
|
||||
fn check_fn(&mut self, cx: &Context,
|
||||
_: &visit::FnKind, decl: &ast::FnDecl,
|
||||
_: visit::FnKind, decl: &ast::FnDecl,
|
||||
_: &ast::Block, _: Span, _: ast::NodeId) {
|
||||
for a in decl.inputs.iter() {
|
||||
self.check_unused_mut_pat(cx, &[a.pat]);
|
||||
|
|
@ -1387,9 +1387,9 @@ impl LintPass for MissingDoc {
|
|||
}
|
||||
|
||||
fn check_fn(&mut self, cx: &Context,
|
||||
fk: &visit::FnKind, _: &ast::FnDecl,
|
||||
fk: visit::FnKind, _: &ast::FnDecl,
|
||||
_: &ast::Block, _: Span, _: ast::NodeId) {
|
||||
match *fk {
|
||||
match fk {
|
||||
visit::FkMethod(_, _, m) => {
|
||||
// If the method is an impl for a trait, don't doc.
|
||||
if method_context(cx, m) == TraitImpl { return; }
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ impl<'a, 'tcx> AstConv<'tcx> for Context<'a, 'tcx>{
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for Context<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
||||
fn visit_item(&mut self, it: &ast::Item) {
|
||||
self.with_lint_attrs(it.attrs.as_slice(), |cx| {
|
||||
run_lints!(cx, check_item, it);
|
||||
|
|
@ -531,9 +531,9 @@ impl<'a, 'tcx> Visitor for Context<'a, 'tcx> {
|
|||
visit::walk_stmt(self, s);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &FnKind, decl: &ast::FnDecl,
|
||||
body: &ast::Block, span: Span, id: ast::NodeId) {
|
||||
match *fk {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, decl: &'v ast::FnDecl,
|
||||
body: &'v ast::Block, span: Span, id: ast::NodeId) {
|
||||
match fk {
|
||||
visit::FkMethod(_, _, m) => {
|
||||
self.with_lint_attrs(m.attrs.as_slice(), |cx| {
|
||||
run_lints!(cx, check_fn, fk, decl, body, span, id);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ pub trait LintPass {
|
|||
fn check_ty(&mut self, _: &Context, _: &ast::Ty) { }
|
||||
fn check_generics(&mut self, _: &Context, _: &ast::Generics) { }
|
||||
fn check_fn(&mut self, _: &Context,
|
||||
_: &FnKind, _: &ast::FnDecl, _: &ast::Block, _: Span, _: ast::NodeId) { }
|
||||
_: FnKind, _: &ast::FnDecl, _: &ast::Block, _: Span, _: ast::NodeId) { }
|
||||
fn check_ty_method(&mut self, _: &Context, _: &ast::TypeMethod) { }
|
||||
fn check_trait_method(&mut self, _: &Context, _: &ast::TraitItem) { }
|
||||
fn check_struct_def(&mut self, _: &Context,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ pub fn read_crates(sess: &Session,
|
|||
warn_if_multiple_versions(sess.diagnostic(), &sess.cstore)
|
||||
}
|
||||
|
||||
impl<'a> visit::Visitor for Env<'a> {
|
||||
impl<'a, 'v> visit::Visitor<'v> for Env<'a> {
|
||||
fn visit_view_item(&mut self, a: &ast::ViewItem) {
|
||||
visit_view_item(self, a);
|
||||
visit::walk_view_item(self, a);
|
||||
|
|
|
|||
|
|
@ -1473,7 +1473,7 @@ struct EncodeVisitor<'a,'b:'a> {
|
|||
index: &'a mut Vec<entry<i64>>,
|
||||
}
|
||||
|
||||
impl<'a,'b> visit::Visitor for EncodeVisitor<'a,'b> {
|
||||
impl<'a, 'b, 'v> Visitor<'v> for EncodeVisitor<'a, 'b> {
|
||||
fn visit_expr(&mut self, ex: &Expr) {
|
||||
visit::walk_expr(self, ex);
|
||||
my_visit_expr(ex);
|
||||
|
|
@ -1775,7 +1775,7 @@ fn encode_struct_field_attrs(rbml_w: &mut Encoder, krate: &Crate) {
|
|||
rbml_w: &'a mut Encoder<'b>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> Visitor for StructFieldVisitor<'a, 'b> {
|
||||
impl<'a, 'b, 'v> Visitor<'v> for StructFieldVisitor<'a, 'b> {
|
||||
fn visit_struct_field(&mut self, field: &ast::StructField) {
|
||||
self.rbml_w.start_tag(tag_struct_field);
|
||||
self.rbml_w.wr_tagged_u32(tag_struct_field_id, field.node.id);
|
||||
|
|
@ -1798,7 +1798,7 @@ struct ImplVisitor<'a, 'b:'a, 'c:'a, 'tcx:'b> {
|
|||
rbml_w: &'a mut Encoder<'c>,
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'c, 'tcx> Visitor for ImplVisitor<'a, 'b, 'c, 'tcx> {
|
||||
impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'b, 'c, 'tcx> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
match item.node {
|
||||
ItemImpl(_, Some(ref trait_ref), _, _) => {
|
||||
|
|
|
|||
|
|
@ -471,7 +471,7 @@ struct StaticInitializerCtxt<'a, 'tcx: 'a> {
|
|||
bccx: &'a BorrowckCtxt<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for StaticInitializerCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, ex: &Expr) {
|
||||
match ex.node {
|
||||
ast::ExprAddrOf(mutbl, ref base) => {
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ pub struct LoanDataFlowOperator;
|
|||
|
||||
pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator>;
|
||||
|
||||
impl<'a, 'tcx> Visitor for BorrowckCtxt<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl,
|
||||
b: &Block, s: Span, n: NodeId) {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
|
||||
b: &'v Block, s: Span, n: NodeId) {
|
||||
borrowck_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ pub struct AnalysisData<'a, 'tcx: 'a> {
|
|||
}
|
||||
|
||||
fn borrowck_fn(this: &mut BorrowckCtxt,
|
||||
fk: &FnKind,
|
||||
fk: FnKind,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
sp: Span,
|
||||
|
|
@ -146,7 +146,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
|
|||
}
|
||||
|
||||
fn build_borrowck_dataflow_data<'a, 'tcx>(this: &mut BorrowckCtxt<'a, 'tcx>,
|
||||
fk: &FnKind,
|
||||
fk: FnKind,
|
||||
decl: &ast::FnDecl,
|
||||
cfg: &cfg::CFG,
|
||||
body: &ast::Block,
|
||||
|
|
@ -217,7 +217,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
|
|||
let p = input.fn_parts;
|
||||
|
||||
let dataflow_data = build_borrowck_dataflow_data(&mut bccx,
|
||||
&p.kind,
|
||||
p.kind,
|
||||
&*p.decl,
|
||||
input.cfg,
|
||||
&*p.body,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for CheckCrateVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &Item) {
|
||||
check_item(self, i);
|
||||
}
|
||||
|
|
@ -238,7 +238,7 @@ pub fn check_item_recursion<'a>(sess: &'a Session,
|
|||
visitor.visit_item(it);
|
||||
}
|
||||
|
||||
impl<'a> Visitor for CheckItemRecursionVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a> {
|
||||
fn visit_item(&mut self, it: &Item) {
|
||||
if self.idstack.iter().any(|x| x == &(it.id)) {
|
||||
self.sess.span_fatal(self.root_it.span, "recursive constant");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub fn check_crate(sess: &Session, krate: &ast::Crate) {
|
|||
visit::walk_crate(&mut CheckLoopVisitor { sess: sess, cx: Normal }, krate)
|
||||
}
|
||||
|
||||
impl<'a> Visitor for CheckLoopVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for CheckLoopVisitor<'a> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
self.with_context(Normal, |v| visit::walk_item(v, i));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,14 +119,15 @@ enum WitnessPreference {
|
|||
LeaveOutWitness
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for MatchCheckCtxt<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, ex: &Expr) {
|
||||
check_expr(self, ex);
|
||||
}
|
||||
fn visit_local(&mut self, l: &Local) {
|
||||
check_local(self, l);
|
||||
}
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId) {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
|
||||
b: &'v Block, s: Span, _: NodeId) {
|
||||
check_fn(self, fk, fd, b, s);
|
||||
}
|
||||
}
|
||||
|
|
@ -868,7 +869,7 @@ fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) {
|
|||
}
|
||||
|
||||
fn check_fn(cx: &mut MatchCheckCtxt,
|
||||
kind: &FnKind,
|
||||
kind: FnKind,
|
||||
decl: &FnDecl,
|
||||
body: &Block,
|
||||
sp: Span) {
|
||||
|
|
@ -1022,7 +1023,7 @@ struct AtBindingPatternVisitor<'a, 'b:'a, 'tcx:'b> {
|
|||
bindings_allowed: bool
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx> Visitor for AtBindingPatternVisitor<'a, 'b, 'tcx> {
|
||||
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
|
||||
fn visit_pat(&mut self, pat: &Pat) {
|
||||
if !self.bindings_allowed && pat_is_binding(&self.cx.tcx.def_map, pat) {
|
||||
self.cx.tcx.sess.span_err(pat.span,
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ struct RvalueContext<'a, 'tcx: 'a> {
|
|||
tcx: &'a ty::ctxt<'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> visit::Visitor for RvalueContext<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||
fn visit_fn(&mut self,
|
||||
_: &visit::FnKind,
|
||||
fd: &ast::FnDecl,
|
||||
b: &ast::Block,
|
||||
_: visit::FnKind<'v>,
|
||||
fd: &'v ast::FnDecl,
|
||||
b: &'v ast::Block,
|
||||
_: Span,
|
||||
_: ast::NodeId) {
|
||||
let mut euv = euv::ExprUseVisitor::new(self, self.tcx);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ impl<'a, 'tcx> CheckStaticVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for CheckStaticVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
debug!("visit_item(item={})", pprust::item_to_string(i));
|
||||
match i.node {
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ impl<'a, 'tcx> ConstEvalVisitor<'a, 'tcx> {
|
|||
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for ConstEvalVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for ConstEvalVisitor<'a, 'tcx> {
|
||||
fn visit_ty(&mut self, t: &Ty) {
|
||||
match t.node {
|
||||
TyFixedLengthVec(_, expr) => {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ fn build_nodeid_to_index(decl: Option<&ast::FnDecl>,
|
|||
}
|
||||
let mut formals = Formals { entry: entry, index: index };
|
||||
visit::walk_fn_decl(&mut formals, decl);
|
||||
impl<'a> visit::Visitor for Formals<'a> {
|
||||
impl<'a, 'v> visit::Visitor<'v> for Formals<'a> {
|
||||
fn visit_pat(&mut self, p: &ast::Pat) {
|
||||
self.index.insert(p.id, self.entry);
|
||||
visit::walk_pat(self, p)
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for MarkSymbolVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_struct_def(&mut self, def: &ast::StructDef, _: ast::Ident,
|
||||
_: &ast::Generics, _: ast::NodeId) {
|
||||
|
|
@ -329,7 +329,7 @@ struct LifeSeeder {
|
|||
worklist: Vec<ast::NodeId> ,
|
||||
}
|
||||
|
||||
impl Visitor for LifeSeeder {
|
||||
impl<'v> Visitor<'v> for LifeSeeder {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
if has_allow_dead_code_or_lang_attr(item.attrs.as_slice()) {
|
||||
self.worklist.push(item.id);
|
||||
|
|
@ -349,11 +349,11 @@ impl Visitor for LifeSeeder {
|
|||
visit::walk_item(self, item);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind,
|
||||
_: &ast::FnDecl, block: &ast::Block,
|
||||
fn visit_fn(&mut self, fk: visit::FnKind<'v>,
|
||||
_: &'v ast::FnDecl, block: &'v ast::Block,
|
||||
_: codemap::Span, id: ast::NodeId) {
|
||||
// Check for method here because methods are not ast::Item
|
||||
match *fk {
|
||||
match fk {
|
||||
visit::FkMethod(_, _, method) => {
|
||||
if has_allow_dead_code_or_lang_attr(method.attrs.as_slice()) {
|
||||
self.worklist.push(id);
|
||||
|
|
@ -499,7 +499,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for DeadVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
let ctor_id = get_struct_ctor_id(item);
|
||||
if !self.symbol_is_live(item.id, ctor_id) && should_warn(item) {
|
||||
|
|
@ -515,15 +515,14 @@ impl<'a, 'tcx> Visitor for DeadVisitor<'a, 'tcx> {
|
|||
visit::walk_foreign_item(self, fi);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind,
|
||||
_: &ast::FnDecl, block: &ast::Block,
|
||||
fn visit_fn(&mut self, fk: visit::FnKind<'v>,
|
||||
_: &'v ast::FnDecl, block: &'v ast::Block,
|
||||
span: codemap::Span, id: ast::NodeId) {
|
||||
// Have to warn method here because methods are not ast::Item
|
||||
match *fk {
|
||||
visit::FkMethod(..) => {
|
||||
let ident = visit::name_of_fn(fk);
|
||||
match fk {
|
||||
visit::FkMethod(name, _, _) => {
|
||||
if !self.symbol_is_live(id, None) {
|
||||
self.warn_dead_code(id, span, ident);
|
||||
self.warn_dead_code(id, span, name);
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for EffectCheckVisitor<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fn_kind: &visit::FnKind, fn_decl: &ast::FnDecl,
|
||||
block: &ast::Block, span: Span, _: ast::NodeId) {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fn_kind: visit::FnKind<'v>, fn_decl: &'v ast::FnDecl,
|
||||
block: &'v ast::Block, span: Span, _: ast::NodeId) {
|
||||
|
||||
let (is_item_fn, is_unsafe_fn) = match *fn_kind {
|
||||
let (is_item_fn, is_unsafe_fn) = match fn_kind {
|
||||
visit::FkItemFn(_, _, fn_style, _) =>
|
||||
(true, fn_style == ast::UnsafeFn),
|
||||
visit::FkMethod(_, _, method) =>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ struct EntryContext<'a> {
|
|||
non_main_fns: Vec<(NodeId, Span)> ,
|
||||
}
|
||||
|
||||
impl<'a> Visitor for EntryContext<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for EntryContext<'a> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
find_item(item, self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ struct CollectFreevarsVisitor<'a> {
|
|||
depth: uint
|
||||
}
|
||||
|
||||
impl<'a> Visitor for CollectFreevarsVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for CollectFreevarsVisitor<'a> {
|
||||
fn visit_item(&mut self, _: &ast::Item) {
|
||||
// ignore_item
|
||||
}
|
||||
|
|
@ -144,9 +144,9 @@ struct AnnotateFreevarsVisitor<'a> {
|
|||
capture_mode_map: CaptureModeMap,
|
||||
}
|
||||
|
||||
impl<'a> Visitor for AnnotateFreevarsVisitor<'a> {
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
|
||||
blk: &ast::Block, s: Span, nid: ast::NodeId) {
|
||||
impl<'a, 'v> Visitor<'v> for AnnotateFreevarsVisitor<'a> {
|
||||
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
|
||||
blk: &'v ast::Block, s: Span, nid: ast::NodeId) {
|
||||
let vars = collect_freevars(self.def_map,
|
||||
blk,
|
||||
&mut self.capture_mode_map);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, expr: &ast::Expr) {
|
||||
match expr.node {
|
||||
ast::ExprPath(..) => {
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ pub struct Context<'a, 'tcx: 'a> {
|
|||
parameter_environments: Vec<ParameterEnvironment>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for Context<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, ex: &Expr) {
|
||||
check_expr(self, ex);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &FnDecl,
|
||||
b: &Block, s: Span, n: NodeId) {
|
||||
fn visit_fn(&mut self, fk: visit::FnKind, fd: &'v FnDecl,
|
||||
b: &'v Block, s: Span, n: NodeId) {
|
||||
check_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ fn with_appropriate_checker(cx: &Context,
|
|||
// to the copy/move kind bounds. Then recursively check the function body.
|
||||
fn check_fn(
|
||||
cx: &mut Context,
|
||||
fk: &visit::FnKind,
|
||||
fk: visit::FnKind,
|
||||
decl: &FnDecl,
|
||||
body: &Block,
|
||||
sp: Span,
|
||||
|
|
@ -356,7 +356,7 @@ fn check_fn(
|
|||
});
|
||||
});
|
||||
|
||||
match *fk {
|
||||
match fk {
|
||||
visit::FkFnBlock(..) => {
|
||||
let ty = ty::node_id_to_type(cx.tcx, fn_id);
|
||||
check_bounds_on_structs_or_enums_in_type_if_possible(cx, sp, ty);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ struct LanguageItemCollector<'a> {
|
|||
item_refs: HashMap<&'static str, uint>,
|
||||
}
|
||||
|
||||
impl<'a> Visitor for LanguageItemCollector<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
match extract(item.attrs.as_slice()) {
|
||||
Some(value) => {
|
||||
|
|
|
|||
|
|
@ -179,8 +179,9 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &ty::ctxt) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for IrMaps<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId) {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for IrMaps<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
|
||||
b: &'v Block, s: Span, n: NodeId) {
|
||||
visit_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
fn visit_local(&mut self, l: &Local) { visit_local(self, l); }
|
||||
|
|
@ -343,8 +344,8 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for Liveness<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId) {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for Liveness<'a, 'tcx> {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, n: NodeId) {
|
||||
check_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
fn visit_local(&mut self, l: &Local) {
|
||||
|
|
@ -359,7 +360,7 @@ impl<'a, 'tcx> Visitor for Liveness<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_fn(ir: &mut IrMaps,
|
||||
fk: &FnKind,
|
||||
fk: FnKind,
|
||||
decl: &FnDecl,
|
||||
body: &Block,
|
||||
sp: Span,
|
||||
|
|
@ -1462,7 +1463,7 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
|
|||
}
|
||||
|
||||
fn check_fn(_v: &Liveness,
|
||||
_fk: &FnKind,
|
||||
_fk: FnKind,
|
||||
_decl: &FnDecl,
|
||||
_body: &Block,
|
||||
_sp: Span,
|
||||
|
|
@ -1474,7 +1475,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
fn check_ret(&self,
|
||||
id: NodeId,
|
||||
sp: Span,
|
||||
_fk: &FnKind,
|
||||
_fk: FnKind,
|
||||
entry_ln: LiveNode,
|
||||
body: &Block) {
|
||||
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ struct ParentVisitor {
|
|||
curparent: ast::NodeId,
|
||||
}
|
||||
|
||||
impl Visitor for ParentVisitor {
|
||||
impl<'v> Visitor<'v> for ParentVisitor {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
self.parents.insert(item.id, self.curparent);
|
||||
|
||||
|
|
@ -100,8 +100,8 @@ impl Visitor for ParentVisitor {
|
|||
visit::walk_foreign_item(self, a);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, a: &visit::FnKind, b: &ast::FnDecl,
|
||||
c: &ast::Block, d: Span, id: ast::NodeId) {
|
||||
fn visit_fn(&mut self, a: visit::FnKind<'v>, b: &'v ast::FnDecl,
|
||||
c: &'v ast::Block, d: Span, id: ast::NodeId) {
|
||||
// We already took care of some trait methods above, otherwise things
|
||||
// like impl methods and pub trait methods are parented to the
|
||||
// containing module, not the containing trait.
|
||||
|
|
@ -112,7 +112,7 @@ impl Visitor for ParentVisitor {
|
|||
}
|
||||
|
||||
fn visit_struct_def(&mut self, s: &ast::StructDef, _: ast::Ident,
|
||||
_: &ast::Generics, n: ast::NodeId) {
|
||||
_: &'v ast::Generics, n: ast::NodeId) {
|
||||
// Struct constructors are parented to their struct definitions because
|
||||
// they essentially are the struct definitions.
|
||||
match s.ctor_id {
|
||||
|
|
@ -180,7 +180,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for EmbargoVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
let orig_all_pub = self.prev_public;
|
||||
self.prev_public = orig_all_pub && item.vis == ast::Public;
|
||||
|
|
@ -802,7 +802,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for PrivacyVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
let orig_curitem = replace(&mut self.curitem, item.id);
|
||||
visit::walk_item(self, item);
|
||||
|
|
@ -1036,7 +1036,7 @@ struct SanePrivacyVisitor<'a, 'tcx: 'a> {
|
|||
in_fn: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for SanePrivacyVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for SanePrivacyVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
if self.in_fn {
|
||||
self.check_all_inherited(item);
|
||||
|
|
@ -1053,8 +1053,8 @@ impl<'a, 'tcx> Visitor for SanePrivacyVisitor<'a, 'tcx> {
|
|||
self.in_fn = orig_in_fn;
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
|
||||
b: &ast::Block, s: Span, _: ast::NodeId) {
|
||||
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
|
||||
b: &'v ast::Block, s: Span, _: ast::NodeId) {
|
||||
// This catches both functions and methods
|
||||
let orig_in_fn = replace(&mut self.in_fn, true);
|
||||
visit::walk_fn(self, fk, fd, b, s);
|
||||
|
|
@ -1264,7 +1264,7 @@ impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx> Visitor for CheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
|
||||
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for CheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
|
||||
fn visit_ty(&mut self, ty: &ast::Ty) {
|
||||
match ty.node {
|
||||
ast::TyPath(_, _, path_id) => {
|
||||
|
|
@ -1287,7 +1287,7 @@ impl<'a, 'b, 'tcx> Visitor for CheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
|
|||
fn visit_expr(&mut self, _: &ast::Expr) {}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for VisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
match item.node {
|
||||
// contents of a private mod can be reexported, so we need
|
||||
|
|
@ -1434,8 +1434,8 @@ impl<'a, 'tcx> Visitor for VisiblePrivateTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
|
||||
b: &ast::Block, s: Span, id: ast::NodeId) {
|
||||
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
|
||||
b: &'v ast::Block, s: Span, id: ast::NodeId) {
|
||||
// needs special handling for methods.
|
||||
if self.exported_items.contains(&id) {
|
||||
visit::walk_fn(self, fk, fd, b, s);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ struct ReachableContext<'a, 'tcx: 'a> {
|
|||
any_library: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for ReachableContext<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
|
||||
|
||||
fn visit_expr(&mut self, expr: &ast::Expr) {
|
||||
|
||||
|
|
|
|||
|
|
@ -796,7 +796,7 @@ fn resolve_item(visitor: &mut RegionResolutionVisitor, item: &ast::Item) {
|
|||
}
|
||||
|
||||
fn resolve_fn(visitor: &mut RegionResolutionVisitor,
|
||||
fk: &FnKind,
|
||||
fk: FnKind,
|
||||
decl: &ast::FnDecl,
|
||||
body: &ast::Block,
|
||||
sp: Span,
|
||||
|
|
@ -821,7 +821,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor,
|
|||
|
||||
// The body of the fn itself is either a root scope (top-level fn)
|
||||
// or it continues with the inherited scope (closures).
|
||||
match *fk {
|
||||
match fk {
|
||||
visit::FkItemFn(..) | visit::FkMethod(..) => {
|
||||
visitor.cx = Context { parent: None, var_parent: None };
|
||||
visitor.visit_block(body);
|
||||
|
|
@ -841,7 +841,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Visitor for RegionResolutionVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for RegionResolutionVisitor<'a> {
|
||||
|
||||
fn visit_block(&mut self, b: &Block) {
|
||||
resolve_block(self, b);
|
||||
|
|
@ -851,8 +851,8 @@ impl<'a> Visitor for RegionResolutionVisitor<'a> {
|
|||
resolve_item(self, i);
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl,
|
||||
b: &Block, s: Span, n: NodeId) {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
|
||||
b: &'v Block, s: Span, n: NodeId) {
|
||||
resolve_fn(self, fk, fd, b, s, n);
|
||||
}
|
||||
fn visit_arm(&mut self, a: &Arm) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ enum NameDefinition {
|
|||
ImportNameDefinition(Def, LastPrivate) //< The name identifies an import.
|
||||
}
|
||||
|
||||
impl<'a> Visitor for Resolver<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for Resolver<'a> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
self.resolve_item(item);
|
||||
}
|
||||
|
|
@ -906,7 +906,7 @@ struct BuildReducedGraphVisitor<'a, 'b:'a> {
|
|||
parent: ReducedGraphParent
|
||||
}
|
||||
|
||||
impl<'a, 'b> Visitor for BuildReducedGraphVisitor<'a, 'b> {
|
||||
impl<'a, 'b, 'v> Visitor<'v> for BuildReducedGraphVisitor<'a, 'b> {
|
||||
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
let p = self.resolver.build_reduced_graph_for_item(item, self.parent.clone());
|
||||
|
|
@ -945,7 +945,7 @@ struct UnusedImportCheckVisitor<'a, 'b:'a> {
|
|||
resolver: &'a mut Resolver<'b>
|
||||
}
|
||||
|
||||
impl<'a, 'b> Visitor for UnusedImportCheckVisitor<'a, 'b> {
|
||||
impl<'a, 'b, 'v> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b> {
|
||||
fn visit_view_item(&mut self, vi: &ViewItem) {
|
||||
self.resolver.check_for_item_unused_imports(vi);
|
||||
visit::walk_view_item(self, vi);
|
||||
|
|
@ -4593,7 +4593,7 @@ impl<'a> Resolver<'a> {
|
|||
// pat_idents are variants
|
||||
self.check_consistent_bindings(arm);
|
||||
|
||||
visit::walk_expr_opt(self, arm.guard);
|
||||
visit::walk_expr_opt(self, &arm.guard);
|
||||
self.resolve_expr(&*arm.body);
|
||||
|
||||
self.value_ribs.borrow_mut().pop();
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ pub fn krate(sess: &Session, krate: &ast::Crate) -> NamedRegionMap {
|
|||
named_region_map
|
||||
}
|
||||
|
||||
impl<'a> Visitor for LifetimeContext<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
let lifetimes = match item.node {
|
||||
ast::ItemFn(..) | // fn lifetimes get added in visit_fn below
|
||||
|
|
@ -110,9 +110,9 @@ impl<'a> Visitor for LifetimeContext<'a> {
|
|||
});
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
|
||||
b: &ast::Block, s: Span, n: ast::NodeId) {
|
||||
match *fk {
|
||||
fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl,
|
||||
b: &'v ast::Block, s: Span, n: ast::NodeId) {
|
||||
match fk {
|
||||
visit::FkItemFn(_, generics, _, _) |
|
||||
visit::FkMethod(_, generics, _) => {
|
||||
self.visit_fn_decl(n, generics, |v| visit::walk_fn(v, fk, fd, b, s))
|
||||
|
|
@ -450,7 +450,7 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
|
|||
late_bound: &'a mut Vec<ast::Name>,
|
||||
}
|
||||
|
||||
impl<'a> Visitor for FreeLifetimeCollector<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for FreeLifetimeCollector<'a> {
|
||||
fn visit_lifetime_ref(&mut self, lifetime_ref: &ast::Lifetime) {
|
||||
shuffle(self.early_bound, self.late_bound,
|
||||
lifetime_ref.name);
|
||||
|
|
|
|||
|
|
@ -833,7 +833,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
ex: &ast::Expr,
|
||||
path: &ast::Path,
|
||||
fields: &Vec<ast::Field>,
|
||||
base: Option<Gc<ast::Expr>>) {
|
||||
base: &Option<Gc<ast::Expr>>) {
|
||||
if generated_code(path.span) {
|
||||
return
|
||||
}
|
||||
|
|
@ -1018,8 +1018,8 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'l, 'tcx> Visitor for DxrVisitor<'l, 'tcx> {
|
||||
fn visit_item(&mut self, item:&ast::Item) {
|
||||
impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
if generated_code(item.span) {
|
||||
return
|
||||
}
|
||||
|
|
@ -1082,16 +1082,16 @@ impl<'l, 'tcx> Visitor for DxrVisitor<'l, 'tcx> {
|
|||
// We don't actually index functions here, that is done in visit_item/ItemFn.
|
||||
// Here we just visit methods.
|
||||
fn visit_fn(&mut self,
|
||||
fk: &visit::FnKind,
|
||||
fd: &ast::FnDecl,
|
||||
b: &ast::Block,
|
||||
fk: visit::FnKind<'v>,
|
||||
fd: &'v ast::FnDecl,
|
||||
b: &'v ast::Block,
|
||||
s: Span,
|
||||
_: NodeId) {
|
||||
if generated_code(s) {
|
||||
return;
|
||||
}
|
||||
|
||||
match *fk {
|
||||
match fk {
|
||||
visit::FkMethod(_, _, method) => self.process_method(method),
|
||||
_ => visit::walk_fn(self, fk, fd, b, s),
|
||||
}
|
||||
|
|
@ -1143,7 +1143,7 @@ impl<'l, 'tcx> Visitor for DxrVisitor<'l, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_view_item(&mut self, i:&ast::ViewItem) {
|
||||
fn visit_view_item(&mut self, i: &ast::ViewItem) {
|
||||
if generated_code(i.span) {
|
||||
return
|
||||
}
|
||||
|
|
@ -1275,7 +1275,7 @@ impl<'l, 'tcx> Visitor for DxrVisitor<'l, 'tcx> {
|
|||
visit::walk_expr(self, ex);
|
||||
},
|
||||
ast::ExprPath(ref path) => self.process_path(ex, path),
|
||||
ast::ExprStruct(ref path, ref fields, base) =>
|
||||
ast::ExprStruct(ref path, ref fields, ref base) =>
|
||||
self.process_struct_lit(ex, path, fields, base),
|
||||
ast::ExprMethodCall(_, _, ref args) => self.process_method_call(ex, args),
|
||||
ast::ExprField(sub_ex, ident, _) => {
|
||||
|
|
@ -1410,11 +1410,11 @@ impl<'l, 'tcx> Visitor for DxrVisitor<'l, 'tcx> {
|
|||
}
|
||||
}
|
||||
self.collected_paths.clear();
|
||||
visit::walk_expr_opt(self, arm.guard);
|
||||
visit::walk_expr_opt(self, &arm.guard);
|
||||
self.visit_expr(&*arm.body);
|
||||
}
|
||||
|
||||
fn visit_stmt(&mut self, s:&ast::Stmt) {
|
||||
fn visit_stmt(&mut self, s: &ast::Stmt) {
|
||||
if generated_code(s.span) {
|
||||
return
|
||||
}
|
||||
|
|
@ -1422,7 +1422,7 @@ impl<'l, 'tcx> Visitor for DxrVisitor<'l, 'tcx> {
|
|||
visit::walk_stmt(self, s)
|
||||
}
|
||||
|
||||
fn visit_local(&mut self, l:&ast::Local) {
|
||||
fn visit_local(&mut self, l: &ast::Local) {
|
||||
if generated_code(l.span) {
|
||||
return
|
||||
}
|
||||
|
|
@ -1455,7 +1455,7 @@ impl<'l, 'tcx> Visitor for DxrVisitor<'l, 'tcx> {
|
|||
|
||||
// Just walk the initialiser and type (don't want to walk the pattern again).
|
||||
self.visit_ty(&*l.ty);
|
||||
visit::walk_expr_opt(self, l.init);
|
||||
visit::walk_expr_opt(self, &l.init);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,13 +59,14 @@ impl Annotator {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor for Annotator {
|
||||
impl<'v> Visitor<'v> for Annotator {
|
||||
fn visit_item(&mut self, i: &Item) {
|
||||
self.annotate(i.id, &i.attrs, |v| visit::walk_item(v, i));
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId) {
|
||||
match *fk {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
|
||||
b: &'v Block, s: Span, _: NodeId) {
|
||||
match fk {
|
||||
FkMethod(_, _, meth) => {
|
||||
self.annotate(meth.id, &meth.attrs, |v| visit::walk_fn(v, fk, fd, b, s));
|
||||
}
|
||||
|
|
@ -85,7 +86,7 @@ impl Visitor for Annotator {
|
|||
self.annotate(id, attrs, |v| visit::walk_trait_item(v, t));
|
||||
}
|
||||
|
||||
fn visit_variant(&mut self, var: &Variant, g: &Generics) {
|
||||
fn visit_variant(&mut self, var: &Variant, g: &'v Generics) {
|
||||
self.annotate(var.node.id, &var.node.attrs, |v| visit::walk_variant(v, var, g))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1335,7 +1335,7 @@ impl CheckForNestedReturnsVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Visitor for CheckForNestedReturnsVisitor {
|
||||
impl<'v> Visitor<'v> for CheckForNestedReturnsVisitor {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
match e.node {
|
||||
ast::ExprRet(..) => {
|
||||
|
|
@ -1360,7 +1360,7 @@ fn has_nested_returns(tcx: &ty::ctxt, id: ast::NodeId) -> bool {
|
|||
let mut explicit = CheckForNestedReturnsVisitor::explicit();
|
||||
let mut implicit = CheckForNestedReturnsVisitor::implicit();
|
||||
visit::walk_item(&mut explicit, &*i);
|
||||
visit::walk_expr_opt(&mut implicit, blk.expr);
|
||||
visit::walk_expr_opt(&mut implicit, &blk.expr);
|
||||
explicit.found || implicit.found
|
||||
}
|
||||
_ => tcx.sess.bug("unexpected item variant in has_nested_returns")
|
||||
|
|
@ -1374,7 +1374,7 @@ fn has_nested_returns(tcx: &ty::ctxt, id: ast::NodeId) -> bool {
|
|||
let mut explicit = CheckForNestedReturnsVisitor::explicit();
|
||||
let mut implicit = CheckForNestedReturnsVisitor::implicit();
|
||||
visit::walk_method_helper(&mut explicit, &*m);
|
||||
visit::walk_expr_opt(&mut implicit, blk.expr);
|
||||
visit::walk_expr_opt(&mut implicit, &blk.expr);
|
||||
explicit.found || implicit.found
|
||||
}
|
||||
ast::MethMac(_) => tcx.sess.bug("unexpanded macro")
|
||||
|
|
@ -1394,7 +1394,7 @@ fn has_nested_returns(tcx: &ty::ctxt, id: ast::NodeId) -> bool {
|
|||
let mut explicit = CheckForNestedReturnsVisitor::explicit();
|
||||
let mut implicit = CheckForNestedReturnsVisitor::implicit();
|
||||
visit::walk_method_helper(&mut explicit, &**m);
|
||||
visit::walk_expr_opt(&mut implicit, blk.expr);
|
||||
visit::walk_expr_opt(&mut implicit, &blk.expr);
|
||||
explicit.found || implicit.found
|
||||
}
|
||||
ast::MethMac(_) => tcx.sess.bug("unexpanded macro")
|
||||
|
|
@ -1410,7 +1410,7 @@ fn has_nested_returns(tcx: &ty::ctxt, id: ast::NodeId) -> bool {
|
|||
let mut explicit = CheckForNestedReturnsVisitor::explicit();
|
||||
let mut implicit = CheckForNestedReturnsVisitor::implicit();
|
||||
visit::walk_expr(&mut explicit, &*e);
|
||||
visit::walk_expr_opt(&mut implicit, blk.expr);
|
||||
visit::walk_expr_opt(&mut implicit, &blk.expr);
|
||||
explicit.found || implicit.found
|
||||
}
|
||||
_ => tcx.sess.bug("unexpected expr variant in has_nested_returns")
|
||||
|
|
@ -2141,7 +2141,7 @@ pub struct TransItemVisitor<'a, 'tcx: 'a> {
|
|||
pub ccx: &'a CrateContext<'a, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for TransItemVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for TransItemVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
trans_item(self.ccx, i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ fn static_inherited_fields<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>)
|
|||
struct CheckItemTypesVisitor<'a, 'tcx: 'a> { ccx: &'a CrateCtxt<'a, 'tcx> }
|
||||
struct CheckTypeWellFormedVisitor<'a, 'tcx: 'a> { ccx: &'a CrateCtxt<'a, 'tcx> }
|
||||
|
||||
impl<'a, 'tcx> Visitor for CheckTypeWellFormedVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
check_type_well_formed(self.ccx, i);
|
||||
visit::walk_item(self, i);
|
||||
|
|
@ -383,7 +383,7 @@ impl<'a, 'tcx> Visitor for CheckTypeWellFormedVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
|
||||
impl<'a, 'tcx> Visitor for CheckItemTypesVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckItemTypesVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
check_item(self.ccx, i);
|
||||
visit::walk_item(self, i);
|
||||
|
|
@ -394,7 +394,7 @@ struct CheckItemSizedTypesVisitor<'a, 'tcx: 'a> {
|
|||
ccx: &'a CrateCtxt<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for CheckItemSizedTypesVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for CheckItemSizedTypesVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
check_item_sized(self.ccx, i);
|
||||
visit::walk_item(self, i);
|
||||
|
|
@ -464,7 +464,7 @@ impl<'a, 'tcx> GatherLocalsVisitor<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for GatherLocalsVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for GatherLocalsVisitor<'a, 'tcx> {
|
||||
// Add explicitly-declared locals.
|
||||
fn visit_local(&mut self, local: &ast::Local) {
|
||||
let o_ty = match local.ty.node {
|
||||
|
|
@ -516,8 +516,8 @@ impl<'a, 'tcx> Visitor for GatherLocalsVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
// Don't descend into fns and items
|
||||
fn visit_fn(&mut self, _: &visit::FnKind, _: &ast::FnDecl,
|
||||
_: &ast::Block, _: Span, _: ast::NodeId) { }
|
||||
fn visit_fn(&mut self, _: visit::FnKind<'v>, _: &'v ast::FnDecl,
|
||||
_: &'v ast::Block, _: Span, _: ast::NodeId) { }
|
||||
fn visit_item(&mut self, _: &ast::Item) { }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ impl<'fcx, 'tcx> mc::Typer<'tcx> for Rcx<'fcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for Rcx<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for Rcx<'a, 'tcx> {
|
||||
// (..) FIXME(#3238) should use visit_pat, not visit_arm/visit_local,
|
||||
// However, right now we run into an issue whereby some free
|
||||
// regions are not properly related if they appear within the
|
||||
|
|
@ -488,8 +488,8 @@ impl<'a, 'tcx> Visitor 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, _fd: &ast::FnDecl,
|
||||
b: &ast::Block, _s: Span, id: ast::NodeId) {
|
||||
fn visit_fn(&mut self, _fk: visit::FnKind<'v>, _fd: &'v ast::FnDecl,
|
||||
b: &'v ast::Block, _s: Span, id: ast::NodeId) {
|
||||
self.visit_fn_body(id, b)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1025,7 +1025,7 @@ pub fn trans_resolve_method(tcx: &ty::ctxt, id: ast::NodeId,
|
|||
false)
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'tcx> visit::Visitor for &'a FnCtxt<'b, 'tcx> {
|
||||
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for &'a FnCtxt<'b, 'tcx> {
|
||||
fn visit_expr(&mut self, ex: &ast::Expr) {
|
||||
early_resolve_expr(ex, *self, false);
|
||||
visit::walk_expr(self, ex);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
|||
// below. In general, a function is made into a `visitor` if it must
|
||||
// traffic in node-ids or update tables in the type context etc.
|
||||
|
||||
impl<'cx, 'tcx> Visitor for WritebackCx<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> {
|
||||
fn visit_item(&mut self, _: &ast::Item) {
|
||||
// Ignore items
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ impl<'cx, 'tcx> Visitor for WritebackCx<'cx, 'tcx> {
|
|||
visit::walk_stmt(self, s);
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, e:&ast::Expr) {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
if self.fcx.writeback_errors.get() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ struct CoherenceCheckVisitor<'a, 'tcx: 'a> {
|
|||
cc: &'a CoherenceChecker<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> visit::Visitor for CoherenceCheckVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for CoherenceCheckVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
|
||||
//debug!("(checking coherence) item '{}'", token::get_ident(item.ident));
|
||||
|
|
@ -218,7 +218,7 @@ struct PrivilegedScopeVisitor<'a, 'tcx: 'a> {
|
|||
cc: &'a CoherenceChecker<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> visit::Visitor for PrivilegedScopeVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for PrivilegedScopeVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &Item) {
|
||||
|
||||
match item.node {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ struct CollectTraitDefVisitor<'a, 'tcx: 'a> {
|
|||
ccx: &'a CrateCtxt<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> visit::Visitor for CollectTraitDefVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for CollectTraitDefVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
match i.node {
|
||||
ast::ItemTrait(..) => {
|
||||
|
|
@ -120,7 +120,7 @@ struct CollectItemTypesVisitor<'a, 'tcx: 'a> {
|
|||
ccx: &'a CrateCtxt<'a, 'tcx>
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> visit::Visitor for CollectItemTypesVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> visit::Visitor<'v> for CollectItemTypesVisitor<'a, 'tcx> {
|
||||
fn visit_item(&mut self, i: &ast::Item) {
|
||||
convert(self.ccx, i);
|
||||
visit::walk_item(self, i);
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for TermsContext<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
debug!("add_inferreds for item {}", item.repr(self.tcx));
|
||||
|
||||
|
|
@ -477,7 +477,7 @@ fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
|
|||
constraint_cx
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Visitor for ConstraintContext<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
let did = ast_util::local_def(item.id);
|
||||
let tcx = self.terms_cx.tcx;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ impl<'a> Context<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Visitor for Context<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for Context<'a> {
|
||||
fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
|
||||
match lang_items::extract(i.attrs.as_slice()) {
|
||||
None => {}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct RegistrarFinder {
|
|||
registrars: Vec<(ast::NodeId, Span)> ,
|
||||
}
|
||||
|
||||
impl Visitor for RegistrarFinder {
|
||||
impl<'v> Visitor<'v> for RegistrarFinder {
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
match item.node {
|
||||
ast::ItemFn(..) => {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
|
|||
}
|
||||
|
||||
// note that macros aren't expanded yet, and therefore macros can't add plugins.
|
||||
impl<'a> Visitor for PluginLoader<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
|
||||
fn visit_view_item(&mut self, vi: &ast::ViewItem) {
|
||||
match vi.node {
|
||||
ast::ViewItemExternCrate(name, _, _) => {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ struct LoopQueryVisitor<'a> {
|
|||
flag: bool,
|
||||
}
|
||||
|
||||
impl<'a> Visitor for LoopQueryVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for LoopQueryVisitor<'a> {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
self.flag |= (self.p)(&e.node);
|
||||
match e.node {
|
||||
|
|
@ -90,7 +90,7 @@ struct BlockQueryVisitor<'a> {
|
|||
flag: bool,
|
||||
}
|
||||
|
||||
impl<'a> Visitor for BlockQueryVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for BlockQueryVisitor<'a> {
|
||||
fn visit_expr(&mut self, e: &ast::Expr) {
|
||||
self.flag |= (self.p)(e);
|
||||
visit::walk_expr(self, e)
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ mod svh_visitor {
|
|||
}
|
||||
fn content<K:InternKey>(k: K) -> token::InternedString { k.get_content() }
|
||||
|
||||
impl<'a> Visitor for StrictVersionHashVisitor<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for StrictVersionHashVisitor<'a> {
|
||||
|
||||
fn visit_mac(&mut self, macro: &Mac) {
|
||||
// macro invocations, namely macro_rules definitions,
|
||||
|
|
@ -469,7 +469,8 @@ mod svh_visitor {
|
|||
SawGenerics.hash(self.st); visit::walk_generics(self, g)
|
||||
}
|
||||
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId) {
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
|
||||
b: &'v Block, s: Span, _: NodeId) {
|
||||
SawFn.hash(self.st); visit::walk_fn(self, fk, fd, b, s)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ impl<'a, O: IdVisitingOperation> IdVisitor<'a, O> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, O: IdVisitingOperation> Visitor for IdVisitor<'a, O> {
|
||||
impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
|
||||
fn visit_mod(&mut self,
|
||||
module: &Mod,
|
||||
_: Span,
|
||||
|
|
@ -475,13 +475,13 @@ impl<'a, O: IdVisitingOperation> Visitor for IdVisitor<'a, O> {
|
|||
}
|
||||
|
||||
fn visit_fn(&mut self,
|
||||
function_kind: &visit::FnKind,
|
||||
function_declaration: &FnDecl,
|
||||
block: &Block,
|
||||
function_kind: visit::FnKind<'v>,
|
||||
function_declaration: &'v FnDecl,
|
||||
block: &'v Block,
|
||||
span: Span,
|
||||
node_id: NodeId) {
|
||||
if !self.pass_through_items {
|
||||
match *function_kind {
|
||||
match function_kind {
|
||||
visit::FkMethod(..) if self.visited_outermost => return,
|
||||
visit::FkMethod(..) => self.visited_outermost = true,
|
||||
_ => {}
|
||||
|
|
@ -490,7 +490,7 @@ impl<'a, O: IdVisitingOperation> Visitor for IdVisitor<'a, O> {
|
|||
|
||||
self.operation.visit_id(node_id);
|
||||
|
||||
match *function_kind {
|
||||
match function_kind {
|
||||
visit::FkItemFn(_, generics, _, _) |
|
||||
visit::FkMethod(_, generics, _) => {
|
||||
self.visit_generics_helper(generics)
|
||||
|
|
@ -509,7 +509,7 @@ impl<'a, O: IdVisitingOperation> Visitor for IdVisitor<'a, O> {
|
|||
span);
|
||||
|
||||
if !self.pass_through_items {
|
||||
match *function_kind {
|
||||
match function_kind {
|
||||
visit::FkMethod(..) => self.visited_outermost = false,
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -571,7 +571,7 @@ pub fn compute_id_range_for_inlined_item(item: &InlinedItem) -> IdRange {
|
|||
visitor.result.get()
|
||||
}
|
||||
|
||||
pub fn compute_id_range_for_fn_body(fk: &visit::FnKind,
|
||||
pub fn compute_id_range_for_fn_body(fk: visit::FnKind,
|
||||
decl: &FnDecl,
|
||||
body: &Block,
|
||||
sp: Span,
|
||||
|
|
@ -639,7 +639,7 @@ struct EachViewItemData<'a> {
|
|||
callback: |&ast::ViewItem|: 'a -> bool,
|
||||
}
|
||||
|
||||
impl<'a> Visitor for EachViewItemData<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for EachViewItemData<'a> {
|
||||
fn visit_view_item(&mut self, view_item: &ast::ViewItem) {
|
||||
let _ = (self.callback)(view_item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -651,7 +651,7 @@ struct PatIdentFinder {
|
|||
ident_accumulator: Vec<ast::Ident>
|
||||
}
|
||||
|
||||
impl Visitor for PatIdentFinder {
|
||||
impl<'v> Visitor<'v> for PatIdentFinder {
|
||||
fn visit_pat(&mut self, pattern: &ast::Pat) {
|
||||
match *pattern {
|
||||
ast::Pat { id: _, node: ast::PatIdent(_, ref path1, ref inner), span: _ } => {
|
||||
|
|
@ -1107,7 +1107,7 @@ struct MacroExterminator<'a>{
|
|||
sess: &'a parse::ParseSess
|
||||
}
|
||||
|
||||
impl<'a> Visitor for MacroExterminator<'a> {
|
||||
impl<'a, 'v> Visitor<'v> for MacroExterminator<'a> {
|
||||
fn visit_mac(&mut self, macro: &ast::Mac) {
|
||||
self.sess.span_diagnostic.span_bug(macro.span,
|
||||
"macro exterminator: expected AST \
|
||||
|
|
@ -1144,7 +1144,7 @@ mod test {
|
|||
path_accumulator: Vec<ast::Path> ,
|
||||
}
|
||||
|
||||
impl Visitor for PathExprFinderContext {
|
||||
impl<'v> Visitor<'v> for PathExprFinderContext {
|
||||
fn visit_expr(&mut self, expr: &ast::Expr) {
|
||||
match expr.node {
|
||||
ast::ExprPath(ref p) => {
|
||||
|
|
@ -1169,7 +1169,7 @@ mod test {
|
|||
ident_accumulator: Vec<ast::Ident>
|
||||
}
|
||||
|
||||
impl Visitor for IdentFinder {
|
||||
impl<'v> Visitor<'v> for IdentFinder {
|
||||
fn visit_ident(&mut self, _: codemap::Span, id: ast::Ident){
|
||||
self.ident_accumulator.push(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@
|
|||
use abi::Abi;
|
||||
use ast::*;
|
||||
use ast;
|
||||
use ast_util;
|
||||
use codemap::Span;
|
||||
use parse;
|
||||
use owned_slice::OwnedSlice;
|
||||
|
||||
use std::gc::Gc;
|
||||
|
|
@ -45,23 +43,6 @@ pub enum FnKind<'a> {
|
|||
FkFnBlock,
|
||||
}
|
||||
|
||||
pub fn name_of_fn(fk: &FnKind) -> Ident {
|
||||
match *fk {
|
||||
FkItemFn(name, _, _, _) | FkMethod(name, _, _) => name,
|
||||
FkFnBlock(..) => parse::token::special_idents::invalid
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generics_of_fn(fk: &FnKind) -> Generics {
|
||||
match *fk {
|
||||
FkItemFn(_, generics, _, _) |
|
||||
FkMethod(_, generics, _) => {
|
||||
(*generics).clone()
|
||||
}
|
||||
FkFnBlock(..) => ast_util::empty_generics(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Each method of the Visitor trait is a hook to be potentially
|
||||
/// overridden. Each method's default implementation recursively visits
|
||||
/// the substructure of the input via the corresponding `walk` method;
|
||||
|
|
@ -71,38 +52,38 @@ pub fn generics_of_fn(fk: &FnKind) -> Generics {
|
|||
/// explicitly, you need to override each method. (And you also need
|
||||
/// to monitor future changes to `Visitor` in case a new method with a
|
||||
/// new default implementation gets introduced.)
|
||||
pub trait Visitor {
|
||||
pub trait Visitor<'v> {
|
||||
|
||||
fn visit_ident(&mut self, _sp: Span, _ident: Ident) {
|
||||
/*! Visit the idents */
|
||||
}
|
||||
fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
|
||||
fn visit_view_item(&mut self, i: &ViewItem) { walk_view_item(self, i) }
|
||||
fn visit_foreign_item(&mut self, i: &ForeignItem) { walk_foreign_item(self, i) }
|
||||
fn visit_item(&mut self, i: &Item) { walk_item(self, i) }
|
||||
fn visit_local(&mut self, l: &Local) { walk_local(self, l) }
|
||||
fn visit_block(&mut self, b: &Block) { walk_block(self, b) }
|
||||
fn visit_stmt(&mut self, s: &Stmt) { walk_stmt(self, s) }
|
||||
fn visit_arm(&mut self, a: &Arm) { walk_arm(self, a) }
|
||||
fn visit_pat(&mut self, p: &Pat) { walk_pat(self, p) }
|
||||
fn visit_decl(&mut self, d: &Decl) { walk_decl(self, d) }
|
||||
fn visit_expr(&mut self, ex: &Expr) { walk_expr(self, ex) }
|
||||
fn visit_expr_post(&mut self, _ex: &Expr) { }
|
||||
fn visit_ty(&mut self, t: &Ty) { walk_ty(self, t) }
|
||||
fn visit_generics(&mut self, g: &Generics) { walk_generics(self, g) }
|
||||
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId) {
|
||||
fn visit_mod(&mut self, m: &'v Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
|
||||
fn visit_view_item(&mut self, i: &'v ViewItem) { walk_view_item(self, i) }
|
||||
fn visit_foreign_item(&mut self, i: &'v ForeignItem) { walk_foreign_item(self, i) }
|
||||
fn visit_item(&mut self, i: &'v Item) { walk_item(self, i) }
|
||||
fn visit_local(&mut self, l: &'v Local) { walk_local(self, l) }
|
||||
fn visit_block(&mut self, b: &'v Block) { walk_block(self, b) }
|
||||
fn visit_stmt(&mut self, s: &'v Stmt) { walk_stmt(self, s) }
|
||||
fn visit_arm(&mut self, a: &'v Arm) { walk_arm(self, a) }
|
||||
fn visit_pat(&mut self, p: &'v Pat) { walk_pat(self, p) }
|
||||
fn visit_decl(&mut self, d: &'v Decl) { walk_decl(self, d) }
|
||||
fn visit_expr(&mut self, ex: &'v Expr) { walk_expr(self, ex) }
|
||||
fn visit_expr_post(&mut self, _ex: &'v Expr) { }
|
||||
fn visit_ty(&mut self, t: &'v Ty) { walk_ty(self, t) }
|
||||
fn visit_generics(&mut self, g: &'v Generics) { walk_generics(self, g) }
|
||||
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, _: NodeId) {
|
||||
walk_fn(self, fk, fd, b, s)
|
||||
}
|
||||
fn visit_ty_method(&mut self, t: &TypeMethod) { walk_ty_method(self, t) }
|
||||
fn visit_trait_item(&mut self, t: &TraitItem) { walk_trait_item(self, t) }
|
||||
fn visit_struct_def(&mut self, s: &StructDef, _: Ident, _: &Generics, _: NodeId) {
|
||||
fn visit_ty_method(&mut self, t: &'v TypeMethod) { walk_ty_method(self, t) }
|
||||
fn visit_trait_item(&mut self, t: &'v TraitItem) { walk_trait_item(self, t) }
|
||||
fn visit_struct_def(&mut self, s: &'v StructDef, _: Ident, _: &'v Generics, _: NodeId) {
|
||||
walk_struct_def(self, s)
|
||||
}
|
||||
fn visit_struct_field(&mut self, s: &StructField) { walk_struct_field(self, s) }
|
||||
fn visit_variant(&mut self, v: &Variant, g: &Generics) { walk_variant(self, v, g) }
|
||||
fn visit_struct_field(&mut self, s: &'v StructField) { walk_struct_field(self, s) }
|
||||
fn visit_variant(&mut self, v: &'v Variant, g: &'v Generics) { walk_variant(self, v, g) }
|
||||
fn visit_opt_lifetime_ref(&mut self,
|
||||
_span: Span,
|
||||
opt_lifetime: &Option<Lifetime>) {
|
||||
opt_lifetime: &'v Option<Lifetime>) {
|
||||
/*!
|
||||
* Visits an optional reference to a lifetime. The `span` is
|
||||
* the span of some surrounding reference should opt_lifetime
|
||||
|
|
@ -113,16 +94,16 @@ pub trait Visitor {
|
|||
None => ()
|
||||
}
|
||||
}
|
||||
fn visit_lifetime_ref(&mut self, _lifetime: &Lifetime) {
|
||||
fn visit_lifetime_ref(&mut self, _lifetime: &'v Lifetime) {
|
||||
/*! Visits a reference to a lifetime */
|
||||
}
|
||||
fn visit_lifetime_decl(&mut self, _lifetime: &LifetimeDef) {
|
||||
fn visit_lifetime_decl(&mut self, _lifetime: &'v LifetimeDef) {
|
||||
/*! Visits a declaration of a lifetime */
|
||||
}
|
||||
fn visit_explicit_self(&mut self, es: &ExplicitSelf) {
|
||||
fn visit_explicit_self(&mut self, es: &'v ExplicitSelf) {
|
||||
walk_explicit_self(self, es)
|
||||
}
|
||||
fn visit_mac(&mut self, _macro: &Mac) {
|
||||
fn visit_mac(&mut self, _macro: &'v Mac) {
|
||||
fail!("visit_mac disabled by default");
|
||||
// NB: see note about macros above.
|
||||
// if you really want a visitor that
|
||||
|
|
@ -130,23 +111,23 @@ pub trait Visitor {
|
|||
// definition in your trait impl:
|
||||
// visit::walk_mac(self, _macro)
|
||||
}
|
||||
fn visit_path(&mut self, path: &Path, _id: ast::NodeId) {
|
||||
fn visit_path(&mut self, path: &'v Path, _id: ast::NodeId) {
|
||||
walk_path(self, path)
|
||||
}
|
||||
fn visit_attribute(&mut self, _attr: &Attribute) {}
|
||||
fn visit_attribute(&mut self, _attr: &'v Attribute) {}
|
||||
}
|
||||
|
||||
pub fn walk_inlined_item<V: Visitor>(visitor: &mut V, item: &ast::InlinedItem) {
|
||||
pub fn walk_inlined_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v InlinedItem) {
|
||||
match *item {
|
||||
IIItem(i) => visitor.visit_item(&*i),
|
||||
IIForeign(i) => visitor.visit_foreign_item(&*i),
|
||||
IITraitItem(_, iti) => {
|
||||
match iti {
|
||||
ProvidedInlinedTraitItem(m) => {
|
||||
walk_method_helper(visitor, &*m)
|
||||
IIItem(ref i) => visitor.visit_item(&**i),
|
||||
IIForeign(ref i) => visitor.visit_foreign_item(&**i),
|
||||
IITraitItem(_, ref iti) => {
|
||||
match *iti {
|
||||
ProvidedInlinedTraitItem(ref m) => {
|
||||
walk_method_helper(visitor, &**m)
|
||||
}
|
||||
RequiredInlinedTraitItem(m) => {
|
||||
walk_method_helper(visitor, &*m)
|
||||
RequiredInlinedTraitItem(ref m) => {
|
||||
walk_method_helper(visitor, &**m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,14 +135,14 @@ pub fn walk_inlined_item<V: Visitor>(visitor: &mut V, item: &ast::InlinedItem) {
|
|||
}
|
||||
|
||||
|
||||
pub fn walk_crate<V: Visitor>(visitor: &mut V, krate: &Crate) {
|
||||
pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate) {
|
||||
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID);
|
||||
for attr in krate.attrs.iter() {
|
||||
visitor.visit_attribute(attr);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_mod<V: Visitor>(visitor: &mut V, module: &Mod) {
|
||||
pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod) {
|
||||
for view_item in module.view_items.iter() {
|
||||
visitor.visit_view_item(view_item)
|
||||
}
|
||||
|
|
@ -171,7 +152,7 @@ pub fn walk_mod<V: Visitor>(visitor: &mut V, module: &Mod) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_view_item<V: Visitor>(visitor: &mut V, vi: &ViewItem) {
|
||||
pub fn walk_view_item<'v, V: Visitor<'v>>(visitor: &mut V, vi: &'v ViewItem) {
|
||||
match vi.node {
|
||||
ViewItemExternCrate(name, _, _) => {
|
||||
visitor.visit_ident(vi.span, name)
|
||||
|
|
@ -204,16 +185,14 @@ pub fn walk_view_item<V: Visitor>(visitor: &mut V, vi: &ViewItem) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_local<V: Visitor>(visitor: &mut V, local: &Local) {
|
||||
pub fn walk_local<'v, V: Visitor<'v>>(visitor: &mut V, local: &'v Local) {
|
||||
visitor.visit_pat(&*local.pat);
|
||||
visitor.visit_ty(&*local.ty);
|
||||
match local.init {
|
||||
None => {}
|
||||
Some(initializer) => visitor.visit_expr(&*initializer),
|
||||
}
|
||||
walk_expr_opt(visitor, &local.init);
|
||||
}
|
||||
|
||||
pub fn walk_explicit_self<V: Visitor>(visitor: &mut V, explicit_self: &ExplicitSelf) {
|
||||
pub fn walk_explicit_self<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
explicit_self: &'v ExplicitSelf) {
|
||||
match explicit_self.node {
|
||||
SelfStatic | SelfValue(_) => {},
|
||||
SelfRegion(ref lifetime, _, _) => {
|
||||
|
|
@ -225,21 +204,21 @@ pub fn walk_explicit_self<V: Visitor>(visitor: &mut V, explicit_self: &ExplicitS
|
|||
|
||||
/// Like with walk_method_helper this doesn't correspond to a method
|
||||
/// in Visitor, and so it gets a _helper suffix.
|
||||
pub fn walk_trait_ref_helper<V: Visitor>(visitor: &mut V, trait_ref: &TraitRef) {
|
||||
pub fn walk_trait_ref_helper<'v, V: Visitor<'v>>(visitor: &mut V, trait_ref: &'v TraitRef) {
|
||||
visitor.visit_path(&trait_ref.path, trait_ref.ref_id)
|
||||
}
|
||||
|
||||
pub fn walk_item<V: Visitor>(visitor: &mut V, item: &Item) {
|
||||
pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
visitor.visit_ident(item.span, item.ident);
|
||||
match item.node {
|
||||
ItemStatic(ref typ, _, ref expr) => {
|
||||
visitor.visit_ty(&**typ);
|
||||
visitor.visit_expr(&**expr);
|
||||
}
|
||||
ItemFn(declaration, fn_style, abi, ref generics, body) => {
|
||||
visitor.visit_fn(&FkItemFn(item.ident, generics, fn_style, abi),
|
||||
&*declaration,
|
||||
&*body,
|
||||
ItemFn(ref declaration, fn_style, abi, ref generics, ref body) => {
|
||||
visitor.visit_fn(FkItemFn(item.ident, generics, fn_style, abi),
|
||||
&**declaration,
|
||||
&**body,
|
||||
item.span,
|
||||
item.id)
|
||||
}
|
||||
|
|
@ -264,7 +243,7 @@ pub fn walk_item<V: Visitor>(visitor: &mut V, item: &Item) {
|
|||
}
|
||||
ItemImpl(ref type_parameters,
|
||||
ref trait_reference,
|
||||
typ,
|
||||
ref typ,
|
||||
ref impl_items) => {
|
||||
visitor.visit_generics(type_parameters);
|
||||
match *trait_reference {
|
||||
|
|
@ -272,11 +251,11 @@ pub fn walk_item<V: Visitor>(visitor: &mut V, item: &Item) {
|
|||
trait_reference),
|
||||
None => ()
|
||||
}
|
||||
visitor.visit_ty(&*typ);
|
||||
visitor.visit_ty(&**typ);
|
||||
for impl_item in impl_items.iter() {
|
||||
match *impl_item {
|
||||
MethodImplItem(method) => {
|
||||
walk_method_helper(visitor, &*method)
|
||||
MethodImplItem(ref method) => {
|
||||
walk_method_helper(visitor, &**method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -302,17 +281,17 @@ pub fn walk_item<V: Visitor>(visitor: &mut V, item: &Item) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_enum_def<V: Visitor>(visitor: &mut V,
|
||||
enum_definition: &EnumDef,
|
||||
generics: &Generics) {
|
||||
for &variant in enum_definition.variants.iter() {
|
||||
visitor.visit_variant(&*variant, generics);
|
||||
pub fn walk_enum_def<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
enum_definition: &'v EnumDef,
|
||||
generics: &'v Generics) {
|
||||
for variant in enum_definition.variants.iter() {
|
||||
visitor.visit_variant(&**variant, generics);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_variant<V: Visitor>(visitor: &mut V,
|
||||
variant: &Variant,
|
||||
generics: &Generics) {
|
||||
pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
variant: &'v Variant,
|
||||
generics: &'v Generics) {
|
||||
visitor.visit_ident(variant.span, variant.node.name);
|
||||
|
||||
match variant.node.kind {
|
||||
|
|
@ -337,14 +316,14 @@ pub fn walk_variant<V: Visitor>(visitor: &mut V,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn skip_ty<V: Visitor>(_: &mut V, _: &Ty) {
|
||||
pub fn skip_ty<'v, V: Visitor<'v>>(_: &mut V, _: &'v Ty) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
pub fn walk_ty<V: Visitor>(visitor: &mut V, typ: &Ty) {
|
||||
pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
|
||||
match typ.node {
|
||||
TyUniq(ty) | TyVec(ty) | TyBox(ty) | TyParen(ty) => {
|
||||
visitor.visit_ty(&*ty)
|
||||
TyUniq(ref ty) | TyVec(ref ty) | TyBox(ref ty) | TyParen(ref ty) => {
|
||||
visitor.visit_ty(&**ty)
|
||||
}
|
||||
TyPtr(ref mutable_type) => {
|
||||
visitor.visit_ty(&*mutable_type.ty)
|
||||
|
|
@ -354,8 +333,8 @@ pub fn walk_ty<V: Visitor>(visitor: &mut V, typ: &Ty) {
|
|||
visitor.visit_ty(&*mutable_type.ty)
|
||||
}
|
||||
TyTup(ref tuple_element_types) => {
|
||||
for &tuple_element_type in tuple_element_types.iter() {
|
||||
visitor.visit_ty(&*tuple_element_type)
|
||||
for tuple_element_type in tuple_element_types.iter() {
|
||||
visitor.visit_ty(&**tuple_element_type)
|
||||
}
|
||||
}
|
||||
TyClosure(ref function_declaration) => {
|
||||
|
|
@ -407,13 +386,14 @@ pub fn walk_ty<V: Visitor>(visitor: &mut V, typ: &Ty) {
|
|||
}
|
||||
}
|
||||
|
||||
fn walk_lifetime_decls<V: Visitor>(visitor: &mut V, lifetimes: &Vec<LifetimeDef>) {
|
||||
fn walk_lifetime_decls<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
lifetimes: &'v Vec<LifetimeDef>) {
|
||||
for l in lifetimes.iter() {
|
||||
visitor.visit_lifetime_decl(l);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_path<V: Visitor>(visitor: &mut V, path: &Path) {
|
||||
pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) {
|
||||
for segment in path.segments.iter() {
|
||||
visitor.visit_ident(path.span, segment.identifier);
|
||||
|
||||
|
|
@ -426,7 +406,7 @@ pub fn walk_path<V: Visitor>(visitor: &mut V, path: &Path) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_pat<V: Visitor>(visitor: &mut V, pattern: &Pat) {
|
||||
pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
|
||||
match pattern.node {
|
||||
PatEnum(ref path, ref children) => {
|
||||
visitor.visit_path(path, pattern.id);
|
||||
|
|
@ -479,7 +459,8 @@ pub fn walk_pat<V: Visitor>(visitor: &mut V, pattern: &Pat) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_foreign_item<V: Visitor>(visitor: &mut V, foreign_item: &ForeignItem) {
|
||||
pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
foreign_item: &'v ForeignItem) {
|
||||
visitor.visit_ident(foreign_item.span, foreign_item.ident);
|
||||
|
||||
match foreign_item.node {
|
||||
|
|
@ -495,8 +476,8 @@ pub fn walk_foreign_item<V: Visitor>(visitor: &mut V, foreign_item: &ForeignItem
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_ty_param_bounds<V: Visitor>(visitor: &mut V,
|
||||
bounds: &OwnedSlice<TyParamBound>) {
|
||||
pub fn walk_ty_param_bounds<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
bounds: &'v OwnedSlice<TyParamBound>) {
|
||||
for bound in bounds.iter() {
|
||||
match *bound {
|
||||
TraitTyParamBound(ref typ) => {
|
||||
|
|
@ -515,7 +496,7 @@ pub fn walk_ty_param_bounds<V: Visitor>(visitor: &mut V,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_generics<V: Visitor>(visitor: &mut V, generics: &Generics) {
|
||||
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
|
||||
for type_parameter in generics.ty_params.iter() {
|
||||
walk_ty_param_bounds(visitor, &type_parameter.bounds);
|
||||
match type_parameter.default {
|
||||
|
|
@ -530,7 +511,7 @@ pub fn walk_generics<V: Visitor>(visitor: &mut V, generics: &Generics) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_fn_decl<V: Visitor>(visitor: &mut V, function_declaration: &FnDecl) {
|
||||
pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &'v FnDecl) {
|
||||
for argument in function_declaration.inputs.iter() {
|
||||
visitor.visit_pat(&*argument.pat);
|
||||
visitor.visit_ty(&*argument.ty)
|
||||
|
|
@ -542,13 +523,13 @@ pub fn walk_fn_decl<V: Visitor>(visitor: &mut V, function_declaration: &FnDecl)
|
|||
// visit_fn() and check for FkMethod(). I named this visit_method_helper()
|
||||
// because it is not a default impl of any method, though I doubt that really
|
||||
// clarifies anything. - Niko
|
||||
pub fn walk_method_helper<V: Visitor>(visitor: &mut V, method: &Method) {
|
||||
pub fn walk_method_helper<'v, V: Visitor<'v>>(visitor: &mut V, method: &'v Method) {
|
||||
match method.node {
|
||||
MethDecl(ident, ref generics, _, _, _, decl, body, _) => {
|
||||
MethDecl(ident, ref generics, _, _, _, ref decl, ref body, _) => {
|
||||
visitor.visit_ident(method.span, ident);
|
||||
visitor.visit_fn(&FkMethod(ident, generics, method),
|
||||
&*decl,
|
||||
&*body,
|
||||
visitor.visit_fn(FkMethod(ident, generics, method),
|
||||
&**decl,
|
||||
&**body,
|
||||
method.span,
|
||||
method.id);
|
||||
for attr in method.attrs.iter() {
|
||||
|
|
@ -560,14 +541,14 @@ pub fn walk_method_helper<V: Visitor>(visitor: &mut V, method: &Method) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_fn<V: Visitor>(visitor: &mut V,
|
||||
function_kind: &FnKind,
|
||||
function_declaration: &FnDecl,
|
||||
function_body: &Block,
|
||||
_span: Span) {
|
||||
pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
function_kind: FnKind<'v>,
|
||||
function_declaration: &'v FnDecl,
|
||||
function_body: &'v Block,
|
||||
_span: Span) {
|
||||
walk_fn_decl(visitor, function_declaration);
|
||||
|
||||
match *function_kind {
|
||||
match function_kind {
|
||||
FkItemFn(_, generics, _, _) => {
|
||||
visitor.visit_generics(generics);
|
||||
}
|
||||
|
|
@ -586,7 +567,7 @@ pub fn walk_fn<V: Visitor>(visitor: &mut V,
|
|||
visitor.visit_block(function_body)
|
||||
}
|
||||
|
||||
pub fn walk_ty_method<V: Visitor>(visitor: &mut V, method_type: &TypeMethod) {
|
||||
pub fn walk_ty_method<'v, V: Visitor<'v>>(visitor: &mut V, method_type: &'v TypeMethod) {
|
||||
visitor.visit_ident(method_type.span, method_type.ident);
|
||||
visitor.visit_explicit_self(&method_type.explicit_self);
|
||||
for argument_type in method_type.decl.inputs.iter() {
|
||||
|
|
@ -599,7 +580,7 @@ pub fn walk_ty_method<V: Visitor>(visitor: &mut V, method_type: &TypeMethod) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_trait_item<V: Visitor>(visitor: &mut V, trait_method: &TraitItem) {
|
||||
pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_method: &'v TraitItem) {
|
||||
match *trait_method {
|
||||
RequiredMethod(ref method_type) => {
|
||||
visitor.visit_ty_method(method_type)
|
||||
|
|
@ -608,8 +589,8 @@ pub fn walk_trait_item<V: Visitor>(visitor: &mut V, trait_method: &TraitItem) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_struct_def<V: Visitor>(visitor: &mut V,
|
||||
struct_definition: &StructDef) {
|
||||
pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
struct_definition: &'v StructDef) {
|
||||
match struct_definition.super_struct {
|
||||
Some(ref t) => visitor.visit_ty(&**t),
|
||||
None => {},
|
||||
|
|
@ -619,8 +600,8 @@ pub fn walk_struct_def<V: Visitor>(visitor: &mut V,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_struct_field<V: Visitor>(visitor: &mut V,
|
||||
struct_field: &StructField) {
|
||||
pub fn walk_struct_field<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
struct_field: &'v StructField) {
|
||||
match struct_field.node.kind {
|
||||
NamedField(name, _) => {
|
||||
visitor.visit_ident(struct_field.span, name)
|
||||
|
|
@ -635,17 +616,17 @@ pub fn walk_struct_field<V: Visitor>(visitor: &mut V,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_block<V: Visitor>(visitor: &mut V, block: &Block) {
|
||||
pub fn walk_block<'v, V: Visitor<'v>>(visitor: &mut V, block: &'v Block) {
|
||||
for view_item in block.view_items.iter() {
|
||||
visitor.visit_view_item(view_item)
|
||||
}
|
||||
for statement in block.stmts.iter() {
|
||||
visitor.visit_stmt(&**statement)
|
||||
}
|
||||
walk_expr_opt(visitor, block.expr)
|
||||
walk_expr_opt(visitor, &block.expr)
|
||||
}
|
||||
|
||||
pub fn walk_stmt<V: Visitor>(visitor: &mut V, statement: &Stmt) {
|
||||
pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
|
||||
match statement.node {
|
||||
StmtDecl(ref declaration, _) => visitor.visit_decl(&**declaration),
|
||||
StmtExpr(ref expression, _) | StmtSemi(ref expression, _) => {
|
||||
|
|
@ -655,32 +636,32 @@ pub fn walk_stmt<V: Visitor>(visitor: &mut V, statement: &Stmt) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn walk_decl<V: Visitor>(visitor: &mut V, declaration: &Decl) {
|
||||
pub fn walk_decl<'v, V: Visitor<'v>>(visitor: &mut V, declaration: &'v Decl) {
|
||||
match declaration.node {
|
||||
DeclLocal(ref local) => visitor.visit_local(&**local),
|
||||
DeclItem(ref item) => visitor.visit_item(&**item),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_expr_opt<V: Visitor>(visitor: &mut V,
|
||||
optional_expression: Option<Gc<Expr>>) {
|
||||
match optional_expression {
|
||||
pub fn walk_expr_opt<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
optional_expression: &'v Option<Gc<Expr>>) {
|
||||
match *optional_expression {
|
||||
None => {}
|
||||
Some(ref expression) => visitor.visit_expr(&**expression),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_exprs<V: Visitor>(visitor: &mut V, expressions: &[Gc<Expr>]) {
|
||||
pub fn walk_exprs<'v, V: Visitor<'v>>(visitor: &mut V, expressions: &'v [Gc<Expr>]) {
|
||||
for expression in expressions.iter() {
|
||||
visitor.visit_expr(&**expression)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_mac<V: Visitor>(_: &mut V, _: &Mac) {
|
||||
pub fn walk_mac<'v, V: Visitor<'v>>(_: &mut V, _: &'v Mac) {
|
||||
// Empty!
|
||||
}
|
||||
|
||||
pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
||||
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
|
||||
match expression.node {
|
||||
ExprBox(ref place, ref subexpression) => {
|
||||
visitor.visit_expr(&**place);
|
||||
|
|
@ -693,7 +674,7 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
|||
visitor.visit_expr(&**element);
|
||||
visitor.visit_expr(&**count)
|
||||
}
|
||||
ExprStruct(ref path, ref fields, optional_base) => {
|
||||
ExprStruct(ref path, ref fields, ref optional_base) => {
|
||||
visitor.visit_path(path, expression.id);
|
||||
for field in fields.iter() {
|
||||
visitor.visit_expr(&*field.expr)
|
||||
|
|
@ -729,7 +710,7 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
|||
visitor.visit_expr(&**subexpression);
|
||||
visitor.visit_ty(&**typ)
|
||||
}
|
||||
ExprIf(ref head_expression, ref if_block, optional_else) => {
|
||||
ExprIf(ref head_expression, ref if_block, ref optional_else) => {
|
||||
visitor.visit_expr(&**head_expression);
|
||||
visitor.visit_block(&**if_block);
|
||||
walk_expr_opt(visitor, optional_else)
|
||||
|
|
@ -751,21 +732,21 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
|||
}
|
||||
}
|
||||
ExprFnBlock(_, ref function_declaration, ref body) => {
|
||||
visitor.visit_fn(&FkFnBlock,
|
||||
visitor.visit_fn(FkFnBlock,
|
||||
&**function_declaration,
|
||||
&**body,
|
||||
expression.span,
|
||||
expression.id)
|
||||
}
|
||||
ExprUnboxedFn(_, _, ref function_declaration, ref body) => {
|
||||
visitor.visit_fn(&FkFnBlock,
|
||||
visitor.visit_fn(FkFnBlock,
|
||||
&**function_declaration,
|
||||
&**body,
|
||||
expression.span,
|
||||
expression.id)
|
||||
}
|
||||
ExprProc(ref function_declaration, ref body) => {
|
||||
visitor.visit_fn(&FkFnBlock,
|
||||
visitor.visit_fn(FkFnBlock,
|
||||
&**function_declaration,
|
||||
&**body,
|
||||
expression.span,
|
||||
|
|
@ -800,7 +781,7 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
|||
visitor.visit_path(path, expression.id)
|
||||
}
|
||||
ExprBreak(_) | ExprAgain(_) => {}
|
||||
ExprRet(optional_expression) => {
|
||||
ExprRet(ref optional_expression) => {
|
||||
walk_expr_opt(visitor, optional_expression)
|
||||
}
|
||||
ExprMac(ref macro) => visitor.visit_mac(macro),
|
||||
|
|
@ -808,10 +789,12 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
|||
visitor.visit_expr(&**subexpression)
|
||||
}
|
||||
ExprInlineAsm(ref ia) => {
|
||||
for &(_, ref input) in ia.inputs.iter() {
|
||||
for input in ia.inputs.iter() {
|
||||
let (_, ref input) = *input;
|
||||
visitor.visit_expr(&**input)
|
||||
}
|
||||
for &(_, ref output, _) in ia.outputs.iter() {
|
||||
for output in ia.outputs.iter() {
|
||||
let (_, ref output, _) = *output;
|
||||
visitor.visit_expr(&**output)
|
||||
}
|
||||
}
|
||||
|
|
@ -820,11 +803,11 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expression: &Expr) {
|
|||
visitor.visit_expr_post(expression)
|
||||
}
|
||||
|
||||
pub fn walk_arm<V: Visitor>(visitor: &mut V, arm: &Arm) {
|
||||
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
|
||||
for pattern in arm.pats.iter() {
|
||||
visitor.visit_pat(&**pattern)
|
||||
}
|
||||
walk_expr_opt(visitor, arm.guard);
|
||||
walk_expr_opt(visitor, &arm.guard);
|
||||
visitor.visit_expr(&*arm.body);
|
||||
for attr in arm.attrs.iter() {
|
||||
visitor.visit_attribute(attr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue