From 675caa82278d90da8339c6221fa93b9f0ba7ef4f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 12 Jun 2016 16:10:47 -0700 Subject: [PATCH] Add test for expansion inside of cfg_attr --- serde_tests/tests/test_macros.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/serde_tests/tests/test_macros.rs b/serde_tests/tests/test_macros.rs index 491acca205..72a768455f 100644 --- a/serde_tests/tests/test_macros.rs +++ b/serde_tests/tests/test_macros.rs @@ -14,9 +14,20 @@ trait Trait { #[deny(unused_variables)] enum Void {} -#[derive(Debug, PartialEq, Serialize, Deserialize)] +// Test that `derive` expansion works inside of `cfg_attr`. The `all()` is +// equivalent to true. This struct is used below in a way that requires it to +// implement all four traits. +#[cfg_attr(all(), derive(Debug, PartialEq, Serialize, Deserialize))] struct NamedUnit; +// Test that `derive` expansion pays attention to the `cfg_attr`. The `any()` +// is equivalent to false. +#[allow(dead_code)] +struct NotSerializable; +#[allow(dead_code)] +#[cfg_attr(any(), derive(Serialize))] +struct AlsoNotSerializable(NotSerializable); + #[derive(Debug, PartialEq, Serialize)] struct SerNamedTuple<'a, 'b, A: 'a, B: 'b, C>(&'a A, &'b mut B, C);