From 28b5334580e5814d102b006e310ca0d1f03cdd72 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 16 Dec 2020 23:42:03 +0100 Subject: Avoid querying attributes in item tree lowering ItemTree is per-file, so there is no unique crate associated with it. This means that it cannot know the active CfgOptions and thus couldn't handle `cfg_attr`. Prepare it for `cfg_attr`s by avoiding accessing attributes. --- crates/hir_def/src/item_tree/lower.rs | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'crates/hir_def/src/item_tree/lower.rs') diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index dd3409762..7de385ee8 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -539,39 +539,19 @@ impl Ctx { fn lower_macro_rules(&mut self, m: &ast::MacroRules) -> Option> { let name = m.name().map(|it| it.as_name())?; - let attrs = Attrs::new(m, &self.hygiene); - let ast_id = self.source_ast_id_map.ast_id(m); - // FIXME: cfg_attr - let export_attr = attrs.by_key("macro_export"); - - let is_export = export_attr.exists(); - let is_local_inner = if is_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 is_builtin = attrs.by_key("rustc_builtin_macro").exists(); - let res = MacroRules { name, is_export, is_builtin, is_local_inner, ast_id }; + let res = MacroRules { name, ast_id }; Some(id(self.data().macro_rules.alloc(res))) } fn lower_macro_def(&mut self, m: &ast::MacroDef) -> Option> { let name = m.name().map(|it| it.as_name())?; - let attrs = Attrs::new(m, &self.hygiene); let ast_id = self.source_ast_id_map.ast_id(m); let visibility = self.lower_visibility(m); - let is_builtin = attrs.by_key("rustc_builtin_macro").exists(); - let res = MacroDef { name, is_builtin, ast_id, visibility }; + let res = MacroDef { name, ast_id, visibility }; Some(id(self.data().macro_defs.alloc(res))) } -- cgit v1.2.3