about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-08-30 18:00:38 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-09-23 18:23:21 -0700
commit9a4de3f3058ddb2cd43863c7c2723cec3d0fc30a (patch)
tree1e288570b1c33e5fc7579805015d223ebe249336 /src/libsyntax
parente95996399fe6d306a206082eb1a49189c5afe878 (diff)
downloadrust-9a4de3f3058ddb2cd43863c7c2723cec3d0fc30a.tar.gz
rust-9a4de3f3058ddb2cd43863c7c2723cec3d0fc30a.zip
libsyntax: Introduce routines and remove all `@fn`s from libsyntax save the old visitor
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/fmt.rs2
-rw-r--r--src/libsyntax/fold.rs36
2 files changed, 11 insertions, 27 deletions
diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs
index 9adb02ecc98..d48fa03c0ef 100644
--- a/src/libsyntax/ext/fmt.rs
+++ b/src/libsyntax/ext/fmt.rs
@@ -38,7 +38,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
     fn parse_fmt_err_(cx: @ExtCtxt, sp: Span, msg: &str) -> ! {
         cx.span_fatal(sp, msg);
     }
-    let parse_fmt_err: @fn(&str) -> ! = |s| parse_fmt_err_(cx, fmtspan, s);
+    let parse_fmt_err: &fn(&str) -> ! = |s| parse_fmt_err_(cx, fmtspan, s);
     let pieces = parse_fmt_string(fmt, parse_fmt_err);
     MRExpr(pieces_to_expr(cx, sp, pieces, args))
 }
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 18ddee34171..66fe125aef4 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -869,35 +869,19 @@ mod test {
     use parse::token;
     use print::pprust;
     use super::*;
-
-    struct IdentFolder {
-        f: @fn(ast::ident)->ast::ident,
-    }
-
-    impl ast_fold for IdentFolder {
-        fn fold_ident(@self, i: ident) -> ident {
-            (self.f)(i)
-        }
-    }
-
-    // taken from expand
-    // given a function from idents to idents, produce
-    // an ast_fold that applies that function:
-    pub fn fun_to_ident_folder(f: @fn(ast::ident)->ast::ident) -> @ast_fold {
-        @IdentFolder {
-            f: f,
-        } as @ast_fold
-    }
-
+    
     // this version doesn't care about getting comments or docstrings in.
     fn fake_print_crate(s: @pprust::ps, crate: &ast::Crate) {
         pprust::print_mod(s, &crate.module, crate.attrs);
     }
 
     // change every identifier to "zz"
-    pub fn to_zz() -> @fn(ast::Ident)->ast::Ident {
-        let zz_id = token::str_to_ident("zz");
-        |_id| {zz_id}
+    struct ToZzIdentFolder;
+
+    impl ast_fold for ToZzIdentFolder {
+        fn fold_ident(&self, _: ident) -> ident {
+            token::str_to_ident("zz")
+        }
     }
 
     // maybe add to expand.rs...
@@ -917,7 +901,7 @@ mod test {
 
     // make sure idents get transformed everywhere
     #[test] fn ident_transformation () {
-        let zz_fold = fun_to_ident_folder(to_zz());
+        let zz_fold = ToZzIdentFolder;
         let ast = string_to_crate(@"#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}");
         assert_pred!(matches_codepattern,
                      "matches_codepattern",
@@ -928,7 +912,7 @@ mod test {
 
     // even inside macro defs....
     #[test] fn ident_transformation_in_defs () {
-        let zz_fold = fun_to_ident_folder(to_zz());
+        let zz_fold = ToZzIdentFolder;
         let ast = string_to_crate(@"macro_rules! a {(b $c:expr $(d $e:token)f+
 => (g $(d $d $e)+))} ");
         assert_pred!(matches_codepattern,
@@ -940,7 +924,7 @@ mod test {
 
     // and in cast expressions... this appears to be an existing bug.
     #[test] fn ident_transformation_in_types () {
-        let zz_fold = fun_to_ident_folder(to_zz());
+        let zz_fold = ToZzIdentFolder;
         let ast = string_to_crate(@"fn a() {let z = 13 as int;}");
         assert_pred!(matches_codepattern,
                      "matches_codepattern",