@@ -48,8 +48,8 @@ fn find_rust_files(files: &mutable [str], path: &str) {
48
48
}
49
49
}
50
50
51
- fn safe_to_steal ( e : ast:: expr_ ) -> bool {
52
- alt e {
51
+ fn safe_to_steal_expr ( e : & @ ast:: expr ) -> bool {
52
+ alt e. node {
53
53
54
54
// https://github.com/graydon/rust/issues/890
55
55
ast:: expr_lit ( lit) {
@@ -89,17 +89,19 @@ fn safe_to_steal(e: ast::expr_) -> bool {
89
89
}
90
90
}
91
91
92
+ // Not type-parameterized: https://github.com/graydon/rust/issues/898
93
+ fn stash_expr_if ( c : fn ( & @ast:: expr) ->bool, es: @mutable [ ast:: expr] , e: & @ast:: expr) {
94
+ if c ( e) {
95
+ * es += [ * e] ;
96
+ } else { /* now my indices are wrong :( */ }
97
+ }
98
+
92
99
fn steal_exprs ( crate : & ast:: crate ) -> [ ast:: expr ] {
93
100
let exprs: @mutable [ ast:: expr ] = @mutable [ ] ;
94
- // "Stash" is not type-parameterized because of the need for safe_to_steal
95
- fn stash_expr ( es : @mutable [ ast:: expr ] , e : & @ast:: expr ) {
96
- if safe_to_steal ( e. node ) {
97
- * es += [ * e] ;
98
- } else { /* now my indices are wrong :( */ }
99
- }
100
- let v =
101
- visit:: mk_simple_visitor ( @{ visit_expr: bind stash_expr ( exprs, _)
102
- with * visit:: default_simple_visitor ( ) } ) ;
101
+ let v = visit:: mk_simple_visitor ( @{
102
+ visit_expr: bind stash_expr_if ( safe_to_steal_expr, exprs, _)
103
+ with * visit:: default_simple_visitor ( )
104
+ } ) ;
103
105
visit:: visit_crate ( crate , ( ) , v) ; ;
104
106
* exprs
105
107
}
0 commit comments