@@ -47,7 +47,8 @@ use middle::trans::type_::Type;
47
47
48
48
use syntax:: ast;
49
49
use syntax:: ast_map;
50
- use syntax:: oldvisit;
50
+ use syntax:: visit;
51
+ use syntax:: visit:: Visitor ;
51
52
52
53
// Represents a (possibly monomorphized) top-level fn item or method
53
54
// 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,
525
526
ArgVals ( args) , Some ( dest) , DontAutorefArg ) . bcx ;
526
527
}
527
528
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
+
534
538
if !* cx {
535
539
match e. node {
536
540
ast:: expr_ret( _) => * cx = true ,
537
- _ => oldvisit :: visit_expr ( e , ( cx , v ) ) ,
541
+ _ => visit :: walk_expr ( self , e , cx ) ,
538
542
}
539
543
}
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) ;
543
552
* cx
544
553
}
545
554
0 commit comments