Return the Vec from decoder::get_item_attrs.
Using a closure unnecessarily obfuscates the code.
This commit is contained in:
parent
4fc9b41238
commit
56f3554f52
@ -209,7 +209,7 @@ pub fn get_item_attrs<F>(cstore: &cstore::CStore,
|
||||
F: FnOnce(Vec<ast::Attribute>),
|
||||
{
|
||||
let cdata = cstore.get_crate_data(def_id.krate);
|
||||
decoder::get_item_attrs(&*cdata, def_id.node, f)
|
||||
f(decoder::get_item_attrs(&*cdata, def_id.node));
|
||||
}
|
||||
|
||||
pub fn get_struct_fields(cstore: &cstore::CStore,
|
||||
|
@ -1025,18 +1025,16 @@ pub fn get_tuple_struct_definition_if_ctor(cdata: Cmd,
|
||||
ret
|
||||
}
|
||||
|
||||
pub fn get_item_attrs<F>(cdata: Cmd,
|
||||
orig_node_id: ast::NodeId,
|
||||
f: F) where
|
||||
F: FnOnce(Vec<ast::Attribute>),
|
||||
{
|
||||
pub fn get_item_attrs(cdata: Cmd,
|
||||
orig_node_id: ast::NodeId)
|
||||
-> Vec<ast::Attribute> {
|
||||
// The attributes for a tuple struct are attached to the definition, not the ctor;
|
||||
// we assume that someone passing in a tuple struct ctor is actually wanting to
|
||||
// look at the definition
|
||||
let node_id = get_tuple_struct_definition_if_ctor(cdata, orig_node_id);
|
||||
let node_id = node_id.map(|x| x.node).unwrap_or(orig_node_id);
|
||||
let item = lookup_item(node_id, cdata.data());
|
||||
f(get_attributes(item));
|
||||
get_attributes(item)
|
||||
}
|
||||
|
||||
pub fn get_struct_field_attrs(cdata: Cmd) -> HashMap<ast::NodeId, Vec<ast::Attribute>> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user