Skip to content

Commit b2ff252

Browse files
committed
wip: add some test
1 parent 3353199 commit b2ff252

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

tests/ui/resolve/fresh-should-shadow-definitation-in-macro-expand-in-block.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,37 @@ fn ff5() {
154154
}
155155
}
156156

157+
fn f_with_macro_export0() {
158+
{
159+
let a: BindingF = 42;
160+
let c0: BindingF = crate::m!();
161+
{
162+
let d0: BindingF = m!();
163+
#[macro_export]
164+
macro_rules! m { () => { a } }
165+
use m;
166+
let d1: BindingF = m!();
167+
}
168+
let c1: BindingF = crate::m!();
169+
}
170+
crate::m!(); // TODO: error
171+
}
172+
173+
fn f_with_macro_export1() {
174+
fn f() {};
175+
{
176+
let a: BindingF = 42;
177+
let c0: BindingF = crate::m!();
178+
{
179+
let d0: BindingF = m!();
180+
#[macro_export]
181+
macro_rules! m { () => { a } }
182+
use m;
183+
let d1: BindingF = m!();
184+
}
185+
let c1: BindingF = crate::m!();
186+
}
187+
crate::m!(); // TODO: error
188+
}
189+
157190
fn main () {}

tests/ui/resolve/fresh-should-shadow-definitation-in-macro-expand.rs

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,40 @@
55
type FnF = i8;
66
type BindingF = i16;
77

8-
fn f_without_definition_f() {
8+
fn f_without_definition_f0() {
9+
// let f -> macro m
910
let f = || -> BindingF { 42 };
10-
let a: BindingF = m!();
11+
let a0: BindingF = m!();
1112
macro_rules! m {() => ( f() )}
1213
use m;
14+
let a1: BindingF = m!();
15+
}
16+
17+
fn f_without_definition_f1() {
18+
// macro m -> let f
19+
let a: BindingF = m!(); //~ NOTE in this expansion of m!
20+
macro_rules! m {() => ( f() )} //~ ERROR cannot find function `f` in this scope
21+
//~| NOTE not found in this scope
22+
use m;
23+
let f = || -> BindingF { 42 };
1324
}
1425

1526
fn f_without_closure_f0() {
27+
// fn f -> macro f
1628
fn f() -> FnF { 42 }
1729
let a: FnF = m!();
1830
macro_rules! m {() => ( f() )}
1931
use m;
2032
}
2133

34+
fn f_without_closure_f1() {
35+
// macro f -> fn f
36+
let a: FnF = m!();
37+
macro_rules! m {() => ( f() )}
38+
use m;
39+
fn f() -> FnF { 42 }
40+
}
41+
2242
fn ff0() {
2343
// let f -> macro m -> fn f
2444

@@ -156,4 +176,30 @@ fn multiple() {
156176
use {m0, m1, m2};
157177
}
158178

159-
fn main () {}
179+
fn f_with_macro_export() {
180+
let a: BindingF = 42;
181+
182+
#[macro_export]
183+
macro_rules! m { () => { a } } //~ ERROR cannot find value `a` in this scope
184+
//~| ERROR cannot find value `a` in this scope
185+
//~| NOTE not found in this scope
186+
//~| NOTE not found in this scope
187+
let b: BindingF = crate::m!();
188+
}
189+
190+
fn f_use_macro_export_1() {
191+
fn a() {}
192+
193+
crate::m!(); // TODO: Error
194+
}
195+
196+
fn f_use_macro_export_2() {
197+
crate::m!(); //~ NOTE in this expansion of crate::m!
198+
}
199+
200+
fn f_use_macro_export_3() {
201+
let a = 42;
202+
crate::m!(); //~ NOTE in this expansion of crate::m!
203+
}
204+
205+
fn main() {}

0 commit comments

Comments
 (0)