Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for expansion inside of cfg_attr #382

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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