about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-05-14 11:02:31 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-05-14 11:03:10 -0700
commitde421afa5524017ede2af828878f5b8a05f50ea2 (patch)
treedf3bca02de795dac6c45985d3d052df9b6f05eb8 /src
parent8b3f3594424200b28f0297b7b7024ecdbf79e665 (diff)
downloadrust-de421afa5524017ede2af828878f5b8a05f50ea2.tar.gz
rust-de421afa5524017ede2af828878f5b8a05f50ea2.zip
rustc: Use walk instead of fold for the first item collection pass
Diffstat (limited to 'src')
-rw-r--r--src/comp/middle/typeck.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs
index 8116057c09c..2c7d80a8fca 100644
--- a/src/comp/middle/typeck.rs
+++ b/src/comp/middle/typeck.rs
@@ -658,8 +658,7 @@ mod collect {
         ret result;
     }
 
-    fn collect(&@ty_item_table id_to_ty_item, &@ast::item i)
-        -> @ty_item_table {
+    fn collect(&@ty_item_table id_to_ty_item, &@ast::item i) {
         alt (i.node) {
             case (ast::item_ty(_, _, _, ?def_id, _)) {
                 id_to_ty_item.insert(def_id, any_item_rust(i));
@@ -672,22 +671,17 @@ mod collect {
             }
             case (_) { /* empty */ }
         }
-        ret id_to_ty_item;
     }
 
-    fn collect_native(&@ty_item_table id_to_ty_item, &@ast::native_item i)
-        -> @ty_item_table {
+    fn collect_native(&@ty_item_table id_to_ty_item, &@ast::native_item i) {
         alt (i.node) {
             case (ast::native_item_ty(_, ?def_id)) {
                 // The abi of types is not used.
                 id_to_ty_item.insert(def_id,
-                                     any_item_native(i,
-                                                     ast::native_abi_cdecl));
-            }
-            case (_) {
+                    any_item_native(i, ast::native_abi_cdecl));
             }
+            case (_) { /* no-op */ }
         }
-        ret id_to_ty_item;
     }
 
     fn convert(&@env e, &@ast::item i) -> @env {
@@ -884,11 +878,12 @@ mod collect {
             vec(mutable);
         let node_type_table ntt = @mutable ntt_sub;
 
-        auto fld_1 = fold::new_identity_fold[@ty_item_table]();
-        fld_1 = @rec(update_env_for_item = bind collect(_, _),
-                     update_env_for_native_item = bind collect_native(_, _)
-                     with *fld_1);
-        fold::fold_crate[@ty_item_table](id_to_ty_item, fld_1, crate);
+        auto visit = rec(
+            visit_item_pre = bind collect(id_to_ty_item, _),
+            visit_native_item_pre = bind collect_native(id_to_ty_item, _)
+            with walk::default_visitor()
+        );
+        walk::walk_crate(visit, *crate);
 
         // Second pass: translate the types of all items.
         auto type_cache = common::new_def_hash[ty::ty_param_count_and_ty]();