Skip to content

Commit

Permalink
Merge #428
Browse files Browse the repository at this point in the history
428: Fix build failure on nightly and the minimum version r=jeehoonkang a=taiki-e

`target_has_atomic = "cas"` was removed in rust-lang/rust#65214.

Fixes rust-lang/rust#65424 
Fixes #412


Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e committed Oct 16, 2019
2 parents ae148de + 35dc824 commit a5859f3
Show file tree
Hide file tree
Showing 29 changed files with 78 additions and 81 deletions.
24 changes: 16 additions & 8 deletions .travis.yml
Expand Up @@ -16,23 +16,23 @@ matrix:
- rust: 1.28.0
name: "crossbeam on 1.28.0"
script: ./ci/crossbeam.sh
- rust: 1.26.0
name: "crossbeam-channel on 1.26.0"
- rust: 1.28.0
name: "crossbeam-channel on 1.28.0"
script: ./ci/crossbeam-channel.sh
- rust: 1.28.0
name: "crossbeam-deque on 1.28.0"
script: ./ci/crossbeam-deque.sh
- rust: 1.26.0
name: "crossbeam-epoch on 1.26.0"
- rust: 1.28.0
name: "crossbeam-epoch on 1.28.0"
script: ./ci/crossbeam-epoch.sh
- rust: 1.26.0
name: "crossbeam-queue on 1.26.0"
- rust: 1.28.0
name: "crossbeam-queue on 1.28.0"
script: ./ci/crossbeam-queue.sh
- rust: 1.28.0
name: "crossbeam-skiplist on 1.28.0"
script: ./ci/crossbeam-skiplist.sh
- rust: 1.26.0
name: "crossbeam-utils on 1.26.0"
- rust: 1.28.0
name: "crossbeam-utils on 1.28.0"
script: ./ci/crossbeam-utils.sh

# Test crates on nightly Rust.
Expand Down Expand Up @@ -90,3 +90,11 @@ matrix:
- rust: stable
name: "rustfmt"
script: ./ci/rustfmt.sh

before_script:
# cfg-if 0.1.10 requires Rust 1.31+ so downgrade it.
- |
if [[ "$TRAVIS_RUST_VERSION" == "1.28.0" ]]; then
cargo generate-lockfile
cargo update -p cfg-if --precise 0.1.9
fi
4 changes: 1 addition & 3 deletions ci/crossbeam-channel.sh
Expand Up @@ -3,9 +3,7 @@
cd "$(dirname "$0")"/../crossbeam-channel
set -ex

if [[ "$TRAVIS_RUST_VERSION" != "nightly" ]]; then
export RUSTFLAGS="-D warnings"
fi
export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
cargo test -- --test-threads=1
Expand Down
4 changes: 1 addition & 3 deletions ci/crossbeam-deque.sh
Expand Up @@ -3,9 +3,7 @@
cd "$(dirname "$0")"/../crossbeam-deque
set -ex

if [[ "$TRAVIS_RUST_VERSION" != "nightly" ]]; then
export RUSTFLAGS="-D warnings"
fi
export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
cargo test
4 changes: 1 addition & 3 deletions ci/crossbeam-epoch.sh
Expand Up @@ -3,9 +3,7 @@
cd "$(dirname "$0")"/../crossbeam-epoch
set -ex

if [[ "$TRAVIS_RUST_VERSION" != "nightly" ]]; then
export RUSTFLAGS="-D warnings"
fi
export RUSTFLAGS="-D warnings"

cargo check --no-default-features
cargo check --bins --examples --tests
Expand Down
4 changes: 1 addition & 3 deletions ci/crossbeam-queue.sh
Expand Up @@ -3,9 +3,7 @@
cd "$(dirname "$0")"/../crossbeam-queue
set -ex

if [[ "$TRAVIS_RUST_VERSION" != "nightly" ]]; then
export RUSTFLAGS="-D warnings"
fi
export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
cargo test
4 changes: 1 addition & 3 deletions ci/crossbeam-skiplist.sh
Expand Up @@ -3,9 +3,7 @@
cd "$(dirname "$0")"/../crossbeam-skiplist
set -ex

if [[ "$TRAVIS_RUST_VERSION" != "nightly" ]]; then
export RUSTFLAGS="-D warnings"
fi
export RUSTFLAGS="-D warnings"

