Skip to content

Commit

Permalink
Merge #511
Browse files Browse the repository at this point in the history
511: Migrate to Rust 2018 r=jeehoonkang a=taiki-e

This migrates all crates to Rust 2018.

The first commit contains the minimal changes needed for the migration. This was mainly done by `cargo fix --editon`.
The second commit migrates the code to be the Rust 2018 idiomatic style. This mainly based on suggestions from `rust_2018_idioms` lint.

Co-authored-by: Taiki Endo <te316e89@gmail.com>
  • Loading branch information
bors[bot] and taiki-e committed May 23, 2020
2 parents 5f96f86 + 1532530 commit 33b9232
Show file tree
Hide file tree
Showing 119 changed files with 573 additions and 823 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -6,6 +6,7 @@ name = "crossbeam"
# - Create "crossbeam-X.Y.Z" git tag
version = "0.7.3"
authors = ["The Crossbeam Project Developers"]
edition = "2018"
license = "MIT/Apache-2.0"
readme = "README.md"
repository = "https://github.com/crossbeam-rs/crossbeam"
Expand Down Expand Up @@ -44,7 +45,7 @@ alloc = ["crossbeam-epoch/alloc", "crossbeam-queue/alloc"]
nightly = ["crossbeam-epoch/nightly", "crossbeam-utils/nightly", "crossbeam-queue/nightly"]

[dependencies]
cfg-if = "0.1.2"
cfg-if = "0.1.10"

[dependencies.crossbeam-channel]
version = "0.4"
Expand Down
6 changes: 0 additions & 6 deletions README.md
Expand Up @@ -90,12 +90,6 @@ Add this to your `Cargo.toml`:
crossbeam = "0.7"
```

Next, add this to your crate:

```rust
extern crate crossbeam;
```

## Compatibility

Crossbeam supports stable Rust releases going back at least six months,
Expand Down
3 changes: 2 additions & 1 deletion crossbeam-channel/Cargo.toml
Expand Up @@ -6,6 +6,7 @@ name = "crossbeam-channel"
# - Create "crossbeam-channel-X.Y.Z" git tag
version = "0.4.2"
authors = ["The Crossbeam Project Developers"]
edition = "2018"
license = "MIT/Apache-2.0 AND BSD-2-Clause"
readme = "README.md"
repository = "https://github.com/crossbeam-rs/crossbeam"
Expand All @@ -23,7 +24,7 @@ default = ["std"]
std = ["crossbeam-utils/std"]

[dependencies]
cfg-if = "0.1.2"
cfg-if = "0.1.10"

[dependencies.crossbeam-utils]
version = "0.7"
Expand Down
7 changes: 0 additions & 7 deletions crossbeam-channel/README.md
Expand Up @@ -44,13 +44,6 @@ Add this to your `Cargo.toml`:
crossbeam-channel = "0.4"
```

Next, add this to your crate:

```rust
#[macro_use]
extern crate crossbeam_channel;
```

## Compatibility

Crossbeam Channel supports stable Rust releases going back at least six months,
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benches/crossbeam.rs
@@ -1,8 +1,5 @@
#![feature(test)]

extern crate crossbeam_channel;
extern crate crossbeam_utils;
extern crate num_cpus;
extern crate test;

use crossbeam_channel::{bounded, unbounded};
Expand Down
1 change: 1 addition & 0 deletions crossbeam-channel/benchmarks/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "benchmarks"
version = "0.1.0"
edition = "2018"
publish = false

[dependencies]
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benchmarks/atomicring.rs
@@ -1,6 +1,3 @@
extern crate atomicring;
extern crate crossbeam;

use atomicring::AtomicRingBuffer;
use std::thread;

Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benchmarks/atomicringqueue.rs
@@ -1,6 +1,3 @@
extern crate atomicring;
extern crate crossbeam;

use atomicring::AtomicRingQueue;
use std::thread;

Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benchmarks/bus.rs
@@ -1,6 +1,3 @@
extern crate bus;
extern crate crossbeam;

use bus::Bus;

mod message;
Expand Down
6 changes: 2 additions & 4 deletions crossbeam-channel/benchmarks/chan.rs
@@ -1,6 +1,4 @@
#[macro_use]
extern crate chan;
extern crate crossbeam;
use chan::chan_select;

mod message;

Expand All @@ -9,7 +7,7 @@ const THREADS: usize = 4;

