]> git.proxmox.com Git - rustc.git/blob - src/test/ui/proc-macro/cfg-eval.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / proc-macro / cfg-eval.rs
1 // check-pass
2 // compile-flags: -Z span-debug
3 // aux-build:test-macros.rs
4
5 #![feature(cfg_eval)]
6 #![feature(proc_macro_hygiene)]
7 #![feature(stmt_expr_attributes)]
8 #![feature(rustc_attrs)]
9 #![no_std] // Don't load unnecessary hygiene information from std
10 extern crate std;
11
12 #[macro_use]
13 extern crate test_macros;
14
15 #[cfg_eval]
16 #[print_attr]
17 struct S1 {
18 #[cfg(FALSE)]
19 field_false: u8,
20 #[cfg(all(/*true*/))]
21 #[cfg_attr(FALSE, unknown_attr)]
22 #[cfg_attr(all(/*true*/), allow())]
23 field_true: u8,
24 }
25
26 #[cfg_eval]
27 #[cfg(FALSE)]
28 struct S2 {}
29
30 fn main() {
31 // Subtle - we need a trailing comma after the '1' - otherwise, `#[cfg_eval]` will
32 // turn this into `(#[cfg(all())] 1)`, which is a parenthesized expression, not a tuple
33 // expression. `#[cfg]` is not supported inside parenthesized expressions, so this will
34 // produce an error when attribute collection runs.
35 let _ = #[cfg_eval] #[print_attr] #[cfg_attr(not(FALSE), rustc_dummy)]
36 (#[cfg(FALSE)] 0, #[cfg(all(/*true*/))] 1,);
37 }