Skip to content

Commit 9d07277

Browse files
committed
Fold context into CalleeTranslationVisitor.
1 parent 2ceebf1 commit 9d07277

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/librustc/middle/trans/callee.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -570,29 +570,30 @@ pub fn trans_lang_call_with_type_params(bcx: @mut Block,
570570
}
571571

572572

573-
struct CalleeTranslationVisitor;
573+
struct CalleeTranslationVisitor {
574+
flag: bool,
575+
}
574576

575-
impl Visitor<@mut bool> for CalleeTranslationVisitor {
577+
impl Visitor<()> for CalleeTranslationVisitor {
576578

577-
fn visit_item(&mut self, _:@ast::item, _:@mut bool) { }
579+
fn visit_item(&mut self, _:@ast::item, _:()) { }
578580

579-
fn visit_expr(&mut self, e:@ast::Expr, cx:@mut bool) {
581+
fn visit_expr(&mut self, e:@ast::Expr, _:()) {
580582

581-
if !*cx {
583+
if !self.flag {
582584
match e.node {
583-
ast::ExprRet(_) => *cx = true,
584-
_ => visit::walk_expr(self, e, cx),
585+
ast::ExprRet(_) => self.flag = true,
586+
_ => visit::walk_expr(self, e, ()),
585587
}
586588
}
587589
}
588590

589591
}
590592

591593
pub fn body_contains_ret(body: &ast::Block) -> bool {
592-
let cx = @mut false;
593-
let mut v = CalleeTranslationVisitor;
594-
visit::walk_block(&mut v, body, cx);
595-
*cx
594+
let mut v = CalleeTranslationVisitor{ flag: false };
595+
visit::walk_block(&mut v, body, ());
596+
v.flag
596597
}
597598

598599
pub fn trans_call_inner(in_cx: @mut Block,

0 commit comments

Comments
 (0)