Skip to content

Commit 9d552c4

Browse files
committed
Rust 2018
1 parent 401678e commit 9d552c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+307
-365
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ matrix:
99
fast_finish: true
1010
include:
1111
# NB: To help with CI delays, each `pull_request` is only tested on Linux,
12-
# with 1.28 for compatibility and stable+rayon_unstable for broad test
12+
# with 1.31 for compatibility and stable+rayon_unstable for broad test
1313
# coverage. The bors bot counts as a `push` type, which will run it all.
1414

15-
- rust: 1.28.0
15+
- rust: 1.31.0
1616
os: linux
1717
#if: everything!
1818
before_script: cp ci/compat-Cargo.lock ./Cargo.lock

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ version = "1.2.1"
55
authors = ["Niko Matsakis <[email protected]>",
66
"Josh Stone <[email protected]>"]
77
description = "Simple work-stealing parallelism for Rust"
8+
edition = "2018"
89
license = "Apache-2.0/MIT"
910
repository = "https://github.com/rayon-rs/rayon"
1011
documentation = "https://docs.rs/rayon/"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ just add:
9090
use rayon::prelude::*;
9191
```
9292

93-
Rayon currently requires `rustc 1.28.0` or greater.
93+
Rayon currently requires `rustc 1.31.0` or greater.
9494

9595
## Contribution
9696

ci/alt-core/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[package]
2+
edition = "2018"
23
name = "alt-core"
34
version = "0.0.0"
45
authors = ["Josh Stone <[email protected]>"]

ci/highlander/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[package]
22
authors = ["Josh Stone <[email protected]>"]
3+
edition = "2018"
34
name = "highlander"
45
description = "There Can Be Only One"
56
version = "0.0.0"

examples/cpu_monitor.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
extern crate docopt;
2-
extern crate rayon;
31
#[macro_use]
42
extern crate serde_derive;
5-
extern crate serde;
63

74
use docopt::Docopt;
5+
use rayon;
86
use std::io;
97
use std::process;
108

rayon-core/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ description = "Core APIs for Rayon"
77
license = "Apache-2.0/MIT"
88
repository = "https://github.com/rayon-rs/rayon"
99
documentation = "https://docs.rs/rayon/"
10+
edition = "2018"
1011
links = "rayon-core"
1112
build = "build.rs"
1213
readme = "README.md"

rayon-core/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Please see [Rayon Docs] for details about using Rayon.
88

99
[Rayon Docs]: https://docs.rs/rayon/
1010

11-
Rayon-core currently requires `rustc 1.28.0` or greater.
11+
Rayon-core currently requires `rustc 1.31.0` or greater.

rayon-core/src/internal/task.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub unsafe trait ScopeHandle<'scope>: 'scope {
6060
/// This takes ownership of the scope handle, meaning that once
6161
/// you invoke `panicked`, the scope is permitted to terminate
6262
/// (and, in particular, the Rust lifetime `'scope` may end).
63-
fn panicked(self, err: Box<Any + Send>);
63+
fn panicked(self, err: Box<dyn Any + Send>);
6464

6565
/// Indicates that the sub-tasks of this scope that you have
6666
/// spawned concluded successfully.

rayon-core/src/internal/worker.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! worker thread. Intended for building abstractions atop the
33
//! rayon-core thread pool, rather than direct use by end users.
44
5-
use latch::LatchProbe;
6-
use registry;
5+
use crate::latch::LatchProbe;
6+
use crate::registry;
77
use std::fmt;
88

