From 9d552c49ef173693504554a5c1723d48af6a7978 Mon Sep 17 00:00:00 2001 From: Caio Date: Tue, 10 Dec 2019 19:34:34 -0300 Subject: [PATCH] Rust 2018 --- .travis.yml | 4 +-- Cargo.toml | 1 + README.md | 2 +- ci/alt-core/Cargo.toml | 1 + ci/highlander/Cargo.toml | 1 + examples/cpu_monitor.rs | 4 +-- rayon-core/Cargo.toml | 1 + rayon-core/README.md | 2 +- rayon-core/src/internal/task.rs | 2 +- rayon-core/src/internal/worker.rs | 10 +++--- rayon-core/src/job.rs | 4 +-- rayon-core/src/join/mod.rs | 12 +++---- rayon-core/src/join/test.rs | 6 ++-- rayon-core/src/latch.rs | 2 +- rayon-core/src/lib.rs | 40 ++++++++++-------------- rayon-core/src/private.rs | 6 ++-- rayon-core/src/registry.rs | 22 ++++++------- rayon-core/src/scope/internal.rs | 4 +-- rayon-core/src/scope/mod.rs | 12 +++---- rayon-core/src/scope/test.rs | 6 ++-- rayon-core/src/sleep/mod.rs | 2 +- rayon-core/src/spawn/mod.rs | 6 ++-- rayon-core/src/spawn/test.rs | 4 +-- rayon-core/src/test.rs | 4 +-- rayon-core/src/thread_pool/internal.rs | 8 ++--- rayon-core/src/thread_pool/mod.rs | 16 +++++----- rayon-core/src/thread_pool/test.rs | 12 +++---- rayon-core/tests/double_init_fail.rs | 2 -- rayon-core/tests/init_zero_threads.rs | 2 -- rayon-core/tests/scope_join.rs | 2 +- rayon-core/tests/scoped_threadpool.rs | 3 -- rayon-core/tests/simple_panic.rs | 2 -- rayon-core/tests/stack_overflow_crash.rs | 1 - rayon-demo/Cargo.toml | 1 + rayon-demo/src/fibonacci/mod.rs | 3 +- rayon-demo/src/find/mod.rs | 2 +- rayon-demo/src/life/mod.rs | 2 +- rayon-demo/src/main.rs | 18 ++--------- rayon-demo/src/map_collect.rs | 20 ++++++------ rayon-demo/src/mergesort/mod.rs | 2 +- rayon-demo/src/nbody/bench.rs | 2 +- rayon-demo/src/nbody/mod.rs | 6 ++-- rayon-demo/src/nbody/visualize.rs | 6 ++-- rayon-demo/src/noop/mod.rs | 2 +- rayon-demo/src/quicksort/mod.rs | 2 +- rayon-demo/src/sort.rs | 12 +++---- rayon-demo/src/str_split.rs | 2 +- rayon-demo/src/tsp/step.rs | 6 ++-- rayon-demo/src/vec_collect.rs | 12 +++---- rayon-futures/Cargo.toml | 1 + rayon-futures/src/lib.rs | 23 ++++++-------- src/collections/binary_heap.rs | 8 ++--- src/collections/btree_map.rs | 10 +++--- src/collections/btree_set.rs | 8 ++--- src/collections/hash_map.rs | 10 +++--- src/collections/hash_set.rs | 8 ++--- src/collections/linked_list.rs | 10 +++--- src/collections/vec_deque.rs | 12 +++---- src/iter/chunks.rs | 2 +- src/iter/collect/consumer.rs | 4 +-- src/iter/collect/mod.rs | 2 +- src/iter/collect/test.rs | 2 +- src/iter/empty.rs | 4 +-- src/iter/filter.rs | 4 +-- src/iter/filter_map.rs | 4 +-- src/iter/find.rs | 4 +-- src/iter/find_first_last/mod.rs | 4 +-- src/iter/flat_map.rs | 4 +-- src/iter/fold.rs | 6 ++-- src/iter/for_each.rs | 2 +- src/iter/inspect.rs | 6 ++-- src/iter/map.rs | 6 ++-- src/iter/map_with.rs | 12 +++---- src/iter/once.rs | 4 +-- src/iter/panic_fuse.rs | 2 +- src/iter/par_bridge.rs | 8 ++--- src/iter/plumbing/mod.rs | 6 ++-- src/iter/reduce.rs | 4 +-- src/iter/splitter.rs | 2 +- src/iter/test.rs | 4 +-- src/iter/try_fold.rs | 6 ++-- src/iter/try_reduce.rs | 4 +-- src/iter/try_reduce_with.rs | 4 +-- src/iter/unzip.rs | 6 ++-- src/iter/update.rs | 6 ++-- src/lib.rs | 8 ----- src/option.rs | 8 ++--- src/par_either.rs | 6 ++-- src/prelude.rs | 22 ++++++------- src/private.rs | 6 ++-- src/range.rs | 6 ++-- src/range_inclusive.rs | 6 ++-- src/result.rs | 10 +++--- src/slice/mergesort.rs | 4 +-- src/slice/mod.rs | 30 +++++++++--------- src/split_producer.rs | 4 +-- src/str.rs | 14 ++++----- src/vec.rs | 8 ++--- tests/clones.rs | 2 -- tests/debug.rs | 2 -- tests/intersperse.rs | 2 -- tests/issue671-unzip.rs | 2 -- tests/issue671.rs | 2 -- tests/iter_panic.rs | 2 -- tests/named-threads.rs | 2 -- tests/octillion.rs | 2 -- tests/producer_split_at.rs | 2 -- tests/sort-panic-safe.rs | 2 -- tests/str.rs | 4 --- 109 files changed, 307 insertions(+), 365 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5991f7a76..6a9366323 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,10 @@ matrix: fast_finish: true include: # NB: To help with CI delays, each `pull_request` is only tested on Linux, - # with 1.28 for compatibility and stable+rayon_unstable for broad test + # with 1.31 for compatibility and stable+rayon_unstable for broad test # coverage. The bors bot counts as a `push` type, which will run it all. - - rust: 1.28.0 + - rust: 1.31.0 os: linux #if: everything! before_script: cp ci/compat-Cargo.lock ./Cargo.lock diff --git a/Cargo.toml b/Cargo.toml index cbbb97ccb..b5518f9d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ version = "1.2.1" authors = ["Niko Matsakis ", "Josh Stone "] description = "Simple work-stealing parallelism for Rust" +edition = "2018" license = "Apache-2.0/MIT" repository = "https://github.com/rayon-rs/rayon" documentation = "https://docs.rs/rayon/" diff --git a/README.md b/README.md index 16c5ed116..eedebb3ec 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ just add: use rayon::prelude::*; ``` -Rayon currently requires `rustc 1.28.0` or greater. +Rayon currently requires `rustc 1.31.0` or greater. ## Contribution diff --git a/ci/alt-core/Cargo.toml b/ci/alt-core/Cargo.toml index 90c1bb050..3a6cedc73 100644 --- a/ci/alt-core/Cargo.toml +++ b/ci/alt-core/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "alt-core" version = "0.0.0" authors = ["Josh Stone "] diff --git a/ci/highlander/Cargo.toml b/ci/highlander/Cargo.toml index aa185c94b..74f2331ac 100644 --- a/ci/highlander/Cargo.toml +++ b/ci/highlander/Cargo.toml @@ -1,5 +1,6 @@ [package] authors = ["Josh Stone "] +edition = "2018" name = "highlander" description = "There Can Be Only One" version = "0.0.0" diff --git a/examples/cpu_monitor.rs b/examples/cpu_monitor.rs index 5e049e692..bc449569a 100644 --- a/examples/cpu_monitor.rs +++ b/examples/cpu_monitor.rs @@ -1,10 +1,8 @@ -extern crate docopt; -extern crate rayon; #[macro_use] extern crate serde_derive; -extern crate serde; use docopt::Docopt; +use rayon; use std::io; use std::process; diff --git a/rayon-core/Cargo.toml b/rayon-core/Cargo.toml index 4e69269f6..c08be1ee4 100644 --- a/rayon-core/Cargo.toml +++ b/rayon-core/Cargo.toml @@ -7,6 +7,7 @@ description = "Core APIs for Rayon" license = "Apache-2.0/MIT" repository = "https://github.com/rayon-rs/rayon" documentation = "https://docs.rs/rayon/" +edition = "2018" links = "rayon-core" build = "build.rs" readme = "README.md" diff --git a/rayon-core/README.md b/rayon-core/README.md index 0af629ce1..3f0e77973 100644 --- a/rayon-core/README.md +++ b/rayon-core/README.md @@ -8,4 +8,4 @@ Please see [Rayon Docs] for details about using Rayon. [Rayon Docs]: https://docs.rs/rayon/ -Rayon-core currently requires `rustc 1.28.0` or greater. +Rayon-core currently requires `rustc 1.31.0` or greater. diff --git a/rayon-core/src/internal/task.rs b/rayon-core/src/internal/task.rs index 5c49964e2..573ed3263 100644 --- a/rayon-core/src/internal/task.rs +++ b/rayon-core/src/internal/task.rs @@ -60,7 +60,7 @@ pub unsafe trait ScopeHandle<'scope>: 'scope { /// This takes ownership of the scope handle, meaning that once /// you invoke `panicked`, the scope is permitted to terminate /// (and, in particular, the Rust lifetime `'scope` may end). - fn panicked(self, err: Box); + fn panicked(self, err: Box); /// Indicates that the sub-tasks of this scope that you have /// spawned concluded successfully. diff --git a/rayon-core/src/internal/worker.rs b/rayon-core/src/internal/worker.rs index fdf31ac8d..1b2a596bf 100644 --- a/rayon-core/src/internal/worker.rs +++ b/rayon-core/src/internal/worker.rs @@ -2,8 +2,8 @@ //! worker thread. Intended for building abstractions atop the //! rayon-core thread pool, rather than direct use by end users. -use latch::LatchProbe; -use registry; +use crate::latch::LatchProbe; +use crate::registry; use std::fmt; /// Represents the active worker thread. @@ -29,7 +29,7 @@ impl<'w> WorkerThread<'w> { where F: Fn() -> bool, { - struct DummyLatch<'a, F: 'a> { + struct DummyLatch<'a, F> { f: &'a F, } @@ -44,7 +44,7 @@ impl<'w> WorkerThread<'w> { } impl<'w> fmt::Debug for WorkerThread<'w> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("WorkerThread") .field("pool", &self.thread.registry().id()) .field("index", &self.thread.index()) @@ -58,7 +58,7 @@ impl<'w> fmt::Debug for WorkerThread<'w> { /// a Rayon worker thread, `None` is immediately returned. pub fn if_in_worker_thread(if_true: F) -> Option where - F: FnOnce(&WorkerThread) -> R, + F: FnOnce(&WorkerThread<'_>) -> R, { unsafe { let thread = registry::WorkerThread::current().as_ref()?; diff --git a/rayon-core/src/job.rs b/rayon-core/src/job.rs index cd205990d..c56a69254 100644 --- a/rayon-core/src/job.rs +++ b/rayon-core/src/job.rs @@ -1,9 +1,9 @@ use crossbeam_queue::SegQueue; -use latch::Latch; +use crate::latch::Latch; use std::any::Any; use std::cell::UnsafeCell; use std::mem; -use unwind; +use crate::unwind; pub(super) enum JobResult { None, diff --git a/rayon-core/src/join/mod.rs b/rayon-core/src/join/mod.rs index 676fbdfbf..c0aa06bff 100644 --- a/rayon-core/src/join/mod.rs +++ b/rayon-core/src/join/mod.rs @@ -1,11 +1,11 @@ -use job::StackJob; -use latch::{LatchProbe, SpinLatch}; -use log::Event::*; -use registry::{self, WorkerThread}; +use crate::job::StackJob; +use crate::latch::{LatchProbe, SpinLatch}; +use crate::log::Event::*; +use crate::registry::{self, WorkerThread}; use std::any::Any; -use unwind; +use crate::unwind; -use FnContext; +use crate::FnContext; #[cfg(test)] mod test; diff --git a/rayon-core/src/join/test.rs b/rayon-core/src/join/test.rs index fbf4690db..00db3b100 100644 --- a/rayon-core/src/join/test.rs +++ b/rayon-core/src/join/test.rs @@ -1,11 +1,11 @@ //! Tests for the join code. -use join::*; +use crate::join::*; use rand::distributions::Standard; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng; -use unwind; -use ThreadPoolBuilder; +use crate::unwind; +use crate::ThreadPoolBuilder; fn quick_sort(v: &mut [T]) { if v.len() <= 1 { diff --git a/rayon-core/src/latch.rs b/rayon-core/src/latch.rs index db97224f0..667747e90 100644 --- a/rayon-core/src/latch.rs +++ b/rayon-core/src/latch.rs @@ -2,7 +2,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Condvar, Mutex}; use std::usize; -use sleep::Sleep; +use crate::sleep::Sleep; /// We define various kinds of latches, which are all a primitive signaling /// mechanism. A latch starts as false. Eventually someone calls `set()` and diff --git a/rayon-core/src/lib.rs b/rayon-core/src/lib.rs index de87ed523..94288726a 100644 --- a/rayon-core/src/lib.rs +++ b/rayon-core/src/lib.rs @@ -32,18 +32,9 @@ use std::io; use std::marker::PhantomData; use std::str::FromStr; -extern crate crossbeam_deque; -extern crate crossbeam_queue; -extern crate crossbeam_utils; #[cfg(any(debug_assertions, rayon_unstable))] #[macro_use] extern crate lazy_static; -extern crate num_cpus; - -#[cfg(test)] -extern crate rand; -#[cfg(test)] -extern crate rand_xorshift; #[macro_use] mod log; @@ -66,16 +57,19 @@ mod test; #[cfg(rayon_unstable)] pub mod internal; -pub use join::{join, join_context}; -pub use registry::ThreadBuilder; -pub use scope::{scope, Scope}; -pub use scope::{scope_fifo, ScopeFifo}; -pub use spawn::{spawn, spawn_fifo}; -pub use thread_pool::current_thread_has_pending_tasks; -pub use thread_pool::current_thread_index; -pub use thread_pool::ThreadPool; -use registry::{CustomSpawn, DefaultSpawn, ThreadSpawn}; +pub use self::join::{join, join_context}; +pub use self::registry::ThreadBuilder; +pub use self::scope::{scope, Scope}; +pub use self::scope::{scope_fifo, ScopeFifo}; +pub use self::spawn::{spawn, spawn_fifo}; +pub use self::thread_pool::current_thread_has_pending_tasks; +pub use self::thread_pool::current_thread_index; +pub use self::thread_pool::ThreadPool; + +use crossbeam_utils; +use num_cpus; +use self::registry::{CustomSpawn, DefaultSpawn, ThreadSpawn}; /// Returns the number of threads in the current registry. If this /// code is executing within a Rayon thread-pool, then this will be @@ -96,7 +90,7 @@ use registry::{CustomSpawn, DefaultSpawn, ThreadSpawn}; /// /// [snt]: struct.ThreadPoolBuilder.html#method.num_threads pub fn current_num_threads() -> usize { - ::registry::Registry::current_num_threads() + crate::registry::Registry::current_num_threads() } /// Error when initializing a thread pool. @@ -667,7 +661,7 @@ impl Error for ThreadPoolBuildError { } impl fmt::Display for ThreadPoolBuildError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.kind { ErrorKind::IOError(ref e) => e.fmt(f), _ => self.description().fmt(f), @@ -683,7 +677,7 @@ pub fn initialize(config: Configuration) -> Result<(), Box> { } impl fmt::Debug for ThreadPoolBuilder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let ThreadPoolBuilder { ref num_threads, ref get_thread_name, @@ -699,7 +693,7 @@ impl fmt::Debug for ThreadPoolBuilder { // output. struct ClosurePlaceholder; impl fmt::Debug for ClosurePlaceholder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("") } } @@ -731,7 +725,7 @@ impl Default for Configuration { #[allow(deprecated)] impl fmt::Debug for Configuration { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.builder.fmt(f) } } diff --git a/rayon-core/src/private.rs b/rayon-core/src/private.rs index 5d084ff14..a99dd11fb 100644 --- a/rayon-core/src/private.rs +++ b/rayon-core/src/private.rs @@ -13,14 +13,14 @@ macro_rules! private_decl { /// This trait is private; this method exists to make it /// impossible to implement outside the crate. #[doc(hidden)] - fn __rayon_private__(&self) -> ::private::PrivateMarker; + fn __rayon_private__(&self) -> crate::private::PrivateMarker; } } macro_rules! private_impl { () => { - fn __rayon_private__(&self) -> ::private::PrivateMarker { - ::private::PrivateMarker + fn __rayon_private__(&self) -> crate::private::PrivateMarker { + crate::private::PrivateMarker } } } diff --git a/rayon-core/src/registry.rs b/rayon-core/src/registry.rs index 1c43ac8d8..65dbed04f 100644 --- a/rayon-core/src/registry.rs +++ b/rayon-core/src/registry.rs @@ -1,13 +1,13 @@ use crossbeam_deque::{Steal, Stealer, Worker}; use crossbeam_queue::SegQueue; #[cfg(rayon_unstable)] -use internal::task::Task; +use crate::internal::task::Task; #[cfg(rayon_unstable)] -use job::Job; -use job::{JobFifo, JobRef, StackJob}; -use latch::{CountLatch, Latch, LatchProbe, LockLatch, SpinLatch, TickleLatch}; -use log::Event::*; -use sleep::Sleep; +use crate::job::Job; +use crate::job::{JobFifo, JobRef, StackJob}; +use crate::latch::{CountLatch, Latch, LatchProbe, LockLatch, SpinLatch, TickleLatch}; +use crate::log::Event::*; +use crate::sleep::Sleep; use std::any::Any; use std::cell::Cell; use std::collections::hash_map::DefaultHasher; @@ -22,9 +22,9 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Once}; use std::thread; use std::usize; -use unwind; -use util::leak; -use {ErrorKind, ExitHandler, PanicHandler, StartHandler, ThreadPoolBuildError, ThreadPoolBuilder}; +use crate::unwind; +use crate::util::leak; +use crate::{ErrorKind, ExitHandler, PanicHandler, StartHandler, ThreadPoolBuildError, ThreadPoolBuilder}; /// Thread builder used for customization via /// [`ThreadPoolBuilder::spawn_handler`](struct.ThreadPoolBuilder.html#method.spawn_handler). @@ -60,7 +60,7 @@ impl ThreadBuilder { } impl fmt::Debug for ThreadBuilder { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("ThreadBuilder") .field("pool", &self.registry.id()) .field("index", &self.index) @@ -79,7 +79,7 @@ pub trait ThreadSpawn { /// Spawn a thread with the `ThreadBuilder` parameters, and then /// call `ThreadBuilder::run()`. - fn spawn(&mut self, ThreadBuilder) -> io::Result<()>; + fn spawn(&mut self, thread: ThreadBuilder) -> io::Result<()>; } /// Spawns a thread in the "normal" way with `std::thread::Builder`. diff --git a/rayon-core/src/scope/internal.rs b/rayon-core/src/scope/internal.rs index 30e07920a..03c53f368 100644 --- a/rayon-core/src/scope/internal.rs +++ b/rayon-core/src/scope/internal.rs @@ -1,7 +1,7 @@ #![cfg(rayon_unstable)] use super::{Scope, ScopeBase}; -use internal::task::{ScopeHandle, Task, ToScopeHandle}; +use crate::internal::task::{ScopeHandle, Task, ToScopeHandle}; use std::any::Any; use std::mem; use std::sync::Arc; @@ -52,7 +52,7 @@ unsafe impl<'scope> ScopeHandle<'scope> for LocalScopeHandle<'scope> { mem::drop(self); } - fn panicked(self, err: Box) { + fn panicked(self, err: Box) { unsafe { (*self.scope).job_panicked(err); mem::forget(self); // no need to run dtor now diff --git a/rayon-core/src/scope/mod.rs b/rayon-core/src/scope/mod.rs index c3ad5b259..9a9457ff5 100644 --- a/rayon-core/src/scope/mod.rs +++ b/rayon-core/src/scope/mod.rs @@ -4,10 +4,10 @@ //! [`scope()`]: fn.scope.html //! [`join()`]: ../join/join.fn.html -use job::{HeapJob, JobFifo}; -use latch::{CountLatch, Latch}; -use log::Event::*; -use registry::{in_worker, Registry, WorkerThread}; +use crate::job::{HeapJob, JobFifo}; +use crate::latch::{CountLatch, Latch}; +use crate::log::Event::*; +use crate::registry::{in_worker, Registry, WorkerThread}; use std::any::Any; use std::fmt; use std::marker::PhantomData; @@ -15,7 +15,7 @@ use std::mem; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use std::sync::Arc; -use unwind; +use crate::unwind; mod internal; #[cfg(test)] @@ -635,7 +635,7 @@ impl<'scope> fmt::Debug for Scope<'scope> { } impl<'scope> fmt::Debug for ScopeFifo<'scope> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("ScopeFifo") .field("num_fifos", &self.fifos.len()) .field("pool_id", &self.base.registry.id()) diff --git a/rayon-core/src/scope/test.rs b/rayon-core/src/scope/test.rs index 37f5e29a0..e3bd3e26f 100644 --- a/rayon-core/src/scope/test.rs +++ b/rayon-core/src/scope/test.rs @@ -5,9 +5,9 @@ use std::iter::once; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Mutex; use std::vec; -use unwind; -use ThreadPoolBuilder; -use {scope, scope_fifo, Scope}; +use crate::unwind; +use crate::ThreadPoolBuilder; +use crate::{scope, scope_fifo, Scope}; #[test] fn scope_empty() { diff --git a/rayon-core/src/sleep/mod.rs b/rayon-core/src/sleep/mod.rs index 96f4c37ff..5e125ed2a 100644 --- a/rayon-core/src/sleep/mod.rs +++ b/rayon-core/src/sleep/mod.rs @@ -1,7 +1,7 @@ //! Code that decides when workers should go to sleep. See README.md //! for an overview. -use log::Event::*; +use crate::log::Event::*; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Condvar, Mutex}; use std::thread; diff --git a/rayon-core/src/spawn/mod.rs b/rayon-core/src/spawn/mod.rs index 37b2d1b36..9dabb667a 100644 --- a/rayon-core/src/spawn/mod.rs +++ b/rayon-core/src/spawn/mod.rs @@ -1,8 +1,8 @@ -use job::*; -use registry::Registry; +use crate::job::*; +use crate::registry::Registry; use std::mem; use std::sync::Arc; -use unwind; +use crate::unwind; /// Fires off a task into the Rayon threadpool in the "static" or /// "global" scope. Just like a standard thread, this task is not diff --git a/rayon-core/src/spawn/test.rs b/rayon-core/src/spawn/test.rs index 9b9daab17..9c59754f7 100644 --- a/rayon-core/src/spawn/test.rs +++ b/rayon-core/src/spawn/test.rs @@ -1,10 +1,10 @@ -use scope; +use crate::scope; use std::any::Any; use std::sync::mpsc::channel; use std::sync::Mutex; use super::{spawn, spawn_fifo}; -use ThreadPoolBuilder; +use crate::ThreadPoolBuilder; #[test] fn spawn_then_join_in_worker() { diff --git a/rayon-core/src/test.rs b/rayon-core/src/test.rs index 2ba27e0e8..b9fae03cd 100644 --- a/rayon-core/src/test.rs +++ b/rayon-core/src/test.rs @@ -3,8 +3,8 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, Barrier}; #[allow(deprecated)] -use Configuration; -use {ThreadPoolBuildError, ThreadPoolBuilder}; +use crate::Configuration; +use crate::{ThreadPoolBuildError, ThreadPoolBuilder}; #[test] fn worker_thread_index() { diff --git a/rayon-core/src/thread_pool/internal.rs b/rayon-core/src/thread_pool/internal.rs index 29e439026..e28c37fb4 100644 --- a/rayon-core/src/thread_pool/internal.rs +++ b/rayon-core/src/thread_pool/internal.rs @@ -1,8 +1,8 @@ #![cfg(rayon_unstable)] use super::ThreadPool; -use internal::task::{ScopeHandle, Task, ToScopeHandle}; -use registry::Registry; +use crate::internal::task::{ScopeHandle, Task, ToScopeHandle}; +use crate::registry::Registry; use std::any::Any; use std::fmt; use std::sync::Arc; @@ -20,7 +20,7 @@ pub struct ThreadPoolScopeHandle { } impl fmt::Debug for ThreadPoolScopeHandle { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("ThreadPoolScopeHandle") .field("pool", &self.registry.id()) .finish() @@ -59,7 +59,7 @@ unsafe impl ScopeHandle<'static> for ThreadPoolScopeHandle { fn ok(self) {} - fn panicked(self, err: Box) { + fn panicked(self, err: Box) { self.registry.handle_panic(err); } } diff --git a/rayon-core/src/thread_pool/mod.rs b/rayon-core/src/thread_pool/mod.rs index 093546ee0..d6cc8bd46 100644 --- a/rayon-core/src/thread_pool/mod.rs +++ b/rayon-core/src/thread_pool/mod.rs @@ -3,17 +3,17 @@ //! //! [`ThreadPool`]: struct.ThreadPool.html -use join; -use registry::{Registry, ThreadSpawn, WorkerThread}; -use spawn; +use crate::join; +use crate::registry::{Registry, ThreadSpawn, WorkerThread}; +use crate::spawn; use std::error::Error; use std::fmt; use std::sync::Arc; #[allow(deprecated)] -use Configuration; -use {scope, Scope}; -use {scope_fifo, ScopeFifo}; -use {ThreadPoolBuildError, ThreadPoolBuilder}; +use crate::Configuration; +use crate::{scope, Scope}; +use crate::{scope_fifo, ScopeFifo}; +use crate::{ThreadPoolBuildError, ThreadPoolBuilder}; mod internal; mod test; @@ -283,7 +283,7 @@ impl Drop for ThreadPool { } impl fmt::Debug for ThreadPool { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("ThreadPool") .field("num_threads", &self.current_num_threads()) .field("id", &self.registry.id()) diff --git a/rayon-core/src/thread_pool/test.rs b/rayon-core/src/thread_pool/test.rs index c1ddca982..dc077d21d 100644 --- a/rayon-core/src/thread_pool/test.rs +++ b/rayon-core/src/thread_pool/test.rs @@ -4,12 +4,12 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::mpsc::channel; use std::sync::{Arc, Mutex}; -use join; -use thread_pool::ThreadPool; -use unwind; +use crate::join; +use crate::thread_pool::ThreadPool; + #[allow(deprecated)] -use Configuration; -use ThreadPoolBuilder; +use crate::Configuration; +use crate::ThreadPoolBuilder; #[test] #[should_panic(expected = "Hello, world!")] @@ -134,7 +134,7 @@ fn panic_thread_name() { format!("panic_thread_name#{}", i) }); - let pool = unwind::halt_unwinding(|| builder.build()); + let pool = crate::unwind::halt_unwinding(|| builder.build()); assert!(pool.is_err(), "thread-name panic should propagate!"); // Assuming they're created in order, threads 0 through 4 should have diff --git a/rayon-core/tests/double_init_fail.rs b/rayon-core/tests/double_init_fail.rs index 2b9818465..49b652365 100644 --- a/rayon-core/tests/double_init_fail.rs +++ b/rayon-core/tests/double_init_fail.rs @@ -1,5 +1,3 @@ -extern crate rayon_core; - use rayon_core::ThreadPoolBuilder; use std::error::Error; diff --git a/rayon-core/tests/init_zero_threads.rs b/rayon-core/tests/init_zero_threads.rs index eb4137e9a..ebd73c585 100644 --- a/rayon-core/tests/init_zero_threads.rs +++ b/rayon-core/tests/init_zero_threads.rs @@ -1,5 +1,3 @@ -extern crate rayon_core; - use rayon_core::ThreadPoolBuilder; #[test] diff --git a/rayon-core/tests/scope_join.rs b/rayon-core/tests/scope_join.rs index 30985eb74..3bf07d6b5 100644 --- a/rayon-core/tests/scope_join.rs +++ b/rayon-core/tests/scope_join.rs @@ -1,4 +1,4 @@ -extern crate rayon_core; +use rayon_core; /// Test that one can emulate join with `scope`: fn pseudo_join(f: F, g: G) diff --git a/rayon-core/tests/scoped_threadpool.rs b/rayon-core/tests/scoped_threadpool.rs index f1abdea2e..fdafb7737 100644 --- a/rayon-core/tests/scoped_threadpool.rs +++ b/rayon-core/tests/scoped_threadpool.rs @@ -1,6 +1,3 @@ -extern crate crossbeam_utils; -extern crate rayon_core; - #[macro_use] extern crate scoped_tls; diff --git a/rayon-core/tests/simple_panic.rs b/rayon-core/tests/simple_panic.rs index 3a5a7890a..2564482a4 100644 --- a/rayon-core/tests/simple_panic.rs +++ b/rayon-core/tests/simple_panic.rs @@ -1,5 +1,3 @@ -extern crate rayon_core; - use rayon_core::join; #[test] diff --git a/rayon-core/tests/stack_overflow_crash.rs b/rayon-core/tests/stack_overflow_crash.rs index 954823bdd..ee4bc1702 100644 --- a/rayon-core/tests/stack_overflow_crash.rs +++ b/rayon-core/tests/stack_overflow_crash.rs @@ -1,6 +1,5 @@ #[cfg(unix)] extern crate libc; -extern crate rayon_core; use rayon_core::ThreadPoolBuilder; diff --git a/rayon-demo/Cargo.toml b/rayon-demo/Cargo.toml index ac7b604e3..b25ac1fb2 100644 --- a/rayon-demo/Cargo.toml +++ b/rayon-demo/Cargo.toml @@ -1,4 +1,5 @@ [package] +edition = "2018" name = "rayon-demo" version = "0.0.0" authors = ["Niko Matsakis "] diff --git a/rayon-demo/src/fibonacci/mod.rs b/rayon-demo/src/fibonacci/mod.rs index 89e2e8553..21d8be86c 100644 --- a/rayon-demo/src/fibonacci/mod.rs +++ b/rayon-demo/src/fibonacci/mod.rs @@ -13,9 +13,10 @@ //! unless you have a whole lot of CPUs. The iterative version reveals the //! joke. -extern crate rayon; extern crate test; +use rayon; + const N: u32 = 32; const FN: u32 = 2_178_309; diff --git a/rayon-demo/src/find/mod.rs b/rayon-demo/src/find/mod.rs index 12257c7cb..4f469fc90 100644 --- a/rayon-demo/src/find/mod.rs +++ b/rayon-demo/src/find/mod.rs @@ -10,7 +10,7 @@ macro_rules! make_tests { lazy_static! { static ref HAYSTACK: Vec<[u32; $n]> = { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); rng.sample_iter(&Standard) .map(|x| { let mut result: [u32; $n] = [0; $n]; diff --git a/rayon-demo/src/life/mod.rs b/rayon-demo/src/life/mod.rs index 569f54b06..550685b15 100644 --- a/rayon-demo/src/life/mod.rs +++ b/rayon-demo/src/life/mod.rs @@ -14,7 +14,7 @@ Options: -h, --help Show this message. "; -use cpu_time::{self, CpuMeasure}; +use crate::cpu_time::{self, CpuMeasure}; use rand::distributions::Standard; use rand::{thread_rng, Rng}; use std::iter::repeat; diff --git a/rayon-demo/src/main.rs b/rayon-demo/src/main.rs index 492ec93c0..9494e992a 100644 --- a/rayon-demo/src/main.rs +++ b/rayon-demo/src/main.rs @@ -36,32 +36,20 @@ mod str_split; #[cfg(test)] mod vec_collect; -extern crate docopt; -extern crate rayon; // all // all #[macro_use] extern crate serde_derive; // all -extern crate cgmath; -extern crate serde; // all // nbody #[macro_use] extern crate glium; // nbody -#[cfg(unix)] -extern crate libc; // life -#[cfg(test)] -extern crate num; -extern crate odds; // sieve -extern crate rand; // nbody -extern crate rand_xorshift; // nbody -extern crate time; // nbody, sieve // factorial #[macro_use] extern crate lazy_static; // find -extern crate fixedbitset; // tsp -extern crate regex; // tsp #[cfg(windows)] extern crate winapi; // life - #[cfg(test)] extern crate test; +use rand; +use rand_xorshift; + const USAGE: &str = " Usage: rayon-demo bench rayon-demo [ options ] diff --git a/rayon-demo/src/map_collect.rs b/rayon-demo/src/map_collect.rs index af071cb85..3a57f18a1 100644 --- a/rayon-demo/src/map_collect.rs +++ b/rayon-demo/src/map_collect.rs @@ -205,7 +205,7 @@ macro_rules! make_bench { ($generate:ident, $check:ident) => { #[bench] fn with_collect(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::collect($generate()))); $check(&map.unwrap()); @@ -213,7 +213,7 @@ macro_rules! make_bench { #[bench] fn with_mutex(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::mutex($generate()))); $check(&map.unwrap()); @@ -221,7 +221,7 @@ macro_rules! make_bench { #[bench] fn with_mutex_vec(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::mutex_vec($generate()))); $check(&map.unwrap()); @@ -229,7 +229,7 @@ macro_rules! make_bench { #[bench] fn with_linked_list_collect(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::linked_list_collect($generate()))); $check(&map.unwrap()); @@ -237,7 +237,7 @@ macro_rules! make_bench { #[bench] fn with_linked_list_collect_vec(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::linked_list_collect_vec($generate()))); $check(&map.unwrap()); @@ -245,7 +245,7 @@ macro_rules! make_bench { #[bench] fn with_linked_list_collect_vec_sized(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::linked_list_collect_vec_sized($generate()))); $check(&map.unwrap()); @@ -253,7 +253,7 @@ macro_rules! make_bench { #[bench] fn with_linked_list_map_reduce_vec_sized(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::linked_list_map_reduce_vec_sized($generate()))); $check(&map.unwrap()); @@ -261,7 +261,7 @@ macro_rules! make_bench { #[bench] fn with_vec_vec_sized(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::vec_vec_sized($generate()))); $check(&map.unwrap()); @@ -269,7 +269,7 @@ macro_rules! make_bench { #[bench] fn with_fold(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::fold($generate()))); $check(&map.unwrap()); @@ -277,7 +277,7 @@ macro_rules! make_bench { #[bench] fn with_fold_vec(b: &mut ::test::Bencher) { - use map_collect::util; + use crate::map_collect::util; let mut map = None; b.iter(|| map = Some(util::fold_vec($generate()))); $check(&map.unwrap()); diff --git a/rayon-demo/src/mergesort/mod.rs b/rayon-demo/src/mergesort/mod.rs index 27d94da22..33eafcc64 100644 --- a/rayon-demo/src/mergesort/mod.rs +++ b/rayon-demo/src/mergesort/mod.rs @@ -217,7 +217,7 @@ pub fn is_sorted(v: &mut [T]) -> bool { } fn default_vec(n: usize) -> Vec { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); rng.sample_iter(&Standard).take(n).collect() } diff --git a/rayon-demo/src/nbody/bench.rs b/rayon-demo/src/nbody/bench.rs index 086b63664..1e44b388e 100644 --- a/rayon-demo/src/nbody/bench.rs +++ b/rayon-demo/src/nbody/bench.rs @@ -11,7 +11,7 @@ fn nbody_bench(b: &mut test::Bencher, mut tick: TICK) where TICK: FnMut(&mut NBodyBenchmark), { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let mut benchmark = NBodyBenchmark::new(BENCH_BODIES, &mut rng); b.iter(|| { for _ in 0..BENCH_TICKS { diff --git a/rayon-demo/src/nbody/mod.rs b/rayon-demo/src/nbody/mod.rs index 99954ad51..b359a89e2 100644 --- a/rayon-demo/src/nbody/mod.rs +++ b/rayon-demo/src/nbody/mod.rs @@ -81,7 +81,7 @@ fn run_benchmarks(mode: Option, bodies: usize, ticks: usize) { let run_seq = mode.map(|m| m == ExecutionMode::Seq).unwrap_or(true); let par_time = if run_par { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let mut benchmark = NBodyBenchmark::new(bodies, &mut rng); let par_start = time::precise_time_ns(); @@ -98,7 +98,7 @@ fn run_benchmarks(mode: Option, bodies: usize, ticks: usize) { }; let par_reduce_time = if run_par_reduce { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let mut benchmark = NBodyBenchmark::new(bodies, &mut rng); let par_start = time::precise_time_ns(); @@ -115,7 +115,7 @@ fn run_benchmarks(mode: Option, bodies: usize, ticks: usize) { }; let seq_time = if run_seq { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let mut benchmark = NBodyBenchmark::new(bodies, &mut rng); let seq_start = time::precise_time_ns(); diff --git a/rayon-demo/src/nbody/visualize.rs b/rayon-demo/src/nbody/visualize.rs index 7d428ab07..dfe30e97f 100644 --- a/rayon-demo/src/nbody/visualize.rs +++ b/rayon-demo/src/nbody/visualize.rs @@ -8,8 +8,8 @@ use glium::{Display, Program, Surface}; use glium::{IndexBuffer, VertexBuffer}; use rand::{self, Rng}; -use nbody::nbody::NBodyBenchmark; -use nbody::ExecutionMode; +use crate::nbody::nbody::NBodyBenchmark; +use crate::nbody::ExecutionMode; #[derive(Copy, Clone)] struct Vertex { @@ -121,7 +121,7 @@ pub fn visualize_benchmarks(num_bodies: usize, mut mode: ExecutionMode) { let vertex_buffer = VertexBuffer::new(&display, &vertices).unwrap(); let index_buffer = IndexBuffer::new(&display, PrimitiveType::TrianglesList, &indices).unwrap(); - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let instances: Vec<_> = (0..num_bodies) .map(|_| Instance { color: [ diff --git a/rayon-demo/src/noop/mod.rs b/rayon-demo/src/noop/mod.rs index 16290f773..f4515d66c 100644 --- a/rayon-demo/src/noop/mod.rs +++ b/rayon-demo/src/noop/mod.rs @@ -8,7 +8,7 @@ Options: --iters N Total time to execution (in millis). [default: 100] "; -use cpu_time; +use crate::cpu_time; use docopt::Docopt; #[derive(Deserialize)] diff --git a/rayon-demo/src/quicksort/mod.rs b/rayon-demo/src/quicksort/mod.rs index bd362825b..f6b001173 100644 --- a/rayon-demo/src/quicksort/mod.rs +++ b/rayon-demo/src/quicksort/mod.rs @@ -108,7 +108,7 @@ pub fn is_sorted(v: &[T]) -> bool { } fn default_vec(n: usize) -> Vec { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); rng.sample_iter(&Standard).take(n).collect() } diff --git a/rayon-demo/src/sort.rs b/rayon-demo/src/sort.rs index e63b78b4a..20265c511 100644 --- a/rayon-demo/src/sort.rs +++ b/rayon-demo/src/sort.rs @@ -15,12 +15,12 @@ fn gen_descending(len: usize) -> Vec { } fn gen_random(len: usize) -> Vec { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); rng.sample_iter(&Standard).take(len).collect() } fn gen_mostly_ascending(len: usize) -> Vec { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let len_dist = Uniform::new(0, len); let mut v = gen_ascending(len); for _ in (0usize..).take_while(|x| x * x <= len) { @@ -32,7 +32,7 @@ fn gen_mostly_ascending(len: usize) -> Vec { } fn gen_mostly_descending(len: usize) -> Vec { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let len_dist = Uniform::new(0, len); let mut v = gen_descending(len); for _ in (0usize..).take_while(|x| x * x <= len) { @@ -44,7 +44,7 @@ fn gen_mostly_descending(len: usize) -> Vec { } fn gen_strings(len: usize) -> Vec { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let len_dist = Uniform::new(1, 21); let mut v = vec![]; for _ in 0..len { @@ -55,7 +55,7 @@ fn gen_strings(len: usize) -> Vec { } fn gen_big_random(len: usize) -> Vec<[u64; 16]> { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); rng.sample_iter(&Standard) .map(|x| [x; 16]) .take(len) @@ -230,7 +230,7 @@ trait QuickSort { impl QuickSort for [T] { fn demo_quick_sort(&mut self) { - use quicksort::{quick_sort, Parallel}; + use crate::quicksort::{quick_sort, Parallel}; quick_sort::(self); } } diff --git a/rayon-demo/src/str_split.rs b/rayon-demo/src/str_split.rs index b2f7d6e14..249cf0fdd 100644 --- a/rayon-demo/src/str_split.rs +++ b/rayon-demo/src/str_split.rs @@ -6,7 +6,7 @@ use test::Bencher; lazy_static! { static ref HAYSTACK: String = { - let mut rng = ::seeded_rng(); + let mut rng = crate::seeded_rng(); let mut bytes: Vec = "abcdefg ".bytes().cycle().take(1_000_000).collect(); bytes.shuffle(&mut rng); String::from_utf8(bytes).unwrap() diff --git a/rayon-demo/src/tsp/step.rs b/rayon-demo/src/tsp/step.rs index 311c55244..4a4060b7a 100644 --- a/rayon-demo/src/tsp/step.rs +++ b/rayon-demo/src/tsp/step.rs @@ -98,7 +98,7 @@ fn compute_lower_bound( min_weights.iter().fold(Weight::zero(), |w1, &w2| w1 + w2) + weight } -fn solve_tour_seq(solver: &SolverCx, element: Arc) { +fn solve_tour_seq(solver: &SolverCx<'_>, element: Arc) { // Sequentially enumerate all possible tours starting from this point. let graph = solver.graph(); let mut path = Vec::with_capacity(graph.num_nodes() + 1); @@ -128,7 +128,7 @@ fn solve_tour_seq(solver: &SolverCx, element: Arc) { } fn enumerate_sequentially( - solver: &SolverCx, + solver: &SolverCx<'_>, path: &mut Vec, visited: &mut NodeSet, mut weight: Weight, @@ -173,7 +173,7 @@ fn enumerate_sequentially( } } -fn complete_tour(solver: &SolverCx, path: &mut Vec, weight: Weight) { +fn complete_tour(solver: &SolverCx<'_>, path: &mut Vec, weight: Weight) { let graph = solver.graph(); debug_assert!(path.len() == graph.num_nodes()); let home = path[0]; diff --git a/rayon-demo/src/vec_collect.rs b/rayon-demo/src/vec_collect.rs index 0c6d60284..ba7b1f469 100644 --- a/rayon-demo/src/vec_collect.rs +++ b/rayon-demo/src/vec_collect.rs @@ -127,7 +127,7 @@ macro_rules! make_bench { ($generate:ident, $check:ident) => { #[bench] fn with_collect(b: &mut ::test::Bencher) { - use vec_collect::util; + use crate::vec_collect::util; let mut vec = None; b.iter(|| vec = Some(util::collect($generate()))); $check(&vec.unwrap()); @@ -135,7 +135,7 @@ macro_rules! make_bench { #[bench] fn with_linked_list_collect_vec(b: &mut ::test::Bencher) { - use vec_collect::util; + use crate::vec_collect::util; let mut vec = None; b.iter(|| vec = Some(util::linked_list_collect_vec($generate()))); $check(&vec.unwrap()); @@ -143,7 +143,7 @@ macro_rules! make_bench { #[bench] fn with_linked_list_collect_vec_sized(b: &mut ::test::Bencher) { - use vec_collect::util; + use crate::vec_collect::util; let mut vec = None; b.iter(|| vec = Some(util::linked_list_collect_vec_sized($generate()))); $check(&vec.unwrap()); @@ -151,7 +151,7 @@ macro_rules! make_bench { #[bench] fn with_linked_list_map_reduce_vec_sized(b: &mut ::test::Bencher) { - use vec_collect::util; + use crate::vec_collect::util; let mut vec = None; b.iter(|| vec = Some(util::linked_list_map_reduce_vec_sized($generate()))); $check(&vec.unwrap()); @@ -159,7 +159,7 @@ macro_rules! make_bench { #[bench] fn with_vec_vec_sized(b: &mut ::test::Bencher) { - use vec_collect::util; + use crate::vec_collect::util; let mut vec = None; b.iter(|| vec = Some(util::vec_vec_sized($generate()))); $check(&vec.unwrap()); @@ -167,7 +167,7 @@ macro_rules! make_bench { #[bench] fn with_fold(b: &mut ::test::Bencher) { - use vec_collect::util; + use crate::vec_collect::util; let mut vec = None; b.iter(|| vec = Some(util::fold($generate()))); $check(&vec.unwrap()); diff --git a/rayon-futures/Cargo.toml b/rayon-futures/Cargo.toml index 4522b2e0b..971ccdb3f 100644 --- a/rayon-futures/Cargo.toml +++ b/rayon-futures/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" # reminder to update html_root_url attribute authors = ["Niko Matsakis ", "Josh Stone "] description = "Futures integration into Rayon" +edition = "2018" license = "Apache-2.0/MIT" repository = "https://github.com/rayon-rs/rayon" documentation = "https://docs.rs/rayon-futures/" diff --git a/rayon-futures/src/lib.rs b/rayon-futures/src/lib.rs index 040134e5e..1f82cde40 100644 --- a/rayon-futures/src/lib.rs +++ b/rayon-futures/src/lib.rs @@ -4,9 +4,6 @@ #![deny(missing_debug_implementations)] #![doc(html_root_url = "https://docs.rs/rayon-futures/0.1")] -extern crate futures; -extern crate rayon_core; - use futures::future::CatchUnwind; use futures::task::{self, Spawn, Task}; use futures::{Async, Future, Poll}; @@ -60,8 +57,8 @@ where } unsafe fn hide_lifetime<'l, T, E>( - x: Arc + 'l>, - ) -> Arc> { + x: Arc + 'l>, + ) -> Arc> { mem::transmute(x) } } @@ -75,7 +72,7 @@ where /// Any panics that occur while computing the spawned future will be /// propagated when this future is polled. pub struct RayonFuture { - inner: Arc, Box>>, + inner: Arc, Box>>, } impl RayonFuture { @@ -127,7 +124,7 @@ impl Drop for RayonFuture { } impl fmt::Debug for RayonFuture { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("RayonFuture").finish() } } @@ -148,7 +145,7 @@ type CUError = as Future>::Error; struct ScopeFutureContents<'scope, F, S> where - F: Future + Send + 'scope, + F: Future + Send, S: ScopeHandle<'scope>, { spawn: Option>>, @@ -173,7 +170,7 @@ where F: Future + Send + 'scope, S: ScopeHandle<'scope>, { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt.debug_struct("ScopeFutureContents").finish() } } @@ -182,7 +179,7 @@ where #[derive(Debug)] struct ArcScopeFuture<'scope, F, S>(Arc>) where - F: Future + Send + 'scope, + F: Future + Send, S: ScopeHandle<'scope>; impl<'scope, F, S> Clone for ArcScopeFuture<'scope, F, S> @@ -217,7 +214,7 @@ where // Arc in futures-rs, we need to roll our own to drop the 'static bound. // A ScopeFuture that is inside a ArcScopeFuture. #[derive(Debug)] -struct ScopeFutureWrapped<'scope, F: 'scope, S>(PhantomData<(&'scope F, S)>); +struct ScopeFutureWrapped<'scope, F, S>(PhantomData<(&'scope F, S)>); unsafe impl<'scope, F, S> Send for ScopeFutureWrapped<'scope, F, S> {} unsafe impl<'scope, F, S> Sync for ScopeFutureWrapped<'scope, F, S> {} @@ -303,7 +300,7 @@ where // `F` outlive `counter`. And we can see from `complete()` // that we drop all values of type `F` before decrementing // `counter`. - NotifyHandle::new(mem::transmute(ptr as *mut UnsafeNotify)) + NotifyHandle::new(mem::transmute(ptr as *mut dyn UnsafeNotify)) } } } @@ -578,7 +575,7 @@ trait ScopeFutureTrait: Send + Sync { impl<'scope, F, S> ScopeFutureTrait, CUError> for ScopeFuture<'scope, F, S> where - F: Future + Send, + F: Future + Send + 'scope, S: ScopeHandle<'scope>, { fn probe(&self) -> bool { diff --git a/src/collections/binary_heap.rs b/src/collections/binary_heap.rs index b878ce5ca..c8f1014c1 100644 --- a/src/collections/binary_heap.rs +++ b/src/collections/binary_heap.rs @@ -4,10 +4,10 @@ use std::collections::BinaryHeap; -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; -use vec; +use crate::vec; /// Parallel iterator over a binary heap #[derive(Debug, Clone)] @@ -33,7 +33,7 @@ delegate_indexed_iterator! { /// Parallel iterator over an immutable reference to a binary heap #[derive(Debug)] -pub struct Iter<'a, T: Ord + Sync + 'a> { +pub struct Iter<'a, T: Ord + Sync> { inner: vec::IntoIter<&'a T>, } diff --git a/src/collections/btree_map.rs b/src/collections/btree_map.rs index 1523db745..12436dca1 100644 --- a/src/collections/btree_map.rs +++ b/src/collections/btree_map.rs @@ -4,10 +4,10 @@ use std::collections::BTreeMap; -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; -use vec; +use crate::vec; /// Parallel iterator over a B-Tree map #[derive(Debug)] // std doesn't Clone @@ -27,7 +27,7 @@ delegate_iterator! { /// Parallel iterator over an immutable reference to a B-Tree map #[derive(Debug)] -pub struct Iter<'a, K: Ord + Sync + 'a, V: Sync + 'a> { +pub struct Iter<'a, K: Ord + Sync, V: Sync> { inner: vec::IntoIter<(&'a K, &'a V)>, } @@ -51,7 +51,7 @@ delegate_iterator! { /// Parallel iterator over a mutable reference to a B-Tree map #[derive(Debug)] -pub struct IterMut<'a, K: Ord + Sync + 'a, V: Send + 'a> { +pub struct IterMut<'a, K: Ord + Sync, V: Send> { inner: vec::IntoIter<(&'a K, &'a mut V)>, } diff --git a/src/collections/btree_set.rs b/src/collections/btree_set.rs index e27f2ec58..061d37c7e 100644 --- a/src/collections/btree_set.rs +++ b/src/collections/btree_set.rs @@ -4,10 +4,10 @@ use std::collections::BTreeSet; -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; -use vec; +use crate::vec; /// Parallel iterator over a B-Tree set #[derive(Debug)] // std doesn't Clone @@ -27,7 +27,7 @@ delegate_iterator! { /// Parallel iterator over an immutable reference to a B-Tree set #[derive(Debug)] -pub struct Iter<'a, T: Ord + Sync + 'a> { +pub struct Iter<'a, T: Ord + Sync> { inner: vec::IntoIter<&'a T>, } diff --git a/src/collections/hash_map.rs b/src/collections/hash_map.rs index 69149075b..e9adbc12e 100644 --- a/src/collections/hash_map.rs +++ b/src/collections/hash_map.rs @@ -5,10 +5,10 @@ use std::collections::HashMap; use std::hash::{BuildHasher, Hash}; -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; -use vec; +use crate::vec; /// Parallel iterator over a hash map #[derive(Debug)] // std doesn't Clone @@ -28,7 +28,7 @@ delegate_iterator! { /// Parallel iterator over an immutable reference to a hash map #[derive(Debug)] -pub struct Iter<'a, K: Hash + Eq + Sync + 'a, V: Sync + 'a> { +pub struct Iter<'a, K: Hash + Eq + Sync, V: Sync> { inner: vec::IntoIter<(&'a K, &'a V)>, } @@ -52,7 +52,7 @@ delegate_iterator! { /// Parallel iterator over a mutable reference to a hash map #[derive(Debug)] -pub struct IterMut<'a, K: Hash + Eq + Sync + 'a, V: Send + 'a> { +pub struct IterMut<'a, K: Hash + Eq + Sync, V: Send> { inner: vec::IntoIter<(&'a K, &'a mut V)>, } diff --git a/src/collections/hash_set.rs b/src/collections/hash_set.rs index dbf9e5b4f..bf43f89a3 100644 --- a/src/collections/hash_set.rs +++ b/src/collections/hash_set.rs @@ -5,10 +5,10 @@ use std::collections::HashSet; use std::hash::{BuildHasher, Hash}; -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; -use vec; +use crate::vec; /// Parallel iterator over a hash set #[derive(Debug)] // std doesn't Clone @@ -28,7 +28,7 @@ delegate_iterator! { /// Parallel iterator over an immutable reference to a hash set #[derive(Debug)] -pub struct Iter<'a, T: Hash + Eq + Sync + 'a> { +pub struct Iter<'a, T: Hash + Eq + Sync> { inner: vec::IntoIter<&'a T>, } diff --git a/src/collections/linked_list.rs b/src/collections/linked_list.rs index 976e9c8eb..bddd2b0fc 100644 --- a/src/collections/linked_list.rs +++ b/src/collections/linked_list.rs @@ -4,10 +4,10 @@ use std::collections::LinkedList; -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; -use vec; +use crate::vec; /// Parallel iterator over a linked list #[derive(Debug, Clone)] @@ -27,7 +27,7 @@ delegate_iterator! { /// Parallel iterator over an immutable reference to a linked list #[derive(Debug)] -pub struct Iter<'a, T: Sync + 'a> { +pub struct Iter<'a, T: Sync> { inner: vec::IntoIter<&'a T>, } @@ -51,7 +51,7 @@ delegate_iterator! { /// Parallel iterator over a mutable reference to a linked list #[derive(Debug)] -pub struct IterMut<'a, T: Send + 'a> { +pub struct IterMut<'a, T: Send> { inner: vec::IntoIter<&'a mut T>, } diff --git a/src/collections/vec_deque.rs b/src/collections/vec_deque.rs index 897333861..54494c471 100644 --- a/src/collections/vec_deque.rs +++ b/src/collections/vec_deque.rs @@ -4,11 +4,11 @@ use std::collections::VecDeque; -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; -use slice; -use vec; +use crate::slice; +use crate::vec; /// Parallel iterator over a double-ended queue #[derive(Debug, Clone)] @@ -28,7 +28,7 @@ delegate_indexed_iterator! { /// Parallel iterator over an immutable reference to a double-ended queue #[derive(Debug)] -pub struct Iter<'a, T: Sync + 'a> { +pub struct Iter<'a, T: Sync> { inner: Chain, slice::Iter<'a, T>>, } @@ -59,7 +59,7 @@ delegate_indexed_iterator! { /// Parallel iterator over a mutable reference to a double-ended queue #[derive(Debug)] -pub struct IterMut<'a, T: Send + 'a> { +pub struct IterMut<'a, T: Send> { inner: Chain, slice::IterMut<'a, T>>, } diff --git a/src/iter/chunks.rs b/src/iter/chunks.rs index 330a49dcb..1ae5c7e5d 100644 --- a/src/iter/chunks.rs +++ b/src/iter/chunks.rs @@ -2,7 +2,7 @@ use std::cmp::min; use super::plumbing::*; use super::*; -use math::div_round_up; +use crate::math::div_round_up; /// `Chunks` is an iterator that groups elements of an underlying iterator. /// diff --git a/src/iter/collect/consumer.rs b/src/iter/collect/consumer.rs index eafa72116..7b8746a9b 100644 --- a/src/iter/collect/consumer.rs +++ b/src/iter/collect/consumer.rs @@ -4,7 +4,7 @@ use std::ptr; use std::slice; use std::sync::atomic::{AtomicUsize, Ordering}; -pub(super) struct CollectConsumer<'c, T: Send + 'c> { +pub(super) struct CollectConsumer<'c, T: Send> { /// Tracks how many items we successfully wrote. Used to guarantee /// safety in the face of panics or buggy parallel iterators. /// @@ -19,7 +19,7 @@ pub(super) struct CollectConsumer<'c, T: Send + 'c> { target: &'c mut [T], } -pub(super) struct CollectFolder<'c, T: Send + 'c> { +pub(super) struct CollectFolder<'c, T: Send> { global_writes: &'c AtomicUsize, local_writes: usize, diff --git a/src/iter/collect/mod.rs b/src/iter/collect/mod.rs index 21328108b..17a12e147 100644 --- a/src/iter/collect/mod.rs +++ b/src/iter/collect/mod.rs @@ -67,7 +67,7 @@ where } /// Manage the collection vector. -struct Collect<'c, T: Send + 'c> { +struct Collect<'c, T: Send> { writes: AtomicUsize, vec: &'c mut Vec, len: usize, diff --git a/src/iter/collect/test.rs b/src/iter/collect/test.rs index eec3d67e6..922e1167b 100644 --- a/src/iter/collect/test.rs +++ b/src/iter/collect/test.rs @@ -6,7 +6,7 @@ // result in panics. use super::Collect; -use iter::plumbing::*; +use crate::iter::plumbing::*; use rayon_core::join; /// Promises to produce 2 items, but then produces 3. Does not do any diff --git a/src/iter/empty.rs b/src/iter/empty.rs index 2f68df46c..eb5797c9d 100644 --- a/src/iter/empty.rs +++ b/src/iter/empty.rs @@ -1,5 +1,5 @@ -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; use std; use std::fmt; diff --git a/src/iter/filter.rs b/src/iter/filter.rs index 48dda5e51..aad6cae7b 100644 --- a/src/iter/filter.rs +++ b/src/iter/filter.rs @@ -50,7 +50,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct FilterConsumer<'p, C, P: 'p> { +struct FilterConsumer<'p, C, P> { base: C, filter_op: &'p P, } @@ -105,7 +105,7 @@ where } } -struct FilterFolder<'p, C, P: 'p> { +struct FilterFolder<'p, C, P> { base: C, filter_op: &'p P, } diff --git a/src/iter/filter_map.rs b/src/iter/filter_map.rs index 885998dce..dd71c3ebb 100644 --- a/src/iter/filter_map.rs +++ b/src/iter/filter_map.rs @@ -50,7 +50,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct FilterMapConsumer<'p, C, P: 'p> { +struct FilterMapConsumer<'p, C, P> { base: C, filter_op: &'p P, } @@ -106,7 +106,7 @@ where } } -struct FilterMapFolder<'p, C, P: 'p> { +struct FilterMapFolder<'p, C, P> { base: C, filter_op: &'p P, } diff --git a/src/iter/find.rs b/src/iter/find.rs index 6358d5280..971db2b3c 100644 --- a/src/iter/find.rs +++ b/src/iter/find.rs @@ -12,7 +12,7 @@ where pi.drive_unindexed(consumer) } -struct FindConsumer<'p, P: 'p> { +struct FindConsumer<'p, P> { find_op: &'p P, found: &'p AtomicBool, } @@ -63,7 +63,7 @@ where } } -struct FindFolder<'p, T, P: 'p> { +struct FindFolder<'p, T, P> { find_op: &'p P, found: &'p AtomicBool, item: Option, diff --git a/src/iter/find_first_last/mod.rs b/src/iter/find_first_last/mod.rs index b89aeec3f..e5da8f0dd 100644 --- a/src/iter/find_first_last/mod.rs +++ b/src/iter/find_first_last/mod.rs @@ -58,7 +58,7 @@ where pi.drive_unindexed(consumer) } -struct FindConsumer<'p, P: 'p> { +struct FindConsumer<'p, P> { find_op: &'p P, lower_bound: Cell, upper_bound: usize, @@ -163,7 +163,7 @@ where } } -struct FindFolder<'p, T, P: 'p> { +struct FindFolder<'p, T, P> { find_op: &'p P, boundary: usize, match_position: MatchPosition, diff --git a/src/iter/flat_map.rs b/src/iter/flat_map.rs index 076c23ad5..5043dd17f 100644 --- a/src/iter/flat_map.rs +++ b/src/iter/flat_map.rs @@ -51,7 +51,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct FlatMapConsumer<'f, C, F: 'f> { +struct FlatMapConsumer<'f, C, F> { base: C, map_op: &'f F, } @@ -109,7 +109,7 @@ where } } -struct FlatMapFolder<'f, C, F: 'f, R> { +struct FlatMapFolder<'f, C, F, R> { base: C, map_op: &'f F, previous: Option, diff --git a/src/iter/fold.rs b/src/iter/fold.rs index 0de0aa3f0..345afbd50 100644 --- a/src/iter/fold.rs +++ b/src/iter/fold.rs @@ -60,7 +60,7 @@ where } } -struct FoldConsumer<'c, C, ID: 'c, F: 'c> { +struct FoldConsumer<'c, C, ID, F> { base: C, fold_op: &'c F, identity: &'c ID, @@ -121,7 +121,7 @@ where } } -struct FoldFolder<'r, C, ID, F: 'r> { +struct FoldFolder<'r, C, ID, F> { base: C, fold_op: &'r F, item: ID, @@ -237,7 +237,7 @@ where } } -struct FoldWithConsumer<'c, C, U, F: 'c> { +struct FoldWithConsumer<'c, C, U, F> { base: C, item: U, fold_op: &'c F, diff --git a/src/iter/for_each.rs b/src/iter/for_each.rs index 5307939ba..3b77bebe1 100644 --- a/src/iter/for_each.rs +++ b/src/iter/for_each.rs @@ -12,7 +12,7 @@ where pi.drive_unindexed(consumer) } -struct ForEachConsumer<'f, F: 'f> { +struct ForEachConsumer<'f, F> { op: &'f F, } diff --git a/src/iter/inspect.rs b/src/iter/inspect.rs index 145032d01..2de2d12ab 100644 --- a/src/iter/inspect.rs +++ b/src/iter/inspect.rs @@ -108,7 +108,7 @@ where /// //////////////////////////////////////////////////////////////////////// -struct InspectProducer<'f, P, F: 'f> { +struct InspectProducer<'f, P, F> { base: P, inspect_op: &'f F, } @@ -162,7 +162,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct InspectConsumer<'f, C, F: 'f> { +struct InspectConsumer<'f, C, F> { base: C, inspect_op: &'f F, } @@ -217,7 +217,7 @@ where } } -struct InspectFolder<'f, C, F: 'f> { +struct InspectFolder<'f, C, F> { base: C, inspect_op: &'f F, } diff --git a/src/iter/map.rs b/src/iter/map.rs index 218539835..9b959aa93 100644 --- a/src/iter/map.rs +++ b/src/iter/map.rs @@ -110,7 +110,7 @@ where /// //////////////////////////////////////////////////////////////////////// -struct MapProducer<'f, P, F: 'f> { +struct MapProducer<'f, P, F> { base: P, map_op: &'f F, } @@ -164,7 +164,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct MapConsumer<'f, C, F: 'f> { +struct MapConsumer<'f, C, F> { base: C, map_op: &'f F, } @@ -221,7 +221,7 @@ where } } -struct MapFolder<'f, C, F: 'f> { +struct MapFolder<'f, C, F> { base: C, map_op: &'f F, } diff --git a/src/iter/map_with.rs b/src/iter/map_with.rs index 22733b315..ea16f81ef 100644 --- a/src/iter/map_with.rs +++ b/src/iter/map_with.rs @@ -119,7 +119,7 @@ where /// //////////////////////////////////////////////////////////////////////// -struct MapWithProducer<'f, P, U, F: 'f> { +struct MapWithProducer<'f, P, U, F> { base: P, item: U, map_op: &'f F, @@ -179,7 +179,7 @@ where } } -struct MapWithIter<'f, I, U, F: 'f> { +struct MapWithIter<'f, I, U, F> { base: I, item: U, map_op: &'f F, @@ -226,7 +226,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct MapWithConsumer<'f, C, U, F: 'f> { +struct MapWithConsumer<'f, C, U, F> { base: C, item: U, map_op: &'f F, @@ -287,7 +287,7 @@ where } } -struct MapWithFolder<'f, C, U, F: 'f> { +struct MapWithFolder<'f, C, U, F> { base: C, item: U, map_op: &'f F, @@ -448,7 +448,7 @@ where /// //////////////////////////////////////////////////////////////////////// -struct MapInitProducer<'f, P, INIT: 'f, F: 'f> { +struct MapInitProducer<'f, P, INIT, F> { base: P, init: &'f INIT, map_op: &'f F, @@ -511,7 +511,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct MapInitConsumer<'f, C, INIT: 'f, F: 'f> { +struct MapInitConsumer<'f, C, INIT, F> { base: C, init: &'f INIT, map_op: &'f F, diff --git a/src/iter/once.rs b/src/iter/once.rs index 3819c20e8..5140b6b9f 100644 --- a/src/iter/once.rs +++ b/src/iter/once.rs @@ -1,5 +1,5 @@ -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; /// Creates a parallel iterator that produces an element exactly once. /// diff --git a/src/iter/panic_fuse.rs b/src/iter/panic_fuse.rs index b0d1ac0eb..a4239a5eb 100644 --- a/src/iter/panic_fuse.rs +++ b/src/iter/panic_fuse.rs @@ -306,7 +306,7 @@ where where I: IntoIterator, { - fn cool<'a, T>(fuse: &'a Fuse) -> impl Fn(&T) -> bool + 'a { + fn cool<'a, T>(fuse: &'a Fuse<'_>) -> impl Fn(&T) -> bool + 'a { move |_| !fuse.panicked() } diff --git a/src/iter/par_bridge.rs b/src/iter/par_bridge.rs index c8197ea65..07d26de08 100644 --- a/src/iter/par_bridge.rs +++ b/src/iter/par_bridge.rs @@ -4,9 +4,9 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Mutex, TryLockError}; use std::thread::yield_now; -use current_num_threads; -use iter::plumbing::{bridge_unindexed, Folder, UnindexedConsumer, UnindexedProducer}; -use iter::ParallelIterator; +use crate::current_num_threads; +use crate::iter::plumbing::{bridge_unindexed, Folder, UnindexedConsumer, UnindexedProducer}; +use crate::iter::ParallelIterator; /// Conversion trait to convert an `Iterator` to a `ParallelIterator`. /// @@ -96,7 +96,7 @@ where } } -struct IterParallelProducer<'a, Iter: Iterator + 'a> { +struct IterParallelProducer<'a, Iter: Iterator> { split_count: &'a AtomicUsize, done: &'a AtomicBool, iter: &'a Mutex<(Iter, Worker)>, diff --git a/src/iter/plumbing/mod.rs b/src/iter/plumbing/mod.rs index d6cc5a169..74faf5863 100644 --- a/src/iter/plumbing/mod.rs +++ b/src/iter/plumbing/mod.rs @@ -4,7 +4,7 @@ //! //! [r]: https://github.com/rayon-rs/rayon/blob/master/src/iter/plumbing/README.md -use join_context; +use crate::join_context; use super::IndexedParallelIterator; @@ -264,7 +264,7 @@ impl Splitter { #[inline] fn new() -> Splitter { Splitter { - splits: ::current_num_threads(), + splits: crate::current_num_threads(), } } @@ -275,7 +275,7 @@ impl Splitter { if stolen { // This job was stolen! Reset the number of desired splits to the // thread count, if that's more than we had remaining anyway. - self.splits = cmp::max(::current_num_threads(), self.splits / 2); + self.splits = cmp::max(crate::current_num_threads(), self.splits / 2); true } else if splits > 0 { // We have splits remaining, make it so. diff --git a/src/iter/reduce.rs b/src/iter/reduce.rs index 8ba4f1a4e..321b5dd86 100644 --- a/src/iter/reduce.rs +++ b/src/iter/reduce.rs @@ -15,7 +15,7 @@ where pi.drive_unindexed(consumer) } -struct ReduceConsumer<'r, R: 'r, ID: 'r> { +struct ReduceConsumer<'r, R, ID> { identity: &'r ID, reduce_op: &'r R, } @@ -78,7 +78,7 @@ where } } -struct ReduceFolder<'r, R: 'r, T> { +struct ReduceFolder<'r, R, T> { reduce_op: &'r R, item: T, } diff --git a/src/iter/splitter.rs b/src/iter/splitter.rs index 45b0081c1..40935ac2b 100644 --- a/src/iter/splitter.rs +++ b/src/iter/splitter.rs @@ -146,7 +146,7 @@ where } } -struct SplitProducer<'a, D, S: 'a> { +struct SplitProducer<'a, D, S> { data: D, splitter: &'a S, } diff --git a/src/iter/test.rs b/src/iter/test.rs index b632383f3..71f4a138c 100644 --- a/src/iter/test.rs +++ b/src/iter/test.rs @@ -1,7 +1,7 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use super::*; -use prelude::*; +use crate::prelude::*; use rayon_core::*; use rand::distributions::Standard; @@ -1851,7 +1851,7 @@ fn check_partition_map() { #[test] fn check_either() { - type I = ::vec::IntoIter; + type I = crate::vec::IntoIter; type E = Either; let v: Vec = (0..1024).collect(); diff --git a/src/iter/try_fold.rs b/src/iter/try_fold.rs index 51f988179..c1a57a4e6 100644 --- a/src/iter/try_fold.rs +++ b/src/iter/try_fold.rs @@ -65,7 +65,7 @@ where } } -struct TryFoldConsumer<'c, U, C, ID: 'c, F: 'c> { +struct TryFoldConsumer<'c, U, C, ID, F> { base: C, identity: &'c ID, fold_op: &'c F, @@ -127,7 +127,7 @@ where } } -struct TryFoldFolder<'r, C, U: Try, F: 'r> { +struct TryFoldFolder<'r, C, U: Try, F> { base: C, fold_op: &'r F, result: Result, @@ -227,7 +227,7 @@ where } } -struct TryFoldWithConsumer<'c, C, U: Try, F: 'c> { +struct TryFoldWithConsumer<'c, C, U: Try, F> { base: C, item: U::Ok, fold_op: &'c F, diff --git a/src/iter/try_reduce.rs b/src/iter/try_reduce.rs index 6c9f24181..76b38505d 100644 --- a/src/iter/try_reduce.rs +++ b/src/iter/try_reduce.rs @@ -20,7 +20,7 @@ where pi.drive_unindexed(consumer) } -struct TryReduceConsumer<'r, R: 'r, ID: 'r> { +struct TryReduceConsumer<'r, R, ID> { identity: &'r ID, reduce_op: &'r R, full: &'r AtomicBool, @@ -89,7 +89,7 @@ where } } -struct TryReduceFolder<'r, R: 'r, T: Try> { +struct TryReduceFolder<'r, R, T: Try> { reduce_op: &'r R, result: Result, full: &'r AtomicBool, diff --git a/src/iter/try_reduce_with.rs b/src/iter/try_reduce_with.rs index 137dd5886..6be3100f0 100644 --- a/src/iter/try_reduce_with.rs +++ b/src/iter/try_reduce_with.rs @@ -18,7 +18,7 @@ where pi.drive_unindexed(consumer) } -struct TryReduceWithConsumer<'r, R: 'r> { +struct TryReduceWithConsumer<'r, R> { reduce_op: &'r R, full: &'r AtomicBool, } @@ -88,7 +88,7 @@ where } } -struct TryReduceWithFolder<'r, R: 'r, T: Try> { +struct TryReduceWithFolder<'r, R, T: Try> { reduce_op: &'r R, opt_result: Option>, full: &'r AtomicBool, diff --git a/src/iter/unzip.rs b/src/iter/unzip.rs index b5a669970..3c5ff6842 100644 --- a/src/iter/unzip.rs +++ b/src/iter/unzip.rs @@ -191,7 +191,7 @@ where } /// A fake iterator to intercept the `Consumer` for type `A`. -struct UnzipA<'b, I, OP, FromB: 'b> { +struct UnzipA<'b, I, OP, FromB> { base: I, op: OP, b: &'b mut FromB, @@ -283,7 +283,7 @@ where } /// `Consumer` that unzips into two other `Consumer`s -struct UnzipConsumer<'a, OP: 'a, CA, CB> { +struct UnzipConsumer<'a, OP, CA, CB> { op: &'a OP, left: CA, right: CB, @@ -358,7 +358,7 @@ where } /// `Folder` that unzips into two other `Folder`s -struct UnzipFolder<'a, OP: 'a, FA, FB> { +struct UnzipFolder<'a, OP, FA, FB> { op: &'a OP, left: FA, right: FB, diff --git a/src/iter/update.rs b/src/iter/update.rs index e822f4878..3e8eabe0d 100644 --- a/src/iter/update.rs +++ b/src/iter/update.rs @@ -107,7 +107,7 @@ where /// //////////////////////////////////////////////////////////////////////// -struct UpdateProducer<'f, P, F: 'f> { +struct UpdateProducer<'f, P, F> { base: P, update_op: &'f F, } @@ -163,7 +163,7 @@ where /// //////////////////////////////////////////////////////////////////////// /// Consumer implementation -struct UpdateConsumer<'f, C, F: 'f> { +struct UpdateConsumer<'f, C, F> { base: C, update_op: &'f F, } @@ -218,7 +218,7 @@ where } } -struct UpdateFolder<'f, C, F: 'f> { +struct UpdateFolder<'f, C, F> { base: C, update_op: &'f F, } diff --git a/src/lib.rs b/src/lib.rs index 1bd122774..630828cec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,14 +83,6 @@ //! //! [faq]: https://github.com/rayon-rs/rayon/blob/master/FAQ.md -extern crate crossbeam_deque; -extern crate either; -extern crate rayon_core; - -#[cfg(test)] -extern crate rand; -#[cfg(test)] -extern crate rand_xorshift; #[cfg(test)] #[macro_use] extern crate doc_comment; diff --git a/src/option.rs b/src/option.rs index 925107f82..fc1f7d286 100644 --- a/src/option.rs +++ b/src/option.rs @@ -5,8 +5,8 @@ //! //! [std::option]: https://doc.rust-lang.org/stable/std/option/ -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; use std; use std::sync::atomic::{AtomicBool, Ordering}; @@ -85,7 +85,7 @@ impl IndexedParallelIterator for IntoIter { /// [`Some`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.Some /// [`par_iter`]: ../iter/trait.IntoParallelRefIterator.html#tymethod.par_iter #[derive(Debug)] -pub struct Iter<'a, T: Sync + 'a> { +pub struct Iter<'a, T: Sync> { inner: IntoIter<&'a T>, } @@ -123,7 +123,7 @@ delegate_indexed_iterator! { /// [`Some`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.Some /// [`par_iter_mut`]: ../iter/trait.IntoParallelRefMutIterator.html#tymethod.par_iter_mut #[derive(Debug)] -pub struct IterMut<'a, T: Send + 'a> { +pub struct IterMut<'a, T: Send> { inner: IntoIter<&'a mut T>, } diff --git a/src/par_either.rs b/src/par_either.rs index d72e5140b..a19ce5399 100644 --- a/src/par_either.rs +++ b/src/par_either.rs @@ -1,6 +1,6 @@ -use iter::plumbing::*; -use iter::Either::{Left, Right}; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::Either::{Left, Right}; +use crate::iter::*; /// `Either` is a parallel iterator if both `L` and `R` are parallel iterators. impl ParallelIterator for Either diff --git a/src/prelude.rs b/src/prelude.rs index 7c32aab74..348547514 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -2,14 +2,14 @@ //! The intention is that one can include `use rayon::prelude::*` and //! have easy access to the various traits and methods you will need. -pub use iter::FromParallelIterator; -pub use iter::IndexedParallelIterator; -pub use iter::IntoParallelIterator; -pub use iter::IntoParallelRefIterator; -pub use iter::IntoParallelRefMutIterator; -pub use iter::ParallelBridge; -pub use iter::ParallelExtend; -pub use iter::ParallelIterator; -pub use slice::ParallelSlice; -pub use slice::ParallelSliceMut; -pub use str::ParallelString; +pub use crate::iter::FromParallelIterator; +pub use crate::iter::IndexedParallelIterator; +pub use crate::iter::IntoParallelIterator; +pub use crate::iter::IntoParallelRefIterator; +pub use crate::iter::IntoParallelRefMutIterator; +pub use crate::iter::ParallelBridge; +pub use crate::iter::ParallelExtend; +pub use crate::iter::ParallelIterator; +pub use crate::slice::ParallelSlice; +pub use crate::slice::ParallelSliceMut; +pub use crate::str::ParallelString; diff --git a/src/private.rs b/src/private.rs index 5d084ff14..a99dd11fb 100644 --- a/src/private.rs +++ b/src/private.rs @@ -13,14 +13,14 @@ macro_rules! private_decl { /// This trait is private; this method exists to make it /// impossible to implement outside the crate. #[doc(hidden)] - fn __rayon_private__(&self) -> ::private::PrivateMarker; + fn __rayon_private__(&self) -> crate::private::PrivateMarker; } } macro_rules! private_impl { () => { - fn __rayon_private__(&self) -> ::private::PrivateMarker { - ::private::PrivateMarker + fn __rayon_private__(&self) -> crate::private::PrivateMarker { + crate::private::PrivateMarker } } } diff --git a/src/range.rs b/src/range.rs index 1a0f2c5d3..67b8e0b01 100644 --- a/src/range.rs +++ b/src/range.rs @@ -16,8 +16,8 @@ //! //! [std::range]: https://doc.rust-lang.org/core/ops/struct.Range.html -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; use std::ops::Range; use std::usize; @@ -287,7 +287,7 @@ fn test_u128_opt_len() { #[cfg(target_pointer_width = "64")] fn test_usize_i64_overflow() { use std::i64; - use ThreadPoolBuilder; + use crate::ThreadPoolBuilder; let iter = (-2..i64::MAX).into_par_iter(); assert_eq!(iter.opt_len(), Some(i64::MAX as usize + 2)); diff --git a/src/range_inclusive.rs b/src/range_inclusive.rs index fadbf71e3..7b224f3a3 100644 --- a/src/range_inclusive.rs +++ b/src/range_inclusive.rs @@ -16,8 +16,8 @@ //! //! [std::range]: https://doc.rust-lang.org/core/ops/struct.RangeInclusive.html -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; use std::ops::RangeInclusive; /// Parallel iterator over an inclusive range, implemented for all integer types. @@ -192,7 +192,7 @@ fn test_u128_opt_len() { #[cfg(target_pointer_width = "64")] fn test_usize_i64_overflow() { use std::i64; - use ThreadPoolBuilder; + use crate::ThreadPoolBuilder; let iter = (-2..=i64::MAX).into_par_iter(); assert_eq!(iter.opt_len(), Some(i64::MAX as usize + 3)); diff --git a/src/result.rs b/src/result.rs index e0a63dbc7..43685ca43 100644 --- a/src/result.rs +++ b/src/result.rs @@ -5,11 +5,11 @@ //! //! [std::result]: https://doc.rust-lang.org/stable/std/result/ -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; use std::sync::Mutex; -use option; +use crate::option; /// Parallel iterator over a result #[derive(Debug, Clone)] @@ -35,7 +35,7 @@ delegate_indexed_iterator! { /// Parallel iterator over an immutable reference to a result #[derive(Debug)] -pub struct Iter<'a, T: Sync + 'a> { +pub struct Iter<'a, T: Sync> { inner: option::IntoIter<&'a T>, } @@ -65,7 +65,7 @@ delegate_indexed_iterator! { /// Parallel iterator over a mutable reference to a result #[derive(Debug)] -pub struct IterMut<'a, T: Send + 'a> { +pub struct IterMut<'a, T: Send> { inner: option::IntoIter<&'a mut T>, } diff --git a/src/slice/mergesort.rs b/src/slice/mergesort.rs index 45029c443..07a3e0c30 100644 --- a/src/slice/mergesort.rs +++ b/src/slice/mergesort.rs @@ -4,9 +4,9 @@ //! The only difference from the original is that the sequential `mergesort` returns //! `MergesortResult` and leaves descending arrays intact. -use iter::*; +use crate::iter::*; use rayon_core; -use slice::ParallelSliceMut; +use crate::slice::ParallelSliceMut; use std::mem; use std::mem::size_of; use std::ptr; diff --git a/src/slice/mod.rs b/src/slice/mod.rs index 72f50f713..4ceb4248e 100644 --- a/src/slice/mod.rs +++ b/src/slice/mod.rs @@ -12,9 +12,9 @@ mod test; use self::mergesort::par_mergesort; use self::quicksort::par_quicksort; -use iter::plumbing::*; -use iter::*; -use split_producer::*; +use crate::iter::plumbing::*; +use crate::iter::*; +use crate::split_producer::*; use std::cmp; use std::cmp::Ordering; use std::fmt::{self, Debug}; @@ -443,7 +443,7 @@ impl<'data, T: Send + 'data> IntoParallelIterator for &'data mut Vec { /// Parallel iterator over immutable items in a slice #[derive(Debug)] -pub struct Iter<'data, T: 'data + Sync> { +pub struct Iter<'data, T: Sync> { slice: &'data [T], } @@ -488,7 +488,7 @@ impl<'data, T: Sync + 'data> IndexedParallelIterator for Iter<'data, T> { } } -struct IterProducer<'data, T: 'data + Sync> { +struct IterProducer<'data, T: Sync> { slice: &'data [T], } @@ -508,7 +508,7 @@ impl<'data, T: 'data + Sync> Producer for IterProducer<'data, T> { /// Parallel iterator over immutable non-overlapping chunks of a slice #[derive(Debug)] -pub struct Chunks<'data, T: 'data + Sync> { +pub struct Chunks<'data, T: Sync> { chunk_size: usize, slice: &'data [T], } @@ -557,7 +557,7 @@ impl<'data, T: Sync + 'data> IndexedParallelIterator for Chunks<'data, T> { } } -struct ChunksProducer<'data, T: 'data + Sync> { +struct ChunksProducer<'data, T: Sync> { chunk_size: usize, slice: &'data [T], } @@ -588,7 +588,7 @@ impl<'data, T: 'data + Sync> Producer for ChunksProducer<'data, T> { /// Parallel iterator over immutable overlapping windows of a slice #[derive(Debug)] -pub struct Windows<'data, T: 'data + Sync> { +pub struct Windows<'data, T: Sync> { window_size: usize, slice: &'data [T], } @@ -638,7 +638,7 @@ impl<'data, T: Sync + 'data> IndexedParallelIterator for Windows<'data, T> { } } -struct WindowsProducer<'data, T: 'data + Sync> { +struct WindowsProducer<'data, T: Sync> { window_size: usize, slice: &'data [T], } @@ -670,7 +670,7 @@ impl<'data, T: 'data + Sync> Producer for WindowsProducer<'data, T> { /// Parallel iterator over mutable items in a slice #[derive(Debug)] -pub struct IterMut<'data, T: 'data + Send> { +pub struct IterMut<'data, T: Send> { slice: &'data mut [T], } @@ -709,7 +709,7 @@ impl<'data, T: Send + 'data> IndexedParallelIterator for IterMut<'data, T> { } } -struct IterMutProducer<'data, T: 'data + Send> { +struct IterMutProducer<'data, T: Send> { slice: &'data mut [T], } @@ -732,7 +732,7 @@ impl<'data, T: 'data + Send> Producer for IterMutProducer<'data, T> { /// Parallel iterator over mutable non-overlapping chunks of a slice #[derive(Debug)] -pub struct ChunksMut<'data, T: 'data + Send> { +pub struct ChunksMut<'data, T: Send> { chunk_size: usize, slice: &'data mut [T], } @@ -775,7 +775,7 @@ impl<'data, T: Send + 'data> IndexedParallelIterator for ChunksMut<'data, T> { } } -struct ChunksMutProducer<'data, T: 'data + Send> { +struct ChunksMutProducer<'data, T: Send> { chunk_size: usize, slice: &'data mut [T], } @@ -805,7 +805,7 @@ impl<'data, T: 'data + Send> Producer for ChunksMutProducer<'data, T> { } /// Parallel iterator over slices separated by a predicate -pub struct Split<'data, T: 'data, P> { +pub struct Split<'data, T, P> { slice: &'data [T], separator: P, } @@ -881,7 +881,7 @@ where } /// Parallel iterator over mutable slices separated by a predicate -pub struct SplitMut<'data, T: 'data, P> { +pub struct SplitMut<'data, T, P> { slice: &'data mut [T], separator: P, } diff --git a/src/split_producer.rs b/src/split_producer.rs index 99c2a89c5..568657af8 100644 --- a/src/split_producer.rs +++ b/src/split_producer.rs @@ -2,10 +2,10 @@ //! //! This module is private, so these items are effectively `pub(super)` -use iter::plumbing::{Folder, UnindexedProducer}; +use crate::iter::plumbing::{Folder, UnindexedProducer}; /// Common producer for splitting on a predicate. -pub(super) struct SplitProducer<'p, P: 'p, V> { +pub(super) struct SplitProducer<'p, P, V> { data: V, separator: &'p P, diff --git a/src/str.rs b/src/str.rs index 3b4573cf0..2fdaaa731 100644 --- a/src/str.rs +++ b/src/str.rs @@ -13,9 +13,9 @@ //! //! [std::str]: https://doc.rust-lang.org/stable/std/str/ -use iter::plumbing::*; -use iter::*; -use split_producer::*; +use crate::iter::plumbing::*; +use crate::iter::*; +use crate::split_producer::*; /// Test if a byte is the start of a UTF-8 character. /// (extracted from `str::is_char_boundary`) @@ -274,7 +274,7 @@ impl ParallelString for str { /// would be nicer to have its basic existence and implementors public while /// keeping all of the methods private. mod private { - use iter::plumbing::Folder; + use crate::iter::plumbing::Folder; /// Pattern-matching trait for `ParallelString`, somewhat like a mix of /// `std::str::pattern::{Pattern, Searcher}`. @@ -646,7 +646,7 @@ pub struct SplitTerminator<'ch, P: Pattern> { terminator: P, } -struct SplitTerminatorProducer<'ch, 'sep, P: Pattern + 'sep> { +struct SplitTerminatorProducer<'ch, 'sep, P: Pattern> { splitter: SplitProducer<'sep, P, &'ch str>, skip_last: bool, } @@ -766,7 +766,7 @@ pub struct Matches<'ch, P: Pattern> { pattern: P, } -struct MatchesProducer<'ch, 'pat, P: Pattern + 'pat> { +struct MatchesProducer<'ch, 'pat, P: Pattern> { chars: &'ch str, pattern: &'pat P, } @@ -822,7 +822,7 @@ pub struct MatchIndices<'ch, P: Pattern> { pattern: P, } -struct MatchIndicesProducer<'ch, 'pat, P: Pattern + 'pat> { +struct MatchIndicesProducer<'ch, 'pat, P: Pattern> { index: usize, chars: &'ch str, pattern: &'pat P, diff --git a/src/vec.rs b/src/vec.rs index 767bf8ca0..617cfac18 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -5,8 +5,8 @@ //! //! [std::vec]: https://doc.rust-lang.org/stable/std/vec/ -use iter::plumbing::*; -use iter::*; +use crate::iter::plumbing::*; +use crate::iter::*; use std; /// Parallel iterator that moves out of a vector. @@ -73,7 +73,7 @@ impl IndexedParallelIterator for IntoIter { /// //////////////////////////////////////////////////////////////////////// -struct VecProducer<'data, T: 'data + Send> { +struct VecProducer<'data, T: Send> { slice: &'data mut [T], } @@ -108,7 +108,7 @@ impl<'data, T: 'data + Send> Drop for VecProducer<'data, T> { /// //////////////////////////////////////////////////////////////////////// // like std::vec::Drain, without updating a source Vec -struct SliceDrain<'data, T: 'data> { +struct SliceDrain<'data, T> { iter: std::slice::IterMut<'data, T>, } diff --git a/tests/clones.rs b/tests/clones.rs index 1a242b698..a435db5bc 100644 --- a/tests/clones.rs +++ b/tests/clones.rs @@ -1,5 +1,3 @@ -extern crate rayon; - use rayon::prelude::*; fn check(iter: I) diff --git a/tests/debug.rs b/tests/debug.rs index 4a019a8d1..c1310d84c 100644 --- a/tests/debug.rs +++ b/tests/debug.rs @@ -1,5 +1,3 @@ -extern crate rayon; - use rayon::prelude::*; use std::fmt::Debug; diff --git a/tests/intersperse.rs b/tests/intersperse.rs index d81cbb116..aaa5b6530 100644 --- a/tests/intersperse.rs +++ b/tests/intersperse.rs @@ -1,5 +1,3 @@ -extern crate rayon; - use rayon::prelude::*; #[test] diff --git a/tests/issue671-unzip.rs b/tests/issue671-unzip.rs index 83353d7ea..c9af7e6e3 100644 --- a/tests/issue671-unzip.rs +++ b/tests/issue671-unzip.rs @@ -1,7 +1,5 @@ #![type_length_limit = "10000"] -extern crate rayon; - use rayon::prelude::*; #[test] diff --git a/tests/issue671.rs b/tests/issue671.rs index a2000d88f..9d0953fe6 100644 --- a/tests/issue671.rs +++ b/tests/issue671.rs @@ -1,7 +1,5 @@ #![type_length_limit = "500000"] -extern crate rayon; - use rayon::prelude::*; #[test] diff --git a/tests/iter_panic.rs b/tests/iter_panic.rs index f40071287..4885a28be 100644 --- a/tests/iter_panic.rs +++ b/tests/iter_panic.rs @@ -1,5 +1,3 @@ -extern crate rayon; - use rayon::prelude::*; use rayon::ThreadPoolBuilder; use std::ops::Range; diff --git a/tests/named-threads.rs b/tests/named-threads.rs index 408b13536..fd1b0be2d 100644 --- a/tests/named-threads.rs +++ b/tests/named-threads.rs @@ -1,5 +1,3 @@ -extern crate rayon; - use std::collections::HashSet; use rayon::prelude::*; diff --git a/tests/octillion.rs b/tests/octillion.rs index 8bccb10be..9257c689b 100644 --- a/tests/octillion.rs +++ b/tests/octillion.rs @@ -1,5 +1,3 @@ -extern crate rayon; - use rayon::prelude::*; const OCTILLION: u128 = 1_000_000_000_000_000_000_000_000_000; diff --git a/tests/producer_split_at.rs b/tests/producer_split_at.rs index 9ce2c7038..f1fe20d01 100644 --- a/tests/producer_split_at.rs +++ b/tests/producer_split_at.rs @@ -1,5 +1,3 @@ -extern crate rayon; - use rayon::iter::plumbing::*; use rayon::prelude::*; diff --git a/tests/sort-panic-safe.rs b/tests/sort-panic-safe.rs index c216c46e9..0461a84f8 100644 --- a/tests/sort-panic-safe.rs +++ b/tests/sort-panic-safe.rs @@ -1,7 +1,5 @@ #[macro_use] extern crate lazy_static; -extern crate rand; -extern crate rayon; use rand::distributions::Uniform; use rand::{thread_rng, Rng}; diff --git a/tests/str.rs b/tests/str.rs index 4354d8903..c6224d5ed 100644 --- a/tests/str.rs +++ b/tests/str.rs @@ -1,7 +1,3 @@ -extern crate rand; -extern crate rand_xorshift; -extern crate rayon; - use rand::distributions::Standard; use rand::{Rng, SeedableRng}; use rand_xorshift::XorShiftRng;