Skip to content

Commit

Permalink
Auto merge of #382 - dtolnay:cfg, r=erickt
Browse files Browse the repository at this point in the history
Add test for expansion inside of cfg_attr

Test for #148. Requires serde-deprecated/syntex#71 + Syntex release.
  • Loading branch information
homu committed Jun 23, 2016
2 parents 1fb2172 + 675caa8 commit b09eee0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion serde_tests/tests/test_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b09eee0

Please sign in to comment.