]> git.proxmox.com Git - rustc.git/blob - tests/ui/const-generics/min_const_generics/macro.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / const-generics / min_const_generics / macro.rs
1 // run-pass
2 struct Example<const N: usize>;
3
4 macro_rules! external_macro {
5 () => {{
6 const X: usize = 1337;
7 X
8 }}
9 }
10
11 trait Marker<const N: usize> {}
12 impl<const N: usize> Marker<N> for Example<N> {}
13
14 fn make_marker() -> impl Marker<{
15 #[macro_export]
16 macro_rules! const_macro { () => {{ 3 }} } inline!()
17 }> {
18 Example::<{ const_macro!() }>
19 }
20
21 fn from_marker(_: impl Marker<{
22 #[macro_export]
23 macro_rules! inline { () => {{ 3 }} } inline!()
24 }>) {}
25
26 fn main() {
27 let _ok = Example::<{
28 #[macro_export]
29 macro_rules! gimme_a_const {
30 ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
31 }
32 gimme_a_const!(run)
33 }>;
34
35 let _ok = Example::<{ external_macro!() }>;
36
37 let _ok: [_; gimme_a_const!(blah)] = [0,0,0];
38 let _ok: [[u8; gimme_a_const!(blah)]; gimme_a_const!(blah)];
39 let _ok: [u8; gimme_a_const!(blah)];
40
41 let _ok: [u8; {
42 #[macro_export]
43 macro_rules! const_two { () => {{ 2 }} }
44 const_two!()
45 }];
46
47 let _ok = [0; {
48 #[macro_export]
49 macro_rules! const_three { () => {{ 3 }} }
50 const_three!()
51 }];
52 let _ok = [0; const_three!()];
53
54 from_marker(make_marker());
55 }