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`
This commit is contained in:
parent
e37c99fa1c
commit
a17175f4dd
|
@ -1,29 +1,65 @@
|
||||||
// check-pass
|
// check-pass
|
||||||
// compile-flags: -Z span-debug
|
// compile-flags: -Z span-debug --error-format human
|
||||||
// aux-build:test-macros.rs
|
// aux-build:test-macros.rs
|
||||||
|
|
||||||
// Regression test for issue #75930
|
// Regression test for issue #75930
|
||||||
// Tests that we cfg-strip all targets before invoking
|
// Tests that we cfg-strip all targets before invoking
|
||||||
// a derive macro
|
// a derive macro
|
||||||
|
// We need '--error-format human' to stop compiletest from
|
||||||
|
// trying to interpret proc-macro output as JSON messages
|
||||||
|
// (a pretty-printed struct may cause a line to start with '{' )
|
||||||
|
// FIXME: We currently lose spans here (see issue #43081)
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate test_macros;
|
extern crate test_macros;
|
||||||
|
|
||||||
|
#[print_helper(a)]
|
||||||
|
#[cfg_attr(not(FALSE), allow(dead_code))]
|
||||||
|
#[print_attr]
|
||||||
#[derive(Print)]
|
#[derive(Print)]
|
||||||
|
#[print_helper(b)]
|
||||||
struct Foo<#[cfg(FALSE)] A, B> {
|
struct Foo<#[cfg(FALSE)] A, B> {
|
||||||
#[cfg(FALSE)] first: String,
|
#[cfg(FALSE)] first: String,
|
||||||
second: bool,
|
#[cfg_attr(FALSE, deny(warnings))] second: bool,
|
||||||
third: [u8; {
|
third: [u8; {
|
||||||
#[cfg(FALSE)] struct Bar;
|
#[cfg(FALSE)] struct Bar;
|
||||||
#[cfg(not(FALSE))] struct Inner;
|
#[cfg(not(FALSE))] struct Inner;
|
||||||
#[cfg(FALSE)] let a = 25;
|
#[cfg(FALSE)] let a = 25;
|
||||||
match true {
|
match true {
|
||||||
#[cfg(FALSE)] true => {},
|
#[cfg(FALSE)] true => {},
|
||||||
false => {},
|
#[cfg_attr(not(FALSE), allow(warnings))] false => {},
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[print_helper(should_be_removed)]
|
||||||
|
fn removed_fn() {
|
||||||
|
#![cfg(FALSE)]
|
||||||
|
}
|
||||||
|
|
||||||
|
#[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() {
|
||||||
|
#![cfg(not(FALSE))]
|
||||||
|
let my_val = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TupleEnum {
|
||||||
|
Foo(
|
||||||
|
#[cfg(FALSE)] u8,
|
||||||
|
#[cfg(FALSE)] bool,
|
||||||
|
#[cfg(not(FALSE))] i32,
|
||||||
|
#[cfg(FALSE)] String, u8
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TupleStruct(
|
||||||
|
#[cfg(FALSE)] String,
|
||||||
|
#[cfg(not(FALSE))] i32,
|
||||||
|
#[cfg(FALSE)] bool,
|
||||||
|
u8
|
||||||
|
);
|
||||||
|
|
||||||
0
|
0
|
||||||
}],
|
}],
|
||||||
|
#[print_helper(d)]
|
||||||
fourth: B
|
fourth: B
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue