Add missing dyn in tests

This commit is contained in:
ljedrz 2018-07-11 09:11:39 +02:00
parent b29a6fbabc
commit 1915cd1dc2
5 changed files with 9 additions and 9 deletions

View file

@ -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),

View file

@ -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]

View file

@ -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());
}

View file

@ -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());
}

View file

@ -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;
@ -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)());
@ -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>());