]>
Commit | Line | Data |
---|---|---|
7cac9316 XL |
1 | #![feature(decl_macro)] |
2 | ||
3 | mod foo { | |
4 | pub fn f() {} | |
5 | } | |
6 | ||
7 | mod bar { | |
8 | pub fn g() {} | |
9 | } | |
10 | ||
11 | macro m($($t:tt)*) { | |
12 | $($t)* | |
13 | use foo::*; | |
14 | f(); | |
15 | g(); //~ ERROR cannot find function `g` in this scope | |
16 | } | |
17 | ||
18 | fn main() { | |
19 | m! { | |
20 | use bar::*; | |
21 | g(); | |
22 | f(); //~ ERROR cannot find function `f` in this scope | |
23 | } | |
24 | } | |
25 | ||
26 | n!(f); | |
27 | macro n($i:ident) { | |
28 | mod foo { | |
29 | pub fn $i() -> u32 { 0 } | |
30 | pub fn f() {} | |
31 | ||
32 | mod test { | |
33 | use super::*; | |
34 | fn g() { | |
35 | let _: u32 = $i(); | |
36 | let _: () = f(); | |
37 | } | |
38 | } | |
39 | ||
40 | macro n($j:ident) { | |
41 | mod test { | |
42 | use super::*; | |
43 | fn g() { | |
44 | let _: u32 = $i(); | |
45 | let _: () = f(); | |
46 | $j(); | |
47 | } | |
48 | } | |
49 | } | |
8faf50e0 XL |
50 | macro n_with_super($j:ident) { |
51 | mod test { | |
52 | use super::*; | |
53 | fn g() { | |
54 | let _: u32 = $i(); | |
55 | let _: () = f(); | |
56 | super::$j(); | |
57 | } | |
58 | } | |
59 | } | |
7cac9316 | 60 | |
8faf50e0 XL |
61 | n!(f); //~ ERROR cannot find function `f` in this scope |
62 | n_with_super!(f); | |
7cac9316 XL |
63 | mod test2 { |
64 | super::n! { | |
65 | f //~ ERROR cannot find function `f` in this scope | |
66 | } | |
8faf50e0 XL |
67 | super::n_with_super! { |
68 | f | |
69 | } | |
7cac9316 XL |
70 | } |
71 | } | |
72 | } |