Skip to content

Commit 1676e77

Browse files
committed
librustc: Remove garbage-collected functions from util/common.
1 parent 7796d51 commit 1676e77

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/librustc/util/common.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ pub fn field_exprs(fields: ~[ast::Field]) -> ~[@ast::Expr] {
6060
fields.map(|f| f.expr)
6161
}
6262

63-
struct LoopQueryVisitor {
64-
p: @fn(&ast::Expr_) -> bool
63+
struct LoopQueryVisitor<'self> {
64+
p: &'self fn(&ast::Expr_) -> bool
6565
}
6666

67-
impl Visitor<@mut bool> for LoopQueryVisitor {
68-
fn visit_expr(&mut self, e:@ast::Expr, flag:@mut bool) {
67+
impl<'self> Visitor<@mut bool> for LoopQueryVisitor<'self> {
68+
fn visit_expr(&mut self, e: @ast::Expr, flag: @mut bool) {
6969
*flag |= (self.p)(&e.node);
7070
match e.node {
7171
// Skip inner loops, since a break in the inner loop isn't a
@@ -78,29 +78,33 @@ impl Visitor<@mut bool> for LoopQueryVisitor {
7878

7979
// Takes a predicate p, returns true iff p is true for any subexpressions
8080
// of b -- skipping any inner loops (loop, while, loop_body)
81-
pub fn loop_query(b: &ast::Block, p: @fn(&ast::Expr_) -> bool) -> bool {
81+
pub fn loop_query(b: &ast::Block, p: &fn(&ast::Expr_) -> bool) -> bool {
8282
let rs = @mut false;
83-
let mut v = LoopQueryVisitor { p: p };
83+
let mut v = LoopQueryVisitor {
84+
p: p,
85+
};
8486
visit::walk_block(&mut v, b, rs);
8587
return *rs;
8688
}
8789

88-
struct BlockQueryVisitor {
89-
p: @fn(@ast::Expr) -> bool
90+
struct BlockQueryVisitor<'self> {
91+
p: &'self fn(@ast::Expr) -> bool
9092
}
9193

92-
impl Visitor<@mut bool> for BlockQueryVisitor {
93-
fn visit_expr(&mut self, e:@ast::Expr, flag:@mut bool) {
94+
impl<'self> Visitor<@mut bool> for BlockQueryVisitor<'self> {
95+
fn visit_expr(&mut self, e: @ast::Expr, flag: @mut bool) {
9496
*flag |= (self.p)(e);
9597
visit::walk_expr(self, e, flag)
9698
}
9799
}
98100

99101
// Takes a predicate p, returns true iff p is true for any subexpressions
100102
// of b -- skipping any inner loops (loop, while, loop_body)
101-
pub fn block_query(b: &ast::Block, p: @fn(@ast::Expr) -> bool) -> bool {
103+
pub fn block_query(b: &ast::Block, p: &fn(@ast::Expr) -> bool) -> bool {
102104
let rs = @mut false;
103-
let mut v = BlockQueryVisitor { p: p };
105+
let mut v = BlockQueryVisitor {
106+
p: p,
107+
};
104108
visit::walk_block(&mut v, b, rs);
105109
return *rs;
106110
}

0 commit comments

Comments
 (0)