Skip to content

Commit b7c05a3

Browse files
Rollup merge of #77243 - Aaron1011:more-derive-test, r=petrochenkov
Test more attributes in test issue-75930-derive-cfg.rs Split out from #76130 This tests our handling of combining derives, derive helper attributes, attribute macros, and `cfg`/`cfg_attr`
2 parents 7a1a871 + a17175f commit b7c05a3

File tree

2 files changed

+1652
-6
lines changed

2 files changed

+1652
-6
lines changed

src/test/ui/proc-macro/issue-75930-derive-cfg.rs

+39-3
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,65 @@
11
// check-pass
2-
// compile-flags: -Z span-debug
2+
// compile-flags: -Z span-debug --error-format human
33
// aux-build:test-macros.rs
44

55
// Regression test for issue #75930
66
// Tests that we cfg-strip all targets before invoking
77
// 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)
812

913
#[macro_use]
1014
extern crate test_macros;
1115

16+
#[print_helper(a)]
17+
#[cfg_attr(not(FALSE), allow(dead_code))]
18+
#[print_attr]
1219
#[derive(Print)]
20+
#[print_helper(b)]
1321
struct Foo<#[cfg(FALSE)] A, B> {
1422
#[cfg(FALSE)] first: String,
15-
second: bool,
23+
#[cfg_attr(FALSE, deny(warnings))] second: bool,
1624
third: [u8; {
1725
#[cfg(FALSE)] struct Bar;
1826
#[cfg(not(FALSE))] struct Inner;
1927
#[cfg(FALSE)] let a = 25;
2028
match true {
2129
#[cfg(FALSE)] true => {},
22-
false => {},
30+
#[cfg_attr(not(FALSE), allow(warnings))] false => {},
2331
_ => {}
2432
};
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+
2560
0
2661
}],
62+
#[print_helper(d)]
2763
fourth: B
2864
}
2965

0 commit comments

Comments
 (0)