summaryrefslogtreecommitdiffstats
path: root/src/test/ui/proc-macro/issue-75930-derive-cfg.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/proc-macro/issue-75930-derive-cfg.rs')
-rw-r--r--src/test/ui/proc-macro/issue-75930-derive-cfg.rs42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.rs b/src/test/ui/proc-macro/issue-75930-derive-cfg.rs
index e0f248c..a051d23 100644
--- a/src/test/ui/proc-macro/issue-75930-derive-cfg.rs
+++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.rs
@@ -1,29 +1,65 @@
1// check-pass 1// check-pass
2// compile-flags: -Z span-debug 2// compile-flags: -Z span-debug --error-format human
3// aux-build:test-macros.rs 3// aux-build:test-macros.rs
4 4
5// Regression test for issue #75930 5// Regression test for issue #75930
6// Tests that we cfg-strip all targets before invoking 6// Tests that we cfg-strip all targets before invoking
7// a derive macro 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#[macro_use] 13#[macro_use]
10extern crate test_macros; 14extern crate test_macros;
11 15
16#[print_helper(a)]
17#[cfg_attr(not(FALSE), allow(dead_code))]
18#[print_attr]
12#[derive(Print)] 19#[derive(Print)]
20#[print_helper(b)]
13struct Foo<#[cfg(FALSE)] A, B> { 21struct Foo<#[cfg(FALSE)] A, B> {
14 #[cfg(FALSE)] first: String, 22 #[cfg(FALSE)] first: String,
15 second: bool, 23 #[cfg_attr(FALSE, deny(warnings))] second: bool,
16 third: [u8; { 24 third: [u8; {
17 #[cfg(FALSE)] struct Bar; 25 #[cfg(FALSE)] struct Bar;
18 #[cfg(not(FALSE))] struct Inner; 26 #[cfg(not(FALSE))] struct Inner;
19 #[cfg(FALSE)] let a = 25; 27 #[cfg(FALSE)] let a = 25;
20 match true { 28 match true {
21 #[cfg(FALSE)] true => {}, 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 0 60 0
26 }], 61 }],
62 #[print_helper(d)]
27 fourth: B 63 fourth: B
28} 64}
29 65