From b01f5950b1bd26e7abdd62f0b6b5c7c467cdd783 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 14 Jun 2019 00:10:18 +0700 Subject: [PATCH] ci: Run cargo fmt on all workspaces --- .travis.yml | 9 ++++++++- tests/testsuite/support/paths.rs | 18 +++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 695d9317beb..a13fca22930 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: rust rust: stable -sudo: required dist: trusty git: @@ -8,6 +7,14 @@ git: matrix: include: + - name: "rustfmt" + env: TARGET=x86_64-unknown-linux-gnu + rust: stable + before_script: + - rustup component add rustfmt + script: + - cargo fmt --all -- --check + - env: TARGET=x86_64-unknown-linux-gnu ALT=i686-unknown-linux-gnu if: branch != master OR type = pull_request diff --git a/tests/testsuite/support/paths.rs b/tests/testsuite/support/paths.rs index 66868d27b76..918da387c82 100644 --- a/tests/testsuite/support/paths.rs +++ b/tests/testsuite/support/paths.rs @@ -51,18 +51,16 @@ thread_local! { } pub struct TestIdGuard { - _private: () + _private: (), } pub fn init_root() -> TestIdGuard { static NEXT_ID: AtomicUsize = AtomicUsize::new(0); let id = NEXT_ID.fetch_add(1, Ordering::Relaxed); - TEST_ID.with(|n| { *n.borrow_mut() = Some(id) } ); + TEST_ID.with(|n| *n.borrow_mut() = Some(id)); - let guard = TestIdGuard { - _private: () - }; + let guard = TestIdGuard { _private: () }; root().mkdir_p(); @@ -71,15 +69,17 @@ pub fn init_root() -> TestIdGuard { impl Drop for TestIdGuard { fn drop(&mut self) { - TEST_ID.with(|n| { *n.borrow_mut() = None } ); + TEST_ID.with(|n| *n.borrow_mut() = None); } } pub fn root() -> PathBuf { let id = TEST_ID.with(|n| { - n.borrow().expect("Tests must use the `#[cargo_test]` attribute in \ - order to be able to use the crate root.") - } ); + n.borrow().expect( + "Tests must use the `#[cargo_test]` attribute in \ + order to be able to use the crate root.", + ) + }); GLOBAL_ROOT.join(&format!("t{}", id)) }