syntax: Make attributes sendable for rustdoc's benefit

This commit is contained in:
Brian Anderson
2012-09-20 17:37:10 -07:00
parent 19ad88c2b8
commit 90e3665fa7
18 changed files with 106 additions and 106 deletions

View File

@@ -385,23 +385,23 @@ fn build_link_meta(sess: session, c: ast::crate, output: &Path,
type provided_metas =
{name: Option<~str>,
vers: Option<~str>,
cmh_items: ~[@ast::meta_item]};
cmh_items: ~[ast::meta_item]};
fn provided_link_metas(sess: session, c: ast::crate) ->
provided_metas {
let mut name: Option<~str> = None;
let mut vers: Option<~str> = None;
let mut cmh_items: ~[@ast::meta_item] = ~[];
let mut cmh_items: ~[ast::meta_item] = ~[];
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess.diagnostic(), linkage_metas);
for linkage_metas.each |meta| {
if attr::get_meta_item_name(*meta) == ~"name" {
match attr::get_meta_item_value_str(*meta) {
if attr::get_meta_item_name(meta) == ~"name" {
match attr::get_meta_item_value_str(meta) {
Some(v) => { name = Some(v); }
None => vec::push(cmh_items, *meta)
}
} else if attr::get_meta_item_name(*meta) == ~"vers" {
match attr::get_meta_item_value_str(*meta) {
} else if attr::get_meta_item_name(meta) == ~"vers" {
match attr::get_meta_item_value_str(meta) {
Some(v) => { vers = Some(v); }
None => vec::push(cmh_items, *meta)
}

View File

@@ -127,7 +127,7 @@ fn in_cfg(cfg: ast::crate_cfg, attrs: ~[ast::attribute]) -> bool {
metas_in_cfg(cfg, attr::attr_metas(attrs))
}
fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[@ast::meta_item]) -> bool {
fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[ast::meta_item]) -> bool {
// The "cfg" attributes on the item
let cfg_metas = attr::find_meta_items_by_name(metas, ~"cfg");
@@ -136,13 +136,13 @@ fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[@ast::meta_item]) -> bool {
// so we can match against them. This is the list of configurations for
// which the item is valid
let cfg_metas = vec::concat(vec::filter_map(cfg_metas,
|&&i| attr::get_meta_item_list(i) ));
|&&i| attr::get_meta_item_list(&i) ));
let has_cfg_metas = vec::len(cfg_metas) > 0u;
if !has_cfg_metas { return true; }
for cfg_metas.each |cfg_mi| {
if attr::contains(cfg, *cfg_mi) { return true; }
if attr::contains(cfg, cfg_mi) { return true; }
}
return false;

View File

@@ -152,7 +152,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool {
let ignoreattrs = attr::find_attrs_by_name(i.attrs, ~"ignore");
let ignoreitems = attr::attr_metas(ignoreattrs);
let cfg_metas = vec::concat(vec::filter_map(ignoreitems,
|&&i| attr::get_meta_item_list(i) ));
|&&i| attr::get_meta_item_list(&i) ));
return if vec::is_not_empty(ignoreitems) {
config::metas_in_cfg(cx.crate.node.config, cfg_metas)
} else {

View File

@@ -41,7 +41,7 @@ type cache_entry = {
cnum: int,
span: span,
hash: ~str,
metas: @~[@ast::meta_item]
metas: @~[ast::meta_item]
};
fn dump_crates(crate_cache: DVec<cache_entry>) {
@@ -150,7 +150,7 @@ fn visit_item(e: env, i: @ast::item) {
}
for link_args.each |a| {
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
match attr::get_meta_item_value_str(&attr::attr_meta(*a)) {
Some(linkarg) => {
cstore::add_used_link_args(cstore, linkarg);
}
@@ -162,8 +162,8 @@ fn visit_item(e: env, i: @ast::item) {
}
}
fn metas_with(ident: ~str, key: ~str, metas: ~[@ast::meta_item])
-> ~[@ast::meta_item] {
fn metas_with(ident: ~str, key: ~str, metas: ~[ast::meta_item])
-> ~[ast::meta_item] {
let name_items = attr::find_meta_items_by_name(metas, key);
if name_items.is_empty() {
vec::append_one(metas, attr::mk_name_value_item_str(key, ident))
@@ -172,12 +172,12 @@ fn metas_with(ident: ~str, key: ~str, metas: ~[@ast::meta_item])
}
}
fn metas_with_ident(ident: ~str, metas: ~[@ast::meta_item])
-> ~[@ast::meta_item] {
fn metas_with_ident(ident: ~str, metas: ~[ast::meta_item])
-> ~[ast::meta_item] {
metas_with(ident, ~"name", metas)
}
fn existing_match(e: env, metas: ~[@ast::meta_item], hash: ~str) ->
fn existing_match(e: env, metas: ~[ast::meta_item], hash: ~str) ->
Option<int> {
for e.crate_cache.each |c| {
@@ -189,7 +189,7 @@ fn existing_match(e: env, metas: ~[@ast::meta_item], hash: ~str) ->
return None;
}
fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item],
fn resolve_crate(e: env, ident: ast::ident, metas: ~[ast::meta_item],
hash: ~str, span: span) -> ast::crate_num {
let metas = metas_with_ident(*e.intr.get(ident), metas);

View File

@@ -108,7 +108,7 @@ fn get_method_names_if_trait(cstore: cstore::cstore, def: ast::def_id)
fn get_item_attrs(cstore: cstore::cstore,
def_id: ast::def_id,
f: fn(~[@ast::meta_item])) {
f: fn(~[ast::meta_item])) {
let cdata = cstore::get_crate_data(cstore, def_id.crate);
decoder::get_item_attrs(cdata, def_id.node, f)

View File

@@ -742,7 +742,7 @@ fn get_method_names_if_trait(intr: ident_interner, cdata: cmd,
fn get_item_attrs(cdata: cmd,
node_id: ast::node_id,
f: fn(~[@ast::meta_item])) {
f: fn(~[ast::meta_item])) {
let item = lookup_item(node_id, cdata.data);
for ebml::tagged_docs(item, tag_attributes) |attributes| {
@@ -841,8 +841,8 @@ fn item_family_to_str(fam: Family) -> ~str {
}
}
fn get_meta_items(md: ebml::Doc) -> ~[@ast::meta_item] {
let mut items: ~[@ast::meta_item] = ~[];
fn get_meta_items(md: ebml::Doc) -> ~[ast::meta_item] {
let mut items: ~[ast::meta_item] = ~[];
for ebml::tagged_docs(md, tag_meta_item_word) |meta_item_doc| {
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd));
@@ -877,7 +877,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
assert (vec::len(meta_items) == 1u);
let meta_item = meta_items[0];
vec::push(attrs,
{node: {style: ast::attr_outer, value: *meta_item,
{node: {style: ast::attr_outer, value: meta_item,
is_sugared_doc: false},
span: ast_util::dummy_sp()});
};

View File

@@ -947,7 +947,7 @@ fn encode_meta_item(ebml_w: ebml::Writer, mi: meta_item) {
ebml_w.writer.write(str::to_bytes(name));
ebml_w.end_tag();
for items.each |inner_item| {
encode_meta_item(ebml_w, **inner_item);
encode_meta_item(ebml_w, *inner_item);
}
ebml_w.end_tag();
}
@@ -970,7 +970,7 @@ fn encode_attributes(ebml_w: ebml::Writer, attrs: ~[attribute]) {
// them in anyway with default values.
fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] {
fn synthesize_link_attr(ecx: @encode_ctxt, items: ~[@meta_item]) ->
fn synthesize_link_attr(ecx: @encode_ctxt, items: ~[meta_item]) ->
attribute {
assert (ecx.link_meta.name != ~"");

View File

@@ -31,7 +31,7 @@ type ctxt = {
filesearch: filesearch,
span: span,
ident: ast::ident,
metas: ~[@ast::meta_item],
metas: ~[ast::meta_item],
hash: ~str,
os: os,
static: bool,
@@ -120,11 +120,11 @@ fn find_library_crate_aux(cx: ctxt,
}
}
fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> ~str {
fn crate_name_from_metas(metas: ~[ast::meta_item]) -> ~str {
let name_items = attr::find_meta_items_by_name(metas, ~"name");
match vec::last_opt(name_items) {
Some(i) => {
match attr::get_meta_item_value_str(i) {
match attr::get_meta_item_value_str(&i) {
Some(n) => n,
// FIXME (#2406): Probably want a warning here since the user
// is using the wrong type of meta item.
@@ -143,7 +143,7 @@ fn note_linkage_attrs(intr: ident_interner, diag: span_handler,
}
}
fn crate_matches(crate_data: @~[u8], metas: ~[@ast::meta_item],
fn crate_matches(crate_data: @~[u8], metas: ~[ast::meta_item],
hash: ~str) -> bool {
let attrs = decoder::get_crate_attributes(crate_data);
let linkage_metas = attr::find_linkage_metas(attrs);
@@ -154,14 +154,14 @@ fn crate_matches(crate_data: @~[u8], metas: ~[@ast::meta_item],
metadata_matches(linkage_metas, metas)
}
fn metadata_matches(extern_metas: ~[@ast::meta_item],
local_metas: ~[@ast::meta_item]) -> bool {
fn metadata_matches(extern_metas: ~[ast::meta_item],
local_metas: ~[ast::meta_item]) -> bool {
debug!("matching %u metadata requirements against %u items",
vec::len(local_metas), vec::len(extern_metas));
for local_metas.each |needed| {
if !attr::contains(extern_metas, *needed) {
if !attr::contains(extern_metas, needed) {
return false;
}
}

View File

@@ -208,7 +208,7 @@ impl LanguageItemCollector {
do get_item_attrs(crate_store, def_id) |meta_items| {
for meta_items.each |meta_item| {
self.match_and_collect_meta_item(def_id, **meta_item);
self.match_and_collect_meta_item(def_id, *meta_item);
}
}
}

View File

@@ -2368,10 +2368,10 @@ fn gather_local_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) {
let attr_metas = attr::attr_metas(
attr::find_attrs_by_name(item.attrs, ~"rt"));
for vec::each(attr_metas) |attr_meta| {
match attr::get_meta_item_list(*attr_meta) {
match attr::get_meta_item_list(attr_meta) {
Some(list) => {
let head = vec::head(list);
let name = attr::get_meta_item_name(head);
let name = attr::get_meta_item_name(&head);
push_rtcall(ccx, name, {crate: ast::local_crate,
node: item.id});
}