Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add missing dyn in tests
  • Loading branch information
ljedrz committed Jul 11, 2018
commit 1915cd1dc2d5ea66d322d52958271b8072ec4c97
4 changes: 2 additions & 2 deletions src/libstd/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,13 @@ mod tests {
#[test]
fn downcasting() {
let mut a = A;
let a = &mut a as &mut (Error + 'static);
let a = &mut a as &mut (dyn Error + 'static);
assert_eq!(a.downcast_ref::<A>(), Some(&A));
assert_eq!(a.downcast_ref::<B>(), None);
assert_eq!(a.downcast_mut::<A>(), Some(&mut A));
assert_eq!(a.downcast_mut::<B>(), None);

let a: Box<Error> = Box::new(A);
let a: Box<dyn Error> = Box::new(A);
match a.downcast::<B>() {
Ok(..) => panic!("expected error"),
Err(e) => assert_eq!(*e.downcast::<A>().unwrap(), A),
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ mod tests {
assert_eq!(copy(&mut r, &mut w).unwrap(), 4);

let mut r = repeat(0).take(1 << 17);
assert_eq!(copy(&mut r as &mut Read, &mut w as &mut Write).unwrap(), 1 << 17);
assert_eq!(copy(&mut r as &mut dyn Read, &mut w as &mut dyn Write).unwrap(), 1 << 17);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ mod tests {
use time::{Instant, Duration};
use thread;

fn each_ip(f: &mut FnMut(SocketAddr)) {
fn each_ip(f: &mut dyn FnMut(SocketAddr)) {
f(next_test_ip4());
f(next_test_ip6());
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ mod tests {
use time::{Instant, Duration};
use thread;

fn each_ip(f: &mut FnMut(SocketAddr, SocketAddr)) {
fn each_ip(f: &mut dyn FnMut(SocketAddr, SocketAddr)) {
f(next_test_ip4(), next_test_ip4());
f(next_test_ip6(), next_test_ip6());
}
Expand Down
8 changes: 4 additions & 4 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ mod tests {
rx.recv().unwrap();
}

fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Box<Fn() + Send>) {
fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Box<dyn Fn() + Send>) {
let (tx, rx) = channel();

let x: Box<_> = box 1;
Expand Down Expand Up @@ -1485,7 +1485,7 @@ mod tests {
// (well, it would if the constant were 8000+ - I lowered it to be more
// valgrind-friendly. try this at home, instead..!)
const GENERATIONS: u32 = 16;
fn child_no(x: u32) -> Box<Fn() + Send> {
fn child_no(x: u32) -> Box<dyn Fn() + Send> {
return Box::new(move|| {
if x < GENERATIONS {
thread::spawn(move|| child_no(x+1)());
Expand Down Expand Up @@ -1531,10 +1531,10 @@ mod tests {
#[test]
fn test_try_panic_message_any() {
match thread::spawn(move|| {
panic!(box 413u16 as Box<Any + Send>);
panic!(box 413u16 as Box<dyn Any + Send>);
}).join() {
Err(e) => {
type T = Box<Any + Send>;
type T = Box<dyn Any + Send>;
assert!(e.is::<T>());
let any = e.downcast::<T>().unwrap();
assert!(any.is::<u16>());
Expand Down