From 99bca9852c55eb7265310833ae38740f608bea27 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Tue, 13 May 2025 15:28:29 +0200 Subject: [PATCH] Opt in to edition 2024 formatting --- .github/workflows/ci.yml | 2 ++ benches/mutex.rs | 4 ++-- rustfmt.toml | 1 + src/graph.rs | 2 +- src/lib.rs | 12 +++++++----- src/lockapi.rs | 2 +- src/parkinglot.rs | 20 ++++++++++---------- src/parkinglot/tracing.rs | 2 +- src/stdsync/tracing.rs | 2 +- 9 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 rustfmt.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be359e3..728e4cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,8 @@ jobs: - run: cargo build --all-features --all-targets - run: cargo test --all-features - run: cargo fmt --all -- --check + # Note: Rust 1.74 doesn't understand edition 2024 formatting so no point + if: "${{ matrix.rust != '1.74' }}" - run: cargo clippy --all-features --all-targets -- -D warnings msrv: diff --git a/benches/mutex.rs b/benches/mutex.rs index 3fe8b83..045c7b0 100644 --- a/benches/mutex.rs +++ b/benches/mutex.rs @@ -1,11 +1,11 @@ use std::sync::Arc; use std::sync::Mutex; -use criterion::criterion_group; -use criterion::criterion_main; use criterion::BenchmarkId; use criterion::Criterion; use criterion::Throughput; +use criterion::criterion_group; +use criterion::criterion_main; use rand::prelude::*; use tracing_mutex::stdsync::tracing::Mutex as TracingMutex; diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..bc403f8 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +style_edition="2024" diff --git a/src/graph.rs b/src/graph.rs index dbd0f8f..86361f6 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1,7 +1,7 @@ use std::cell::Cell; -use std::collections::hash_map::Entry; use std::collections::HashMap; use std::collections::HashSet; +use std::collections::hash_map::Entry; use std::hash::Hash; type Order = usize; diff --git a/src/lib.rs b/src/lib.rs index 185da76..16e0caa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,12 +77,12 @@ use std::fmt; use std::marker::PhantomData; use std::ops::Deref; use std::ops::DerefMut; -use std::sync::atomic::AtomicUsize; -use std::sync::atomic::Ordering; use std::sync::Mutex; use std::sync::MutexGuard; use std::sync::OnceLock; use std::sync::PoisonError; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; #[cfg(feature = "lock_api")] #[cfg_attr(docsrs, doc(cfg(feature = "lockapi")))] @@ -351,9 +351,11 @@ mod tests { drop(b); // If b's destructor correctly ran correctly we can now add an edge from c to a. - assert!(get_dependency_graph() - .add_edge(c.value(), a.value(), Dep::capture) - .is_ok()); + assert!( + get_dependency_graph() + .add_edge(c.value(), a.value(), Dep::capture) + .is_ok() + ); } /// Test creating a cycle, then panicking. diff --git a/src/lockapi.rs b/src/lockapi.rs index afd4fa7..771ae9f 100644 --- a/src/lockapi.rs +++ b/src/lockapi.rs @@ -24,9 +24,9 @@ use lock_api::RawRwLockUpgradeDowngrade; use lock_api::RawRwLockUpgradeFair; use lock_api::RawRwLockUpgradeTimed; -use crate::util::PrivateTraced; use crate::LazyMutexId; use crate::MutexId; +use crate::util::PrivateTraced; /// Tracing wrapper for all [`lock_api`] traits. /// diff --git a/src/parkinglot.rs b/src/parkinglot.rs index eed59b7..a2cf2e7 100644 --- a/src/parkinglot.rs +++ b/src/parkinglot.rs @@ -49,18 +49,18 @@ pub mod tracing; #[cfg(debug_assertions)] pub use tracing::{ - const_fair_mutex, const_mutex, const_reentrant_mutex, const_rwlock, FairMutex, FairMutexGuard, - MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, MappedRwLockReadGuard, - MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex, RawRwLock, - ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, - RwLockWriteGuard, + FairMutex, FairMutexGuard, MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, + MappedRwLockReadGuard, MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex, + RawRwLock, ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard, + RwLockUpgradableReadGuard, RwLockWriteGuard, const_fair_mutex, const_mutex, + const_reentrant_mutex, const_rwlock, }; #[cfg(not(debug_assertions))] pub use parking_lot::{ - const_fair_mutex, const_mutex, const_reentrant_mutex, const_rwlock, FairMutex, FairMutexGuard, - MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, MappedRwLockReadGuard, - MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex, RawRwLock, - ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard, RwLockUpgradableReadGuard, - RwLockWriteGuard, + FairMutex, FairMutexGuard, MappedFairMutexGuard, MappedMutexGuard, MappedReentrantMutexGuard, + MappedRwLockReadGuard, MappedRwLockWriteGuard, Mutex, MutexGuard, Once, RawFairMutex, RawMutex, + RawRwLock, ReentrantMutex, ReentrantMutexGuard, RwLock, RwLockReadGuard, + RwLockUpgradableReadGuard, RwLockWriteGuard, const_fair_mutex, const_mutex, + const_reentrant_mutex, const_rwlock, }; diff --git a/src/parkinglot/tracing.rs b/src/parkinglot/tracing.rs index 5d65260..f47333e 100644 --- a/src/parkinglot/tracing.rs +++ b/src/parkinglot/tracing.rs @@ -2,8 +2,8 @@ pub use parking_lot::OnceState; pub use parking_lot::RawThreadId; -use crate::lockapi::TracingWrapper; use crate::LazyMutexId; +use crate::lockapi::TracingWrapper; pub type RawFairMutex = TracingWrapper<::parking_lot::RawFairMutex>; pub type RawMutex = TracingWrapper<::parking_lot::RawMutex>; diff --git a/src/stdsync/tracing.rs b/src/stdsync/tracing.rs index a47d493..2b813af 100644 --- a/src/stdsync/tracing.rs +++ b/src/stdsync/tracing.rs @@ -10,9 +10,9 @@ use std::sync::TryLockResult; use std::sync::WaitTimeoutResult; use std::time::Duration; -use crate::util::PrivateTraced; use crate::BorrowedMutex; use crate::LazyMutexId; +use crate::util::PrivateTraced; #[cfg(has_std__sync__LazyLock)] pub use lazy_lock::LazyLock;