diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2022-12-08 21:06:28 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-12-08 21:06:28 +0000 |
commit | 1ec781d16264759946d3f0cd5d50205d5500eba8 (patch) | |
tree | 36bef811d6198660ec13c8bc50480e0696c96fe9 | |
parent | 8430278912a461368d1ae6a1444ab51932f4b486 (diff) | |
parent | 6e162b3c9475d35f6e243a906cbb431d77ce93ec (diff) | |
download | crossbeam-channel-1ec781d16264759946d3f0cd5d50205d5500eba8.tar.gz |
Upgrade crossbeam-channel to 0.5.6 am: eb774e880c am: 6e162b3c94
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/crossbeam-channel/+/2335347
Change-Id: I6a1caae904df84888efa598519423ce1fcbebd19
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | Cargo.lock.saved (renamed from Cargo.lock) | 10 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Cargo.toml.orig | 4 | ||||
-rw-r--r-- | METADATA | 12 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | src/flavors/array.rs | 4 | ||||
-rw-r--r-- | src/flavors/list.rs | 18 | ||||
-rw-r--r-- | src/flavors/zero.rs | 10 | ||||
-rw-r--r-- | tests/array.rs | 6 | ||||
-rw-r--r-- | tests/golang.rs | 7 | ||||
-rw-r--r-- | tests/list.rs | 3 | ||||
-rw-r--r-- | tests/mpsc.rs | 15 | ||||
-rw-r--r-- | tests/select.rs | 1 | ||||
-rw-r--r-- | tests/select_macro.rs | 1 | ||||
-rw-r--r-- | tests/thread_locals.rs | 2 | ||||
-rw-r--r-- | tests/zero.rs | 8 |
19 files changed, 59 insertions, 58 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 1ea95d0..d38e4ea 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "16769892dc5e1ba14c8ea14e92e85f442e25f4aa" + "sha1": "5e0f59a9990c032c33e1db16a6bfc64b4ab6102d" }, "path_in_vcs": "crossbeam-channel" }
\ No newline at end of file @@ -47,7 +47,7 @@ rust_library { host_supported: true, crate_name: "crossbeam_channel", cargo_env_compat: true, - cargo_pkg_version: "0.5.5", + cargo_pkg_version: "0.5.6", srcs: ["src/lib.rs"], edition: "2018", features: [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f627cf..f0d11e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 0.5.6 + +- Bump the minimum supported Rust version to 1.38. (#877) + # Version 0.5.5 - Replace Spinlock with Mutex. (#835) diff --git a/Cargo.lock b/Cargo.lock.saved index cd6eb05..e40f836 100644 --- a/Cargo.lock +++ b/Cargo.lock.saved @@ -10,7 +10,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "crossbeam-channel" -version = "0.5.5" +version = "0.5.6" dependencies = [ "cfg-if", "crossbeam-utils", @@ -21,9 +21,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.9" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff1f980957787286a554052d03c7aee98d99cc32e09f6d45f0a814133c87978" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" dependencies = [ "cfg-if", "once_cell", @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "ppv-lite86" @@ -11,9 +11,9 @@ [package] edition = "2018" -rust-version = "1.36" +rust-version = "1.38" name = "crossbeam-channel" -version = "0.5.5" +version = "0.5.6" description = "Multi-producer multi-consumer channels for message passing" homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel" readme = "README.md" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 344092c..8089202 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -4,9 +4,9 @@ name = "crossbeam-channel" # - Update CHANGELOG.md # - Update README.md # - Create "crossbeam-channel-X.Y.Z" git tag -version = "0.5.5" +version = "0.5.6" edition = "2018" -rust-version = "1.36" +rust-version = "1.38" license = "MIT OR Apache-2.0" repository = "https://github.com/crossbeam-rs/crossbeam" homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel" @@ -1,3 +1,7 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update rust/crates/crossbeam-channel +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + name: "crossbeam-channel" description: "Multi-producer multi-consumer channels for message passing" third_party { @@ -7,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/crossbeam-channel/crossbeam-channel-0.5.5.crate" + value: "https://static.crates.io/crates/crossbeam-channel/crossbeam-channel-0.5.6.crate" } - version: "0.5.5" + version: "0.5.6" license_type: NOTICE last_upgrade_date { year: 2022 - month: 6 - day: 28 + month: 12 + day: 8 } } @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel#license) https://crates.io/crates/crossbeam-channel) [![Documentation](https://docs.rs/crossbeam-channel/badge.svg)]( https://docs.rs/crossbeam-channel) -[![Rust 1.36+](https://img.shields.io/badge/rust-1.36+-lightgray.svg)]( +[![Rust 1.38+](https://img.shields.io/badge/rust-1.38+-lightgray.svg)]( https://www.rust-lang.org) [![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.com/invite/JXYwgWZ) @@ -48,7 +48,7 @@ crossbeam-channel = "0.5" Crossbeam Channel supports stable Rust releases going back at least six months, and every time the minimum supported Rust version is increased, a new minor -version is released. Currently, the minimum supported Rust version is 1.36. +version is released. Currently, the minimum supported Rust version is 1.38. ## License diff --git a/src/flavors/array.rs b/src/flavors/array.rs index 73557d3..63b82eb 100644 --- a/src/flavors/array.rs +++ b/src/flavors/array.rs @@ -216,7 +216,7 @@ impl<T> Channel<T> { return Err(msg); } - let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>); + let slot: &Slot<T> = &*token.array.slot.cast::<Slot<T>>(); // Write the message into the slot and update the stamp. slot.msg.get().write(MaybeUninit::new(msg)); @@ -307,7 +307,7 @@ impl<T> Channel<T> { return Err(()); } - let slot: &Slot<T> = &*(token.array.slot as *const Slot<T>); + let slot: &Slot<T> = &*token.array.slot.cast::<Slot<T>>(); // Read the message from the slot and update the stamp. let msg = slot.msg.get().read().assume_init(); diff --git a/src/flavors/list.rs b/src/flavors/list.rs index 9bda6d1..6090b8d 100644 --- a/src/flavors/list.rs +++ b/src/flavors/list.rs @@ -49,6 +49,11 @@ struct Slot<T> { } impl<T> Slot<T> { + const UNINIT: Self = Self { + msg: UnsafeCell::new(MaybeUninit::uninit()), + state: AtomicUsize::new(0), + }; + /// Waits until a message is written into the slot. fn wait_write(&self) { let backoff = Backoff::new(); @@ -72,13 +77,10 @@ struct Block<T> { impl<T> Block<T> { /// Creates an empty block. fn new() -> Block<T> { - // SAFETY: This is safe because: - // [1] `Block::next` (AtomicPtr) may be safely zero initialized. - // [2] `Block::slots` (Array) may be safely zero initialized because of [3, 4]. - // [3] `Slot::msg` (UnsafeCell) may be safely zero initialized because it - // holds a MaybeUninit. - // [4] `Slot::state` (AtomicUsize) may be safely zero initialized. - unsafe { MaybeUninit::zeroed().assume_init() } + Self { + next: AtomicPtr::new(ptr::null_mut()), + slots: [Slot::UNINIT; BLOCK_CAP], + } } /// Waits until the next pointer is set. @@ -283,7 +285,7 @@ impl<T> Channel<T> { } // Write the message into the slot. - let block = token.list.block as *mut Block<T>; + let block = token.list.block.cast::<Block<T>>(); let offset = token.list.offset; let slot = (*block).slots.get_unchecked(offset); slot.msg.get().write(MaybeUninit::new(msg)); diff --git a/src/flavors/zero.rs b/src/flavors/zero.rs index 31e62af..aae2ea3 100644 --- a/src/flavors/zero.rs +++ b/src/flavors/zero.rs @@ -190,7 +190,7 @@ impl<T> Channel<T> { // heap-allocated packet. packet.wait_ready(); let msg = packet.msg.get().replace(None).unwrap(); - drop(Box::from_raw(token.zero.0 as *mut Packet<T>)); + drop(Box::from_raw(token.zero.0.cast::<Packet<T>>())); Ok(msg) } } @@ -409,7 +409,7 @@ impl<T> SelectHandle for Receiver<'_, T> { let mut inner = self.0.inner.lock().unwrap(); inner .receivers - .register_with_packet(oper, packet as *mut (), cx); + .register_with_packet(oper, packet.cast::<()>(), cx); inner.senders.notify(); inner.senders.can_select() || inner.is_disconnected } @@ -417,7 +417,7 @@ impl<T> SelectHandle for Receiver<'_, T> { fn unregister(&self, oper: Operation) { if let Some(operation) = self.0.inner.lock().unwrap().receivers.unregister(oper) { unsafe { - drop(Box::from_raw(operation.packet as *mut Packet<T>)); + drop(Box::from_raw(operation.packet.cast::<Packet<T>>())); } } } @@ -459,7 +459,7 @@ impl<T> SelectHandle for Sender<'_, T> { let mut inner = self.0.inner.lock().unwrap(); inner .senders - .register_with_packet(oper, packet as *mut (), cx); + .register_with_packet(oper, packet.cast::<()>(), cx); inner.receivers.notify(); inner.receivers.can_select() || inner.is_disconnected } @@ -467,7 +467,7 @@ impl<T> SelectHandle for Sender<'_, T> { fn unregister(&self, oper: Operation) { if let Some(operation) = self.0.inner.lock().unwrap().senders.unregister(oper) { unsafe { - drop(Box::from_raw(operation.packet as *mut Packet<T>)); + drop(Box::from_raw(operation.packet.cast::<Packet<T>>())); } } } diff --git a/tests/array.rs b/tests/array.rs index de843cd..6fd8ffc 100644 --- a/tests/array.rs +++ b/tests/array.rs @@ -377,7 +377,7 @@ fn spsc() { #[test] fn mpmc() { #[cfg(miri)] - const COUNT: usize = 100; + const COUNT: usize = 50; #[cfg(not(miri))] const COUNT: usize = 25_000; const THREADS: usize = 4; @@ -532,16 +532,12 @@ fn drops() { scope.spawn(|_| { for _ in 0..steps { r.recv().unwrap(); - #[cfg(miri)] - std::thread::yield_now(); // https://github.com/rust-lang/miri/issues/1388 } }); scope.spawn(|_| { for _ in 0..steps { s.send(DropCounter).unwrap(); - #[cfg(miri)] - std::thread::yield_now(); // https://github.com/rust-lang/miri/issues/1388 } }); }) diff --git a/tests/golang.rs b/tests/golang.rs index 6a46c03..8050716 100644 --- a/tests/golang.rs +++ b/tests/golang.rs @@ -959,7 +959,7 @@ mod chan_test { #[test] fn test_chan() { #[cfg(miri)] - const N: i32 = 20; + const N: i32 = 12; #[cfg(not(miri))] const N: i32 = 200; @@ -1489,7 +1489,7 @@ mod chan_test { fn test_multi_consumer() { const NWORK: usize = 23; #[cfg(miri)] - const NITER: usize = 100; + const NITER: usize = 50; #[cfg(not(miri))] const NITER: usize = 271828; @@ -1580,9 +1580,7 @@ mod race_chan_test { } // https://github.com/golang/go/blob/master/test/ken/chan.go -#[cfg(not(miri))] // Miri is too slow mod chan { - use super::*; const MESSAGES_PER_CHANEL: u32 = 76; @@ -2052,6 +2050,7 @@ mod chan { } #[test] + #[cfg_attr(miri, ignore)] // Miri is too slow fn main() { let mut ctx = Context { nproc: Arc::new(Mutex::new(0)), diff --git a/tests/list.rs b/tests/list.rs index a0b9087..ebe6f6f 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -67,6 +67,7 @@ fn len_empty_full() { } #[test] +#[cfg_attr(miri, ignore)] // this test makes timing assumptions, but Miri is so slow it violates them fn try_recv() { let (s, r) = unbounded(); @@ -433,8 +434,6 @@ fn drops() { scope.spawn(|_| { for _ in 0..steps { r.recv().unwrap(); - #[cfg(miri)] - std::thread::yield_now(); // https://github.com/rust-lang/miri/issues/1388 } }); diff --git a/tests/mpsc.rs b/tests/mpsc.rs index 3db4812..d7cc8e2 100644 --- a/tests/mpsc.rs +++ b/tests/mpsc.rs @@ -339,25 +339,22 @@ mod channel_tests { #[test] fn stress_shared() { - #[cfg(miri)] - const AMT: u32 = 100; - #[cfg(not(miri))] - const AMT: u32 = 10000; - const NTHREADS: u32 = 8; + let amt: u32 = if cfg!(miri) { 100 } else { 10_000 }; + let nthreads: u32 = if cfg!(miri) { 4 } else { 8 }; let (tx, rx) = channel::<i32>(); let t = thread::spawn(move || { - for _ in 0..AMT * NTHREADS { + for _ in 0..amt * nthreads { assert_eq!(rx.recv().unwrap(), 1); } assert!(rx.try_recv().is_err()); }); - let mut ts = Vec::with_capacity(NTHREADS as usize); - for _ in 0..NTHREADS { + let mut ts = Vec::with_capacity(nthreads as usize); + for _ in 0..nthreads { let tx = tx.clone(); let t = thread::spawn(move || { - for _ in 0..AMT { + for _ in 0..amt { tx.send(1).unwrap(); } }); diff --git a/tests/select.rs b/tests/select.rs index e7691f5..bc5824d 100644 --- a/tests/select.rs +++ b/tests/select.rs @@ -408,7 +408,6 @@ fn both_ready() { .unwrap(); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn loop_try() { const RUNS: usize = 20; diff --git a/tests/select_macro.rs b/tests/select_macro.rs index 91c04e1..119454c 100644 --- a/tests/select_macro.rs +++ b/tests/select_macro.rs @@ -284,7 +284,6 @@ fn both_ready() { .unwrap(); } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn loop_try() { const RUNS: usize = 20; diff --git a/tests/thread_locals.rs b/tests/thread_locals.rs index effb6a1..fb4e577 100644 --- a/tests/thread_locals.rs +++ b/tests/thread_locals.rs @@ -1,6 +1,6 @@ //! Tests that make sure accessing thread-locals while exiting the thread doesn't cause panics. -#![cfg(not(miri))] // error: abnormal termination: the evaluated program aborted execution +#![cfg(not(miri))] // Miri detects that this test is buggy: the destructor of `FOO` uses `std::thread::current()`! use std::thread; use std::time::Duration; diff --git a/tests/zero.rs b/tests/zero.rs index c90d741..74c9a3e 100644 --- a/tests/zero.rs +++ b/tests/zero.rs @@ -328,9 +328,11 @@ fn stress_oneshot() { } } -#[cfg_attr(miri, ignore)] // Miri is too slow #[test] fn stress_iter() { + #[cfg(miri)] + const COUNT: usize = 50; + #[cfg(not(miri))] const COUNT: usize = 1000; let (request_s, request_r) = bounded(0); @@ -403,7 +405,7 @@ fn drops() { #[cfg(not(miri))] const RUNS: usize = 100; #[cfg(miri)] - const STEPS: usize = 500; + const STEPS: usize = 100; #[cfg(not(miri))] const STEPS: usize = 10_000; @@ -485,7 +487,7 @@ fn fairness() { #[test] fn fairness_duplicates() { #[cfg(miri)] - const COUNT: usize = 50; + const COUNT: usize = 100; #[cfg(not(miri))] const COUNT: usize = 10_000; |