Skip to content

Commit 23ce08a

Browse files
committed
port callee.rs from oldvisit to <V:Visitor> trait API.
1 parent 3281d58 commit 23ce08a

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/librustc/middle/trans/callee.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ use middle::trans::type_::Type;
4747

4848
use syntax::ast;
4949
use syntax::ast_map;
50-
use syntax::oldvisit;
50+
use syntax::visit;
51+
use syntax::visit::Visitor;
5152

5253
// Represents a (possibly monomorphized) top-level fn item or method
5354
// 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,
525526
ArgVals(args), Some(dest), DontAutorefArg).bcx;
526527
}
527528

528-
pub fn body_contains_ret(body: &ast::Block) -> bool {
529-
let cx = @mut false;
530-
oldvisit::visit_block(body, (cx, oldvisit::mk_vt(@oldvisit::Visitor {
531-
visit_item: |_i, (_cx, _v)| { },
532-
visit_expr: |e: @ast::expr,
533-
(cx, v): (@mut bool, oldvisit::vt<@mut bool>)| {
529+
530+
struct CalleeTranslationVisitor;
531+
532+
impl Visitor<@mut bool> for CalleeTranslationVisitor {
533+
534+
fn visit_item(&mut self, _:@ast::item, _:@mut bool) { }
535+
536+
fn visit_expr(&mut self, e:@ast::expr, cx:@mut bool) {
537+
534538
if !*cx {
535539
match e.node {
536540
ast::expr_ret(_) => *cx = true,
537-
_ => oldvisit::visit_expr(e, (cx, v)),
541+
_ => visit::walk_expr(self, e, cx),
538542
}
539543
}
540-
},
541-
..*oldvisit::default_visitor()
542-
})));
544+
}
545+
546+
}
547+
548+
pub fn body_contains_ret(body: &ast::Block) -> bool {
549+
let cx = @mut false;
550+
let mut v = CalleeTranslationVisitor;
551+
visit::walk_block(&mut v, body, cx);
543552
*cx
544553
}
545554

0 commit comments

Comments
 (0)