Skip to content

Commit 3081be6

Browse files
committed
Also dump legacy-textual-scope macros
1 parent 217e3ca commit 3081be6

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

crates/hir-def/src/expr_store/tests/body/block.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ fn f() {
255255
256256
crate
257257
- f : value
258+
- (legacy) mark : macro!
258259
"#]],
259260
);
260261
}
@@ -328,6 +329,8 @@ fn main() {
328329
crate
329330
- foo : macro!
330331
- main : value
332+
- (legacy) bar : macro!
333+
- (legacy) foo : macro!
331334
"#]],
332335
);
333336
}
@@ -362,6 +365,7 @@ fn f() {
362365
363366
crate::module
364367
- f : value
368+
- (legacy) m : macro!
365369
"#]],
366370
)
367371
}
@@ -449,6 +453,8 @@ fn foo() {
449453
450454
crate
451455
- foo : value
456+
- (legacy) declare : macro!
457+
- (legacy) inner_declare : macro!
452458
"#]],
453459
)
454460
}
@@ -501,6 +507,7 @@ fn foo() {
501507
502508
crate
503509
- foo : value
510+
- (legacy) mac : macro!
504511
"#]],
505512
)
506513
}
@@ -523,6 +530,7 @@ fn f() {$0
523530
524531
crate
525532
- f : value
533+
- (legacy) foo : macro!
526534
"#]],
527535
)
528536
}

crates/hir-def/src/item_scope.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,21 @@ impl ItemScope {
786786

787787
buf.push('\n');
788788
}
789+
790+
// Also dump legacy-textual-scope macros visible at the _end_ of the scope.
791+
//
792+
// For tests involving a cursor position, this might include macros that
793+
// are _not_ visible at the cursor position.
794+
let mut legacy_macros = self.legacy_macros().collect::<Vec<_>>();
795+
legacy_macros.sort_by(|(a, _), (b, _)| Ord::cmp(a, b));
796+
for (name, macros) in legacy_macros {
797+
format_to!(buf, "- (legacy) {} :", name.display(db, Edition::LATEST));
798+
for &macro_id in macros {
799+
buf.push_str(" macro");
800+
print_macro_sub_ns(buf, macro_id);
801+
}
802+
buf.push('\n');
803+
}
789804
}
790805

