Skip to content

Commit 1b804ce

Browse files
committed
Merge find_linkage_attrs with find_linkage_metas
This gets rid of a gratuitous `match check`.
1 parent 0a5f88a commit 1b804ce

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

src/libsyntax/attr.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,25 +297,15 @@ fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) ->
297297
});
298298
}
299299

300-
fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] {
301-
let mut found = ~[];
302-
for find_attrs_by_name(attrs, ~"link").each |attr| {
303-
match attr.node.value.node {
304-
ast::meta_list(_, _) => vec::push(found, attr),
305-
_ => debug!{"ignoring link attribute that has incorrect type"}
306-
}
307-
}
308-
return found;
309-
}
310-
311300
/**
312-
* From a list of crate attributes get only the meta_items that impact crate
301+
* From a list of crate attributes get only the meta_items that affect crate
313302
* linkage
314303
*/
315304
fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
316-
do find_linkage_attrs(attrs).flat_map |attr| {
317-
match check attr.node.value.node {
318-
ast::meta_list(_, items) => /* FIXME (#2543) */ copy items
305+
do find_attrs_by_name(attrs, ~"link").flat_map |attr| {
306+
match attr.node.value.node {
307+
ast::meta_list(_, items) => /* FIXME (#2543) */ copy items,
308+
_ => ~[]
319309
}
320310
}
321311
}

src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ fn item_to_str(i: @ast::item, intr: ident_interner) -> ~str {
117117
to_str(i, print_item, intr)
118118
}
119119

120-
fn attr_to_str(i: ast::attribute, intr: ident_interner) -> ~str {
121-
to_str(i, print_attribute, intr)
122-
}
123-
124120
fn typarams_to_str(tps: ~[ast::ty_param], intr: ident_interner) -> ~str {
125121
to_str(tps, print_type_params, intr)
126122
}
@@ -165,8 +161,8 @@ fn block_to_str(blk: ast::blk, intr: ident_interner) -> ~str {
165161
io::mem_buffer_str(buffer)
166162
}
167163

168-
fn meta_item_to_str(mi: ast::meta_item, intr: ident_interner) -> ~str {
169-
to_str(@mi, print_meta_item, intr)
164+
fn meta_item_to_str(mi: @ast::meta_item, intr: ident_interner) -> ~str {
165+
to_str(mi, print_meta_item, intr)
170166
}
171167

172168
fn attribute_to_str(attr: ast::attribute, intr: ident_interner) -> ~str {

src/rustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
823823
fn list_meta_items(intr: ident_interner,
824824
meta_items: ebml::doc, out: io::Writer) {
825825
for get_meta_items(meta_items).each |mi| {
826-
out.write_str(fmt!{"%s\n", pprust::meta_item_to_str(*mi, intr)});
826+
out.write_str(fmt!{"%s\n", pprust::meta_item_to_str(mi, intr)});
827827
}
828828
}
829829

src/rustc/metadata/loader.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> ~str {
136136

137137
fn note_linkage_attrs(intr: ident_interner, diag: span_handler,
138138
attrs: ~[ast::attribute]) {
139-
for attr::find_linkage_attrs(attrs).each |attr| {
140-
diag.handler().note(fmt!{"meta: %s", pprust::attr_to_str(attr,intr)});
139+
for attr::find_linkage_metas(attrs).each |mi| {
140+
diag.handler().note(fmt!{"meta: %s",
141+
pprust::meta_item_to_str(mi,intr)});
141142
}
142143
}
143144

0 commit comments

Comments
 (0)