diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-07-06 11:26:26 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-07-06 11:26:26 -0700 |
| commit | bbdba21b1f3c7dfc4c0bac3525cc35939ae8ca4c (patch) | |
| tree | d9cb0046b2a608b4b44c54eacce7951326c65df2 /src/comp/front | |
| parent | ec890fff23d80da97086e89f29ef7f8d14dbaab8 (diff) | |
rustc: Revert the conversion to interior vectors due to heap corruption
Diffstat (limited to 'src/comp/front')
| -rw-r--r-- | src/comp/front/attr.rs | 27 | ||||
| -rw-r--r-- | src/comp/front/config.rs | 15 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs index 376158b426a..37bcd0bb8b8 100644 --- a/src/comp/front/attr.rs +++ b/src/comp/front/attr.rs @@ -1,6 +1,5 @@ // Functions dealing with attributes and meta_items -import std::ivec; import std::vec; import std::str; import std::map; @@ -29,11 +28,13 @@ 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 = ~[]; +fn find_linkage_metas(vec[ast::attribute] attrs) -> vec[@ast::meta_item] { + let vec[@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"; } @@ -43,8 +44,8 @@ fn find_linkage_metas(&ast::attribute[] attrs) -> (@ast::meta_item)[] { } // 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[] { +fn find_attrs_by_name(vec[ast::attribute] attrs, + ast::ident name) -> vec[ast::attribute] { auto filter = bind fn(&ast::attribute a, ast::ident name) -> option::t[ast::attribute] { if (get_attr_name(a) == name) { @@ -53,7 +54,7 @@ fn find_attrs_by_name(&ast::attribute[] attrs, option::none } } (_, name); - ret ivec::filter_map(filter, attrs); + ret vec::filter_map(filter, attrs); } fn get_attr_name(&ast::attribute attr) -> ast::ident { @@ -100,10 +101,8 @@ 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)]; } - ret mitems; +fn attr_metas(&vec[ast::attribute] attrs) -> vec[@ast::meta_item] { + ret vec::map(attr_meta, attrs); } fn eq(@ast::meta_item a, @ast::meta_item b) -> bool { @@ -131,7 +130,7 @@ fn eq(@ast::meta_item a, @ast::meta_item b) -> bool { } } -fn contains(&(@ast::meta_item)[] haystack, @ast::meta_item needle) -> bool { +fn contains(&vec[@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) { @@ -220,8 +219,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, &(@ast::meta_item)[] items) - -> @ast::meta_item { +fn mk_list_item(ast::ident name, + &vec[@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 dd6c6b574f3..4e6bb485cd2 100644 --- a/src/comp/front/config.rs +++ b/src/comp/front/config.rs @@ -1,4 +1,3 @@ -import std::ivec; import std::option; import std::vec; import syntax::ast; @@ -98,20 +97,20 @@ fn native_item_in_cfg(&ast::crate_cfg cfg, &@ast::native_item item) -> bool { // 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(&ast::crate_cfg cfg, &vec[ast::attribute] attrs) -> 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; + auto item_has_cfg_attrs = vec::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, + fn extract_metas(&vec[@ast::meta_item] inner_items, &@ast::meta_item cfg_item) - -> (@ast::meta_item)[] { + -> vec[@ast::meta_item] { alt (cfg_item.node) { case (ast::meta_list(?name, ?items)) { @@ -122,11 +121,13 @@ fn in_cfg(&ast::crate_cfg cfg, &ast::attribute[] attrs) -> bool { } } auto cfg_metas = attr::attr_metas(item_cfg_attrs); - ivec::foldl(extract_metas, ~[], cfg_metas) + vec::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; |
