]>
Commit | Line | Data |
---|---|---|
7cac9316 XL |
1 | // Copyright 2017 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | #![feature(decl_macro)] | |
12 | ||
13 | mod foo { | |
14 | pub fn f() {} | |
15 | } | |
16 | ||
17 | mod bar { | |
18 | pub fn g() {} | |
19 | } | |
20 | ||
21 | macro m($($t:tt)*) { | |
22 | $($t)* | |
23 | use foo::*; | |
24 | f(); | |
25 | g(); //~ ERROR cannot find function `g` in this scope | |
26 | } | |
27 | ||
28 | fn main() { | |
29 | m! { | |
30 | use bar::*; | |
31 | g(); | |
32 | f(); //~ ERROR cannot find function `f` in this scope | |
33 | } | |
34 | } | |
35 | ||
36 | n!(f); | |
37 | macro n($i:ident) { | |
38 | mod foo { | |
39 | pub fn $i() -> u32 { 0 } | |
40 | pub fn f() {} | |
41 | ||
42 | mod test { | |
43 | use super::*; | |
44 | fn g() { | |
45 | let _: u32 = $i(); | |
46 | let _: () = f(); | |
47 | } | |
48 | } | |
49 | ||
50 | macro n($j:ident) { | |
51 | mod test { | |
52 | use super::*; | |
53 | fn g() { | |
54 | let _: u32 = $i(); | |
55 | let _: () = f(); | |
56 | $j(); | |
57 | } | |
58 | } | |
59 | } | |
60 | ||
61 | n!(f); | |
62 | mod test2 { | |
63 | super::n! { | |
64 | f //~ ERROR cannot find function `f` in this scope | |
65 | } | |
66 | } | |
67 | } | |
68 | } |