791806
pub(crate) fn shrink_to_fit(&mut self) {

crates/hir-def/src/nameres/tests/macros.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ structs!(Bar, Baz);
2525
crate
2626
- Foo : type
2727
- nested : type
28+
- (legacy) structs : macro!
2829
2930
crate::nested
3031
- Bar : type
3132
- Baz : type
33+
- (legacy) structs : macro!
3234
"#]],
3335
);
3436
}
@@ -55,18 +57,23 @@ struct Y;
5557
crate
5658
- m : type
5759
- n1 : type
60+
- (legacy) m : macro!
5861
5962
crate::m
6063
- n3 : type
64+
- (legacy) m : macro!
6165
6266
crate::m::n3
6367
- Y : type value
68+
- (legacy) m : macro!
6469
6570
crate::n1
6671
- n2 : type
72+
- (legacy) m : macro!
6773
6874
crate::n1::n2
6975
- X : type value
76+
- (legacy) m : macro!
7077
"#]],
7178
);
7279
}
@@ -209,6 +216,7 @@ macro_rules! bar {
209216
- Foo : type
210217
- bar : macro! (import)
211218
- foo : macro! (import)
219+
- (legacy) baz : macro!
212220
"#]],
213221
);
214222
}
@@ -401,6 +409,7 @@ mod prelude {
401409
- prelude : type
402410
403411
crate::prelude
412+
- (legacy) declare_mod : macro!
404413
"#]],
405414
);
406415
}
@@ -420,6 +429,7 @@ macro_rules! m {
420429
expect![[r#"
421430
crate
422431
- S : type value
432+
- (legacy) m : macro!
423433
"#]],
424434
);
425435
// FIXME: should not expand. legacy macro scoping is not implemented.
@@ -509,8 +519,11 @@ macro_rules! baz {
509519
- m5 : type
510520
- m7 : type
511521
- ok_double_macro_use_shadow : value
522+
- (legacy) baz : macro!
523+
- (legacy) foo : macro! macro! macro!
512524
513525
crate::m1
526+
- (legacy) bar : macro!
514527
515528
crate::m2
516529
@@ -521,18 +534,30 @@ macro_rules! baz {
521534
- m4 : type
522535
- m5 : type
523536
- ok_shadow : value
537+
- (legacy) bar : macro! macro!
538+
- (legacy) baz : macro!
539+
- (legacy) foo : macro! macro! macro! macro!
524540
525541
crate::m3::m4
526542
- ok_shadow_deep : value
543+
- (legacy) bar : macro!
544+
- (legacy) foo : macro! macro!
527545
528546
crate::m3::m5
547+
- (legacy) bar : macro!
548+
- (legacy) baz : macro!
549+
- (legacy) foo : macro! macro! macro!
529550
530551
crate::m5
531552
- m6 : type
553+
- (legacy) foo : macro! macro!
532554
533555
crate::m5::m6
556+
- (legacy) foo : macro! macro!
534557
535558
crate::m7
559+
- (legacy) baz : macro!
560+
- (legacy) foo : macro! macro!
536561
"#]],
537562
);
538563
// FIXME: should not see `NotFoundBefore`
@@ -558,6 +583,7 @@ fn baz() {}
558583
- bar : type (import) macro! (import)
559584
- baz : type (import) value macro! (import)
560585
- foo : type macro!
586+
- (legacy) foo : macro!
561587
"#]],
562588
);
563589
}
@@ -630,12 +656,15 @@ mod m {
630656
- OkPlain : type value
631657
- bar : macro!
632658
- m : type
659+
- (legacy) foo : macro!
633660
634661
crate::m
635662
- alias1 : macro! (import)
636663
- alias2 : macro! (import)
637664
- alias3 : macro! (import)
638665
- not_found : _
666+
- (legacy) bar : macro!
667+
- (legacy) foo : macro!
639668
"#]],
640669
);
641670
}
@@ -692,8 +721,10 @@ pub struct Baz;
692721
- FooSelf : type (import) value (import)
693722
- foo : type (extern)
694723
- m : type
724+
- (legacy) current : macro!
695725
696726
crate::m
727+
- (legacy) current : macro!
697728
"#]],
698729
);
699730
}
@@ -884,6 +915,7 @@ extern {
884915
expect![[r#"
885916
crate
886917
- S : value
918+
- (legacy) m : macro!
887919
"#]],
888920
);
889921
}
@@ -975,6 +1007,8 @@ b! { static = #[] ();}
9751007
"#,
9761008
expect![[r#"
9771009
crate
1010+
- (legacy) a : macro!
1011+
- (legacy) b : macro!
9781012
"#]],
9791013
);
9801014
}
@@ -996,6 +1030,8 @@ indirect_macro!();
9961030
expect![[r#"
9971031
crate
9981032
- S : type
1033+
- (legacy) indirect_macro : macro!
1034+
- (legacy) item : macro!
9991035
"#]],
10001036
);
10011037
}
@@ -1161,6 +1197,7 @@ m!(
11611197
"#,
11621198
expect![[r#"
11631199
crate
1200+
- (legacy) m : macro!
11641201
"#]],
11651202
)
11661203
}
@@ -1198,6 +1235,9 @@ struct B;
11981235
- B : type value
11991236
- inner_a : macro!
12001237
- inner_b : macro!
1238+
- (legacy) include : macro!
1239+
- (legacy) inner_a : macro!
1240+
- (legacy) inner_b : macro!
12011241
"#]],
12021242
);
12031243
}
@@ -1229,6 +1269,9 @@ struct A;
12291269
crate
12301270
- A : type value
12311271
- inner : macro!
1272+
- (legacy) include : macro!
1273+
- (legacy) inner : macro!
1274+
- (legacy) m : macro!
12321275
"#]],
12331276
);
12341277
// eager -> MBE -> $crate::mbe
@@ -1258,6 +1301,9 @@ struct A;
12581301
crate
12591302
- A : type value
12601303
- inner : macro!
1304+
- (legacy) include : macro!
1305+
- (legacy) inner : macro!
1306+
- (legacy) n : macro!
12611307
"#]],
12621308
);
12631309
}
@@ -1393,29 +1439,37 @@ pub struct Url {}
13931439
expect![[r#"
13941440
crate
13951441
- nested : type
1442+
- (legacy) include : macro!
13961443
13971444
crate::nested
13981445
- company_name : type
13991446
- different_company : type
14001447
- util : type
1448+
- (legacy) include : macro!
14011449
14021450
crate::nested::company_name
14031451
- network : type
1452+
- (legacy) include : macro!
14041453
14051454
crate::nested::company_name::network
14061455
- v1 : type
1456+
- (legacy) include : macro!
14071457
14081458
crate::nested::company_name::network::v1
14091459
- IpAddress : type
1460+
- (legacy) include : macro!
14101461
14111462
crate::nested::different_company
14121463
- network : type
1464+
- (legacy) include : macro!
14131465
14141466
crate::nested::different_company::network
14151467
- Url : type
1468+
- (legacy) include : macro!
14161469
14171470
crate::nested::util
14181471
- Helper : type
1472+
- (legacy) include : macro!
14191473
"#]],
14201474
);
14211475
}
@@ -1535,9 +1589,11 @@ macro_rules! mk_foo {
15351589
crate
15361590
- a : type
15371591
- lib : type (extern)
1592+
- (legacy) foo : macro!
15381593
15391594
crate::a
15401595
- Ok : type value
1596+
- (legacy) foo : macro!
15411597
"#]],
15421598
);
15431599
}

crates/hir-def/src/nameres/tests/mod_resolution.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ pub trait Trait {
965965
966966
crate::module
967967
- Trait : type
968+
- (legacy) m : macro!
968969
"#]],
969970
);
970971
check(
@@ -991,6 +992,7 @@ pub trait Trait {
991992
992993
crate::module
993994
- Trait : type
995+
- (legacy) m : macro!
994996
"#]],
995997
);
996998
}

0 commit comments

Comments
 (0)