From d3187be4ae1d9fc88666d872fda8a311d4c5d5b6 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 23 Jul 2022 16:27:02 +0900 Subject: [PATCH 1/2] Remove deprecated items This removes the following deprecated items: - crossbeam-epoch: - `CompareAndSetError` - `CompareAndSetOrdering` - `Atomic::compare_and_set` - `Atomic::compare_and_set_weak` - crossbeam-utils: - `AtomicCell::compare_and_swap` --- crossbeam-epoch/src/atomic.rs | 205 ---------------------- crossbeam-epoch/src/lib.rs | 3 - crossbeam-utils/src/atomic/atomic_cell.rs | 28 --- 3 files changed, 236 deletions(-) diff --git a/crossbeam-epoch/src/atomic.rs b/crossbeam-epoch/src/atomic.rs index 19bab4729..588ea380c 100644 --- a/crossbeam-epoch/src/atomic.rs +++ b/crossbeam-epoch/src/atomic.rs @@ -13,23 +13,6 @@ use crate::guard::Guard; use crate::primitive::sync::atomic::AtomicUsize; use crossbeam_utils::atomic::AtomicConsume; -/// Given ordering for the success case in a compare-exchange operation, returns the strongest -/// appropriate ordering for the failure case. -#[inline] -fn strongest_failure_ordering(ord: Ordering) -> Ordering { - use self::Ordering::*; - match ord { - Relaxed | Release => Relaxed, - Acquire | AcqRel => Acquire, - _ => SeqCst, - } -} - -/// The error returned on failed compare-and-set operation. -// TODO: remove in the next major version. -#[deprecated(note = "Use `CompareExchangeError` instead")] -pub type CompareAndSetError<'g, T, P> = CompareExchangeError<'g, T, P>; - /// The error returned on failed compare-and-swap operation. pub struct CompareExchangeError<'g, T: ?Sized + Pointable, P: Pointer> { /// The value in the atomic pointer at the time of the failed operation. @@ -48,59 +31,6 @@ impl + fmt::Debug> fmt::Debug for CompareExchangeError<'_, T, P } } -/// Memory orderings for compare-and-set operations. -/// -/// A compare-and-set operation can have different memory orderings depending on whether it -/// succeeds or fails. This trait generalizes different ways of specifying memory orderings. -/// -/// The two ways of specifying orderings for compare-and-set are: -/// -/// 1. Just one `Ordering` for the success case. In case of failure, the strongest appropriate -/// ordering is chosen. -/// 2. A pair of `Ordering`s. The first one is for the success case, while the second one is -/// for the failure case. -// TODO: remove in the next major version. -#[deprecated( - note = "`compare_and_set` and `compare_and_set_weak` that use this trait are deprecated, \ - use `compare_exchange` or `compare_exchange_weak instead`" -)] -pub trait CompareAndSetOrdering { - /// The ordering of the operation when it succeeds. - fn success(&self) -> Ordering; - - /// The ordering of the operation when it fails. - /// - /// The failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than - /// the success ordering. - fn failure(&self) -> Ordering; -} - -#[allow(deprecated)] -impl CompareAndSetOrdering for Ordering { - #[inline] - fn success(&self) -> Ordering { - *self - } - - #[inline] - fn failure(&self) -> Ordering { - strongest_failure_ordering(*self) - } -} - -#[allow(deprecated)] -impl CompareAndSetOrdering for (Ordering, Ordering) { - #[inline] - fn success(&self) -> Ordering { - self.0 - } - - #[inline] - fn failure(&self) -> Ordering { - self.1 - } -} - /// Returns a bitmask containing the unused least significant bits of an aligned pointer to `T`. #[inline] fn low_bits() -> usize { @@ -640,141 +570,6 @@ impl Atomic { Err(prev) } - /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current - /// value is the same as `current`. The tag is also taken into account, so two pointers to the - /// same object, but with different tags, will not be considered equal. - /// - /// The return value is a result indicating whether the new pointer was written. On success the - /// pointer that was written is returned. On failure the actual current value and `new` are - /// returned. - /// - /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory - /// ordering of this operation. - /// - /// # Migrating to `compare_exchange` - /// - /// `compare_and_set` is equivalent to `compare_exchange` with the following mapping for - /// memory orderings: - /// - /// Original | Success | Failure - /// -------- | ------- | ------- - /// Relaxed | Relaxed | Relaxed - /// Acquire | Acquire | Acquire - /// Release | Release | Relaxed - /// AcqRel | AcqRel | Acquire - /// SeqCst | SeqCst | SeqCst - /// - /// # Examples - /// - /// ``` - /// # #![allow(deprecated)] - /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; - /// use std::sync::atomic::Ordering::SeqCst; - /// - /// let a = Atomic::new(1234); - /// - /// let guard = &epoch::pin(); - /// let curr = a.load(SeqCst, guard); - /// let res1 = a.compare_and_set(curr, Shared::null(), SeqCst, guard); - /// let res2 = a.compare_and_set(curr, Owned::new(5678), SeqCst, guard); - /// # unsafe { drop(curr.into_owned()); } // avoid leak - /// ``` - // TODO: remove in the next major version. - #[allow(deprecated)] - #[deprecated(note = "Use `compare_exchange` instead")] - pub fn compare_and_set<'g, O, P>( - &self, - current: Shared<'_, T>, - new: P, - ord: O, - guard: &'g Guard, - ) -> Result, CompareAndSetError<'g, T, P>> - where - O: CompareAndSetOrdering, - P: Pointer, - { - self.compare_exchange(current, new, ord.success(), ord.failure(), guard) - } - - /// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current - /// value is the same as `current`. The tag is also taken into account, so two pointers to the - /// same object, but with different tags, will not be considered equal. - /// - /// Unlike [`compare_and_set`], this method is allowed to spuriously fail even when comparison - /// succeeds, which can result in more efficient code on some platforms. The return value is a - /// result indicating whether the new pointer was written. On success the pointer that was - /// written is returned. On failure the actual current value and `new` are returned. - /// - /// This method takes a [`CompareAndSetOrdering`] argument which describes the memory - /// ordering of this operation. - /// - /// [`compare_and_set`]: Atomic::compare_and_set - /// - /// # Migrating to `compare_exchange_weak` - /// - /// `compare_and_set_weak` is equivalent to `compare_exchange_weak` with the following mapping for - /// memory orderings: - /// - /// Original | Success | Failure - /// -------- | ------- | ------- - /// Relaxed | Relaxed | Relaxed - /// Acquire | Acquire | Acquire - /// Release | Release | Relaxed - /// AcqRel | AcqRel | Acquire - /// SeqCst | SeqCst | SeqCst - /// - /// # Examples - /// - /// ``` - /// # #![allow(deprecated)] - /// use crossbeam_epoch::{self as epoch, Atomic, Owned, Shared}; - /// use std::sync::atomic::Ordering::SeqCst; - /// - /// let a = Atomic::new(1234); - /// let guard = &epoch::pin(); - /// - /// let mut new = Owned::new(5678); - /// let mut ptr = a.load(SeqCst, guard); - /// # unsafe { drop(a.load(SeqCst, guard).into_owned()); } // avoid leak - /// loop { - /// match a.compare_and_set_weak(ptr, new, SeqCst, guard) { - /// Ok(p) => { - /// ptr = p; - /// break; - /// } - /// Err(err) => { - /// ptr = err.current; - /// new = err.new; - /// } - /// } - /// } - /// - /// let mut curr = a.load(SeqCst, guard); - /// loop { - /// match a.compare_and_set_weak(curr, Shared::null(), SeqCst, guard) { - /// Ok(_) => break, - /// Err(err) => curr = err.current, - /// } - /// } - /// # unsafe { drop(curr.into_owned()); } // avoid leak - /// ``` - // TODO: remove in the next major version. - #[allow(deprecated)] - #[deprecated(note = "Use `compare_exchange_weak` instead")] - pub fn compare_and_set_weak<'g, O, P>( - &self, - current: Shared<'_, T>, - new: P, - ord: O, - guard: &'g Guard, - ) -> Result, CompareAndSetError<'g, T, P>> - where - O: CompareAndSetOrdering, - P: Pointer, - { - self.compare_exchange_weak(current, new, ord.success(), ord.failure(), guard) - } - /// Bitwise "and" with the current tag. /// /// Performs a bitwise "and" operation on the current tag and the argument `val`, and sets the diff --git a/crossbeam-epoch/src/lib.rs b/crossbeam-epoch/src/lib.rs index 4cf982b6b..1f8d6c403 100644 --- a/crossbeam-epoch/src/lib.rs +++ b/crossbeam-epoch/src/lib.rs @@ -155,9 +155,6 @@ cfg_if! { }; pub use self::collector::{Collector, LocalHandle}; pub use self::guard::{unprotected, Guard}; - - #[allow(deprecated)] - pub use self::atomic::{CompareAndSetError, CompareAndSetOrdering}; } } diff --git a/crossbeam-utils/src/atomic/atomic_cell.rs b/crossbeam-utils/src/atomic/atomic_cell.rs index 7941c5c87..c60efbc94 100644 --- a/crossbeam-utils/src/atomic/atomic_cell.rs +++ b/crossbeam-utils/src/atomic/atomic_cell.rs @@ -221,34 +221,6 @@ impl AtomicCell { } impl AtomicCell { - /// If the current value equals `current`, stores `new` into the atomic cell. - /// - /// The return value is always the previous value. If it is equal to `current`, then the value - /// was updated. - /// - /// # Examples - /// - /// ``` - /// # #![allow(deprecated)] - /// use crossbeam_utils::atomic::AtomicCell; - /// - /// let a = AtomicCell::new(1); - /// - /// assert_eq!(a.compare_and_swap(2, 3), 1); - /// assert_eq!(a.load(), 1); - /// - /// assert_eq!(a.compare_and_swap(1, 2), 1); - /// assert_eq!(a.load(), 2); - /// ``` - // TODO: remove in the next major version. - #[deprecated(note = "Use `compare_exchange` instead")] - pub fn compare_and_swap(&self, current: T, new: T) -> T { - match self.compare_exchange(current, new) { - Ok(v) => v, - Err(v) => v, - } - } - /// If the current value equals `current`, stores `new` into the atomic cell. /// /// The return value is a result indicating whether the new value was written and containing From d303ef1055ec7e1d845c0d3be4d5e8895954ca20 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sat, 23 Jul 2022 16:41:48 +0900 Subject: [PATCH 2/2] Remove unused nightly features --- Cargo.toml | 7 ------- ci/check-features.sh | 15 +++++---------- ci/san.sh | 1 - ci/test.sh | 5 +---- crossbeam-epoch/Cargo.toml | 9 --------- crossbeam-queue/Cargo.toml | 9 --------- crossbeam-utils/Cargo.toml | 9 --------- 7 files changed, 6 insertions(+), 49 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6b6882a8c..905c8ded6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,13 +33,6 @@ std = [ # This is enabled by default and also enabled if the `std` feature is enabled. alloc = ["crossbeam-epoch/alloc", "crossbeam-queue/alloc"] -# Enable to use of unstable functionality. -# This is disabled by default and requires recent nightly compiler. -# -# NOTE: This feature is outside of the normal semver guarantees and minor or -# patch versions of crossbeam may make breaking changes to them at any time. -nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly", "crossbeam-queue/nightly"] - [dependencies] cfg-if = "1" diff --git a/ci/check-features.sh b/ci/check-features.sh index 6c4a02978..ea6f6c032 100755 --- a/ci/check-features.sh +++ b/ci/check-features.sh @@ -3,17 +3,12 @@ set -euxo pipefail IFS=$'\n\t' cd "$(dirname "$0")"/.. -if [[ "$RUST_VERSION" != "nightly"* ]]; then - # On MSRV, features other than nightly should work. - # * `--feature-powerset` - run for the feature powerset which includes --no-default-features and default features of package - # * `--no-dev-deps` - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866 - # * `--exclude benchmarks` - benchmarks doesn't published. - # * `--skip nightly` - skip `nightly` feature as requires nightly compilers. - cargo hack build --all --feature-powerset --no-dev-deps --exclude benchmarks --skip nightly -else - # On nightly, all feature combinations should work. - cargo hack build --all --feature-powerset --no-dev-deps --exclude benchmarks +# * `--feature-powerset` - run for the feature powerset which includes --no-default-features and default features of package +# * `--no-dev-deps` - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866 +# * `--exclude benchmarks` - benchmarks doesn't published. +cargo hack build --all --feature-powerset --no-dev-deps --exclude benchmarks +if [[ "$RUST_VERSION" == "nightly"* ]]; then # Build for no_std environment. # thumbv7m-none-eabi supports atomic CAS. # thumbv6m-none-eabi supports atomic, but not atomic CAS. diff --git a/ci/san.sh b/ci/san.sh index 0923f6759..4926d8d40 100755 --- a/ci/san.sh +++ b/ci/san.sh @@ -35,7 +35,6 @@ RUSTFLAGS="${RUSTFLAGS:-} -Z sanitizer=address --cfg crossbeam_sanitize" \ cargo run \ --release \ --target x86_64-unknown-linux-gnu \ - --features nightly \ --example sanitize \ --manifest-path crossbeam-epoch/Cargo.toml diff --git a/ci/test.sh b/ci/test.sh index ab70b5e2e..ecaf162ee 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -13,12 +13,9 @@ fi # Otherwise, run tests and checks with the host target. cargo check --all --bins --examples --tests --exclude benchmarks -cargo test --all --exclude benchmarks -- --test-threads=1 +cargo test --all --all-features --exclude benchmarks -- --test-threads=1 if [[ "$RUST_VERSION" == "nightly"* ]]; then - # Some crates have `nightly` feature, so run tests with --all-features. - cargo test --all --all-features --exclude benchmarks -- --test-threads=1 - # Benchmarks are only checked on nightly because depending on unstable features. cargo check --all --benches cargo check --bins --manifest-path crossbeam-channel/benchmarks/Cargo.toml diff --git a/crossbeam-epoch/Cargo.toml b/crossbeam-epoch/Cargo.toml index f40369306..51837da32 100644 --- a/crossbeam-epoch/Cargo.toml +++ b/crossbeam-epoch/Cargo.toml @@ -27,15 +27,6 @@ std = ["alloc", "crossbeam-utils/std", "once_cell"] # NOTE: Disabling both `std` *and* `alloc` features is not supported yet. alloc = [] -# These features are no longer used. -# TODO: remove in the next major version. -# Enable to use of unstable functionality. -# This is disabled by default and requires recent nightly compiler. -# -# NOTE: This feature is outside of the normal semver guarantees and minor or -# patch versions of crossbeam may make breaking changes to them at any time. -nightly = ["crossbeam-utils/nightly"] - # Enable the use of loom for concurrency testing. # # NOTE: This feature is outside of the normal semver guarantees and minor or diff --git a/crossbeam-queue/Cargo.toml b/crossbeam-queue/Cargo.toml index 2e4d7ced7..fbcbc7b7a 100644 --- a/crossbeam-queue/Cargo.toml +++ b/crossbeam-queue/Cargo.toml @@ -27,15 +27,6 @@ std = ["alloc", "crossbeam-utils/std"] # NOTE: Disabling both `std` *and* `alloc` features is not supported yet. alloc = [] -# These features are no longer used. -# TODO: remove in the next major version. -# Enable to use of unstable functionality. -# This is disabled by default and requires recent nightly compiler. -# -# NOTE: This feature is outside of the normal semver guarantees and minor or -# patch versions of crossbeam may make breaking changes to them at any time. -nightly = ["crossbeam-utils/nightly"] - [dependencies] cfg-if = "1" diff --git a/crossbeam-utils/Cargo.toml b/crossbeam-utils/Cargo.toml index e4e5a9a42..f7ec9253a 100644 --- a/crossbeam-utils/Cargo.toml +++ b/crossbeam-utils/Cargo.toml @@ -21,15 +21,6 @@ default = ["std"] # This is enabled by default. std = ["once_cell"] -# These features are no longer used. -# TODO: remove in the next major version. -# Enable to use of unstable functionality. -# This is disabled by default and requires recent nightly compiler. -# -# NOTE: This feature is outside of the normal semver guarantees and minor or -# patch versions of crossbeam may make breaking changes to them at any time. -nightly = [] - [dependencies] cfg-if = "1" once_cell = { version = "1", optional = true }