aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/nameres/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/nameres/tests')
-rw-r--r--crates/ra_hir/src/nameres/tests/macros.rs108
1 files changed, 105 insertions, 3 deletions
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs
index c62152d26..ebc4d6890 100644
--- a/crates/ra_hir/src/nameres/tests/macros.rs
+++ b/crates/ra_hir/src/nameres/tests/macros.rs
@@ -268,12 +268,114 @@ fn prelude_cycle() {
268 ); 268 );
269 assert_snapshot!(map, @r###" 269 assert_snapshot!(map, @r###"
270 ⋮crate 270 ⋮crate
271 ⋮foo: t
272 ⋮prelude: t 271 ⋮prelude: t
273 272
274 ⋮crate::prelude 273 ⋮crate::prelude
275 ⋮declare_mod: m 274 ⋮declare_mod: m
276 275 "###);
277 ⋮crate::foo 276}
277
278#[test]
279fn plain_macros_are_legacy_textual_scoped() {
280 let map = def_map(
281 r#"
282 //- /main.rs
283 mod m1;
284 bar!(NotFoundNotMacroUse);
285
286 mod m2 {
287 foo!(NotFoundBeforeInside2);
288 }
289
290 macro_rules! foo {
291 ($x:ident) => { struct $x; }
292 }
293 foo!(Ok);
294
295 mod m3;
296 foo!(OkShadowStop);
297 bar!(NotFoundMacroUseStop);
298
299 #[macro_use]
300 mod m5 {
301 #[macro_use]
302 mod m6 {
303 macro_rules! foo {
304 ($x:ident) => { fn $x() {} }
305 }
306 }
307 }
308 foo!(ok_double_macro_use_shadow);
309
310 baz!(NotFoundBefore);
311 #[macro_use]
312 mod m7 {
313 macro_rules! baz {
314 ($x:ident) => { struct $x; }
315 }
316 }
317 baz!(OkAfter);
318
319 //- /m1.rs
320 foo!(NotFoundBeforeInside1);
321 macro_rules! bar {
322 ($x:ident) => { struct $x; }
323 }
324
325 //- /m3/mod.rs
326 foo!(OkAfterInside);
327 macro_rules! foo {
328 ($x:ident) => { fn $x() {} }
329 }
330 foo!(ok_shadow);
331
332 #[macro_use]
333 mod m4;
334 bar!(OkMacroUse);
335
336 //- /m3/m4.rs
337 foo!(ok_shadow_deep);
338 macro_rules! bar {
339 ($x:ident) => { struct $x; }
340 }
341 "#,
342 );
343 assert_snapshot!(map, @r###"
344 ⋮crate
345 ⋮Ok: t v
346 ⋮OkAfter: t v
347 ⋮OkShadowStop: t v
348 ⋮foo: m
349 ⋮m1: t
350 ⋮m2: t
351 ⋮m3: t
352 ⋮m5: t
353 ⋮m7: t
354 ⋮ok_double_macro_use_shadow: v
355
356 ⋮crate::m7
357 ⋮baz: m
358
359 ⋮crate::m1
360 ⋮bar: m
361
362 ⋮crate::m5
363 ⋮m6: t
364
365 ⋮crate::m5::m6
366 ⋮foo: m
367
368 ⋮crate::m2
369
370 ⋮crate::m3
371 ⋮OkAfterInside: t v
372 ⋮OkMacroUse: t v
373 ⋮foo: m
374 ⋮m4: t
375 ⋮ok_shadow: v
376
377 ⋮crate::m3::m4
378 ⋮bar: m
379 ⋮ok_shadow_deep: v
278 "###); 380 "###);
279} 381}