|
1 | 1 | // check-pass |
2 | | -// compile-flags: -Z span-debug |
| 2 | +// compile-flags: -Z span-debug --error-format human |
3 | 3 | // aux-build:test-macros.rs |
4 | 4 |
|
5 | 5 | // Regression test for issue #75930 |
6 | 6 | // Tests that we cfg-strip all targets before invoking |
7 | 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) |
8 | 12 |
|
9 | 13 | #[macro_use] |
10 | 14 | extern crate test_macros; |
11 | 15 |
|
| 16 | +#[print_helper(a)] |
| 17 | +#[cfg_attr(not(FALSE), allow(dead_code))] |
| 18 | +#[print_attr] |
12 | 19 | #[derive(Print)] |
| 20 | +#[print_helper(b)] |
13 | 21 | struct Foo<#[cfg(FALSE)] A, B> { |
14 | 22 | #[cfg(FALSE)] first: String, |
15 | | - second: bool, |
| 23 | + #[cfg_attr(FALSE, deny(warnings))] second: bool, |
16 | 24 | third: [u8; { |
17 | 25 | #[cfg(FALSE)] struct Bar; |
18 | 26 | #[cfg(not(FALSE))] struct Inner; |
19 | 27 | #[cfg(FALSE)] let a = 25; |
20 | 28 | match true { |
21 | 29 | #[cfg(FALSE)] true => {}, |
22 | | - false => {}, |
| 30 | + #[cfg_attr(not(FALSE), allow(warnings))] false => {}, |
23 | 31 | _ => {} |
24 | 32 | }; |
| 33 | + |
| 34 | + #[print_helper(should_be_removed)] |
| 35 | + fn removed_fn() { |
| 36 | + #![cfg(FALSE)] |
| 37 | + } |
| 38 | + |
| 39 | + #[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() { |
| 40 | + #![cfg(not(FALSE))] |
| 41 | + let my_val = true; |
| 42 | + } |
| 43 | + |
| 44 | + enum TupleEnum { |
| 45 | + Foo( |
| 46 | + #[cfg(FALSE)] u8, |
| 47 | + #[cfg(FALSE)] bool, |
| 48 | + #[cfg(not(FALSE))] i32, |
| 49 | + #[cfg(FALSE)] String, u8 |
| 50 | + ) |
| 51 | + } |
| 52 | + |
| 53 | + struct TupleStruct( |
| 54 | + #[cfg(FALSE)] String, |
| 55 | + #[cfg(not(FALSE))] i32, |
| 56 | + #[cfg(FALSE)] bool, |
| 57 | + u8 |
| 58 | + ); |
| 59 | + |
25 | 60 | 0 |
26 | 61 | }], |
| 62 | + #[print_helper(d)] |
27 | 63 | fourth: B |
28 | 64 | } |
29 | 65 |
|
|
0 commit comments