about summary refs log tree commit diff
path: root/src/comp/front
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-07-27 14:19:39 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-07-27 15:54:33 +0200
commitdf7f21db093b0f206048b18e977161f91b7c28f1 (patch)
tree36c56d12572266bd0b8d2b3379e52d04bf0e9152 /src/comp/front
parent0e3ee39c41462652f41993a5610265abea6daa96 (diff)
downloadrust-df7f21db093b0f206048b18e977161f91b7c28f1.tar.gz
rust-df7f21db093b0f206048b18e977161f91b7c28f1.zip
Reformat for new syntax
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/attr.rs216
-rw-r--r--src/comp/front/config.rs152
-rw-r--r--src/comp/front/test.rs459
3 files changed, 394 insertions, 433 deletions
diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs
index 667c785debf..a8361ba64ee 100644
--- a/src/comp/front/attr.rs
+++ b/src/comp/front/attr.rs
@@ -29,182 +29,159 @@ export mk_attr;
 
 // From a list of crate attributes get only the meta_items that impact crate
 // linkage
-fn find_linkage_metas(&ast::attribute[] attrs) -> (@ast::meta_item)[] {
-    let (@ast::meta_item)[] metas = ~[];
-    for (ast::attribute attr in find_attrs_by_name(attrs, "link")) {
-        alt (attr.node.value.node) {
-            case (ast::meta_list(_, ?items)) { metas += items; }
-            case (_) {
-                log "ignoring link attribute that has incorrect type";
-            }
+fn find_linkage_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] {
+    let metas: (@ast::meta_item)[] = ~[];
+    for attr: ast::attribute  in find_attrs_by_name(attrs, "link") {
+        alt attr.node.value.node {
+          ast::meta_list(_, items) { metas += items; }
+          _ { log "ignoring link attribute that has incorrect type"; }
         }
     }
     ret metas;
 }
 
 // Search a list of attributes and return only those with a specific name
-fn find_attrs_by_name(&ast::attribute[] attrs,
-                      ast::ident name) -> ast::attribute[] {
-    auto filter = bind fn(&ast::attribute a,
-                          ast::ident name) -> option::t[ast::attribute] {
-        if (get_attr_name(a) == name) {
-            option::some(a)
-        } else {
-            option::none
-        }
-    } (_, name);
+fn find_attrs_by_name(attrs: &ast::attribute[], name: ast::ident) ->
+   ast::attribute[] {
+    let filter =
+        bind fn (a: &ast::attribute, name: ast::ident) ->
+                option::t[ast::attribute] {
+                 if get_attr_name(a) == name {
+                     option::some(a)
+                 } else { option::none }
+             }(_, name);
     ret ivec::filter_map(filter, attrs);
 }
 
-fn get_attr_name(&ast::attribute attr) -> ast::ident {
+fn get_attr_name(attr: &ast::attribute) -> ast::ident {
     get_meta_item_name(@attr.node.value)
 }
 
-fn find_meta_items_by_name(&(@ast::meta_item)[] metas,
-                           ast::ident name) -> (@ast::meta_item)[] {
-    auto filter = bind fn(&@ast::meta_item m,
-                          ast::ident name) -> option::t[@ast::meta_item] {
-        if (get_meta_item_name(m) == name) {
-            option::some(m)
-        } else {
-            option::none
-        }
-    } (_, name);
+fn find_meta_items_by_name(metas: &(@ast::meta_item)[], name: ast::ident) ->
+   (@ast::meta_item)[] {
+    let filter =
+        bind fn (m: &@ast::meta_item, name: ast::ident) ->
+                option::t[@ast::meta_item] {
+                 if get_meta_item_name(m) == name {
+                     option::some(m)
+                 } else { option::none }
+             }(_, name);
     ret ivec::filter_map(filter, metas);
 }
 
-fn get_meta_item_name(&@ast::meta_item meta) -> ast::ident {
-    alt (meta.node) {
-        case (ast::meta_word(?n)) { n }
-        case (ast::meta_name_value(?n, _)) { n }
-        case (ast::meta_list(?n, _)) { n }
+fn get_meta_item_name(meta: &@ast::meta_item) -> ast::ident {
+    alt meta.node {
+      ast::meta_word(n) { n }
+      ast::meta_name_value(n, _) { n }
+      ast::meta_list(n, _) { n }
     }
 }
 
 // Gets the string value if the meta_item is a meta_name_value variant
 // containing a string, otherwise none
-fn get_meta_item_value_str(&@ast::meta_item meta) -> option::t[str] {
-    alt (meta.node) {
-        case (ast::meta_name_value(_, ?v)) {
-            alt (v.node) {
-                case (ast::lit_str(?s, _)) {
-                    option::some(s)
-                }
-                case (_) { option::none }
-            }
+fn get_meta_item_value_str(meta: &@ast::meta_item) -> option::t[str] {
+    alt meta.node {
+      ast::meta_name_value(_, v) {
+        alt v.node {
+          ast::lit_str(s, _) { option::some(s) }
+          _ { option::none }
         }
-        case (_) { option::none }
+      }
+      _ { option::none }
     }
 }
 
-fn attr_meta(&ast::attribute attr) -> @ast::meta_item { @attr.node.value }
+fn attr_meta(attr: &ast::attribute) -> @ast::meta_item { @attr.node.value }
 
 // Get the meta_items from inside a vector of attributes
-fn attr_metas(&ast::attribute[] attrs) -> (@ast::meta_item)[] {
-    auto mitems = ~[];
-    for (ast::attribute a in attrs) { mitems += ~[attr_meta(a)]; }
+fn attr_metas(attrs: &ast::attribute[]) -> (@ast::meta_item)[] {
+    let mitems = ~[];
+    for a: ast::attribute  in attrs { mitems += ~[attr_meta(a)]; }
     ret mitems;
 }
 
-fn eq(@ast::meta_item a, @ast::meta_item b) -> bool {
-    ret alt (a.node) {
-        case (ast::meta_word(?na)) {
-            alt (b.node) {
-                case(ast::meta_word(?nb)) { na == nb }
-                case(_) { false }
+fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
+    ret alt a.node {
+          ast::meta_word(na) {
+            alt b.node { ast::meta_word(nb) { na == nb } _ { false } }
+          }
+          ast::meta_name_value(na, va) {
+            alt b.node {
+              ast::meta_name_value(nb, vb) { na == nb && va.node == vb.node }
+              _ { false }
             }
-        }
-        case (ast::meta_name_value(?na, ?va)) {
-            alt (b.node) {
-                case (ast::meta_name_value(?nb, ?vb)) {
-                    na == nb && va.node == vb.node
-                }
-                case (_) { false }
-            }
-        }
-        case (ast::meta_list(?na, ?la)) {
+          }
+          ast::meta_list(na, la) {
+
             // FIXME (#607): Needs implementing
             // This involves probably sorting the list by name and
             // meta_item variant
             fail "unimplemented meta_item variant"
+          }
         }
-    }
 }
 
-fn contains(&(@ast::meta_item)[] haystack, @ast::meta_item needle) -> bool {
+fn contains(haystack: &(@ast::meta_item)[], needle: @ast::meta_item) -> bool {
     log #fmt("looking for %s",
              syntax::print::pprust::meta_item_to_str(*needle));
-    for (@ast::meta_item item in haystack) {
+    for item: @ast::meta_item  in haystack {
         log #fmt("looking in %s",
                  syntax::print::pprust::meta_item_to_str(*item));
-        if (eq(item, needle)) {
-            log "found it!";
-            ret true;
-        }
+        if eq(item, needle) { log "found it!"; ret true; }
     }
     log "found it not :(";
     ret false;
 }
 
-fn contains_name(&(@ast::meta_item)[] metas, ast::ident name) -> bool {
-    auto matches = find_meta_items_by_name(metas, name);
+fn contains_name(metas: &(@ast::meta_item)[], name: ast::ident) -> bool {
+    let matches = find_meta_items_by_name(metas, name);
     ret ivec::len(matches) > 0u;
 }
 
 // FIXME: This needs to sort by meta_item variant in addition to the item name
-fn sort_meta_items(&(@ast::meta_item)[] items) -> (@ast::meta_item)[] {
-    fn lteq(&@ast::meta_item ma, &@ast::meta_item mb) -> bool {
-        fn key(&@ast::meta_item m) -> ast::ident {
-            alt (m.node) {
-                case (ast::meta_word(?name)) {
-                    name
-                }
-                case (ast::meta_name_value(?name, _)) {
-                    name
-                }
-                case (ast::meta_list(?name, _)) {
-                    name
-                }
+fn sort_meta_items(items: &(@ast::meta_item)[]) -> (@ast::meta_item)[] {
+    fn lteq(ma: &@ast::meta_item, mb: &@ast::meta_item) -> bool {
+        fn key(m: &@ast::meta_item) -> ast::ident {
+            alt m.node {
+              ast::meta_word(name) { name }
+              ast::meta_name_value(name, _) { name }
+              ast::meta_list(name, _) { name }
             }
         }
         ret key(ma) <= key(mb);
     }
 
     // This is sort of stupid here, converting to a vec of mutables and back
-    let (@ast::meta_item)[mutable] v = ~[mutable];
-    for (@ast::meta_item mi in items) {
-        v += ~[mutable mi];
-    }
+    let v: (@ast::meta_item)[mutable ] = ~[mutable ];
+    for mi: @ast::meta_item  in items { v += ~[mutable mi]; }
 
     std::sort::ivector::quick_sort(lteq, v);
 
-    let (@ast::meta_item)[] v2 = ~[];
-    for (@ast::meta_item mi in v) {
-        v2 += ~[mi];
-    }
+    let v2: (@ast::meta_item)[] = ~[];
+    for mi: @ast::meta_item  in v { v2 += ~[mi]; }
     ret v2;
 }
 
-fn remove_meta_items_by_name(&(@ast::meta_item)[] items,
-                             str name) -> (@ast::meta_item)[] {
+fn remove_meta_items_by_name(items: &(@ast::meta_item)[], name: str) ->
+   (@ast::meta_item)[] {
 
-    auto filter = bind fn(&@ast::meta_item item,
-                          str name) -> option::t[@ast::meta_item] {
-        if (get_meta_item_name(item) != name) {
-            option::some(item)
-        } else {
-            option::none
-        }
-    } (_, name);
+    let filter =
+        bind fn (item: &@ast::meta_item, name: str) ->
+                option::t[@ast::meta_item] {
+                 if get_meta_item_name(item) != name {
+                     option::some(item)
+                 } else { option::none }
+             }(_, name);
 
     ret ivec::filter_map(filter, items);
 }
 
-fn require_unique_names(&session::session sess, &(@ast::meta_item)[] metas) {
-    auto map = map::mk_hashmap[str, ()](str::hash, str::eq);
-    for (@ast::meta_item meta in metas) {
-        auto name = get_meta_item_name(meta);
-        if (map.contains_key(name)) {
+fn require_unique_names(sess: &session::session,
+                        metas: &(@ast::meta_item)[]) {
+    let map = map::mk_hashmap[str, ()](str::hash, str::eq);
+    for meta: @ast::meta_item  in metas {
+        let name = get_meta_item_name(meta);
+        if map.contains_key(name) {
             sess.span_fatal(meta.span,
                             #fmt("duplicate meta item `%s`", name));
         }
@@ -212,31 +189,30 @@ fn require_unique_names(&session::session sess, &(@ast::meta_item)[] metas) {
     }
 }
 
-fn span[T](&T item) -> ast::spanned[T] {
-    ret rec(node=item, span=rec(lo=0u, hi=0u));
+fn span[T](item: &T) -> ast::spanned[T] {
+    ret {node: item, span: {lo: 0u, hi: 0u}};
 }
 
-fn mk_name_value_item_str(ast::ident name, str value) -> @ast::meta_item {
-    auto value_lit = span(ast::lit_str(value, ast::sk_rc));
+fn mk_name_value_item_str(name: ast::ident, value: str) -> @ast::meta_item {
+    let value_lit = span(ast::lit_str(value, ast::sk_rc));
     ret mk_name_value_item(name, value_lit);
 }
 
-fn mk_name_value_item(ast::ident name, ast::lit value) -> @ast::meta_item {
+fn mk_name_value_item(name: ast::ident, value: ast::lit) -> @ast::meta_item {
     ret @span(ast::meta_name_value(name, value));
 }
 
-fn mk_list_item(ast::ident name, &(@ast::meta_item)[] items)
-        -> @ast::meta_item {
+fn mk_list_item(name: ast::ident, items: &(@ast::meta_item)[]) ->
+   @ast::meta_item {
     ret @span(ast::meta_list(name, items));
 }
 
-fn mk_word_item(ast::ident name) -> @ast::meta_item {
+fn mk_word_item(name: ast::ident) -> @ast::meta_item {
     ret @span(ast::meta_word(name));
 }
 
-fn mk_attr(@ast::meta_item item) -> ast::attribute {
-    ret span(rec(style = ast::attr_inner,
-                 value = *item));
+fn mk_attr(item: @ast::meta_item) -> ast::attribute {
+    ret span({style: ast::attr_inner, value: *item});
 }
 
 //
diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs
index 592305b4a73..1107e69875f 100644
--- a/src/comp/front/config.rs
+++ b/src/comp/front/config.rs
@@ -8,124 +8,120 @@ export strip_unconfigured_items;
 
 // Support conditional compilation by transforming the AST, stripping out
 // any items that do not belong in the current configuration
-fn strip_unconfigured_items(@ast::crate crate) -> @ast::crate {
-    auto cfg = crate.node.config;
+fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate {
+    let cfg = crate.node.config;
 
-    auto precursor = rec(fold_mod = bind fold_mod(cfg, _, _),
-                         fold_block = bind fold_block(cfg, _, _),
-                         fold_native_mod = bind fold_native_mod(cfg, _, _)
-                         with *fold::default_ast_fold());
+    let precursor =
+        {fold_mod: bind fold_mod(cfg, _, _),
+         fold_block: bind fold_block(cfg, _, _),
+         fold_native_mod: bind fold_native_mod(cfg, _, _)
+            with *fold::default_ast_fold()};
 
-    auto fold = fold::make_fold(precursor);
-    auto res = @fold.fold_crate(*crate);
+    let fold = fold::make_fold(precursor);
+    let res = @fold.fold_crate(*crate);
     // FIXME: This is necessary to break a circular reference
     fold::dummy_out(fold);
     ret res;
 }
 
-fn filter_item(&ast::crate_cfg cfg,
-               &@ast::item item) -> option::t[@ast::item] {
-    if (item_in_cfg(cfg, item)) {
-        option::some(item)
-    } else {
-        option::none
-    }
+fn filter_item(cfg: &ast::crate_cfg, item: &@ast::item) ->
+   option::t[@ast::item] {
+    if item_in_cfg(cfg, item) { option::some(item) } else { option::none }
 }
 
-fn fold_mod(&ast::crate_cfg cfg, &ast::_mod m,
-              fold::ast_fold fld) -> ast::_mod {
-    auto filter = bind filter_item(cfg, _);
-    auto filtered_items = ivec::filter_map(filter, m.items);
-    ret rec(view_items=ivec::map(fld.fold_view_item, m.view_items),
-            items=ivec::map(fld.fold_item, filtered_items));
+fn fold_mod(cfg: &ast::crate_cfg, m: &ast::_mod, fld: fold::ast_fold) ->
+   ast::_mod {
+    let filter = bind filter_item(cfg, _);
+    let filtered_items = ivec::filter_map(filter, m.items);
+    ret {view_items: ivec::map(fld.fold_view_item, m.view_items),
+         items: ivec::map(fld.fold_item, filtered_items)};
 }
 
-fn filter_native_item(&ast::crate_cfg cfg, &@ast::native_item item)
-    -> option::t[@ast::native_item] {
-    if (native_item_in_cfg(cfg, item)) {
+fn filter_native_item(cfg: &ast::crate_cfg, item: &@ast::native_item) ->
+   option::t[@ast::native_item] {
+    if native_item_in_cfg(cfg, item) {
         option::some(item)
-    } else {
-        option::none
-    }
+    } else { option::none }
 }
 
-fn fold_native_mod(&ast::crate_cfg cfg, &ast::native_mod nm,
-                   fold::ast_fold fld) -> ast::native_mod {
-    auto filter = bind filter_native_item(cfg, _);
-    auto filtered_items = ivec::filter_map(filter, nm.items);
-    ret rec(native_name=nm.native_name,
-            abi=nm.abi,
-            view_items=ivec::map(fld.fold_view_item, nm.view_items),
-            items=filtered_items);
+fn fold_native_mod(cfg: &ast::crate_cfg, nm: &ast::native_mod,
+                   fld: fold::ast_fold) -> ast::native_mod {
+    let filter = bind filter_native_item(cfg, _);
+    let filtered_items = ivec::filter_map(filter, nm.items);
+    ret {native_name: nm.native_name,
+         abi: nm.abi,
+         view_items: ivec::map(fld.fold_view_item, nm.view_items),
+         items: filtered_items};
 }
 
-fn filter_stmt(&ast::crate_cfg cfg,
-               &@ast::stmt stmt) -> option::t[@ast::stmt] {
-    alt (stmt.node) {
-        case (ast::stmt_decl(?decl, _)) {
-            alt (decl.node) {
-                case (ast::decl_item(?item)) {
-                    if (item_in_cfg(cfg, item)) {
-                        option::some(stmt)
-                    } else {
-                        option::none
-                    }
-                }
-                case (_) { option::some(stmt) }
-            }
+fn filter_stmt(cfg: &ast::crate_cfg, stmt: &@ast::stmt) ->
+   option::t[@ast::stmt] {
+    alt stmt.node {
+      ast::stmt_decl(decl, _) {
+        alt decl.node {
+          ast::decl_item(item) {
+            if item_in_cfg(cfg, item) {
+                option::some(stmt)
+            } else { option::none }
+          }
+          _ { option::some(stmt) }
         }
-        case (_) { option::some(stmt) }
+      }
+      _ { option::some(stmt) }
     }
 }
 
-fn fold_block(&ast::crate_cfg cfg, &ast::blk_ b,
-              fold::ast_fold fld) -> ast::blk_  {
-    auto filter = bind filter_stmt(cfg, _);
-    auto filtered_stmts = ivec::filter_map(filter, b.stmts);
-    ret rec(stmts=ivec::map(fld.fold_stmt, filtered_stmts),
-            expr=option::map(fld.fold_expr, b.expr),
-            id=b.id);
+fn fold_block(cfg: &ast::crate_cfg, b: &ast::blk_, fld: fold::ast_fold) ->
+   ast::blk_ {
+    let filter = bind filter_stmt(cfg, _);
+    let filtered_stmts = ivec::filter_map(filter, b.stmts);
+    ret {stmts: ivec::map(fld.fold_stmt, filtered_stmts),
+         expr: option::map(fld.fold_expr, b.expr),
+         id: b.id};
 }
 
-fn item_in_cfg(&ast::crate_cfg cfg, &@ast::item item) -> bool {
+fn item_in_cfg(cfg: &ast::crate_cfg, item: &@ast::item) -> bool {
     ret in_cfg(cfg, item.attrs);
 }
 
-fn native_item_in_cfg(&ast::crate_cfg cfg, &@ast::native_item item) -> bool {
+fn native_item_in_cfg(cfg: &ast::crate_cfg, item: &@ast::native_item) ->
+   bool {
     ret in_cfg(cfg, item.attrs);
 }
 
 // Determine if an item should be translated in the current crate
 // configuration based on the item's attributes
-fn in_cfg(&ast::crate_cfg cfg, &ast::attribute[] attrs) -> bool {
+fn in_cfg(cfg: &ast::crate_cfg, attrs: &ast::attribute[]) -> bool {
 
     // The "cfg" attributes on the item
-    auto item_cfg_attrs = attr::find_attrs_by_name(attrs, "cfg");
-    auto item_has_cfg_attrs = ivec::len(item_cfg_attrs) > 0u;
-    if (!item_has_cfg_attrs) { ret true; }
+    let item_cfg_attrs = attr::find_attrs_by_name(attrs, "cfg");
+    let item_has_cfg_attrs = ivec::len(item_cfg_attrs) > 0u;
+    if !item_has_cfg_attrs { ret true; }
 
     // Pull the inner meta_items from the #[cfg(meta_item, ...)]  attributes,
     // so we can match against them. This is the list of configurations for
     // which the item is valid
-    auto item_cfg_metas = {
-        fn extract_metas(&(@ast::meta_item)[] inner_items,
-                         &@ast::meta_item cfg_item)
-        -> (@ast::meta_item)[] {
-
-            alt (cfg_item.node) {
-                case (ast::meta_list(?name, ?items)) {
-                    assert name == "cfg";
+    let 
+
+        item_cfg_metas =
+        {
+            fn extract_metas(inner_items: &(@ast::meta_item)[],
+                             cfg_item: &@ast::meta_item) ->
+               (@ast::meta_item)[] {
+                alt cfg_item.node {
+                  ast::meta_list(name, items) {
+                    assert (name == "cfg");
                     inner_items + items
+                  }
+                  _ { inner_items }
                 }
-                case (_) { inner_items }
             }
-        }
-        auto cfg_metas = attr::attr_metas(item_cfg_attrs);
-        ivec::foldl(extract_metas, ~[], cfg_metas)
-    };
+            let cfg_metas = attr::attr_metas(item_cfg_attrs);
+            ivec::foldl(extract_metas, ~[], cfg_metas)
+        };
 
-    for (@ast::meta_item cfg_mi in item_cfg_metas) {
-        if (attr::contains(cfg, cfg_mi)) { ret true; }
+    for cfg_mi: @ast::meta_item  in item_cfg_metas {
+        if attr::contains(cfg, cfg_mi) { ret true; }
     }
 
     ret false;
diff --git a/src/comp/front/test.rs b/src/comp/front/test.rs
index dc04c8b37a1..8f4afc86877 100644
--- a/src/comp/front/test.rs
+++ b/src/comp/front/test.rs
@@ -9,125 +9,124 @@ import front::attr;
 
 export modify_for_testing;
 
-type node_id_gen = @fn() -> ast::node_id;
+type node_id_gen = @fn() -> ast::node_id ;
 
-type test = rec(ast::ident[] path,
-                bool ignore);
+type test = {path: ast::ident[], ignore: bool};
 
-type test_ctxt = @rec(node_id_gen next_node_id,
-                      mutable ast::ident[] path,
-                      mutable test[] testfns);
+type test_ctxt =
+    @{next_node_id: node_id_gen,
+      mutable path: ast::ident[],
+      mutable testfns: test[]};
 
 // Traverse the crate, collecting all the test functions, eliding any
 // existing main functions, and synthesizing a main test harness
-fn modify_for_testing(@ast::crate crate) -> @ast::crate {
+fn modify_for_testing(crate: @ast::crate) -> @ast::crate {
 
     // FIXME: This hackasaurus assumes that 200000 is a safe number to start
     // generating node_ids at (which is totally not the case). pauls is going
     // to land a patch that puts parse_sess into session, which will give us
     // access to the real next node_id.
-    auto next_node_id = @mutable 200000;
-    auto next_node_id_fn = @bind fn(@mutable ast::node_id next_node_id)
-        -> ast::node_id {
-        auto this_node_id = *next_node_id;
-        *next_node_id = next_node_id + 1;
-        ret this_node_id;
-    } (next_node_id);
-
-    let test_ctxt cx = @rec(next_node_id = next_node_id_fn,
-                            mutable path = ~[],
-                            mutable testfns = ~[]);
-
-    auto precursor = rec(fold_crate = bind fold_crate(cx, _, _),
-                         fold_item = bind fold_item(cx, _, _),
-                         fold_mod = bind fold_mod(cx, _, _)
-                         with *fold::default_ast_fold());
-
-    auto fold = fold::make_fold(precursor);
-    auto res = @fold.fold_crate(*crate);
+    let next_node_id = @mutable 200000;
+    let next_node_id_fn =
+        @bind fn (next_node_id: @mutable ast::node_id) -> ast::node_id {
+                  let this_node_id = *next_node_id;
+                  *next_node_id = next_node_id + 1;
+                  ret this_node_id;
+              }(next_node_id);
+
+    let cx: test_ctxt =
+        @{next_node_id: next_node_id_fn,
+          mutable path: ~[],
+          mutable testfns: ~[]};
+
+    let precursor =
+        {fold_crate: bind fold_crate(cx, _, _),
+         fold_item: bind fold_item(cx, _, _),
+         fold_mod: bind fold_mod(cx, _, _) with *fold::default_ast_fold()};
+
+    let fold = fold::make_fold(precursor);
+    let res = @fold.fold_crate(*crate);
     // FIXME: This is necessary to break a circular reference
     fold::dummy_out(fold);
     ret res;
 }
 
-fn fold_mod(&test_ctxt cx, &ast::_mod m,
-            fold::ast_fold fld) -> ast::_mod {
+fn fold_mod(cx: &test_ctxt, m: &ast::_mod, fld: fold::ast_fold) -> ast::_mod {
 
     // Remove any defined main function from the AST so it doesn't clash with
     // the one we're going to add.  FIXME: This is sloppy. Instead we should
     // have some mechanism to indicate to the translation pass which function
     // we want to be main.
-    fn nomain(&@ast::item item) -> option::t[@ast::item] {
-        alt (item.node) {
-            ast::item_fn(?f, _) {
-                if (item.ident == "main") { option::none }
-                else { option::some(item) }
-            }
-            _ { option::some(item) }
+    fn nomain(item: &@ast::item) -> option::t[@ast::item] {
+        alt item.node {
+          ast::item_fn(f, _) {
+            if item.ident == "main" {
+                option::none
+            } else { option::some(item) }
+          }
+          _ { option::some(item) }
         }
     }
 
-    auto mod_nomain = rec(view_items=m.view_items,
-                          items=ivec::filter_map(nomain, m.items));
+    let mod_nomain =
+        {view_items: m.view_items, items: ivec::filter_map(nomain, m.items)};
     ret fold::noop_fold_mod(mod_nomain, fld);
 }
 
-fn fold_crate(&test_ctxt cx, &ast::crate_ c,
-              fold::ast_fold fld) -> ast::crate_ {
-    auto folded = fold::noop_fold_crate(c, fld);
+fn fold_crate(cx: &test_ctxt, c: &ast::crate_, fld: fold::ast_fold) ->
+   ast::crate_ {
+    let folded = fold::noop_fold_crate(c, fld);
 
     // Add a special __test module to the crate that will contain code
     // generated for the test harness
-    ret rec(module = add_test_module(cx, folded.module)
-            with folded);
+    ret {module: add_test_module(cx, folded.module) with folded};
 }
 
 
-fn fold_item(&test_ctxt cx, &@ast::item i,
-             fold::ast_fold fld) -> @ast::item {
+fn fold_item(cx: &test_ctxt, i: &@ast::item, fld: fold::ast_fold) ->
+   @ast::item {
 
     cx.path += ~[i.ident];
     log #fmt("current path: %s", ast::path_name_i(cx.path));
 
-    if (is_test_fn(i)) {
+    if is_test_fn(i) {
         log "this is a test function";
-        auto test = rec(path = cx.path,
-                        ignore = is_ignored(i));
+        let test = {path: cx.path, ignore: is_ignored(i)};
         cx.testfns += ~[test];
         log #fmt("have %u test functions", ivec::len(cx.testfns));
     }
 
-    auto res = fold::noop_fold_item(i, fld);
+    let res = fold::noop_fold_item(i, fld);
     ivec::pop(cx.path);
     ret res;
 }
 
-fn is_test_fn(&@ast::item i) -> bool {
-    auto has_test_attr =
+fn is_test_fn(i: &@ast::item) -> bool {
+    let has_test_attr =
         ivec::len(attr::find_attrs_by_name(i.attrs, "test")) > 0u;
 
-    fn has_test_signature(&@ast::item i) -> bool {
-        alt (i.node) {
-            case (ast::item_fn(?f, ?tps)) {
-                auto input_cnt = ivec::len(f.decl.inputs);
-                auto no_output = f.decl.output.node == ast::ty_nil;
-                auto tparm_cnt = ivec::len(tps);
-                input_cnt == 0u && no_output && tparm_cnt == 0u
-            }
-            case (_) { false }
+    fn has_test_signature(i: &@ast::item) -> bool {
+        alt i.node {
+          ast::item_fn(f, tps) {
+            let input_cnt = ivec::len(f.decl.inputs);
+            let no_output = f.decl.output.node == ast::ty_nil;
+            let tparm_cnt = ivec::len(tps);
+            input_cnt == 0u && no_output && tparm_cnt == 0u
+          }
+          _ { false }
         }
     }
 
     ret has_test_attr && has_test_signature(i);
 }
 
-fn is_ignored(&@ast::item i) -> bool {
+fn is_ignored(i: &@ast::item) -> bool {
     attr::contains_name(attr::attr_metas(i.attrs), "ignore")
 }
 
-fn add_test_module(&test_ctxt cx, &ast::_mod m) -> ast::_mod {
-    auto testmod = mk_test_module(cx);
-    ret rec(items=m.items + ~[testmod] with m);
+fn add_test_module(cx: &test_ctxt, m: &ast::_mod) -> ast::_mod {
+    let testmod = mk_test_module(cx);
+    ret {items: m.items + ~[testmod] with m};
 }
 
 /*
@@ -147,241 +146,231 @@ mod __test {
 
 */
 
-fn mk_test_module(&test_ctxt cx) -> @ast::item {
+fn mk_test_module(cx: &test_ctxt) -> @ast::item {
     // A function that generates a vector of test descriptors to feed to the
     // test runner
-    auto testsfn = mk_tests(cx);
+    let testsfn = mk_tests(cx);
     // The synthesized main function which will call the console test runner
     // with our list of tests
-    auto mainfn = mk_main(cx);
-    let ast::_mod testmod = rec(view_items=~[],
-                                items=~[mainfn, testsfn]);
-    auto item_ = ast::item_mod(testmod);
-    let ast::item item = rec(ident = "__test",
-                              attrs = ~[],
-                              id = cx.next_node_id(),
-                              node = item_,
-                              span = rec(lo=0u, hi=0u));
+    let mainfn = mk_main(cx);
+    let testmod: ast::_mod = {view_items: ~[], items: ~[mainfn, testsfn]};
+    let item_ = ast::item_mod(testmod);
+    let item: ast::item =
+        {ident: "__test",
+         attrs: ~[],
+         id: cx.next_node_id(),
+         node: item_,
+         span: {lo: 0u, hi: 0u}};
 
     log #fmt("Synthetic test module:\n%s\n", pprust::item_to_str(@item));
 
     ret @item;
 }
 
-fn nospan[T](&T t) -> ast::spanned[T] {
-    ret rec(node=t,
-            span=rec(lo=0u,hi=0u));
+fn nospan[T](t: &T) -> ast::spanned[T] {
+    ret {node: t, span: {lo: 0u, hi: 0u}};
 }
 
-fn mk_tests(&test_ctxt cx) -> @ast::item {
-    auto ret_ty = mk_test_desc_ivec_ty(cx);
+fn mk_tests(cx: &test_ctxt) -> @ast::item {
+    let ret_ty = mk_test_desc_ivec_ty(cx);
 
-    let ast::fn_decl decl = rec(inputs = ~[],
-                                output = ret_ty,
-                                purity = ast::impure_fn,
-                                cf = ast::return,
-                                constraints = ~[]);
-    auto proto = ast::proto_fn;
+    let decl: ast::fn_decl =
+        {inputs: ~[],
+         output: ret_ty,
+         purity: ast::impure_fn,
+         cf: ast::return,
+         constraints: ~[]};
+    let proto = ast::proto_fn;
 
     // The vector of test_descs for this crate
-    auto test_descs = mk_test_desc_vec(cx);
-
-    let ast::blk_ body_= rec(stmts = ~[],
-                               expr = option::some(test_descs),
-                               id = cx.next_node_id());
-    auto body = nospan(body_);
-
-    auto fn_ = rec(decl = decl,
-                   proto = proto,
-                   body = body);
-
-    auto item_ = ast::item_fn(fn_, ~[]);
-    let ast::item item = rec(ident = "tests",
-                             attrs = ~[],
-                             id = cx.next_node_id(),
-                             node = item_,
-                             span = rec(lo=0u, hi=0u));
+    let test_descs = mk_test_desc_vec(cx);
+
+    let body_: ast::blk_ =
+        {stmts: ~[], expr: option::some(test_descs), id: cx.next_node_id()};
+    let body = nospan(body_);
+
+    let fn_ = {decl: decl, proto: proto, body: body};
+
+    let item_ = ast::item_fn(fn_, ~[]);
+    let item: ast::item =
+        {ident: "tests",
+         attrs: ~[],
+         id: cx.next_node_id(),
+         node: item_,
+         span: {lo: 0u, hi: 0u}};
     ret @item;
 }
 
 fn empty_fn_ty() -> ast::ty {
-    auto proto = ast::proto_fn;
-    auto input_ty = ~[];
-    auto ret_ty = @nospan(ast::ty_nil);
-    auto cf = ast::return;
-    auto constrs = ~[];
+    let proto = ast::proto_fn;
+    let input_ty = ~[];
+    let ret_ty = @nospan(ast::ty_nil);
+    let cf = ast::return;
+    let constrs = ~[];
     ret nospan(ast::ty_fn(proto, input_ty, ret_ty, cf, constrs));
 }
 
 // The ast::ty of std::test::test_desc[]
-fn mk_test_desc_ivec_ty(&test_ctxt cx) -> @ast::ty {
-    let ast::path test_desc_ty_path = nospan(rec(global = false,
-                                                 idents = ~["std",
-                                                            "test",
-                                                            "test_desc"],
-                                                 types = ~[]));
+fn mk_test_desc_ivec_ty(cx: &test_ctxt) -> @ast::ty {
+    let test_desc_ty_path: ast::path =
+        nospan({global: false,
+                idents: ~["std", "test", "test_desc"],
+                types: ~[]});
 
-    let ast::ty test_desc_ty = nospan(ast::ty_path(test_desc_ty_path,
-                                                   cx.next_node_id()));
+    let test_desc_ty: ast::ty =
+        nospan(ast::ty_path(test_desc_ty_path, cx.next_node_id()));
 
-    let ast::mt ivec_mt = rec(ty = @test_desc_ty,
-                              mut = ast::imm);
+    let ivec_mt: ast::mt = {ty: @test_desc_ty, mut: ast::imm};
 
     ret @nospan(ast::ty_ivec(ivec_mt));
 }
 
-fn mk_test_desc_vec(&test_ctxt cx) -> @ast::expr {
-    log #fmt("building test vector from %u tests",
-             ivec::len(cx.testfns));
-    auto descs = ~[];
-    for (test test in cx.testfns) {
-        auto test_ = test; // Satisfy alias analysis
+fn mk_test_desc_vec(cx: &test_ctxt) -> @ast::expr {
+    log #fmt("building test vector from %u tests", ivec::len(cx.testfns));
+    let descs = ~[];
+    for test: test  in cx.testfns {
+        let test_ = test; // Satisfy alias analysis
         descs += ~[mk_test_desc_rec(cx, test_)];
     }
 
-    ret @rec(id = cx.next_node_id(),
-             node = ast::expr_vec(descs, ast::imm, ast::sk_unique),
-             span = rec(lo=0u,hi=0u));
+    ret @{id: cx.next_node_id(),
+          node: ast::expr_vec(descs, ast::imm, ast::sk_unique),
+          span: {lo: 0u, hi: 0u}};
 }
 
-fn mk_test_desc_rec(&test_ctxt cx, test test) -> @ast::expr {
-    auto path = test.path;
+fn mk_test_desc_rec(cx: &test_ctxt, test: test) -> @ast::expr {
+    let path = test.path;
 
     log #fmt("encoding %s", ast::path_name_i(path));
 
-    let ast::lit name_lit = nospan(ast::lit_str(ast::path_name_i(path),
-                                                ast::sk_rc));
-    let ast::expr name_expr = rec(id = cx.next_node_id(),
-                                  node = ast::expr_lit(@name_lit),
-                                  span = rec(lo=0u, hi=0u));
-
-    let ast::field name_field = nospan(rec(mut = ast::imm,
-                                           ident = "name",
-                                           expr = @name_expr));
-
-    let ast::path fn_path = nospan(rec(global = false,
-                                       idents = path,
-                                       types = ~[]));
-
-    let ast::expr fn_expr = rec(id = cx.next_node_id(),
-                                node = ast::expr_path(fn_path),
-                                span = rec(lo=0u, hi=0u));
-
-    let ast::field fn_field = nospan(rec(mut = ast::imm,
-                                         ident = "fn",
-                                         expr = @fn_expr));
-
-    let ast::lit ignore_lit = nospan(ast::lit_bool(test.ignore));
-
-    let ast::expr ignore_expr = rec(id = cx.next_node_id(),
-                                    node = ast::expr_lit(@ignore_lit),
-                                    span = rec(lo=0u, hi=0u));
-
-    let ast::field ignore_field = nospan(rec(mut = ast::imm,
-                                             ident = "ignore",
-                                             expr = @ignore_expr));
-
-    let ast::expr_ desc_rec_ = ast::expr_rec(~[name_field,
-                                               fn_field,
-                                               ignore_field],
-                                             option::none);
-    let ast::expr desc_rec = rec(id = cx.next_node_id(),
-                                 node = desc_rec_,
-                                 span = rec(lo=0u, hi=0u));
+    let name_lit: ast::lit =
+        nospan(ast::lit_str(ast::path_name_i(path), ast::sk_rc));
+    let name_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: ast::expr_lit(@name_lit),
+         span: {lo: 0u, hi: 0u}};
+
+    let name_field: ast::field =
+        nospan({mut: ast::imm, ident: "name", expr: @name_expr});
+
+    let fn_path: ast::path =
+        nospan({global: false, idents: path, types: ~[]});
+
+    let fn_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: ast::expr_path(fn_path),
+         span: {lo: 0u, hi: 0u}};
+
+    let fn_field: ast::field =
+        nospan({mut: ast::imm, ident: "fn", expr: @fn_expr});
+
+    let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
+
+    let ignore_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: ast::expr_lit(@ignore_lit),
+         span: {lo: 0u, hi: 0u}};
+
+    let ignore_field: ast::field =
+        nospan({mut: ast::imm, ident: "ignore", expr: @ignore_expr});
+
+    let desc_rec_: ast::expr_ =
+        ast::expr_rec(~[name_field, fn_field, ignore_field], option::none);
+    let desc_rec: ast::expr =
+        {id: cx.next_node_id(), node: desc_rec_, span: {lo: 0u, hi: 0u}};
     ret @desc_rec;
 }
 
-fn mk_main(&test_ctxt cx) -> @ast::item {
+fn mk_main(cx: &test_ctxt) -> @ast::item {
 
-    let ast::mt args_mt = rec(ty = @nospan(ast::ty_str),
-                              mut = ast::imm);
-    let ast::ty args_ty = nospan(ast::ty_vec(args_mt));
+    let args_mt: ast::mt = {ty: @nospan(ast::ty_str), mut: ast::imm};
+    let args_ty: ast::ty = nospan(ast::ty_vec(args_mt));
 
-    let ast::arg args_arg = rec(mode = ast::val,
-                                ty = @args_ty,
-                                ident = "args",
-                                id = cx.next_node_id());
+    let args_arg: ast::arg =
+        {mode: ast::val, ty: @args_ty, ident: "args", id: cx.next_node_id()};
 
-    auto ret_ty = nospan(ast::ty_nil);
+    let ret_ty = nospan(ast::ty_nil);
 
-    let ast::fn_decl decl = rec(inputs = ~[args_arg],
-                                output = @ret_ty,
-                                purity = ast::impure_fn,
-                                cf = ast::return,
-                                constraints = ~[]);
-    auto proto = ast::proto_fn;
+    let decl: ast::fn_decl =
+        {inputs: ~[args_arg],
+         output: @ret_ty,
+         purity: ast::impure_fn,
+         cf: ast::return,
+         constraints: ~[]};
+    let proto = ast::proto_fn;
 
-    auto test_main_call_expr = mk_test_main_call(cx);
+    let test_main_call_expr = mk_test_main_call(cx);
 
-    let ast::blk_ body_ = rec(stmts = ~[],
-                                expr = option::some(test_main_call_expr),
-                                id = cx.next_node_id());
-    auto body = rec(node = body_, span = rec(lo=0u, hi=0u));
+    let body_: ast::blk_ =
+        {stmts: ~[],
+         expr: option::some(test_main_call_expr),
+         id: cx.next_node_id()};
+    let body = {node: body_, span: {lo: 0u, hi: 0u}};
 
-    auto fn_ = rec(decl = decl,
-                   proto = proto,
-                   body = body);
+    let fn_ = {decl: decl, proto: proto, body: body};
 
-    auto item_ = ast::item_fn(fn_, ~[]);
-    let ast::item item = rec(ident = "main",
-                             attrs = ~[],
-                             id = cx.next_node_id(),
-                             node = item_,
-                             span = rec(lo=0u, hi=0u));
+    let item_ = ast::item_fn(fn_, ~[]);
+    let item: ast::item =
+        {ident: "main",
+         attrs: ~[],
+         id: cx.next_node_id(),
+         node: item_,
+         span: {lo: 0u, hi: 0u}};
     ret @item;
 }
 
-fn mk_test_main_call(&test_ctxt cx) -> @ast::expr {
+fn mk_test_main_call(cx: &test_ctxt) -> @ast::expr {
 
     // Get the args passed to main so we can pass the to test_main
-    let ast::path args_path = nospan(rec(global = false,
-                                         idents = ~["args"],
-                                         types = ~[]));
+    let args_path: ast::path =
+        nospan({global: false, idents: ~["args"], types: ~[]});
 
-    let ast::expr_ args_path_expr_ = ast::expr_path(args_path);
+    let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
 
-    let ast::expr args_path_expr = rec(id = cx.next_node_id(),
-                                       node = args_path_expr_,
-                                       span = rec(lo=0u, hi=0u));
+    let args_path_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: args_path_expr_,
+         span: {lo: 0u, hi: 0u}};
 
     // Call __test::test to generate the vector of test_descs
-    let ast::path test_path = nospan(rec(global = false,
-                                         idents = ~["tests"],
-                                         types = ~[]));
+    let test_path: ast::path =
+        nospan({global: false, idents: ~["tests"], types: ~[]});
 
-    let ast::expr_ test_path_expr_ = ast::expr_path(test_path);
+    let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
 
-    let ast::expr test_path_expr = rec(id = cx.next_node_id(),
-                                       node = test_path_expr_,
-                                       span = rec(lo=0u, hi=0u));
+    let test_path_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: test_path_expr_,
+         span: {lo: 0u, hi: 0u}};
 
-    let ast::expr_ test_call_expr_ = ast::expr_call(@test_path_expr, ~[]);
+    let test_call_expr_: ast::expr_ = ast::expr_call(@test_path_expr, ~[]);
 
-    let ast::expr test_call_expr = rec(id = cx.next_node_id(),
-                                       node = test_call_expr_,
-                                       span = rec(lo=0u, hi=0u));
+    let test_call_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: test_call_expr_,
+         span: {lo: 0u, hi: 0u}};
 
     // Call std::test::test_main
-    let ast::path test_main_path = nospan(rec(global = false,
-                                              idents = ~["std",
-                                                         "test",
-                                                         "test_main"],
-                                              types = ~[]));
-
-    let ast::expr_ test_main_path_expr_
-        = ast::expr_path(test_main_path);
-
-    let ast::expr test_main_path_expr = rec(id = cx.next_node_id(),
-                                            node = test_main_path_expr_,
-                                            span = rec(lo=0u, hi=0u));
-
-    let ast::expr_ test_main_call_expr_
-        = ast::expr_call(@test_main_path_expr, ~[@args_path_expr,
-                                                 @test_call_expr]);
-
-    let ast::expr test_main_call_expr = rec(id = cx.next_node_id(),
-                                            node = test_main_call_expr_,
-                                            span = rec(lo=0u, hi=0u));
+    let test_main_path: ast::path =
+        nospan({global: false,
+                idents: ~["std", "test", "test_main"],
+                types: ~[]});
+
+    let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);
+
+    let test_main_path_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: test_main_path_expr_,
+         span: {lo: 0u, hi: 0u}};
+
+    let test_main_call_expr_: ast::expr_ =
+        ast::expr_call(@test_main_path_expr,
+                       ~[@args_path_expr, @test_call_expr]);
+
+    let test_main_call_expr: ast::expr =
+        {id: cx.next_node_id(),
+         node: test_main_call_expr_,
+         span: {lo: 0u, hi: 0u}};
 
     ret @test_main_call_expr;
 }