diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/tests')
-rw-r--r-- | crates/ra_hir/src/nameres/tests/macros.rs | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs index ebfefe273..aece1515b 100644 --- a/crates/ra_hir/src/nameres/tests/macros.rs +++ b/crates/ra_hir/src/nameres/tests/macros.rs | |||
@@ -144,9 +144,6 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() { | |||
144 | let map = def_map_with_crate_graph( | 144 | let map = def_map_with_crate_graph( |
145 | " | 145 | " |
146 | //- /main.rs | 146 | //- /main.rs |
147 | #[macro_use] | ||
148 | extern crate foo; | ||
149 | |||
150 | structs!(Foo); | 147 | structs!(Foo); |
151 | structs_priv!(Bar); | 148 | structs_priv!(Bar); |
152 | structs_not_exported!(MacroNotResolved1); | 149 | structs_not_exported!(MacroNotResolved1); |
@@ -154,6 +151,9 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() { | |||
154 | 151 | ||
155 | mod bar; | 152 | mod bar; |
156 | 153 | ||
154 | #[macro_use] | ||
155 | extern crate foo; | ||
156 | |||
157 | //- /bar.rs | 157 | //- /bar.rs |
158 | structs!(Baz); | 158 | structs!(Baz); |
159 | crate::structs!(MacroNotResolved3); | 159 | crate::structs!(MacroNotResolved3); |
@@ -191,3 +191,60 @@ fn macro_rules_from_other_crates_are_visible_with_macro_use() { | |||
191 | ⋮Baz: t v | 191 | ⋮Baz: t v |
192 | "###); | 192 | "###); |
193 | } | 193 | } |
194 | |||
195 | #[test] | ||
196 | fn prelude_is_macro_use() { | ||
197 | covers!(prelude_is_macro_use); | ||
198 | let map = def_map_with_crate_graph( | ||
199 | " | ||
200 | //- /main.rs | ||
201 | structs!(Foo); | ||
202 | structs_priv!(Bar); | ||
203 | structs_outside!(Out); | ||
204 | crate::structs!(MacroNotResolved2); | ||
205 | |||
206 | mod bar; | ||
207 | |||
208 | //- /bar.rs | ||
209 | structs!(Baz); | ||
210 | crate::structs!(MacroNotResolved3); | ||
211 | |||
212 | //- /lib.rs | ||
213 | #[prelude_import] | ||
214 | use self::prelude::*; | ||
215 | |||
216 | mod prelude { | ||
217 | #[macro_export] | ||
218 | macro_rules! structs { | ||
219 | ($i:ident) => { struct $i; } | ||
220 | } | ||
221 | |||
222 | mod priv_mod { | ||
223 | #[macro_export] | ||
224 | macro_rules! structs_priv { | ||
225 | ($i:ident) => { struct $i; } | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | #[macro_export] | ||
231 | macro_rules! structs_outside { | ||
232 | ($i:ident) => { struct $i; } | ||
233 | } | ||
234 | ", | ||
235 | crate_graph! { | ||
236 | "main": ("/main.rs", ["foo"]), | ||
237 | "foo": ("/lib.rs", []), | ||
238 | }, | ||
239 | ); | ||
240 | assert_snapshot!(map, @r###" | ||
241 | ⋮crate | ||
242 | ⋮Bar: t v | ||
243 | ⋮Foo: t v | ||
244 | ⋮Out: t v | ||
245 | ⋮bar: t | ||
246 | ⋮ | ||
247 | ⋮crate::bar | ||
248 | ⋮Baz: t v | ||
249 | "###); | ||
250 | } | ||