99
/// Represents the active worker thread.
@@ -29,7 +29,7 @@ impl<'w> WorkerThread<'w> {
2929
where
3030
F: Fn() -> bool,
3131
{
32-
struct DummyLatch<'a, F: 'a> {
32+
struct DummyLatch<'a, F> {
3333
f: &'a F,
3434
}
3535

@@ -44,7 +44,7 @@ impl<'w> WorkerThread<'w> {
4444
}
4545

4646
impl<'w> fmt::Debug for WorkerThread<'w> {
47-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
47+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
4848
fmt.debug_struct("WorkerThread")
4949
.field("pool", &self.thread.registry().id())
5050
.field("index", &self.thread.index())
@@ -58,7 +58,7 @@ impl<'w> fmt::Debug for WorkerThread<'w> {
5858
/// a Rayon worker thread, `None` is immediately returned.
5959
pub fn if_in_worker_thread<F, R>(if_true: F) -> Option<R>
6060
where
61-
F: FnOnce(&WorkerThread) -> R,
61+
F: FnOnce(&WorkerThread<'_>) -> R,
6262
{
6363
unsafe {
6464
let thread = registry::WorkerThread::current().as_ref()?;

rayon-core/src/job.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crossbeam_queue::SegQueue;
2-
use latch::Latch;
2+
use crate::latch::Latch;
33
use std::any::Any;
44
use std::cell::UnsafeCell;
55
use std::mem;
6-
use unwind;
6+
use crate::unwind;
77

88
pub(super) enum JobResult<T> {
99
None,

rayon-core/src/join/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use job::StackJob;
2-
use latch::{LatchProbe, SpinLatch};
3-
use log::Event::*;
4-
use registry::{self, WorkerThread};
1+
use crate::job::StackJob;
2+
use crate::latch::{LatchProbe, SpinLatch};
3+
use crate::log::Event::*;
4+
use crate::registry::{self, WorkerThread};
55
use std::any::Any;
6-
use unwind;
6+
use crate::unwind;
77

8-
use FnContext;
8+
use crate::FnContext;
99

1010
#[cfg(test)]
1111
mod test;

rayon-core/src/join/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Tests for the join code.
22
3-
use join::*;
3+
use crate::join::*;
44
use rand::distributions::Standard;
55
use rand::{Rng, SeedableRng};
66
use rand_xorshift::XorShiftRng;
7-
use unwind;
8-
use ThreadPoolBuilder;
7+
use crate::unwind;
8+
use crate::ThreadPoolBuilder;
99

1010
fn quick_sort<T: PartialOrd + Send>(v: &mut [T]) {
1111
if v.len() <= 1 {

rayon-core/src/latch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
22
use std::sync::{Condvar, Mutex};
33
use std::usize;
44

5-
use sleep::Sleep;
5+
use crate::sleep::Sleep;
66

77
/// We define various kinds of latches, which are all a primitive signaling
88
/// mechanism. A latch starts as false. Eventually someone calls `set()` and

rayon-core/src/lib.rs

+17-23
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,9 @@ use std::io;
3232
use std::marker::PhantomData;
3333
use std::str::FromStr;
3434

35-
extern crate crossbeam_deque;
36-
extern crate crossbeam_queue;
37-
extern crate crossbeam_utils;
3835
#[cfg(any(debug_assertions, rayon_unstable))]
3936
#[macro_use]
4037
extern crate lazy_static;
41-
extern crate num_cpus;
42-
43-
#[cfg(test)]
44-
extern crate rand;
45-
#[cfg(test)]
46-
extern crate rand_xorshift;
4738

4839
#[macro_use]
4940
mod log;
@@ -66,16 +57,19 @@ mod test;
6657

6758
#[cfg(rayon_unstable)]
6859
pub mod internal;
69-
pub use join::{join, join_context};
70-
pub use registry::ThreadBuilder;
71-
pub use scope::{scope, Scope};
72-
pub use scope::{scope_fifo, ScopeFifo};
73-
pub use spawn::{spawn, spawn_fifo};
74-
pub use thread_pool::current_thread_has_pending_tasks;
75-
pub use thread_pool::current_thread_index;
76-
pub use thread_pool::ThreadPool;
7760

78-
use registry::{CustomSpawn, DefaultSpawn, ThreadSpawn};
61+
pub use self::join::{join, join_context};
62+
pub use self::registry::ThreadBuilder;
63+
pub use self::scope::{scope, Scope};
64+
pub use self::scope::{scope_fifo, ScopeFifo};
65+
pub use self::spawn::{spawn, spawn_fifo};
66+
pub use self::thread_pool::current_thread_has_pending_tasks;
67+
pub use self::thread_pool::current_thread_index;
68+
pub use self::thread_pool::ThreadPool;
69+
70+
use crossbeam_utils;
71+
use num_cpus;
72+
use self::registry::{CustomSpawn, DefaultSpawn, ThreadSpawn};
7973

8074
/// Returns the number of threads in the current registry. If this
8175
/// code is executing within a Rayon thread-pool, then this will be
@@ -96,7 +90,7 @@ use registry::{CustomSpawn, DefaultSpawn, ThreadSpawn};
9690
///
9791
/// [snt]: struct.ThreadPoolBuilder.html#method.num_threads
9892
pub fn current_num_threads() -> usize {
99-
::registry::Registry::current_num_threads()
93+
crate::registry::Registry::current_num_threads()
10094
}
10195

10296
/// Error when initializing a thread pool.
@@ -667,7 +661,7 @@ impl Error for ThreadPoolBuildError {
667661
}
668662

669663
impl fmt::Display for ThreadPoolBuildError {
670-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
664+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
671665
match self.kind {
672666
ErrorKind::IOError(ref e) => e.fmt(f),
673667
_ => self.description().fmt(f),
@@ -683,7 +677,7 @@ pub fn initialize(config: Configuration) -> Result<(), Box<dyn Error>> {
683677
}
684678

685679
impl<S> fmt::Debug for ThreadPoolBuilder<S> {
686-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
680+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
687681
let ThreadPoolBuilder {
688682
ref num_threads,
689683
ref get_thread_name,
@@ -699,7 +693,7 @@ impl<S> fmt::Debug for ThreadPoolBuilder<S> {
699693
// output.
700694
struct ClosurePlaceholder;
701695
impl fmt::Debug for ClosurePlaceholder {
702-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
696+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
703697
f.write_str("<closure>")
704698
}
705699
}
@@ -731,7 +725,7 @@ impl Default for Configuration {
731725

732726
#[allow(deprecated)]
733727
impl fmt::Debug for Configuration {
734-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
728+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
735729
self.builder.fmt(f)
736730
}
737731
}

rayon-core/src/private.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ macro_rules! private_decl {
1313
/// This trait is private; this method exists to make it
1414
/// impossible to implement outside the crate.
1515
#[doc(hidden)]
16-
fn __rayon_private__(&self) -> ::private::PrivateMarker;
16+
fn __rayon_private__(&self) -> crate::private::PrivateMarker;
1717
}
1818
}
1919

2020
macro_rules! private_impl {
2121
() => {
22-
fn __rayon_private__(&self) -> ::private::PrivateMarker {
23-
::private::PrivateMarker
22+
fn __rayon_private__(&self) -> crate::private::PrivateMarker {
23+
crate::private::PrivateMarker
2424
}
2525
}
2626
}

rayon-core/src/registry.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crossbeam_deque::{Steal, Stealer, Worker};
22
use crossbeam_queue::SegQueue;
33
#[cfg(rayon_unstable)]
4-
use internal::task::Task;
4+
use crate::internal::task::Task;
55
#[cfg(rayon_unstable)]
6-
use job::Job;
7-
use job::{JobFifo, JobRef, StackJob};
8-
use latch::{CountLatch, Latch, LatchProbe, LockLatch, SpinLatch, TickleLatch};
9-
use log::Event::*;
10-
use sleep::Sleep;
6+
use crate::job::Job;
7+
use crate::job::{JobFifo, JobRef, StackJob};
8+
use crate::latch::{CountLatch, Latch, LatchProbe, LockLatch, SpinLatch, TickleLatch};
9+
use crate::log::Event::*;
10+
use crate::sleep::Sleep;
1111
use std::any::Any;
1212
use std::cell::Cell;
1313
use std::collections::hash_map::DefaultHasher;
@@ -22,9 +22,9 @@ use std::sync::atomic::{AtomicUsize, Ordering};
2222
use std::sync::{Arc, Once};
2323
use std::thread;
2424
use std::usize;
25-
use unwind;
26-
use util::leak;
27-
use {ErrorKind, ExitHandler, PanicHandler, StartHandler, ThreadPoolBuildError, ThreadPoolBuilder};
25+
use crate::unwind;
26+
use crate::util::leak;
27+
use crate::{ErrorKind, ExitHandler, PanicHandler, StartHandler, ThreadPoolBuildError, ThreadPoolBuilder};
2828

2929
/// Thread builder used for customization via
3030
/// [`ThreadPoolBuilder::spawn_handler`](struct.ThreadPoolBuilder.html#method.spawn_handler).
@@ -60,7 +60,7 @@ impl ThreadBuilder {
6060
}
6161

6262
impl fmt::Debug for ThreadBuilder {
63-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
63+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6464
f.debug_struct("ThreadBuilder")
6565
.field("pool", &self.registry.id())
6666
.field("index", &self.index)
@@ -79,7 +79,7 @@ pub trait ThreadSpawn {
7979

8080
/// Spawn a thread with the `ThreadBuilder` parameters, and then
8181
/// call `ThreadBuilder::run()`.
82-
fn spawn(&mut self, ThreadBuilder) -> io::Result<()>;
82+
fn spawn(&mut self, thread: ThreadBuilder) -> io::Result<()>;
8383
}
8484

8585
/// Spawns a thread in the "normal" way with `std::thread::Builder`.

rayon-core/src/scope/internal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg(rayon_unstable)]
22

33
use super::{Scope, ScopeBase};
4-
use internal::task::{ScopeHandle, Task, ToScopeHandle};
4+
use crate::internal::task::{ScopeHandle, Task, ToScopeHandle};
55
use std::any::Any;
66
use std::mem;
77
use std::sync::Arc;
@@ -52,7 +52,7 @@ unsafe impl<'scope> ScopeHandle<'scope> for LocalScopeHandle<'scope> {
5252
mem::drop(self);
5353
}
5454

55-
fn panicked(self, err: Box<Any + Send>) {
55+
fn panicked(self, err: Box<dyn Any + Send>) {
5656
unsafe {
5757
(*self.scope).job_panicked(err);
5858
mem::forget(self); // no need to run dtor now

rayon-core/src/scope/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
//! [`scope()`]: fn.scope.html
55
//! [`join()`]: ../join/join.fn.html
66
7-
use job::{HeapJob, JobFifo};
8-
use latch::{CountLatch, Latch};
9-
use log::Event::*;
10-
use registry::{in_worker, Registry, WorkerThread};
7+
use crate::job::{HeapJob, JobFifo};
8+
use crate::latch::{CountLatch, Latch};
9+
use crate::log::Event::*;
10+
use crate::registry::{in_worker, Registry, WorkerThread};
1111
use std::any::Any;
1212
use std::fmt;
1313
use std::marker::PhantomData;
1414
use std::mem;
1515
use std::ptr;
1616
use std::sync::atomic::{AtomicPtr, Ordering};
1717
use std::sync::Arc;
18-
use unwind;
18+
use crate::unwind;
1919

2020
mod internal;
2121
#[cfg(test)]
@@ -635,7 +635,7 @@ impl<'scope> fmt::Debug for Scope<'scope> {
635635
}
636636

637637
impl<'scope> fmt::Debug for ScopeFifo<'scope> {
638-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
638+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
639639
fmt.debug_struct("ScopeFifo")
640640
.field("num_fifos", &self.fifos.len())
641641
.field("pool_id", &self.base.registry.id())

rayon-core/src/scope/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use std::iter::once;
55
use std::sync::atomic::{AtomicUsize, Ordering};
66
use std::sync::Mutex;
77
use std::vec;
8-
use unwind;
9-
use ThreadPoolBuilder;
10-
use {scope, scope_fifo, Scope};
8+
use crate::unwind;
9+
use crate::ThreadPoolBuilder;
10+
use crate::{scope, scope_fifo, Scope};
1111

1212
#[test]
1313
fn scope_empty() {

0 commit comments

Comments
 (0)