From 7bbdeb43a4972300779a8d30c7323445c1105f44 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 1 May 2020 20:58:24 +0800 Subject: Make AttrQuery copyable --- crates/ra_hir_def/src/attr.rs | 1 + crates/ra_hir_def/src/nameres/raw.rs | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 5a86af8ba..576cd0c65 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs @@ -140,6 +140,7 @@ impl Attr { } } +#[derive(Debug, Clone, Copy)] pub struct AttrQuery<'a> { attrs: &'a Attrs, key: &'static str, diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs index aed9dcc72..a71503c76 100644 --- a/crates/ra_hir_def/src/nameres/raw.rs +++ b/crates/ra_hir_def/src/nameres/raw.rs @@ -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 { -- cgit v1.2.3