From 368784949ef96a44a11b96511e9db4cbf6a635d7 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 31 Jan 2017 18:09:37 +0100 Subject: [PATCH] move to cargo clippy instead of using the clippy plugin (#733) * move to cargo clippy instead of using the clippy plugin fixes #729 * non-exectable scripts must be run with `sh` * don't build serde in the clippy travis job * only run clippy tests if installing clippy succeeds * why is travis so picky? * no more serde_codegen * serde_test_suite_deps has no features * don't use empty loops, llvm optimizes them to undefined behaviour * abort the clippy job when clippy lints are triggered * use caches on travis to speed up builds * why are we even using `travis-cargo`? * need to reinstall clippy frequently due to nightly updates * command line tools are hard --- .travis.yml | 17 +++++++---------- serde/Cargo.toml | 5 +---- serde/src/lib.rs | 4 +--- serde_codegen_internals/Cargo.toml | 4 ---- serde_codegen_internals/src/lib.rs | 3 --- serde_derive/Cargo.toml | 2 -- serde_derive/src/lib.rs | 6 ++---- serde_test/Cargo.toml | 4 ---- serde_test/src/lib.rs | 3 --- test_suite/Cargo.toml | 4 ---- test_suite/no_std/src/main.rs | 4 +++- test_suite/tests/test.rs | 3 --- travis.sh | 24 ++++++++++++++++++++++++ 13 files changed, 38 insertions(+), 45 deletions(-) create mode 100644 travis.sh diff --git a/.travis.yml b/.travis.yml index aca19dc8..c415551e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ sudo: false language: rust +cache: cargo # run builds for all the trains (and more) rust: @@ -8,20 +9,16 @@ rust: - beta - nightly +matrix: + include: + - rust: nightly + env: CLIPPY=true + before_script: - pip install 'travis-cargo<0.2' --user - export PATH=$HOME/.local/bin:$PATH -script: - - (cd serde && travis-cargo build) - - (cd serde && travis-cargo --only beta test) - - (cd serde && travis-cargo --only nightly test -- --features unstable-testing) - - (cd serde && travis-cargo build -- --no-default-features) - - (cd serde && travis-cargo --only nightly build -- --no-default-features --features alloc) - - (cd serde && travis-cargo --only nightly build -- --no-default-features --features collections) - - (cd test_suite && travis-cargo --only beta test) - - (cd test_suite/deps && travis-cargo --only nightly build && cd .. && travis-cargo --only nightly test -- --features unstable-testing) - - (cd test_suite/no_std && travis-cargo --only nightly build) +script: sh travis.sh env: global: diff --git a/serde/Cargo.toml b/serde/Cargo.toml index 2cc5dca4..357fff3a 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -22,10 +22,7 @@ std = [] unstable = [] alloc = ["unstable"] collections = ["alloc"] -unstable-testing = ["clippy", "unstable", "std"] - -[dependencies] -clippy = { version = "0.*", optional = true } +unstable-testing = ["unstable", "std"] [dev-dependencies] serde_derive = "0.9" diff --git a/serde/src/lib.rs b/serde/src/lib.rs index efb29411..eb07bbbf 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -64,9 +64,7 @@ #![cfg_attr(feature = "unstable", feature(nonzero, inclusive_range, zero_one))] #![cfg_attr(feature = "alloc", feature(alloc))] #![cfg_attr(feature = "collections", feature(collections, enumset))] -#![cfg_attr(feature = "clippy", feature(plugin))] -#![cfg_attr(feature = "clippy", plugin(clippy))] -#![cfg_attr(feature = "clippy", allow(linkedlist, type_complexity, doc_markdown))] +#![cfg_attr(feature = "cargo-clippy", allow(linkedlist, type_complexity, doc_markdown))] #![deny(missing_docs)] #[cfg(feature = "collections")] diff --git a/serde_codegen_internals/Cargo.toml b/serde_codegen_internals/Cargo.toml index 9d9bfb65..36ec99aa 100644 --- a/serde_codegen_internals/Cargo.toml +++ b/serde_codegen_internals/Cargo.toml @@ -10,11 +10,7 @@ documentation = "https://docs.serde.rs/serde_codegen_internals/" keywords = ["serde", "serialization"] include = ["Cargo.toml", "src/**/*.rs"] -[features] -unstable-testing = ["clippy"] - [dependencies] -clippy = { version = "0.*", optional = true } syn = "0.11" [badges] diff --git a/serde_codegen_internals/src/lib.rs b/serde_codegen_internals/src/lib.rs index 0f37f5fa..cd998deb 100644 --- a/serde_codegen_internals/src/lib.rs +++ b/serde_codegen_internals/src/lib.rs @@ -1,6 +1,3 @@ -#![cfg_attr(feature = "clippy", plugin(clippy))] -#![cfg_attr(feature = "clippy", feature(plugin))] - extern crate syn; pub mod ast; diff --git a/serde_derive/Cargo.toml b/serde_derive/Cargo.toml index 419cd962..e3c5f359 100644 --- a/serde_derive/Cargo.toml +++ b/serde_derive/Cargo.toml @@ -12,7 +12,6 @@ include = ["Cargo.toml", "src/**/*.rs"] [features] unstable = [] -unstable-testing = ["clippy", "serde_codegen_internals/unstable-testing"] [badges] travis-ci = { repository = "serde-rs/serde" } @@ -22,7 +21,6 @@ name = "serde_derive" proc-macro = true [dependencies] -clippy = { version = "0.*", optional = true } quote = "0.3.8" serde_codegen_internals = { version = "=0.12.0", default-features = false, path = "../serde_codegen_internals" } syn = { version = "0.11", features = ["aster", "visit"] } diff --git a/serde_derive/src/lib.rs b/serde_derive/src/lib.rs index cf80dc64..6e6a8c3a 100644 --- a/serde_derive/src/lib.rs +++ b/serde_derive/src/lib.rs @@ -1,7 +1,5 @@ -#![cfg_attr(feature = "clippy", plugin(clippy))] -#![cfg_attr(feature = "clippy", feature(plugin))] -#![cfg_attr(feature = "clippy", allow(too_many_arguments))] -#![cfg_attr(feature = "clippy", allow(used_underscore_binding))] +#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] +#![cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))] // The `quote!` macro requires deep recursion. #![recursion_limit = "192"] diff --git a/serde_test/Cargo.toml b/serde_test/Cargo.toml index 94f6a409..83d90e97 100644 --- a/serde_test/Cargo.toml +++ b/serde_test/Cargo.toml @@ -11,11 +11,7 @@ readme = "../README.md" keywords = ["serde", "serialization"] include = ["Cargo.toml", "src/**/*.rs"] -[features] -unstable-testing = ["clippy"] - [dependencies] -clippy = { version = "0.*", optional = true } serde = { version = "0.9", path = "../serde" } [badges] diff --git a/serde_test/src/lib.rs b/serde_test/src/lib.rs index 4c9397e6..945262c0 100644 --- a/serde_test/src/lib.rs +++ b/serde_test/src/lib.rs @@ -1,6 +1,3 @@ -#![cfg_attr(feature = "clippy", feature(plugin))] -#![cfg_attr(feature = "clippy", plugin(clippy))] - extern crate serde; mod assert; diff --git a/test_suite/Cargo.toml b/test_suite/Cargo.toml index 20039a9c..86ac863f 100644 --- a/test_suite/Cargo.toml +++ b/test_suite/Cargo.toml @@ -13,11 +13,8 @@ publish = false [features] unstable-testing = [ - "clippy", "compiletest_rs", "serde/unstable-testing", - "serde_derive/unstable-testing", - "serde_test/unstable-testing", ] [dev-dependencies] @@ -28,7 +25,6 @@ serde_derive = { path = "../serde_derive" } serde_test = { path = "../serde_test" } [dependencies] -clippy = { version = "0.*", optional = true } compiletest_rs = { version = "0.2", optional = true } [[test]] diff --git a/test_suite/no_std/src/main.rs b/test_suite/no_std/src/main.rs index 5eae5267..6639b5cc 100644 --- a/test_suite/no_std/src/main.rs +++ b/test_suite/no_std/src/main.rs @@ -21,7 +21,9 @@ pub extern fn rust_eh_unwind_resume() {} pub extern fn rust_begin_panic(_msg: core::fmt::Arguments, _file: &'static str, _line: u32) -> ! { - loop {} + unsafe { + libc::abort() + } } ////////////////////////////////////////////////////////////////////////////// diff --git a/test_suite/tests/test.rs b/test_suite/tests/test.rs index 7c1b06b5..b83be636 100644 --- a/test_suite/tests/test.rs +++ b/test_suite/tests/test.rs @@ -1,6 +1,3 @@ -#![cfg_attr(feature = "clippy", feature(plugin))] -#![cfg_attr(feature = "clippy", plugin(clippy))] - #![cfg_attr(feature = "unstable-testing", feature(test, non_ascii_idents))] #[cfg(feature = "unstable-testing")] diff --git a/travis.sh b/travis.sh new file mode 100644 index 00000000..225869ee --- /dev/null +++ b/travis.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -ev +if [ "${CLIPPY}" = "true" ]; then + if cargo install clippy -f; then + (cd serde && cargo clippy --features unstable-testing -- -Dclippy) + (cd serde_derive && cargo clippy --features unstable-testing -- -Dclippy) + (cd test_suite && cargo clippy --features unstable-testing -- -Dclippy) + (cd test_suite/deps && cargo clippy -- -Dclippy) + (cd test_suite/no_std && cargo clippy -- -Dclippy) + else + echo "could not compile clippy, ignoring clippy tests" + fi +else + (cd serde && travis-cargo build) + (cd serde && travis-cargo --only beta test) + (cd serde && travis-cargo --only nightly test -- --features unstable-testing) + (cd serde && travis-cargo build -- --no-default-features) + (cd serde && travis-cargo --only nightly build -- --no-default-features --features alloc) + (cd serde && travis-cargo --only nightly build -- --no-default-features --features collections) + (cd test_suite && travis-cargo --only beta test) + (cd test_suite/deps && travis-cargo --only nightly build) + (cd test_suite travis-cargo --only nightly test -- --features unstable-testing) + (cd test_suite/no_std && travis-cargo --only nightly build) +fi \ No newline at end of file