fn new<T>(cap: Option<usize>) -> (chan::Sender<T>, chan::Receiver<T>) {
match cap {
None => chan::async(),
None => chan::r#async(),
Some(cap) => chan::sync(cap),
}
}
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benchmarks/crossbeam-channel.rs
@@ -1,6 +1,3 @@
extern crate crossbeam;
extern crate crossbeam_channel;

use crossbeam_channel::{bounded, unbounded, Receiver, Select, Sender};

mod message;
Expand Down
5 changes: 1 addition & 4 deletions crossbeam-channel/benchmarks/crossbeam-deque.rs
@@ -1,7 +1,4 @@
extern crate crossbeam;
extern crate crossbeam_deque as deque;

use deque::{Steal, Worker};
use crossbeam_deque::{Steal, Worker};
use std::thread;

mod message;
Expand Down
2 changes: 0 additions & 2 deletions crossbeam-channel/benchmarks/flume.rs
@@ -1,5 +1,3 @@
extern crate crossbeam;

mod message;

const MESSAGES: usize = 5_000_000;
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benchmarks/futures-channel.rs
@@ -1,6 +1,3 @@
extern crate crossbeam;
extern crate futures;

use futures::channel::mpsc;
use futures::executor::ThreadPool;
use futures::prelude::*;
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benchmarks/lockfree.rs
@@ -1,6 +1,3 @@
extern crate crossbeam;
extern crate lockfree;

use lockfree::channel;

mod message;
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/benchmarks/message.rs
Expand Up @@ -6,7 +6,7 @@ const LEN: usize = 1;
pub struct Message(pub [usize; LEN]);

impl fmt::Debug for Message {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("Message")
}
}
Expand Down
3 changes: 0 additions & 3 deletions crossbeam-channel/benchmarks/mpmc.rs
@@ -1,6 +1,3 @@
extern crate crossbeam;
extern crate mpmc;

use std::thread;

mod message;
Expand Down
2 changes: 0 additions & 2 deletions crossbeam-channel/benchmarks/mpsc.rs
@@ -1,5 +1,3 @@
extern crate crossbeam;

use std::sync::mpsc;

mod message;
Expand Down
2 changes: 0 additions & 2 deletions crossbeam-channel/benchmarks/segqueue.rs
@@ -1,5 +1,3 @@
extern crate crossbeam;

use crossbeam::queue::SegQueue;
use std::thread;

Expand Down
2 changes: 0 additions & 2 deletions crossbeam-channel/examples/fibonacci.rs
@@ -1,7 +1,5 @@
//! An asynchronous fibonacci sequence generator.

extern crate crossbeam_channel;

use std::thread;

use crossbeam_channel::{bounded, Sender};
Expand Down
6 changes: 1 addition & 5 deletions crossbeam-channel/examples/matching.rs
Expand Up @@ -42,11 +42,7 @@
//! }
//! ```

#[macro_use]
extern crate crossbeam_channel;
extern crate crossbeam_utils;

use crossbeam_channel::bounded;
use crossbeam_channel::{bounded, select};
use crossbeam_utils::thread;

