Merge find_linkage_attrs with find_linkage_metas
This gets rid of a gratuitous `match check`.
This commit is contained in:
parent
0a5f88a240
commit
1b804ce343
@ -297,25 +297,15 @@ fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) ->
|
||||
});
|
||||
}
|
||||
|
||||
fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] {
|
||||
let mut found = ~[];
|
||||
for find_attrs_by_name(attrs, ~"link").each |attr| {
|
||||
match attr.node.value.node {
|
||||
ast::meta_list(_, _) => vec::push(found, attr),
|
||||
_ => debug!{"ignoring link attribute that has incorrect type"}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* From a list of crate attributes get only the meta_items that impact crate
|
||||
* From a list of crate attributes get only the meta_items that affect crate
|
||||
* linkage
|
||||
*/
|
||||
fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
|
||||
do find_linkage_attrs(attrs).flat_map |attr| {
|
||||
match check attr.node.value.node {
|
||||
ast::meta_list(_, items) => /* FIXME (#2543) */ copy items
|
||||
do find_attrs_by_name(attrs, ~"link").flat_map |attr| {
|
||||
match attr.node.value.node {
|
||||
ast::meta_list(_, items) => /* FIXME (#2543) */ copy items,
|
||||
_ => ~[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,10 +117,6 @@ fn item_to_str(i: @ast::item, intr: ident_interner) -> ~str {
|
||||
to_str(i, print_item, intr)
|
||||
}
|
||||
|
||||
fn attr_to_str(i: ast::attribute, intr: ident_interner) -> ~str {
|
||||
to_str(i, print_attribute, intr)
|
||||
}
|
||||
|
||||
fn typarams_to_str(tps: ~[ast::ty_param], intr: ident_interner) -> ~str {
|
||||
to_str(tps, print_type_params, intr)
|
||||
}
|
||||
@ -165,8 +161,8 @@ fn block_to_str(blk: ast::blk, intr: ident_interner) -> ~str {
|
||||
io::mem_buffer_str(buffer)
|
||||
}
|
||||
|
||||
fn meta_item_to_str(mi: ast::meta_item, intr: ident_interner) -> ~str {
|
||||
to_str(@mi, print_meta_item, intr)
|
||||
fn meta_item_to_str(mi: @ast::meta_item, intr: ident_interner) -> ~str {
|
||||
to_str(mi, print_meta_item, intr)
|
||||
}
|
||||
|
||||
fn attribute_to_str(attr: ast::attribute, intr: ident_interner) -> ~str {
|
||||
|
@ -823,7 +823,7 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
||||
fn list_meta_items(intr: ident_interner,
|
||||
meta_items: ebml::doc, out: io::Writer) {
|
||||
for get_meta_items(meta_items).each |mi| {
|
||||
out.write_str(fmt!{"%s\n", pprust::meta_item_to_str(*mi, intr)});
|
||||
out.write_str(fmt!{"%s\n", pprust::meta_item_to_str(mi, intr)});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,8 +136,9 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> ~str {
|
||||
|
||||
fn note_linkage_attrs(intr: ident_interner, diag: span_handler,
|
||||
attrs: ~[ast::attribute]) {
|
||||
for attr::find_linkage_attrs(attrs).each |attr| {
|
||||
diag.handler().note(fmt!{"meta: %s", pprust::attr_to_str(attr,intr)});
|
||||
for attr::find_linkage_metas(attrs).each |mi| {
|
||||
diag.handler().note(fmt!{"meta: %s",
|
||||
pprust::meta_item_to_str(mi,intr)});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user