aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/nameres/raw.rs4
-rw-r--r--crates/ra_hir/src/nameres/tests/macros.rs37
2 files changed, 40 insertions, 1 deletions
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs
index 04b97cb90..8bf883ac2 100644
--- a/crates/ra_hir/src/nameres/raw.rs
+++ b/crates/ra_hir/src/nameres/raw.rs
@@ -345,7 +345,9 @@ impl RawItemsCollector {
345 345
346 let name = m.name().map(|it| it.as_name()); 346 let name = m.name().map(|it| it.as_name());
347 let ast_id = self.source_ast_id_map.ast_id(&m); 347 let ast_id = self.source_ast_id_map.ast_id(&m);
348 let export = m.has_atom_attr("macro_export"); 348 let export = m.has_atom_attr("macro_export")
349 || m.attrs().filter_map(|x| x.as_call()).any(|(name, _)| name == "macro_export");
350
349 let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export }); 351 let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export });
350 self.push_item(current_module, RawItem::Macro(m)); 352 self.push_item(current_module, RawItem::Macro(m));
351 } 353 }
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs
index 6e0bc437e..bd60f4258 100644
--- a/crates/ra_hir/src/nameres/tests/macros.rs
+++ b/crates/ra_hir/src/nameres/tests/macros.rs
@@ -94,6 +94,43 @@ fn macro_rules_from_other_crates_are_visible() {
94} 94}
95 95
96#[test] 96#[test]
97fn macro_rules_export_with_local_inner_macros_are_visible() {
98 let map = def_map_with_crate_graph(
99 "
100 //- /main.rs
101 foo::structs!(Foo, Bar)
102 mod bar;
103
104 //- /bar.rs
105 use crate::*;
106
107 //- /lib.rs
108 #[macro_export(local_inner_macros)]
109 macro_rules! structs {
110 ($($i:ident),*) => {
111 $(struct $i { field: u32 } )*
112 }
113 }
114 ",
115 crate_graph! {
116 "main": ("/main.rs", ["foo"]),
117 "foo": ("/lib.rs", []),
118 },
119 );
120 assert_snapshot!(map, @r###"
121 ⋮crate
122 ⋮Bar: t v
123 ⋮Foo: t v
124 ⋮bar: t
125
126 ⋮crate::bar
127 ⋮Bar: t v
128 ⋮Foo: t v
129 ⋮bar: t
130 "###);
131}
132
133#[test]
97fn unexpanded_macro_should_expand_by_fixedpoint_loop() { 134fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
98 let map = def_map_with_crate_graph( 135 let map = def_map_with_crate_graph(
99 " 136 "