]> git.lizzy.rs Git - rust.git/commitdiff
Make AttrQuery copyable
authorEdwin Cheng <edwin0cheng@gmail.com>
Fri, 1 May 2020 12:58:24 +0000 (20:58 +0800)
committerEdwin Cheng <edwin0cheng@gmail.com>
Fri, 1 May 2020 12:58:24 +0000 (20:58 +0800)
crates/ra_hir_def/src/attr.rs
crates/ra_hir_def/src/nameres/raw.rs

index 5a86af8ba3788124f6937f4010625576455a5194..576cd0c65ba984b9b00dccf62877588e18981564 100644 (file)
@@ -140,6 +140,7 @@ fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> {
     }
 }
 
+#[derive(Debug, Clone, Copy)]
 pub struct AttrQuery<'a> {
     attrs: &'a Attrs,
     key: &'static str,
index aed9dcc72c1db67cb6dd4d0202e5e9f4b6d9352e..a71503c76ecdfa3aec10bc4d22dff4994f6ccd56 100644 (file)
@@ -404,16 +404,20 @@ fn add_macro(&mut self, current_module: Option<Idx<ModuleData>>, m: ast::MacroCa
         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 {