Skip to content

Commit

Permalink
Merge #682
Browse files Browse the repository at this point in the history
682: Lint cleanup r=cuviper a=cuviper



Co-authored-by: Josh Stone <cuviper@gmail.com>
  • Loading branch information
bors[bot] and cuviper committed Aug 21, 2019
2 parents 83b67e2 + 9bfb3c6 commit 2720d8d
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion rayon-core/src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use unwind;
pub(super) enum JobResult<T> {
None,
Ok(T),
Panic(Box<Any + Send>),
Panic(Box<dyn Any + Send>),
}

/// A `Job` is used to advertise work for other threads that they may
Expand Down
2 changes: 1 addition & 1 deletion rayon-core/src/join/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ where
unsafe fn join_recover_from_panic(
worker_thread: &WorkerThread,
job_b_latch: &SpinLatch,
err: Box<Any + Send>,
err: Box<dyn Any + Send>,
) -> ! {
worker_thread.wait_until(job_b_latch);
unwind::resume_unwinding(err)
Expand Down
16 changes: 8 additions & 8 deletions rayon-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub struct ThreadPoolBuilder<S = DefaultSpawn> {
panic_handler: Option<Box<PanicHandler>>,

/// Closure to compute the name of a thread.
get_thread_name: Option<Box<FnMut(usize) -> String>>,
get_thread_name: Option<Box<dyn FnMut(usize) -> String>>,

/// The stack size for the created worker threads
stack_size: Option<usize>,
Expand Down Expand Up @@ -170,17 +170,17 @@ pub struct Configuration {

/// The type for a panic handling closure. Note that this same closure
/// may be invoked multiple times in parallel.
type PanicHandler = Fn(Box<Any + Send>) + Send + Sync;
type PanicHandler = dyn Fn(Box<dyn Any + Send>) + Send + Sync;

/// The type for a closure that gets invoked when a thread starts. The
/// closure is passed the index of the thread on which it is invoked.
/// Note that this same closure may be invoked multiple times in parallel.
type StartHandler = Fn(usize) + Send + Sync;
type StartHandler = dyn Fn(usize) + Send + Sync;

/// The type for a closure that gets invoked when a thread exits. The
/// closure is passed the index of the thread on which is is invoked.
/// Note that this same closure may be invoked multiple times in parallel.
type ExitHandler = Fn(usize) + Send + Sync;
type ExitHandler = dyn Fn(usize) + Send + Sync;

// NB: We can't `#[derive(Default)]` because `S` is left ambiguous.
impl Default for ThreadPoolBuilder {
Expand Down Expand Up @@ -481,7 +481,7 @@ impl<S> ThreadPoolBuilder<S> {
/// in a call to `std::panic::catch_unwind()`.
pub fn panic_handler<H>(mut self, panic_handler: H) -> Self
where
H: Fn(Box<Any + Send>) + Send + Sync + 'static,
H: Fn(Box<dyn Any + Send>) + Send + Sync + 'static,
{
self.panic_handler = Some(Box::new(panic_handler));
self
Expand Down Expand Up @@ -585,7 +585,7 @@ impl Configuration {
}

/// Deprecated in favor of `ThreadPoolBuilder::build`.
pub fn build(self) -> Result<ThreadPool, Box<Error + 'static>> {
pub fn build(self) -> Result<ThreadPool, Box<dyn Error + 'static>> {
self.builder.build().map_err(Box::from)
}

Expand All @@ -607,7 +607,7 @@ impl Configuration {
/// Deprecated in favor of `ThreadPoolBuilder::panic_handler`.
pub fn panic_handler<H>(mut self, panic_handler: H) -> Configuration
where
H: Fn(Box<Any + Send>) + Send + Sync + 'static,
H: Fn(Box<dyn Any + Send>) + Send + Sync + 'static,
{
self.builder = self.builder.panic_handler(panic_handler);
self
Expand Down Expand Up @@ -678,7 +678,7 @@ impl fmt::Display for ThreadPoolBuildError {
/// Deprecated in favor of `ThreadPoolBuilder::build_global`.
#[deprecated(note = "use `ThreadPoolBuilder::build_global`")]
#[allow(deprecated)]
pub fn initialize(config: Configuration) -> Result<(), Box<Error>> {
pub fn initialize(config: Configuration) -> Result<(), Box<dyn Error>> {
config.into_builder().build_global().map_err(Box::from)
}

Expand Down
6 changes: 3 additions & 3 deletions rayon-core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::ptr;
#[allow(deprecated)]
use std::sync::atomic::ATOMIC_USIZE_INIT;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Once, ONCE_INIT};
use std::sync::{Arc, Once};
use std::thread;
use std::usize;
use unwind;
Expand Down Expand Up @@ -161,7 +161,7 @@ pub(super) struct Registry {
/// Initialization

static mut THE_REGISTRY: Option<&'static Arc<Registry>> = None;
static THE_REGISTRY_SET: Once = ONCE_INIT;
static THE_REGISTRY_SET: Once = Once::new();

/// Starts the worker threads (if that has not already happened). If
/// initialization has not already occurred, use the default
Expand Down Expand Up @@ -322,7 +322,7 @@ impl Registry {
self.thread_infos.len()
}

pub(super) fn handle_panic(&self, err: Box<Any + Send>) {
pub(super) fn handle_panic(&self, err: Box<dyn Any + Send>) {
match self.panic_handler {
Some(ref handler) => {
// If the customizable panic handler itself panics,
Expand Down
8 changes: 4 additions & 4 deletions rayon-core/src/scope/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct ScopeBase<'scope> {

/// if some job panicked, the error is stored here; it will be
/// propagated to the one who created the scope
panic: AtomicPtr<Box<Any + Send + 'static>>,
panic: AtomicPtr<Box<dyn Any + Send + 'static>>,

/// latch to set when the counter drops to zero (and hence this scope is complete)
job_completed_latch: CountLatch,
Expand All @@ -59,7 +59,7 @@ struct ScopeBase<'scope> {
/// all of which outlive `'scope`. They're not actually required to be
/// `Sync`, but it's still safe to let the `Scope` implement `Sync` because
/// the closures are only *moved* across threads to be executed.
marker: PhantomData<Box<FnOnce(&Scope<'scope>) + Send + Sync + 'scope>>,
marker: PhantomData<Box<dyn FnOnce(&Scope<'scope>) + Send + Sync + 'scope>>,
}

/// Create a "fork-join" scope `s` and invokes the closure with a
Expand Down Expand Up @@ -572,7 +572,7 @@ impl<'scope> ScopeBase<'scope> {
}
}

unsafe fn job_panicked(&self, err: Box<Any + Send + 'static>) {
unsafe fn job_panicked(&self, err: Box<dyn Any + Send + 'static>) {
// capture the first error we see, free the rest
let nil = ptr::null_mut();
let mut err = Box::new(err); // box up the fat ptr
Expand Down Expand Up @@ -613,7 +613,7 @@ impl<'scope> ScopeBase<'scope> {
log!(ScopeCompletePanicked {
owner_thread: owner_thread.index()
});
let value: Box<Box<Any + Send + 'static>> = mem::transmute(panic);
let value: Box<Box<dyn Any + Send + 'static>> = mem::transmute(panic);
unwind::resume_unwinding(*value);
} else {
log!(ScopeCompleteNoPanic {
Expand Down
4 changes: 2 additions & 2 deletions rayon-core/src/spawn/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn panic_fwd() {
let (tx, rx) = channel();

let tx = Mutex::new(tx);
let panic_handler = move |err: Box<Any + Send>| {
let panic_handler = move |err: Box<dyn Any + Send>| {
let tx = tx.lock().unwrap();
if let Some(&msg) = err.downcast_ref::<&str>() {
if msg == "Hello, world!" {
Expand Down Expand Up @@ -87,7 +87,7 @@ fn custom_panic_handler_and_spawn() {
// channel; since the closure is potentially executed in parallel
// with itself, we have to wrap `tx` in a mutex.
let tx = Mutex::new(tx);
let panic_handler = move |e: Box<Any + Send>| {
let panic_handler = move |e: Box<dyn Any + Send>| {
tx.lock().unwrap().send(e).unwrap();
};

Expand Down
2 changes: 1 addition & 1 deletion rayon-core/src/thread_pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl ThreadPool {
#[deprecated(note = "Use `ThreadPoolBuilder::build`")]
#[allow(deprecated)]
/// Deprecated in favor of `ThreadPoolBuilder::build`.
pub fn new(configuration: Configuration) -> Result<ThreadPool, Box<Error>> {
pub fn new(configuration: Configuration) -> Result<ThreadPool, Box<dyn Error>> {
Self::build(configuration.into_builder()).map_err(Box::from)
}

Expand Down
2 changes: 1 addition & 1 deletion rayon-core/src/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ where
panic::catch_unwind(AssertUnwindSafe(func))
}

pub(super) fn resume_unwinding(payload: Box<Any + Send>) -> ! {
pub(super) fn resume_unwinding(payload: Box<dyn Any + Send>) -> ! {
panic::resume_unwind(payload)
}

Expand Down
2 changes: 1 addition & 1 deletion rayon-demo/src/tsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn run_solver(datafile: &Path, seq_threshold: usize, from: usize) -> Result<(),
Ok(())
}

fn parse_solver(datafile: &Path) -> Result<Graph, Box<Error>> {
fn parse_solver(datafile: &Path) -> Result<Graph, Box<dyn Error>> {
let mut file = File::open(datafile)?;
let mut text = String::new();
file.read_to_string(&mut text)?;
Expand Down
4 changes: 2 additions & 2 deletions src/iter/collect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ where
// This works like `extend`, but `Vec::append` is more efficient.
let list = super::extend::collect(par_iter);
self.reserve(super::extend::len(&list));
for ref mut vec in list {
self.append(vec);
for mut vec in list {
self.append(&mut vec);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/iter/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ fn as_list<T>(item: T) -> LinkedList<T> {
list
}

fn list_append<T>(mut list1: LinkedList<T>, ref mut list2: LinkedList<T>) -> LinkedList<T> {
list1.append(list2);
fn list_append<T>(mut list1: LinkedList<T>, mut list2: LinkedList<T>) -> LinkedList<T> {
list1.append(&mut list2);
list1
}

Expand Down
2 changes: 1 addition & 1 deletion src/iter/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ fn check_chunks() {

let par_sum_product_triples: i32 = a.par_chunks(3).map(|c| c.iter().product::<i32>()).sum();
let seq_sum_product_triples = a.chunks(3).map(|c| c.iter().product::<i32>()).sum();
assert_eq!(par_sum_product_triples, 5_0 + 12_00 + 2_000_0000 + 1);
assert_eq!(par_sum_product_triples, 5_0 + 12_00 + 20_000_000 + 1);
assert_eq!(par_sum_product_triples, seq_sum_product_triples);
}

Expand Down

0 comments on commit 2720d8d

Please sign in to comment.