]> git.lizzy.rs Git - rust.git/blob - tests/ui/proc-macro/crate-var.rs
Auto merge of #106959 - tmiasko:opt-funclets, r=davidtwco
[rust.git] / tests / ui / proc-macro / crate-var.rs
1 // run-pass
2 // aux-build:double.rs
3 // aux-build:external-crate-var.rs
4
5 #![allow(unused)]
6
7 #[macro_use]
8 extern crate double;
9 #[macro_use]
10 extern crate external_crate_var;
11
12 struct Foo;
13
14 trait Trait {
15     const CONST: u32;
16     type Assoc;
17 }
18
19 impl Trait for Foo {
20     const CONST: u32 = 0;
21     type Assoc = Foo;
22 }
23
24 macro_rules! local { () => {
25     // derive_Double outputs secondary copies of each definition
26     // to test what the proc_macro sees.
27     mod bar {
28         #[derive(Double)]
29         struct Bar($crate::Foo);
30     }
31
32     mod qself {
33         #[derive(Double)]
34         struct QSelf(<::Foo as $crate::Trait>::Assoc);
35     }
36
37     mod qself_recurse {
38         #[derive(Double)]
39         struct QSelfRecurse(<<$crate::Foo as $crate::Trait>::Assoc as $crate::Trait>::Assoc);
40     }
41
42     mod qself_in_const {
43         #[derive(Double)]
44         #[repr(u32)]
45         enum QSelfInConst {
46             Variant = <::Foo as $crate::Trait>::CONST,
47         }
48     }
49 } }
50
51 mod local {
52     local!();
53 }
54
55 // and now repeat the above tests, using a macro defined in another crate
56
57 mod external {
58     external!{}
59 }
60
61 fn main() {}