Skip to content

Commit 1a5b8e4

Browse files
committed
libsyntax: change attr:get_attr_name to take a ref
1 parent bc62bd3 commit 1a5b8e4

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn fold_mod(cx: @mut TestCtxt,
111111
fn nomain(cx: @mut TestCtxt, item: @ast::item) -> @ast::item {
112112
if !*cx.sess.building_library {
113113
@ast::item{attrs: item.attrs.filtered(|attr| {
114-
attr::get_attr_name(*attr) != ~"main"
114+
attr::get_attr_name(attr) != ~"main"
115115
}),.. copy *item}
116116
} else { item }
117117
}

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
10971097
let mut found_link_attr = false;
10981098
for crate.node.attrs.each |attr| {
10991099
attrs.push(
1100-
if attr::get_attr_name(*attr) != ~"link" {
1100+
if attr::get_attr_name(attr) != ~"link" {
11011101
/*bad*/copy *attr
11021102
} else {
11031103
match /*bad*/copy attr.node.value.node {

src/libsyntax/attr.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute {
9090

9191
/* Accessors */
9292

93-
pub fn get_attr_name(attr: ast::attribute) -> ~str {
93+
pub fn get_attr_name(attr: &ast::attribute) -> ~str {
9494
get_meta_item_name(@attr.node.value)
9595
}
9696

@@ -146,14 +146,13 @@ pub fn get_name_value_str_pair(item: @ast::meta_item)
146146
/// Search a list of attributes and return only those with a specific name
147147
pub fn find_attrs_by_name(attrs: &[ast::attribute], name: &str) ->
148148
~[ast::attribute] {
149-
let filter: &fn(a: &ast::attribute) -> Option<ast::attribute> = |a| {
150-
if name == get_attr_name(*a) {
151-
option::Some(*a)
149+
do vec::filter_mapped(attrs) |a| {
150+
if name == get_attr_name(a) {
151+
Some(*a)
152152
} else {
153-
option::None
153+
None
154154
}
155-
};
156-
return vec::filter_mapped(attrs, filter);
155+
}
157156
}
158157

159158
/// Search a list of meta items and return only those with a specific name

src/libsyntax/ext/auto_encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn expand_auto_encode(
114114
in_items: ~[@ast::item]
115115
) -> ~[@ast::item] {
116116
fn is_auto_encode(a: &ast::attribute) -> bool {
117-
attr::get_attr_name(*a) == ~"auto_encode"
117+
attr::get_attr_name(a) == ~"auto_encode"
118118
}
119119

120120
fn filter_attrs(item: @ast::item) -> @ast::item {
@@ -169,7 +169,7 @@ pub fn expand_auto_decode(
169169
in_items: ~[@ast::item]
170170
) -> ~[@ast::item] {
171171
fn is_auto_decode(a: &ast::attribute) -> bool {
172-
attr::get_attr_name(*a) == ~"auto_decode"
172+
attr::get_attr_name(a) == ~"auto_decode"
173173
}
174174

175175
fn filter_attrs(item: @ast::item) -> @ast::item {

0 commit comments

Comments
 (0)