From a05739810d85ac44dce9d1e505e4562c93f984d8 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Mon, 24 Nov 2025 23:07:28 +0100 Subject: [PATCH] Enforce Item granularity --- .github/workflows/ci.yml | 21 +++++++++++++++------ rustfmt.toml | 1 + src/parkinglot.rs | 3 +++ src/stdsync.rs | 3 +++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 642ae1c..13fd2ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,10 +23,10 @@ jobs: steps: - uses: actions/checkout@v5 - - uses: dtolnay/rust-toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - components: rustfmt, clippy + components: clippy # Make sure we test with recent deps - run: cargo update @@ -44,13 +44,24 @@ jobs: steps: - uses: actions/checkout@v5 - - uses: dtolnay/rust-toolchain@v1 + - uses: dtolnay/rust-toolchain@1.74 with: toolchain: "1.70" # Test everything except experimental features. - run: cargo test --features backtraces,lock_api,parking_lot + formatting: + name: Formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + # Use nightly formatting options + - uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt + - run: cargo fmt --check + docs: name: Documentation build runs-on: ubuntu-latest @@ -58,9 +69,7 @@ jobs: steps: - uses: actions/checkout@v5 - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: nightly + - uses: dtolnay/rust-toolchain@nightly - name: Build documentation env: diff --git a/rustfmt.toml b/rustfmt.toml index bc403f8..838d693 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1,2 @@ style_edition="2024" +imports_granularity="Item" diff --git a/src/parkinglot.rs b/src/parkinglot.rs index a2cf2e7..d62db6e 100644 --- a/src/parkinglot.rs +++ b/src/parkinglot.rs @@ -47,6 +47,8 @@ pub use parking_lot::WaitTimeoutResult; pub mod tracing; +// Skip reformatting the combined imports as it duplicates the guards +#[rustfmt::skip] #[cfg(debug_assertions)] pub use tracing::{ FairMutex, FairMutexGuard, MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, @@ -56,6 +58,7 @@ pub use tracing::{ const_reentrant_mutex, const_rwlock, }; +#[rustfmt::skip] #[cfg(not(debug_assertions))] pub use parking_lot::{ FairMutex, FairMutexGuard, MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, diff --git a/src/stdsync.rs b/src/stdsync.rs index 65a1421..beb2969 100644 --- a/src/stdsync.rs +++ b/src/stdsync.rs @@ -20,11 +20,14 @@ //! ``` pub use std::sync as raw; +// Skip reformatting the combined imports as it duplicates the guards +#[rustfmt::skip] #[cfg(not(debug_assertions))] pub use std::sync::{ Condvar, Mutex, MutexGuard, Once, OnceLock, RwLock, RwLockReadGuard, RwLockWriteGuard, }; +#[rustfmt::skip] #[cfg(debug_assertions)] pub use tracing::{ Condvar, Mutex, MutexGuard, Once, OnceLock, RwLock, RwLockReadGuard, RwLockWriteGuard,