Skip to content

Commit 66c4dc9

Browse files
committed
Add missing dyn
1 parent 8646a17 commit 66c4dc9

File tree

23 files changed

+69
-65
lines changed

23 files changed

+69
-65
lines changed

src/liballoc/tests/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn uninhabited() {
1818
a = a.clone();
1919
assert!(a.upgrade().is_none());
2020

21-
let mut a: Weak<Any> = a; // Unsizing
21+
let mut a: Weak<dyn Any> = a; // Unsizing
2222
a = a.clone();
2323
assert!(a.upgrade().is_none());
2424
}
@@ -39,7 +39,7 @@ fn slice() {
3939
#[test]
4040
fn trait_object() {
4141
let a: Arc<u32> = Arc::new(4);
42-
let a: Arc<Any> = a; // Unsizing
42+
let a: Arc<dyn Any> = a; // Unsizing
4343

4444
// Exercise is_dangling() with a DST
4545
let mut a = Arc::downgrade(&a);
@@ -49,7 +49,7 @@ fn trait_object() {
4949
let mut b = Weak::<u32>::new();
5050
b = b.clone();
5151
assert!(b.upgrade().is_none());
52-
let mut b: Weak<Any> = b; // Unsizing
52+
let mut b: Weak<dyn Any> = b; // Unsizing
5353
b = b.clone();
5454
assert!(b.upgrade().is_none());
5555
}

src/liballoc/tests/btree/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn test_hash() {
4040
}
4141

4242
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
43-
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool
43+
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut dyn FnMut(&i32) -> bool) -> bool
4444
{
4545
let mut set_a = BTreeSet::new();
4646
let mut set_b = BTreeSet::new();

src/liballoc/tests/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn test_boxed_hasher() {
6363
5u32.hash(&mut hasher_1);
6464
assert_eq!(ordinary_hash, hasher_1.finish());
6565

66-
let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<Hasher>;
66+
let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
6767
5u32.hash(&mut hasher_2);
6868
assert_eq!(ordinary_hash, hasher_2.finish());
6969
}

src/liballoc/tests/rc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn uninhabited() {
1818
a = a.clone();
1919
assert!(a.upgrade().is_none());
2020

21-
let mut a: Weak<Any> = a; // Unsizing
21+
let mut a: Weak<dyn Any> = a; // Unsizing
2222
a = a.clone();
2323
assert!(a.upgrade().is_none());
2424
}
@@ -39,7 +39,7 @@ fn slice() {
3939
#[test]
4040
fn trait_object() {
4141
let a: Rc<u32> = Rc::new(4);
42-
let a: Rc<Any> = a; // Unsizing
42+
let a: Rc<dyn Any> = a; // Unsizing
4343

4444
// Exercise is_dangling() with a DST
4545
let mut a = Rc::downgrade(&a);
@@ -49,7 +49,7 @@ fn trait_object() {
4949
let mut b = Weak::<u32>::new();
5050
b = b.clone();
5151
assert!(b.upgrade().is_none());
52-
let mut b: Weak<Any> = b; // Unsizing
52+
let mut b: Weak<dyn Any> = b; // Unsizing
5353
b = b.clone();
5454
assert!(b.upgrade().is_none());
5555
}

src/libcore/tests/any.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static TEST: &'static str = "Test";
1717

1818
#[test]
1919
fn any_referenced() {
20-
let (a, b, c) = (&5 as &Any, &TEST as &Any, &Test as &Any);
20+
let (a, b, c) = (&5 as &dyn Any, &TEST as &dyn Any, &Test as &dyn Any);
2121

2222
assert!(a.is::<i32>());
2323
assert!(!b.is::<i32>());
@@ -34,7 +34,11 @@ fn any_referenced() {
3434

3535
#[test]
3636
fn any_owning() {
37-
let (a, b, c) = (box 5_usize as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
37+
let (a, b, c) = (
38+
box 5_usize as Box<dyn Any>,
39+
box TEST as Box<dyn Any>,
40+
box Test as Box<dyn Any>,
41+
);
3842

3943
assert!(a.is::<usize>());
4044
assert!(!b.is::<usize>());
@@ -51,7 +55,7 @@ fn any_owning() {
5155

5256
#[test]
5357
fn any_downcast_ref() {
54-
let a = &5_usize as &Any;
58+
let a = &5_usize as &dyn Any;
5559

5660
match a.downcast_ref::<usize>() {
5761
Some(&5) => {}
@@ -69,9 +73,9 @@ fn any_downcast_mut() {
6973
let mut a = 5_usize;
7074
let mut b: Box<_> = box 7_usize;
7175

72-
let a_r = &mut a as &mut Any;
76+
let a_r = &mut a as &mut dyn Any;
7377
let tmp: &mut usize = &mut *b;
74-
let b_r = tmp as &mut Any;
78+
let b_r = tmp as &mut dyn Any;
7579

7680
match a_r.downcast_mut::<usize>() {
7781
Some(x) => {
@@ -113,7 +117,7 @@ fn any_downcast_mut() {
113117
#[test]
114118
fn any_fixed_vec() {
115119
let test = [0_usize; 8];
116-
let test = &test as &Any;
120+
let test = &test as &dyn Any;
117121
assert!(test.is::<[usize; 8]>());
118122
assert!(!test.is::<[usize; 10]>());
119123
}

src/libcore/tests/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn test_custom_state() {
128128
fn test_indirect_hasher() {
129129
let mut hasher = MyHasher { hash: 0 };
130130
{
131-
let mut indirect_hasher: &mut Hasher = &mut hasher;
131+
let mut indirect_hasher: &mut dyn Hasher = &mut hasher;
132132
5u32.hash(&mut indirect_hasher);
133133
}
134134
assert_eq!(hasher.hash, 5);

src/libcore/tests/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn test_typeid_sized_types() {
2222
#[test]
2323
fn test_typeid_unsized_types() {
2424
trait Z {}
25-
struct X(str); struct Y(Z + 'static);
25+
struct X(str); struct Y(dyn Z + 'static);
2626

2727
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
2828
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());

src/libcore/tests/mem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ fn test_transmute() {
109109
trait Foo { fn dummy(&self) { } }
110110
impl Foo for isize {}
111111

112-
let a = box 100isize as Box<Foo>;
112+
let a = box 100isize as Box<dyn Foo>;
113113
unsafe {
114114
let x: ::core::raw::TraitObject = transmute(a);
115115
assert!(*(x.data as *const isize) == 100);
116-
let _x: Box<Foo> = transmute(x);
116+
let _x: Box<dyn Foo> = transmute(x);
117117
}
118118

119119
unsafe {

src/libcore/tests/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn test_collect() {
240240
assert!(v == None);
241241

242242
// test that it does not take more elements than it needs
243-
let mut functions: [Box<Fn() -> Option<()>>; 3] =
243+
let mut functions: [Box<dyn Fn() -> Option<()>>; 3] =
244244
[box || Some(()), box || None, box || panic!()];
245245

246246
let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect();

src/libcore/tests/ptr.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ fn test_is_null() {
8484
assert!(nms.is_null());
8585

8686
// Pointers to unsized types -- trait objects
87-
let ci: *const ToString = &3;
87+
let ci: *const dyn ToString = &3;
8888
assert!(!ci.is_null());
8989

90-
let mi: *mut ToString = &mut 3;
90+
let mi: *mut dyn ToString = &mut 3;
9191
assert!(!mi.is_null());
9292

93-
let nci: *const ToString = null::<isize>();
93+
let nci: *const dyn ToString = null::<isize>();
9494
assert!(nci.is_null());
9595

96-
let nmi: *mut ToString = null_mut::<isize>();
96+
let nmi: *mut dyn ToString = null_mut::<isize>();
9797
assert!(nmi.is_null());
9898
}
9999

@@ -140,16 +140,16 @@ fn test_as_ref() {
140140
assert_eq!(nms.as_ref(), None);
141141

142142
// Pointers to unsized types -- trait objects
143-
let ci: *const ToString = &3;
143+
let ci: *const dyn ToString = &3;
144144
assert!(ci.as_ref().is_some());
145145

146-
let mi: *mut ToString = &mut 3;
146+
let mi: *mut dyn ToString = &mut 3;
147147
assert!(mi.as_ref().is_some());
148148

149-
let nci: *const ToString = null::<isize>();
149+
let nci: *const dyn ToString = null::<isize>();
150150
assert!(nci.as_ref().is_none());
151151

152-
let nmi: *mut ToString = null_mut::<isize>();
152+
let nmi: *mut dyn ToString = null_mut::<isize>();
153153
assert!(nmi.as_ref().is_none());
154154
}
155155
}
@@ -182,10 +182,10 @@ fn test_as_mut() {
182182
assert_eq!(nms.as_mut(), None);
183183

184184
// Pointers to unsized types -- trait objects
185-
let mi: *mut ToString = &mut 3;
185+
let mi: *mut dyn ToString = &mut 3;
186186
assert!(mi.as_mut().is_some());
187187

188-
let nmi: *mut ToString = null_mut::<isize>();
188+
let nmi: *mut dyn ToString = null_mut::<isize>();
189189
assert!(nmi.as_mut().is_none());
190190
}
191191
}

0 commit comments

Comments
 (0)