about summary refs log tree commit diff
path: root/src/comp/front
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-07-05 17:57:34 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-07-06 15:46:03 -0700
commit401b6362d7f99a3cebc863cb1b8906d62e9ba79b (patch)
tree9736c1e95b6d5e7d1492727f4fba5fbe4dfeb34d /src/comp/front
parent479ce4d7836c13b3e75b2d0ac48e9f534ff859e7 (diff)
downloadrust-401b6362d7f99a3cebc863cb1b8906d62e9ba79b.tar.gz
rust-401b6362d7f99a3cebc863cb1b8906d62e9ba79b.zip
rustc: Make meta items into interior vectors
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/attr.rs34
-rw-r--r--src/comp/front/config.rs10
2 files changed, 20 insertions, 24 deletions
diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs
index fe014fd27da..23d8db3f8cb 100644
--- a/src/comp/front/attr.rs
+++ b/src/comp/front/attr.rs
@@ -29,13 +29,11 @@ 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) -> vec[@ast::meta_item] {
-    let vec[@ast::meta_item] metas = [];
+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 (ast::meta_list(_, ?items)) { metas += items; }
             case (_) {
                 log "ignoring link attribute that has incorrect type";
             }
@@ -62,8 +60,8 @@ fn get_attr_name(&ast::attribute attr) -> ast::ident {
     get_meta_item_name(@attr.node.value)
 }
 
-fn find_meta_items_by_name(vec[@ast::meta_item] metas,
-                           ast::ident name) -> vec[@ast::meta_item] {
+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) {
@@ -72,7 +70,7 @@ fn find_meta_items_by_name(vec[@ast::meta_item] metas,
             option::none
         }
     } (_, name);
-    ret vec::filter_map(filter, metas);
+    ret ivec::filter_map(filter, metas);
 }
 
 fn get_meta_item_name(&@ast::meta_item meta) -> ast::ident {
@@ -102,9 +100,9 @@ fn get_meta_item_value_str(&@ast::meta_item meta) -> option::t[str] {
 fn attr_meta(&ast::attribute attr) -> @ast::meta_item { @attr.node.value }
 
 // Get the meta_items from inside a vector of attributes
-fn attr_metas(&ast::attribute[] attrs) -> vec[@ast::meta_item] {
-    auto mitems = [];
-    for (ast::attribute a in attrs) { mitems += [attr_meta(a)]; }
+fn attr_metas(&ast::attribute[] attrs) -> (@ast::meta_item)[] {
+    auto mitems = ~[];
+    for (ast::attribute a in attrs) { mitems += ~[attr_meta(a)]; }
     ret mitems;
 }
 
@@ -133,7 +131,7 @@ fn eq(@ast::meta_item a, @ast::meta_item b) -> bool {
     }
 }
 
-fn contains(&vec[@ast::meta_item] haystack, @ast::meta_item needle) -> bool {
+fn contains(&(@ast::meta_item)[] haystack, @ast::meta_item needle) -> bool {
     log #fmt("looking for %s",
              syntax::print::pprust::meta_item_to_str(*needle));
     for (@ast::meta_item item in haystack) {
@@ -182,8 +180,8 @@ fn sort_meta_items(&vec[@ast::meta_item] items) -> vec[@ast::meta_item] {
     ret v2;
 }
 
-fn remove_meta_items_by_name(&vec[@ast::meta_item] items,
-                             str name) -> vec[@ast::meta_item] {
+fn remove_meta_items_by_name(&(@ast::meta_item)[] items,
+                             str name) -> (@ast::meta_item)[] {
 
     auto filter = bind fn(&@ast::meta_item item,
                           str name) -> option::t[@ast::meta_item] {
@@ -194,10 +192,10 @@ fn remove_meta_items_by_name(&vec[@ast::meta_item] items,
         }
     } (_, name);
 
-    ret vec::filter_map(filter, items);
+    ret ivec::filter_map(filter, items);
 }
 
-fn require_unique_names(&session::session sess, &vec[@ast::meta_item] metas) {
+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);
@@ -222,8 +220,8 @@ fn mk_name_value_item(ast::ident name, ast::lit value) -> @ast::meta_item {
     ret @span(ast::meta_name_value(name, value));
 }
 
-fn mk_list_item(ast::ident name,
-                &vec[@ast::meta_item] items) -> @ast::meta_item {
+fn mk_list_item(ast::ident name, &(@ast::meta_item)[] items)
+        -> @ast::meta_item {
     ret @span(ast::meta_list(name, items));
 }
 
diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs
index b8351282bec..dd6c6b574f3 100644
--- a/src/comp/front/config.rs
+++ b/src/comp/front/config.rs
@@ -109,9 +109,9 @@ fn in_cfg(&ast::crate_cfg cfg, &ast::attribute[] attrs) -> bool {
     // 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(&vec[@ast::meta_item] inner_items,
+        fn extract_metas(&(@ast::meta_item)[] inner_items,
                          &@ast::meta_item cfg_item)
-        -> vec[@ast::meta_item] {
+        -> (@ast::meta_item)[] {
 
             alt (cfg_item.node) {
                 case (ast::meta_list(?name, ?items)) {
@@ -122,13 +122,11 @@ fn in_cfg(&ast::crate_cfg cfg, &ast::attribute[] attrs) -> bool {
             }
         }
         auto cfg_metas = attr::attr_metas(item_cfg_attrs);
-        vec::foldl(extract_metas, [], cfg_metas)
+        ivec::foldl(extract_metas, ~[], cfg_metas)
     };
 
     for (@ast::meta_item cfg_mi in item_cfg_metas) {
-        if (attr::contains(cfg, cfg_mi)) {
-            ret true;
-        }
+        if (attr::contains(cfg, cfg_mi)) { ret true; }
     }
 
     ret false;