Skip to content

Commit

Permalink
Fix bare_trait_objects warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Oct 16, 2019
1 parent 5d69fab commit 4d952ef
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
16 changes: 8 additions & 8 deletions crossbeam-channel/src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<T: Send> error::Error for SendError<T> {
"sending on a disconnected channel"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ impl<T: Send> error::Error for TrySendError<T> {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<T: Send> error::Error for SendTimeoutError<T> {
"sending on an empty and disconnected channel"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -317,7 +317,7 @@ impl error::Error for RecvError {
"receiving on an empty and disconnected channel"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand All @@ -339,7 +339,7 @@ impl error::Error for TryRecvError {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -387,7 +387,7 @@ impl error::Error for RecvTimeoutError {
}
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand Down Expand Up @@ -429,7 +429,7 @@ impl error::Error for TrySelectError {
"all operations in select would block"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
Expand All @@ -445,7 +445,7 @@ impl error::Error for SelectTimeoutError {
"timed out waiting on select"
}

fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
None
}
}
24 changes: 12 additions & 12 deletions crossbeam-channel/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ enum Timeout {
/// Successful receive operations will have to be followed up by `channel::read()` and successful
/// send operations by `channel::write()`.
fn run_select(
handles: &mut [(&SelectHandle, usize, *const u8)],
handles: &mut [(&dyn SelectHandle, usize, *const u8)],
timeout: Timeout,
) -> Option<(Token, usize, *const u8)> {
if handles.is_empty() {
Expand Down Expand Up @@ -220,7 +220,7 @@ fn run_select(
registered_count += 1;

// If registration returns `false`, that means the operation has just become ready.
if handle.register(Operation::hook::<&SelectHandle>(handle), cx) {
if handle.register(Operation::hook::<&dyn SelectHandle>(handle), cx) {
// Try aborting select.
sel = match cx.try_select(Selected::Aborted) {
Ok(()) => {
Expand Down Expand Up @@ -259,7 +259,7 @@ fn run_select(

// Unregister all registered operations.
for (handle, _, _) in handles.iter_mut().take(registered_count) {
handle.unregister(Operation::hook::<&SelectHandle>(handle));
handle.unregister(Operation::hook::<&dyn SelectHandle>(handle));
}

match sel {
Expand All @@ -279,7 +279,7 @@ fn run_select(
// Find the selected operation.
for (handle, i, ptr) in handles.iter_mut() {
// Is this the selected operation?
if sel == Selected::Operation(Operation::hook::<&SelectHandle>(handle)) {
if sel == Selected::Operation(Operation::hook::<&dyn SelectHandle>(handle)) {
// Try selecting this operation.
if handle.accept(&mut token, cx) {
return Some((*i, *ptr));
Expand Down Expand Up @@ -317,7 +317,7 @@ fn run_select(
}

/// Runs until one of the operations becomes ready, potentially blocking the current thread.
fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout) -> Option<usize> {
fn run_ready(handles: &mut [(&dyn SelectHandle, usize, *const u8)], timeout: Timeout) -> Option<usize> {
if handles.is_empty() {
// Wait until the timeout and return.
match timeout {
Expand Down Expand Up @@ -372,7 +372,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
// Begin watching all operations.
for (handle, _, _) in handles.iter_mut() {
registered_count += 1;
let oper = Operation::hook::<&SelectHandle>(handle);
let oper = Operation::hook::<&dyn SelectHandle>(handle);

// If registration returns `false`, that means the operation has just become ready.
if handle.watch(oper, cx) {
Expand Down Expand Up @@ -410,7 +410,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout

// Unwatch all operations.
for (handle, _, _) in handles.iter_mut().take(registered_count) {
handle.unwatch(Operation::hook::<&SelectHandle>(handle));
handle.unwatch(Operation::hook::<&dyn SelectHandle>(handle));
}

match sel {
Expand All @@ -419,7 +419,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
Selected::Disconnected => {}
Selected::Operation(_) => {
for (handle, i, _) in handles.iter_mut() {
let oper = Operation::hook::<&SelectHandle>(handle);
let oper = Operation::hook::<&dyn SelectHandle>(handle);
if sel == Selected::Operation(oper) {
return Some(*i);
}
Expand All @@ -440,7 +440,7 @@ fn run_ready(handles: &mut [(&SelectHandle, usize, *const u8)], timeout: Timeout
/// Attempts to select one of the operations without blocking.
#[inline]
pub fn try_select<'a>(
handles: &mut [(&'a SelectHandle, usize, *const u8)],
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
) -> Result<SelectedOperation<'a>, TrySelectError> {
match run_select(handles, Timeout::Now) {
None => Err(TrySelectError),
Expand All @@ -455,7 +455,7 @@ pub fn try_select<'a>(

/// Blocks until one of the operations becomes ready and selects it.
#[inline]
pub fn select<'a>(handles: &mut [(&'a SelectHandle, usize, *const u8)]) -> SelectedOperation<'a> {
pub fn select<'a>(handles: &mut [(&'a dyn SelectHandle, usize, *const u8)]) -> SelectedOperation<'a> {
if handles.is_empty() {
panic!("no operations have been added to `Select`");
}
Expand All @@ -472,7 +472,7 @@ pub fn select<'a>(handles: &mut [(&'a SelectHandle, usize, *const u8)]) -> Selec
/// Blocks for a limited time until one of the operations becomes ready and selects it.
#[inline]
pub fn select_timeout<'a>(
handles: &mut [(&'a SelectHandle, usize, *const u8)],
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
timeout: Duration,
) -> Result<SelectedOperation<'a>, SelectTimeoutError> {
let timeout = Timeout::At(Instant::now() + timeout);
Expand Down Expand Up @@ -573,7 +573,7 @@ pub fn select_timeout<'a>(
/// [`ready_timeout`]: struct.Select.html#method.ready_timeout
pub struct Select<'a> {
/// A list of senders and receivers participating in selection.
handles: Vec<(&'a SelectHandle, usize, *const u8)>,
handles: Vec<(&'a dyn SelectHandle, usize, *const u8)>,

/// The next index to assign to an operation.
next_index: usize,
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ fn recv_in_send() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

let (s, r) = bounded::<T>(1);

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/golang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ mod chan_test {
fn test_chan_send_interface() {
struct Mt;

let c = make::<Box<Any>>(1);
let c = make::<Box<dyn Any>>(1);
c.send(Box::new(Mt));

select! {
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ fn recv_in_send() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

let (s, r) = unbounded::<T>();

Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ fn send_recv_same_channel() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

for cap in 1..4 {
let (s, r) = bounded::<T>(cap);
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ fn matching_with_leftover() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

for cap in 0..3 {
let (s, r) = bounded::<T>(cap);
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/select_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ fn matching_with_leftover() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

for cap in 0..3 {
let (s, r) = bounded::<T>(cap);
Expand Down
2 changes: 1 addition & 1 deletion crossbeam-channel/tests/zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ fn recv_in_send() {
fn channel_through_channel() {
const COUNT: usize = 1000;

type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;

let (s, r) = bounded::<T>(0);

Expand Down
4 changes: 2 additions & 2 deletions crossbeam-utils/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ impl<'scope, 'env> ScopedThreadBuilder<'scope, 'env> {
let closure = move || closure.take().unwrap()();

// Allocate `clsoure` on the heap and erase the `'env` bound.
let closure: Box<FnMut() + Send + 'env> = Box::new(closure);
let closure: Box<FnMut() + Send + 'static> = unsafe { mem::transmute(closure) };
let closure: Box<dyn FnMut() + Send + 'env> = Box::new(closure);
let closure: Box<dyn FnMut() + Send + 'static> = unsafe { mem::transmute(closure) };

// Finally, spawn the closure.
let mut closure = closure;
Expand Down
4 changes: 2 additions & 2 deletions crossbeam-utils/tests/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn panic_twice() {

let err = result.unwrap_err();
let vec = err
.downcast_ref::<Vec<Box<Any + Send + 'static>>>()
.downcast_ref::<Vec<Box<dyn Any + Send + 'static>>>()
.unwrap();
assert_eq!(2, vec.len());

Expand All @@ -119,7 +119,7 @@ fn panic_many() {

let err = result.unwrap_err();
let vec = err
.downcast_ref::<Vec<Box<Any + Send + 'static>>>()
.downcast_ref::<Vec<Box<dyn Any + Send + 'static>>>()
.unwrap();
assert_eq!(3, vec.len());

Expand Down

0 comments on commit 4d952ef

Please sign in to comment.