diff options
Diffstat (limited to 'crates/ra_hir/src/nameres')
-rw-r--r-- | crates/ra_hir/src/nameres/tests/macros.rs | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs index 631df2cef..a8ee0ba28 100644 --- a/crates/ra_hir/src/nameres/tests/macros.rs +++ b/crates/ra_hir/src/nameres/tests/macros.rs | |||
@@ -99,14 +99,14 @@ fn macro_rules_from_other_crates_are_visible() { | |||
99 | fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | 99 | fn unexpanded_macro_should_expand_by_fixedpoint_loop() { |
100 | let map = def_map_with_crate_graph( | 100 | let map = def_map_with_crate_graph( |
101 | " | 101 | " |
102 | //- /main.rs | 102 | //- /main.rs |
103 | macro_rules! baz { | 103 | macro_rules! baz { |
104 | () => { | 104 | () => { |
105 | use foo::bar; | 105 | use foo::bar; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | foo!(); | 109 | foo!(); |
110 | bar!(); | 110 | bar!(); |
111 | baz!(); | 111 | baz!(); |
112 | 112 | ||
@@ -114,7 +114,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | |||
114 | #[macro_export] | 114 | #[macro_export] |
115 | macro_rules! foo { | 115 | macro_rules! foo { |
116 | () => { | 116 | () => { |
117 | struct Foo { field: u32 } | 117 | struct Foo { field: u32 } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | #[macro_export] | 120 | #[macro_export] |
@@ -137,3 +137,48 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | |||
137 | ⋮foo: m | 137 | ⋮foo: m |
138 | "###); | 138 | "###); |
139 | } | 139 | } |
140 | |||
141 | #[test] | ||
142 | fn macro_rules_from_other_crates_are_visible_with_macro_use() { | ||
143 | let map = def_map_with_crate_graph( | ||
144 | " | ||
145 | //- /main.rs | ||
146 | #[macro_use] | ||
147 | extern crate foo; | ||
148 | |||
149 | structs!(Foo, Bar) | ||
150 | |||
151 | mod bar; | ||
152 | |||
153 | //- /bar.rs | ||
154 | use crate::*; | ||
155 | |||
156 | //- /lib.rs | ||
157 | #[macro_export] | ||
158 | macro_rules! structs { | ||
159 | ($($i:ident),*) => { | ||
160 | $(struct $i { field: u32 } )* | ||
161 | } | ||
162 | } | ||
163 | ", | ||
164 | crate_graph! { | ||
165 | "main": ("/main.rs", ["foo"]), | ||
166 | "foo": ("/lib.rs", []), | ||
167 | }, | ||
168 | ); | ||
169 | assert_snapshot!(map, @r###" | ||
170 | ⋮crate | ||
171 | ⋮Bar: t v | ||
172 | ⋮Foo: t v | ||
173 | ⋮bar: t | ||
174 | ⋮foo: t | ||
175 | ⋮structs: m | ||
176 | ⋮ | ||
177 | ⋮crate::bar | ||
178 | ⋮Bar: t v | ||
179 | ⋮Foo: t v | ||
180 | ⋮bar: t | ||
181 | ⋮foo: t | ||
182 | ⋮structs: m | ||
183 | "###); | ||
184 | } | ||