about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2013-08-13 14:12:09 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2013-08-15 04:09:19 +0200
commit23ce08a4cde573f3ab5e3f57a7c5142a472595ff (patch)
tree312fb03a7ab6b2a0ebc25ef755984d6668fd4d84
parent3281d58a5d6b719219c451b490d2758a8770e16a (diff)
port callee.rs from oldvisit to <V:Visitor> trait API.
-rw-r--r--src/librustc/middle/trans/callee.rs31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index 4caaf384873..15dbcf55488 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -47,7 +47,8 @@ use middle::trans::type_::Type;
 
 use syntax::ast;
 use syntax::ast_map;
-use syntax::oldvisit;
+use syntax::visit;
+use syntax::visit::Visitor;
 
 // Represents a (possibly monomorphized) top-level fn item or method
 // item.  Note that this is just the fn-ptr and is not a Rust closure
@@ -525,21 +526,29 @@ pub fn trans_lang_call_with_type_params(bcx: @mut Block,
         ArgVals(args), Some(dest), DontAutorefArg).bcx;
 }
 
-pub fn body_contains_ret(body: &ast::Block) -> bool {
-    let cx = @mut false;
-    oldvisit::visit_block(body, (cx, oldvisit::mk_vt(@oldvisit::Visitor {
-        visit_item: |_i, (_cx, _v)| { },
-        visit_expr: |e: @ast::expr,
-                     (cx, v): (@mut bool, oldvisit::vt<@mut bool>)| {
+
+struct CalleeTranslationVisitor;
+
+impl Visitor<@mut bool> for CalleeTranslationVisitor {
+
+    fn visit_item(&mut self, _:@ast::item, _:@mut bool) { }
+
+    fn visit_expr(&mut self, e:@ast::expr, cx:@mut bool) {
+
             if !*cx {
                 match e.node {
                   ast::expr_ret(_) => *cx = true,
-                  _ => oldvisit::visit_expr(e, (cx, v)),
+                  _ => visit::walk_expr(self, e, cx),
                 }
             }
-        },
-        ..*oldvisit::default_visitor()
-    })));
+    }
+
+}
+
+pub fn body_contains_ret(body: &ast::Block) -> bool {
+    let cx = @mut false;
+    let mut v = CalleeTranslationVisitor;
+    visit::walk_block(&mut v, body, cx);
     *cx
 }