]> git.proxmox.com Git - rustc.git/blob - src/test/ui/hygiene/generate-mod.rs
New upstream version 1.38.0+dfsg1
[rustc.git] / src / test / ui / hygiene / generate-mod.rs
1 // This is an equivalent of issue #50504, but for declarative macros.
2
3 #![feature(decl_macro, rustc_attrs)]
4
5 macro genmod($FromOutside: ident, $Outer: ident) {
6 type A = $FromOutside;
7 struct $Outer;
8 mod inner {
9 type A = $FromOutside; // `FromOutside` shouldn't be available from here
10 type Inner = $Outer; // `Outer` shouldn't be available from here
11 }
12 }
13
14 #[rustc_macro_transparency = "transparent"]
15 macro genmod_transparent() {
16 type A = FromOutside;
17 struct Outer;
18 mod inner {
19 type A = FromOutside; //~ ERROR cannot find type `FromOutside` in this scope
20 type Inner = Outer; //~ ERROR cannot find type `Outer` in this scope
21 }
22 }
23
24 macro_rules! genmod_legacy { () => {
25 type A = FromOutside;
26 struct Outer;
27 mod inner {
28 type A = FromOutside; //~ ERROR cannot find type `FromOutside` in this scope
29 type Inner = Outer; //~ ERROR cannot find type `Outer` in this scope
30 }
31 }}
32
33 fn check() {
34 struct FromOutside;
35 genmod!(FromOutside, Outer); //~ ERROR cannot find type `FromOutside` in this scope
36 //~| ERROR cannot find type `Outer` in this scope
37 }
38
39 fn check_transparent() {
40 struct FromOutside;
41 genmod_transparent!();
42 }
43
44 fn check_legacy() {
45 struct FromOutside;
46 genmod_legacy!();
47 }
48
49 fn main() {}