auto merge of #14192 : pongad/rust/walkcleanup, r=pcwalton

Fixes #14134
This commit is contained in:
bors 2014-05-14 07:31:45 -07:00
commit 96bcadc181
11 changed files with 30 additions and 37 deletions

View File

@ -144,7 +144,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
check_loans::check_loans(this, &loan_dfcx, flowed_moves, check_loans::check_loans(this, &loan_dfcx, flowed_moves,
all_loans.as_slice(), body); all_loans.as_slice(), body);
visit::walk_fn(this, fk, decl, body, sp, id, ()); visit::walk_fn(this, fk, decl, body, sp, ());
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -830,4 +830,3 @@ impl Repr for LoanPath {
} }
} }
} }

View File

@ -37,8 +37,8 @@ impl<'a> Visitor<()> for MatchCheckCtxt<'a> {
fn visit_local(&mut self, l: &Local, _: ()) { fn visit_local(&mut self, l: &Local, _: ()) {
check_local(self, l); check_local(self, l);
} }
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, _: ()) { fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId, _: ()) {
check_fn(self, fk, fd, b, s, n); check_fn(self, fk, fd, b, s);
} }
} }
@ -866,9 +866,8 @@ fn check_fn(cx: &mut MatchCheckCtxt,
kind: &FnKind, kind: &FnKind,
decl: &FnDecl, decl: &FnDecl,
body: &Block, body: &Block,
sp: Span, sp: Span) {
id: NodeId) { visit::walk_fn(cx, kind, decl, body, sp, ());
visit::walk_fn(cx, kind, decl, body, sp, id, ());
for input in decl.inputs.iter() { for input in decl.inputs.iter() {
if is_refutable(cx, input.pat) { if is_refutable(cx, input.pat) {
cx.tcx.sess.span_err(input.pat.span, cx.tcx.sess.span_err(input.pat.span,

View File

@ -86,7 +86,7 @@ impl<'a> EffectCheckVisitor<'a> {
impl<'a> Visitor<()> for EffectCheckVisitor<'a> { impl<'a> Visitor<()> for EffectCheckVisitor<'a> {
fn visit_fn(&mut self, fn_kind: &visit::FnKind, fn_decl: &ast::FnDecl, fn visit_fn(&mut self, fn_kind: &visit::FnKind, fn_decl: &ast::FnDecl,
block: &ast::Block, span: Span, node_id: ast::NodeId, _:()) { block: &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, _) => visit::FkItemFn(_, _, fn_style, _) =>
@ -103,7 +103,7 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> {
self.unsafe_context = SafeContext self.unsafe_context = SafeContext
} }
visit::walk_fn(self, fn_kind, fn_decl, block, span, node_id, ()); visit::walk_fn(self, fn_kind, fn_decl, block, span, ());
self.unsafe_context = old_unsafe_context self.unsafe_context = old_unsafe_context
} }

View File

@ -115,7 +115,7 @@ impl<'a> Visitor<()> for AnnotateFreevarsVisitor<'a> {
blk: &ast::Block, s: Span, nid: ast::NodeId, _: ()) { blk: &ast::Block, s: Span, nid: ast::NodeId, _: ()) {
let vars = collect_freevars(self.def_map, blk); let vars = collect_freevars(self.def_map, blk);
self.freevars.insert(nid, vars); self.freevars.insert(nid, vars);
visit::walk_fn(self, fk, fd, blk, s, nid, ()); visit::walk_fn(self, fk, fd, blk, s, ());
} }
} }

View File

@ -235,7 +235,7 @@ fn check_fn(
}); });
}); });
visit::walk_fn(cx, fk, decl, body, sp, fn_id, ()); visit::walk_fn(cx, fk, decl, body, sp, ());
} }
pub fn check_expr(cx: &mut Context, e: &Expr) { pub fn check_expr(cx: &mut Context, e: &Expr) {

View File

@ -1775,7 +1775,7 @@ impl<'a> Visitor<()> for Context<'a> {
fn visit_fn(&mut self, fk: &visit::FnKind, decl: &ast::FnDecl, fn visit_fn(&mut self, fk: &visit::FnKind, decl: &ast::FnDecl,
body: &ast::Block, span: Span, id: ast::NodeId, _: ()) { body: &ast::Block, span: Span, id: ast::NodeId, _: ()) {
let recurse = |this: &mut Context| { let recurse = |this: &mut Context| {
visit::walk_fn(this, fk, decl, body, span, id, ()); visit::walk_fn(this, fk, decl, body, span, ());
}; };
for a in decl.inputs.iter(){ for a in decl.inputs.iter(){
@ -1810,15 +1810,15 @@ impl<'a> Visitor<()> for Context<'a> {
fn visit_struct_def(&mut self, fn visit_struct_def(&mut self,
s: &ast::StructDef, s: &ast::StructDef,
i: ast::Ident, _: ast::Ident,
g: &ast::Generics, _: &ast::Generics,
id: ast::NodeId, id: ast::NodeId,
_: ()) { _: ()) {
check_struct_uppercase_variable(self, s); check_struct_uppercase_variable(self, s);
let old_id = self.cur_struct_def_id; let old_id = self.cur_struct_def_id;
self.cur_struct_def_id = id; self.cur_struct_def_id = id;
visit::walk_struct_def(self, s, i, g, id, ()); visit::walk_struct_def(self, s, ());
self.cur_struct_def_id = old_id; self.cur_struct_def_id = old_id;
} }

View File

@ -383,7 +383,7 @@ fn visit_fn(ir: &mut IrMaps,
// gather up the various local variables, significant expressions, // gather up the various local variables, significant expressions,
// and so forth: // and so forth:
visit::walk_fn(&mut fn_maps, fk, decl, body, sp, id, ()); visit::walk_fn(&mut fn_maps, fk, decl, body, sp, ());
// Special nodes and variables: // Special nodes and variables:
// - exit_ln represents the end of the fn, either by return or fail // - exit_ln represents the end of the fn, either by return or fail

View File

@ -107,11 +107,11 @@ impl Visitor<()> for ParentVisitor {
if !self.parents.contains_key(&id) { if !self.parents.contains_key(&id) {
self.parents.insert(id, self.curparent); self.parents.insert(id, self.curparent);
} }
visit::walk_fn(self, a, b, c, d, id, ()); visit::walk_fn(self, a, b, c, d, ());
} }
fn visit_struct_def(&mut self, s: &ast::StructDef, i: ast::Ident, fn visit_struct_def(&mut self, s: &ast::StructDef, _: ast::Ident,
g: &ast::Generics, n: ast::NodeId, _: ()) { _: &ast::Generics, n: ast::NodeId, _: ()) {
// Struct constructors are parented to their struct definitions because // Struct constructors are parented to their struct definitions because
// they essentially are the struct definitions. // they essentially are the struct definitions.
match s.ctor_id { match s.ctor_id {
@ -124,7 +124,7 @@ impl Visitor<()> for ParentVisitor {
for field in s.fields.iter() { for field in s.fields.iter() {
self.parents.insert(field.node.id, self.curparent); self.parents.insert(field.node.id, self.curparent);
} }
visit::walk_struct_def(self, s, i, g, n, ()) visit::walk_struct_def(self, s, ())
} }
} }
@ -1006,10 +1006,10 @@ impl<'a> Visitor<()> for SanePrivacyVisitor<'a> {
} }
fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl, fn visit_fn(&mut self, fk: &visit::FnKind, fd: &ast::FnDecl,
b: &ast::Block, s: Span, n: ast::NodeId, _: ()) { b: &ast::Block, s: Span, _: ast::NodeId, _: ()) {
// This catches both functions and methods // This catches both functions and methods
let orig_in_fn = replace(&mut self.in_fn, true); let orig_in_fn = replace(&mut self.in_fn, true);
visit::walk_fn(self, fk, fd, b, s, n, ()); visit::walk_fn(self, fk, fd, b, s, ());
self.in_fn = orig_in_fn; self.in_fn = orig_in_fn;
} }
@ -1363,7 +1363,7 @@ impl<'a> Visitor<()> for VisiblePrivateTypesVisitor<'a> {
_: ()) { _: ()) {
// needs special handling for methods. // needs special handling for methods.
if self.exported_items.contains(&id) { if self.exported_items.contains(&id) {
visit::walk_fn(self, fk, fd, b, s, id, ()); visit::walk_fn(self, fk, fd, b, s, ());
} }
} }

View File

@ -102,10 +102,10 @@ impl<'a, 'b> Visitor<Scope<'a>> for LifetimeContext<'b> {
visit::FkMethod(_, generics, _) => { visit::FkMethod(_, generics, _) => {
self.visit_fn_decl( self.visit_fn_decl(
n, generics, scope, n, generics, scope,
|this, scope1| visit::walk_fn(this, fk, fd, b, s, n, scope1)) |this, scope1| visit::walk_fn(this, fk, fd, b, s, scope1))
} }
visit::FkFnBlock(..) => { visit::FkFnBlock(..) => {
visit::walk_fn(self, fk, fd, b, s, n, scope) visit::walk_fn(self, fk, fd, b, s, scope)
} }
} }
} }

View File

@ -546,7 +546,6 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> {
function_declaration, function_declaration,
block, block,
span, span,
node_id,
env); env);
if !self.pass_through_items { if !self.pass_through_items {
@ -564,13 +563,13 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> {
fn visit_struct_def(&mut self, fn visit_struct_def(&mut self,
struct_def: &StructDef, struct_def: &StructDef,
ident: ast::Ident, _: ast::Ident,
generics: &ast::Generics, _: &ast::Generics,
id: NodeId, id: NodeId,
_: ()) { _: ()) {
self.operation.visit_id(id); self.operation.visit_id(id);
struct_def.ctor_id.map(|ctor_id| self.operation.visit_id(ctor_id)); struct_def.ctor_id.map(|ctor_id| self.operation.visit_id(ctor_id));
visit::walk_struct_def(self, struct_def, ident, generics, id, ()); visit::walk_struct_def(self, struct_def, ());
} }
fn visit_trait_method(&mut self, tm: &ast::TraitMethod, _: ()) { fn visit_trait_method(&mut self, tm: &ast::TraitMethod, _: ()) {

View File

@ -79,13 +79,13 @@ pub trait Visitor<E: Clone> {
fn visit_expr_post(&mut self, _ex: &Expr, _e: E) { } fn visit_expr_post(&mut self, _ex: &Expr, _e: E) { }
fn visit_ty(&mut self, t: &Ty, e: E) { walk_ty(self, t, e) } fn visit_ty(&mut self, t: &Ty, e: E) { walk_ty(self, t, e) }
fn visit_generics(&mut self, g: &Generics, e: E) { walk_generics(self, g, e) } fn visit_generics(&mut self, g: &Generics, e: E) { walk_generics(self, g, e) }
fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, n: NodeId, e: E) { fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId, e: E) {
walk_fn(self, fk, fd, b, s, n , e) walk_fn(self, fk, fd, b, s, e)
} }
fn visit_ty_method(&mut self, t: &TypeMethod, e: E) { walk_ty_method(self, t, e) } fn visit_ty_method(&mut self, t: &TypeMethod, e: E) { walk_ty_method(self, t, e) }
fn visit_trait_method(&mut self, t: &TraitMethod, e: E) { walk_trait_method(self, t, e) } fn visit_trait_method(&mut self, t: &TraitMethod, e: E) { walk_trait_method(self, t, e) }
fn visit_struct_def(&mut self, s: &StructDef, i: Ident, g: &Generics, n: NodeId, e: E) { fn visit_struct_def(&mut self, s: &StructDef, _: Ident, _: &Generics, _: NodeId, e: E) {
walk_struct_def(self, s, i, g, n, e) walk_struct_def(self, s, e)
} }
fn visit_struct_field(&mut self, s: &StructField, e: E) { walk_struct_field(self, s, e) } fn visit_struct_field(&mut self, s: &StructField, e: E) { walk_struct_field(self, s, e) }
fn visit_variant(&mut self, v: &Variant, g: &Generics, e: E) { walk_variant(self, v, g, e) } fn visit_variant(&mut self, v: &Variant, g: &Generics, e: E) { walk_variant(self, v, g, e) }
@ -522,7 +522,6 @@ pub fn walk_fn<E: Clone, V: Visitor<E>>(visitor: &mut V,
function_declaration: &FnDecl, function_declaration: &FnDecl,
function_body: &Block, function_body: &Block,
_span: Span, _span: Span,
_: NodeId,
env: E) { env: E) {
walk_fn_decl(visitor, function_declaration, env.clone()); walk_fn_decl(visitor, function_declaration, env.clone());
@ -566,9 +565,6 @@ pub fn walk_trait_method<E: Clone, V: Visitor<E>>(visitor: &mut V,
pub fn walk_struct_def<E: Clone, V: Visitor<E>>(visitor: &mut V, pub fn walk_struct_def<E: Clone, V: Visitor<E>>(visitor: &mut V,
struct_definition: &StructDef, struct_definition: &StructDef,
_: Ident,
_: &Generics,
_: NodeId,
env: E) { env: E) {
match struct_definition.super_struct { match struct_definition.super_struct {
Some(t) => visitor.visit_ty(t, env.clone()), Some(t) => visitor.visit_ty(t, env.clone()),