aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/nameres/raw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/nameres/raw.rs')
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs29
1 files changed, 24 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 39b011ad7..a71503c76 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -188,6 +188,7 @@ pub(super) struct MacroData {
188 pub(super) path: ModPath, 188 pub(super) path: ModPath,
189 pub(super) name: Option<Name>, 189 pub(super) name: Option<Name>,
190 pub(super) export: bool, 190 pub(super) export: bool,
191 pub(super) local_inner: bool,
191 pub(super) builtin: bool, 192 pub(super) builtin: bool,
192} 193}
193 194
@@ -401,14 +402,32 @@ impl RawItemsCollector {
401 402
402 let name = m.name().map(|it| it.as_name()); 403 let name = m.name().map(|it| it.as_name());
403 let ast_id = self.source_ast_id_map.ast_id(&m); 404 let ast_id = self.source_ast_id_map.ast_id(&m);
404 // FIXME: cfg_attr
405 let export = m.attrs().filter_map(|x| x.simple_name()).any(|name| name == "macro_export");
406 405
407 // FIXME: cfg_attr 406 // FIXME: cfg_attr
408 let builtin = 407 let export_attr = attrs.by_key("macro_export");
409 m.attrs().filter_map(|x| x.simple_name()).any(|name| name == "rustc_builtin_macro"); 408
409 let export = export_attr.exists();
410 let local_inner = if export {
411 export_attr.tt_values().map(|it| &it.token_trees).flatten().any(|it| match it {
412 tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) => {
413 ident.text.contains("local_inner_macros")
414 }
415 _ => false,
416 })
417 } else {
418 false
419 };
420
421 let builtin = attrs.by_key("rustc_builtin_macro").exists();
410 422
411 let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export, builtin }); 423 let m = self.raw_items.macros.alloc(MacroData {
424 ast_id,
425 path,
426 name,
427 export,
428 local_inner,
429 builtin,
430 });
412 self.push_item(current_module, attrs, RawItemKind::Macro(m)); 431 self.push_item(current_module, attrs, RawItemKind::Macro(m));
413 } 432 }
414 433