Skip to content

Commit 291d039

Browse files
committed
Add test in name resolutions
1 parent 443762c commit 291d039

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

crates/ra_hir_def/src/nameres/tests/macros.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,43 @@ fn macro_rules_export_with_local_inner_macros_are_visible() {
135135
"###);
136136
}
137137

138+
#[test]
139+
fn local_inner_macros_makes_local_macros_usable() {
140+
let map = def_map(
141+
"
142+
//- /main.rs crate:main deps:foo
143+
foo::structs!(Foo, Bar);
144+
mod bar;
145+
//- /bar.rs
146+
use crate::*;
147+
//- /lib.rs crate:foo
148+
#[macro_export(local_inner_macros)]
149+
macro_rules! structs {
150+
($($i:ident),*) => {
151+
inner!($($i),*);
152+
}
153+
}
154+
#[macro_export]
155+
macro_rules! inner {
156+
($($i:ident),*) => {
157+
$(struct $i { field: u32 } )*
158+
}
159+
}
160+
",
161+
);
162+
assert_snapshot!(map, @r###"
163+
⋮crate
164+
⋮Bar: t v
165+
⋮Foo: t v
166+
⋮bar: t
167+
168+
⋮crate::bar
169+
⋮Bar: t v
170+
⋮Foo: t v
171+
⋮bar: t
172+
"###);
173+
}
174+
138175
#[test]
139176
fn unexpanded_macro_should_expand_by_fixedpoint_loop() {
140177
let map = def_map(

0 commit comments

Comments
 (0)