cargo check --no-default-features
cargo check --bins --examples --tests
Expand Down
4 changes: 1 addition & 3 deletions ci/crossbeam-utils.sh
Expand Up @@ -3,9 +3,7 @@
cd "$(dirname "$0")"/../crossbeam-utils
set -ex

if [[ "$TRAVIS_RUST_VERSION" != "nightly" ]]; then
export RUSTFLAGS="-D warnings"
fi
export RUSTFLAGS="-D warnings"

cargo check --no-default-features
cargo check --bins --examples --tests
Expand Down
4 changes: 1 addition & 3 deletions ci/crossbeam.sh
Expand Up @@ -3,9 +3,7 @@
cd "$(dirname "$0")"/..
set -ex

if [[ "$TRAVIS_RUST_VERSION" != "nightly" ]]; then
export RUSTFLAGS="-D warnings"
fi
export RUSTFLAGS="-D warnings"

cargo check --no-default-features
cargo check --bins --examples --tests
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/README.md
Expand Up @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam-channel)
https://crates.io/crates/crossbeam-channel)
[![Documentation](https://docs.rs/crossbeam-channel/badge.svg)](
https://docs.rs/crossbeam-channel)
[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)](
[![Rust 1.28+](https://img.shields.io/badge/rust-1.28+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq)

Expand Down
16 changes: 8 additions & 8 deletions crossbeam-channel/src/err.rs
Expand Up @@ -132,7 +132,7 @@ impl<T: Send> error::Error for SendError<T> {
"sending on a disconnected channel"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ impl<T: Send> error::Error for TrySendError<T> {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<T: Send> error::Error for SendTimeoutError<T> {
"sending on an empty and disconnected channel"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -317,7 +317,7 @@ impl error::Error for RecvError {
"receiving on an empty and disconnected channel"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand All @@ -339,7 +339,7 @@ impl error::Error for TryRecvError {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -387,7 +387,7 @@ impl error::Error for RecvTimeoutError {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -429,7 +429,7 @@ impl error::Error for TrySelectError {
"all operations in select would block"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand All @@ -445,7 +445,7 @@ impl error::Error for SelectTimeoutError {
"timed out waiting on select"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
30 changes: 18 additions & 12 deletions crossbeam-channel/src/select.rs
Expand Up @@ -171,7 +171,7 @@ enum Timeout {
/// Successful receive operations will have to be followed up by `channel::read()` and successful
/// send operations by `channel::write()`.
fn run_select(
handles: &mut [(&SelectHandle, usize, *const u8)],
handles: &mut [(&dyn SelectHandle, usize, *const u8)],
timeout: Timeout,
) -> Option<(Token, usize, *const u8)> {
if handles.is_empty() {
Expand Down Expand Up @@ -220,7 +220,7 @@ fn run_select(
registered_count += 1;

// If registration returns `false`, that means the operation has just become ready.
if handle.register(Operation::hook::<&SelectHandle>(handle), cx) {
if handle.register(Operation::hook::<&dyn SelectHandle>(handle), cx) {
// Try aborting select.
sel = match cx.try_select(Selected::Aborted) {
Ok(()) => {
Expand Down Expand Up @@ -259,7 +259,7 @@ fn run_select(

// Unregister all registered operations.
for (handle, _, _) in handles.iter_mut().take(registered_count) {
handle.unregister(Operation::hook::<&SelectHandle>(handle));
handle.unregister(Operation::hook::<&dyn SelectHandle>(handle));
}

match sel {
Expand All @@ -279,7 +279,8 @@ fn run_select(
// Find the selected operation.
for (handle, i, ptr) in handles.iter_mut() {
// Is this the selected operation?
if sel == Selected::Operation(Operation::hook::<&SelectHandle>(handle)) {
if sel == Selected::Operation(Operation::hook::<&dyn SelectHandle>(handle))
{
// Try selecting this operation.
if handle.accept(&mut token, cx) {
return Some((*i, *ptr));
Expand Down Expand Up @@ -317,7 +318,10 @@ fn run_select(
}

/// Runs until one of the operations becomes ready, potentially blocking the current thread.
fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout) -> Option<usize> {
fn run_ready(
handles: &mut [(&dyn SelectHandle, usize, *const u8)],
timeout: Timeout,
) -> Option<usize> {
if handles.is_empty() {
// Wait until the timeout and return.
match timeout {
Expand Down Expand Up @@ -372,7 +376,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
// Begin watching all operations.
for (handle, _, _) in handles.iter_mut() {
registered_count += 1;
let oper = Operation::hook::<&SelectHandle>(handle);
let oper = Operation::hook::<&dyn SelectHandle>(handle);

// If registration returns `false`, that means the operation has just become ready.
if handle.watch(oper, cx) {
Expand Down Expand Up @@ -410,7 +414,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout

// Unwatch all operations.
for (handle, _, _) in handles.iter_mut().take(registered_count) {
handle.unwatch(Operation::hook::<&SelectHandle>(handle));
handle.unwatch(Operation::hook::<&dyn SelectHandle>(handle));
}

match sel {
Expand All @@ -419,7 +423,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
Selected::Disconnected => {}
Selected::Operation(_) => {
for (handle, i, _) in handles.iter_mut() {
let oper = Operation::hook::<&SelectHandle>(handle);
let oper = Operation::hook::<&dyn SelectHandle>(handle);
if sel == Selected::Operation(oper) {
return Some(*i);
}
Expand All @@ -440,7 +444,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
/// Attempts to select one of the operations without blocking.
#[inline]
pub fn try_select<'a>(
handles: &mut [(&'a SelectHandle, usize, *const u8)],
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
) -> Result<SelectedOperation<'a>, TrySelectError> {
match run_select(handles, Timeout::Now) {
None => Err(TrySelectError),
Expand All @@ -455,7 +459,9 @@ pub fn try_select<'a>(

/// Blocks until one of the operations becomes ready and selects it.
#[inline]
pub fn select<'a>(handles: &mut [(&'a SelectHandle, usize, *const u8)]) -> SelectedOperation<'a> {
pub fn select<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
) -> SelectedOperation<'a> {
if handles.is_empty() {
panic!("no operations have been added to `Select`");
}
Expand All @@ -472,7 +478,7 @@ pub fn select<'a>(handles: &mut [(&'a SelectHandle, usize, *const u8)]) -> Selec
/// Blocks for a limited time until one of the operations becomes ready and selects it.
#[inline]
pub fn select_timeout<'a>(
handles: &mut [(&'a SelectHandle, usize, *const u8)],
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
timeout: Duration,
) -> Result<SelectedOperation<'a>, SelectTimeoutError> {
let timeout = Timeout::At(Instant::now() + timeout);
Expand Down Expand Up @@ -573,7 +579,7 @@ pub fn select_timeout<'a>(
/// [`ready_timeout`]: struct.Select.html#method.ready_timeout
pub struct Select<'a> {
/// A list of senders and receivers participating in selection.
handles: Vec<(&'a SelectHandle, usize, *const u8)>,
handles: Vec<(&'a dyn SelectHandle, usize, *const u8)>,

/// The next index to assign to an operation.
next_index: usize,
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/array.rs
Expand Up @@ -624,7 +624,7 @@ fn recv_in_send() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

let (s, r) = bounded::<T>(1);

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/golang.rs
Expand Up @@ -1289,7 +1289,7 @@ mod chan_test {
fn test_chan_send_interface() {
struct Mt;

let c = make::<Box<Any>>(1);
let c = make::<Box<dyn Any>>(1);
c.send(Box::new(Mt));

select! {
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/list.rs
Expand Up @@ -503,7 +503,7 @@ fn recv_in_send() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

let (s, r) = unbounded::<T>();

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/ready.rs
Expand Up @@ -673,7 +673,7 @@ fn send_recv_same_channel() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

for cap in 1..4 {
let (s, r) = bounded::<T>(cap);
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/select.rs
Expand Up @@ -947,7 +947,7 @@ fn matching_with_leftover() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

for cap in 0..3 {
let (s, r) = bounded::<T>(cap);
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/select_macro.rs
Expand Up @@ -687,7 +687,7 @@ fn matching_with_leftover() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

for cap in 0..3 {
let (s, r) = bounded::<T>(cap);
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/zero.rs
Expand Up @@ -524,7 +524,7 @@ fn recv_in_send() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

let (s, r) = bounded::<T>(0);

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-epoch/README.md
Expand Up @@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam-epoch)
https://crates.io/crates/crossbeam-epoch)
[![Documentation](https://docs.rs/crossbeam-epoch/badge.svg)](
https://docs.rs/crossbeam-epoch)
[![Rust 1.26+](https://img.shields.io/badge/rust-1.26+-lightgray.svg)](
[![Rust 1.28+](https://img.shields.io/badge/rust-1.28+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.gg/BBYwKq)

Expand Down

0 comments on commit a5859f3

Please sign in to comment.