Skip to content

Commit 56f3554

Browse files
committed
Return the Vec from decoder::get_item_attrs.
Using a closure unnecessarily obfuscates the code.
1 parent 4fc9b41 commit 56f3554

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn get_item_attrs<F>(cstore: &cstore::CStore,
209209
F: FnOnce(Vec<ast::Attribute>),
210210
{
211211
let cdata = cstore.get_crate_data(def_id.krate);
212-
decoder::get_item_attrs(&*cdata, def_id.node, f)
212+
f(decoder::get_item_attrs(&*cdata, def_id.node));
213213
}
214214

215215
pub fn get_struct_fields(cstore: &cstore::CStore,

src/librustc/metadata/decoder.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,18 +1025,16 @@ pub fn get_tuple_struct_definition_if_ctor(cdata: Cmd,
10251025
ret
10261026
}
10271027

1028-
pub fn get_item_attrs<F>(cdata: Cmd,
1029-
orig_node_id: ast::NodeId,
1030-
f: F) where
1031-
F: FnOnce(Vec<ast::Attribute>),
1032-
{
1028+
pub fn get_item_attrs(cdata: Cmd,
1029+
orig_node_id: ast::NodeId)
1030+
-> Vec<ast::Attribute> {
10331031
// The attributes for a tuple struct are attached to the definition, not the ctor;
10341032
// we assume that someone passing in a tuple struct ctor is actually wanting to
10351033
// look at the definition
10361034
let node_id = get_tuple_struct_definition_if_ctor(cdata, orig_node_id);
10371035
let node_id = node_id.map(|x| x.node).unwrap_or(orig_node_id);
10381036
let item = lookup_item(node_id, cdata.data());
1039-
f(get_attributes(item));
1037+
get_attributes(item)
10401038
}
10411039

10421040
pub fn get_struct_field_attrs(cdata: Cmd) -> HashMap<ast::NodeId, Vec<ast::Attribute>> {

0 commit comments

Comments
 (0)