diff --git a/serde_macros/Cargo.toml b/serde_macros/Cargo.toml index 3b6b8a95..cd61e284 100644 --- a/serde_macros/Cargo.toml +++ b/serde_macros/Cargo.toml @@ -21,6 +21,7 @@ clippy = { version = "^0.*", optional = true } serde_codegen = { version = "^0.7.12", path = "../serde_codegen", default-features = false, features = ["nightly"] } [dev-dependencies] +clippy = "^0.0.78" compiletest_rs = "^0.2.0" fnv = "1.0" rustc-serialize = "^0.3.16" diff --git a/serde_macros/tests/compile_tests.rs b/serde_macros/tests/compile_tests.rs index 27c212b4..41942522 100644 --- a/serde_macros/tests/compile_tests.rs +++ b/serde_macros/tests/compile_tests.rs @@ -20,6 +20,11 @@ fn run_mode(mode: &'static str) { } #[test] -fn compile_test() { +fn compile_fail() { run_mode("compile-fail"); } + +#[test] +fn run_pass() { + run_mode("run-pass"); +} diff --git a/serde_macros/tests/run-pass/identity-op.rs b/serde_macros/tests/run-pass/identity-op.rs new file mode 100644 index 00000000..dcf8117a --- /dev/null +++ b/serde_macros/tests/run-pass/identity-op.rs @@ -0,0 +1,12 @@ +#![feature(custom_derive, plugin)] +#![plugin(serde_macros, clippy)] + +#![deny(identity_op)] + +// The derived implementation uses 0+1 to add up the number of fields +// serialized, which Clippy warns about. If the expansion info is registered +// correctly, the Clippy lint is not triggered. +#[derive(Serialize)] +struct A { b: u8 } + +fn main() {}