Skip to content

Commit

Permalink
Rust 2018
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Dec 10, 2019
1 parent 401678e commit 76c545d
Show file tree
Hide file tree
Showing 109 changed files with 298 additions and 356 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ 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
env: RUSTFLAGS='--cfg rayon_unstable'
#if: everything!
before_script: cp ci/compat-Cargo.lock ./Cargo.lock
script: cargo build --locked
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "1.2.1"
authors = ["Niko Matsakis <niko@alum.mit.edu>",
"Josh Stone <cuviper@gmail.com>"]
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/"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions ci/alt-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[package]
edition = "2018"
name = "alt-core"
version = "0.0.0"
authors = ["Josh Stone <cuviper@gmail.com>"]
Expand Down
1 change: 1 addition & 0 deletions ci/highlander/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package]
authors = ["Josh Stone <cuviper@gmail.com>"]
edition = "2018"
name = "highlander"
description = "There Can Be Only One"
version = "0.0.0"
Expand Down
4 changes: 1 addition & 3 deletions examples/cpu_monitor.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 1 addition & 0 deletions rayon-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion rayon-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion rayon-core/src/internal/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any + Send>);
fn panicked(self, err: Box<dyn Any + Send>);

/// Indicates that the sub-tasks of this scope that you have
/// spawned concluded successfully.
Expand Down
10 changes: 5 additions & 5 deletions rayon-core/src/internal/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -29,7 +29,7 @@ impl<'w> WorkerThread<'w> {
where
F: Fn() -> bool,
{
struct DummyLatch<'a, F: 'a> {
struct DummyLatch<'a, F> {
f: &'a F,
}

Expand All @@ -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())
Expand All @@ -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<F, R>(if_true: F) -> Option<R>
where
F: FnOnce(&WorkerThread) -> R,
F: FnOnce(&WorkerThread<'_>) -> R,
{
unsafe {
let thread = registry::WorkerThread::current().as_ref()?;
Expand Down
4 changes: 2 additions & 2 deletions rayon-core/src/job.rs
Original file line number Diff line number Diff line change
@@ -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<T> {
None,
Expand Down
12 changes: 6 additions & 6 deletions rayon-core/src/join/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions rayon-core/src/join/test.rs
Original file line number Diff line number Diff line change
@@ -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<T: PartialOrd + Send>(v: &mut [T]) {
if v.len() <= 1 {
Expand Down
2 changes: 1 addition & 1 deletion rayon-core/src/latch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 7 additions & 14 deletions rayon-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,6 +66,8 @@ pub use thread_pool::current_thread_has_pending_tasks;
pub use thread_pool::current_thread_index;
pub use thread_pool::ThreadPool;

use crossbeam_utils;
use num_cpus;
use registry::{CustomSpawn, DefaultSpawn, ThreadSpawn};

/// Returns the number of threads in the current registry. If this
Expand All @@ -96,7 +89,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.
Expand Down Expand Up @@ -667,7 +660,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),
Expand All @@ -683,7 +676,7 @@ pub fn initialize(config: Configuration) -> Result<(), Box<dyn Error>> {
}

impl<S> fmt::Debug for ThreadPoolBuilder<S> {
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,
Expand All @@ -699,7 +692,7 @@ impl<S> fmt::Debug for ThreadPoolBuilder<S> {
// 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("<closure>")
}
}
Expand Down Expand Up @@ -731,7 +724,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)
}
}
Expand Down
6 changes: 3 additions & 3 deletions rayon-core/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
22 changes: 11 additions & 11 deletions rayon-core/src/registry.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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).
Expand Down Expand Up @@ -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)
Expand All @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions rayon-core/src/scope/internal.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -52,7 +52,7 @@ unsafe impl<'scope> ScopeHandle<'scope> for LocalScopeHandle<'scope> {
mem::drop(self);
}

fn panicked(self, err: Box<Any + Send>) {
fn panicked(self, err: Box<dyn Any + Send>) {
unsafe {
(*self.scope).job_panicked(err);
mem::forget(self); // no need to run dtor now
Expand Down
12 changes: 6 additions & 6 deletions rayon-core/src/scope/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
//! [`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;
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)]
Expand Down Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions rayon-core/src/scope/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion rayon-core/src/sleep/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions rayon-core/src/spawn/mod.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 76c545d

Please sign in to comment.