]> git.proxmox.com Git - rustc.git/blob - src/test/ui/proc-macro/issue-75930-derive-cfg.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / ui / proc-macro / issue-75930-derive-cfg.rs
1 // check-pass
2 // compile-flags: -Z span-debug --error-format human
3 // aux-build:test-macros.rs
4
5 // Regression test for issue #75930
6 // Tests that we cfg-strip all targets before invoking
7 // a derive macro
8 // We need '--error-format human' to stop compiletest from
9 // trying to interpret proc-macro output as JSON messages
10 // (a pretty-printed struct may cause a line to start with '{' )
11 // FIXME: We currently lose spans here (see issue #43081)
12
13 #![no_std] // Don't load unnecessary hygiene information from std
14 extern crate std;
15
16 #[macro_use]
17 extern crate test_macros;
18
19 #[print_helper(a)] //~ WARN derive helper attribute is used before it is introduced
20 //~| WARN this was previously accepted
21 #[cfg_attr(not(FALSE), allow(dead_code))]
22 #[print_attr]
23 #[derive(Print)]
24 #[print_helper(b)]
25 struct Foo<#[cfg(FALSE)] A, B> {
26 #[cfg(FALSE)] first: String,
27 #[cfg_attr(FALSE, deny(warnings))] second: bool,
28 third: [u8; {
29 #[cfg(FALSE)] struct Bar;
30 #[cfg(not(FALSE))] struct Inner;
31 #[cfg(FALSE)] let a = 25;
32 match true {
33 #[cfg(FALSE)] true => {},
34 #[cfg_attr(not(FALSE), allow(warnings))] false => {},
35 _ => {}
36 };
37
38 #[print_helper(should_be_removed)]
39 fn removed_fn() {
40 #![cfg(FALSE)]
41 }
42
43 #[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() {
44 #![cfg(not(FALSE))]
45 let my_val = true;
46 }
47
48 enum TupleEnum {
49 Foo(
50 #[cfg(FALSE)] u8,
51 #[cfg(FALSE)] bool,
52 #[cfg(not(FALSE))] i32,
53 #[cfg(FALSE)] String, u8
54 )
55 }
56
57 struct TupleStruct(
58 #[cfg(FALSE)] String,
59 #[cfg(not(FALSE))] i32,
60 #[cfg(FALSE)] bool,
61 u8
62 );
63
64 fn plain_removed_fn() {
65 #![cfg_attr(not(FALSE), cfg(FALSE))]
66 }
67
68 0
69 }],
70 #[print_helper(d)]
71 fourth: B
72 }
73
74 fn main() {}