fn main() {
Expand Down
6 changes: 1 addition & 5 deletions crossbeam-channel/examples/stopwatch.rs
@@ -1,14 +1,10 @@
//! Prints the elapsed time every 1 second and quits on Ctrl+C.

#[macro_use]
extern crate crossbeam_channel;
extern crate signal_hook;

use std::io;
use std::thread;
use std::time::{Duration, Instant};

use crossbeam_channel::{bounded, tick, Receiver};
use crossbeam_channel::{bounded, select, tick, Receiver};
use signal_hook::iterator::Signals;
use signal_hook::SIGINT;

Expand Down
48 changes: 23 additions & 25 deletions crossbeam-channel/src/channel.rs
Expand Up @@ -7,11 +7,13 @@ use std::panic::{RefUnwindSafe, UnwindSafe};
use std::sync::Arc;
use std::time::{Duration, Instant};

use context::Context;
use counter;
use err::{RecvError, RecvTimeoutError, SendError, SendTimeoutError, TryRecvError, TrySendError};
use flavors;
use select::{Operation, SelectHandle, Token};
use crate::context::Context;
use crate::counter;
use crate::err::{
RecvError, RecvTimeoutError, SendError, SendTimeoutError, TryRecvError, TrySendError,
};
use crate::flavors;
use crate::select::{Operation, SelectHandle, Token};

/// Creates a channel of unbounded capacity.
///
Expand Down Expand Up @@ -134,11 +136,9 @@ pub fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
/// Using an `after` channel for timeouts:
///
/// ```
/// # #[macro_use]
/// # extern crate crossbeam_channel;
/// # fn main() {
/// use std::time::Duration;
/// use crossbeam_channel::{after, unbounded};
/// use crossbeam_channel::{after, select, unbounded};
///
/// let (s, r) = unbounded::<i32>();
/// let timeout = Duration::from_millis(100);
Expand Down Expand Up @@ -187,12 +187,10 @@ pub fn after(duration: Duration) -> Receiver<Instant> {
/// Using a `never` channel to optionally add a timeout to [`select!`]:
///
/// ```
/// # #[macro_use]
/// # extern crate crossbeam_channel;
/// # fn main() {
/// use std::thread;
/// use std::time::{Duration, Instant};
/// use crossbeam_channel::{after, never, unbounded};
/// use crossbeam_channel::{after, select, never, unbounded};
///
/// let (s, r) = unbounded();
///
Expand Down Expand Up @@ -582,7 +580,7 @@ impl<T> Clone for Sender<T> {
}

impl<T> fmt::Debug for Sender<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("Sender { .. }")
}
}
Expand Down Expand Up @@ -941,7 +939,7 @@ impl<T> Receiver<T> {
///
/// assert_eq!(v, [1, 2, 3]);
/// ```
pub fn iter(&self) -> Iter<T> {
pub fn iter(&self) -> Iter<'_, T> {
Iter { receiver: self }
}

Expand Down Expand Up @@ -977,7 +975,7 @@ impl<T> Receiver<T> {
///
/// assert_eq!(v, [1, 2]);
/// ```
pub fn try_iter(&self) -> TryIter<T> {
pub fn try_iter(&self) -> TryIter<'_, T> {
TryIter { receiver: self }
}

Expand Down Expand Up @@ -1040,7 +1038,7 @@ impl<T> Clone for Receiver<T> {
}

impl<T> fmt::Debug for Receiver<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("Receiver { .. }")
}
}
Expand Down Expand Up @@ -1092,22 +1090,22 @@ impl<T> IntoIterator for Receiver<T> {
///
/// assert_eq!(v, [1, 2, 3]);
/// ```
pub struct Iter<'a, T: 'a> {
pub struct Iter<'a, T> {
receiver: &'a Receiver<T>,
}

impl<'a, T> FusedIterator for Iter<'a, T> {}
impl<T> FusedIterator for Iter<'_, T> {}

impl<'a, T> Iterator for Iter<'a, T> {
impl<T> Iterator for Iter<'_, T> {
type Item = T;

fn next(&mut self) -> Option<Self::Item> {
self.receiver.recv().ok()
}
}

impl<'a, T> fmt::Debug for Iter<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl<T> fmt::Debug for Iter<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("Iter { .. }")
}
}
Expand Down Expand Up @@ -1144,20 +1142,20 @@ impl<'a, T> fmt::Debug for Iter<'a, T> {
///
/// assert_eq!(v, [1, 2]);
/// ```
pub struct TryIter<'a, T: 'a> {
pub struct TryIter<'a, T> {
receiver: &'a Receiver<T>,
}

impl<'a, T> Iterator for TryIter<'a, T> {
impl<T> Iterator for TryIter<'_, T> {
type Item = T;

fn next(&mut self) -> Option<Self::Item> {
self.receiver.try_recv().ok()
}
}

impl<'a, T> fmt::Debug for TryIter<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl<T> fmt::Debug for TryIter<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("TryIter { .. }")
}
}
Expand Down Expand Up @@ -1206,7 +1204,7 @@ impl<T> Iterator for IntoIter<T> {
}

impl<T> fmt::Debug for IntoIter<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("IntoIter { .. }")
}
}
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/src/context.rs
Expand Up @@ -8,7 +8,7 @@ use std::time::Instant;

use crossbeam_utils::Backoff;

use select::Selected;
use crate::select::Selected;

/// Thread-local context used in select.
#[derive(Debug, Clone)]
Expand Down

0 comments on commit 33b9232

Please sign in to comment.