dist: trusty
sudo: required
language: rust
cache: cargo
rust:
    - nightly
    - beta
    - stable
matrix:
    allow_failures:
        - rust: nightly
before_install:
    - sudo apt-get -qq update
    - sudo apt-get install -yq --no-install-recommends libdbus-1-dev
install:
    - cargo install rustfmt || true
script:
    - cargo clean
    - cargo fmt -- --write-mode=diff
    - ((test $TRAVIS_RUST_VERSION == "nightly" && cargo build --features "clippy") || true)
    - cargo build --verbose

dist: trusty
sudo: required
language: rust
cache: cargo
rust:
    - nightly
    - beta
    - stable
matrix:
    allow_failures:
        - rust: nightly
before_install:
    - sudo apt-get -qq update
    - sudo apt-get install -yq --no-install-recommends libdbus-1-dev
install:
    - cargo install rustfmt || true
    - if [[ $TRAVIS_RUST_VERSION == "nightly" ]]; then cargo install clippy || true; fi
script:
    - cargo clean
    - cargo fmt -- --write-mode=diff
    - if [[ $TRAVIS_RUST_VERSION == "nightly" ]]; then cargo clippy; fi
    - cargo build --verbose

Use clippy as a cargo subcommand and use an `if`, so that exit statuses are not obscured
Use clippy as a cargo subcommand and use an `if`, so that exit statuses are not obscured
