Make AttrQuery copyable

This commit is contained in:
Edwin Cheng 2020-05-01 20:58:24 +08:00
parent e4267967a8
commit 7bbdeb43a4
2 changed files with 15 additions and 10 deletions

View file

@ -140,6 +140,7 @@ impl Attr {
}
}
#[derive(Debug, Clone, Copy)]
pub struct AttrQuery<'a> {
attrs: &'a Attrs,
key: &'static str,

View file

@ -404,16 +404,20 @@ impl RawItemsCollector {
let ast_id = self.source_ast_id_map.ast_id(&m);
// FIXME: cfg_attr
let export = attrs.by_key("macro_export").exists();
let local_inner =
attrs.by_key("macro_export").tt_values().map(|it| &it.token_trees).flatten().any(
|it| match it {
tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) => {
ident.text.contains("local_inner_macros")
}
_ => false,
},
);
let export_attr = attrs.by_key("macro_export");
let export = export_attr.exists();
let local_inner = if export {
export_attr.tt_values().map(|it| &it.token_trees).flatten().any(|it| match it {
tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) => {
ident.text.contains("local_inner_macros")
}
_ => false,
})
} else {
false
};
let builtin = attrs.by_key("rustc_builtin_macro").exists();
let m = self.raw_items.macros.alloc(MacroData {