Skip to content

Commit badbd57

Browse files
committed
update for rustc warning about missing dyn
1 parent 9dfbebd commit badbd57

26 files changed

+55
-55
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
81970852e172c04322cbf8ba23effabeb491c83c
1+
c28084ac16af4ab594b6860958df140e7c876a13

tests/run-pass/box_box_trait.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ trait MyTrait { fn dummy(&self) { } }
1414
impl MyTrait for Box<DroppableStruct> {}
1515

1616
#[allow(dead_code)]
17-
struct Whatever { w: Box<MyTrait+'static> }
17+
struct Whatever { w: Box<dyn MyTrait+'static> }
1818

1919
impl Whatever {
20-
fn new(w: Box<MyTrait+'static>) -> Whatever {
20+
fn new(w: Box<dyn MyTrait+'static>) -> Whatever {
2121
Whatever { w: w }
2222
}
2323
}
2424

2525
fn main() {
2626
{
2727
let f: Box<_> = box DroppableStruct;
28-
let _a = Whatever::new(box f as Box<MyTrait>);
28+
let _a = Whatever::new(box f as Box<dyn MyTrait>);
2929
}
3030
assert!(unsafe { DROPPED });
3131
}

tests/run-pass/call_drop_on_fat_ptr_array_elements.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl Drop for Bar {
1313
}
1414

1515
fn main() {
16-
let b: [Box<Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)];
16+
let b: [Box<dyn Foo>; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)];
1717
assert_eq!(unsafe { DROP_COUNT }, 0);
1818
drop(b);
1919
assert_eq!(unsafe { DROP_COUNT }, 4);

tests/run-pass/call_drop_through_trait_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl Drop for Bar {
1313
impl Foo for Bar {}
1414

1515
fn main() {
16-
let b: Box<Foo> = Box::new(Bar);
16+
let b: Box<dyn Foo> = Box::new(Bar);
1717
assert!(unsafe { !DROP_CALLED });
1818
drop(b);
1919
assert!(unsafe { DROP_CALLED });

tests/run-pass/call_drop_through_trait_object_rc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl Foo for Bar {}
1515
use std::rc::Rc;
1616

1717
fn main() {
18-
let b: Rc<Foo> = Rc::new(Bar);
18+
let b: Rc<dyn Foo> = Rc::new(Bar);
1919
assert!(unsafe { !DROP_CALLED });
2020
drop(b);
2121
assert!(unsafe { DROP_CALLED });

tests/run-pass/cast-rfc0401-vtable-kinds.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ impl<T> Foo<T> for () {}
1313
impl Foo<u32> for u32 { fn foo(&self, _: u32) -> u32 { self+43 } }
1414
impl Bar for () {}
1515

16-
unsafe fn round_trip_and_call<'a>(t: *const (Foo<u32>+'a)) -> u32 {
17-
let foo_e : *const Foo<u16> = t as *const _;
18-
let r_1 = foo_e as *mut Foo<u32>;
16+
unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo<u32>+'a)) -> u32 {
17+
let foo_e : *const dyn Foo<u16> = t as *const _;
18+
let r_1 = foo_e as *mut dyn Foo<u32>;
1919

2020
(&*r_1).foo(0)
2121
}
@@ -31,8 +31,8 @@ fn foo_to_bar<T:?Sized>(u: *const FooS<T>) -> *const BarS<T> {
3131

3232
fn main() {
3333
let x = 4u32;
34-
let y : &Foo<u32> = &x;
35-
let fl = unsafe { round_trip_and_call(y as *const Foo<u32>) };
34+
let y : &dyn Foo<u32> = &x;
35+
let fl = unsafe { round_trip_and_call(y as *const dyn Foo<u32>) };
3636
assert_eq!(fl, (43+4));
3737

3838
let s = FooS([0,1,2]);

tests/run-pass/dst-field-align.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ fn main() {
2626
// Test that zero-offset works properly
2727
let b : Baz<usize> = Baz { a: 7 };
2828
assert_eq!(b.a.get(), 7);
29-
let b : &Baz<Bar> = &b;
29+
let b : &Baz<dyn Bar> = &b;
3030
assert_eq!(b.a.get(), 7);
3131

3232
// Test that the field is aligned properly
3333
let f : Foo<usize> = Foo { a: 0, b: 11 };
3434
assert_eq!(f.b.get(), 11);
3535
let ptr1 : *const u8 = &f.b as *const _ as *const u8;
3636

37-
let f : &Foo<Bar> = &f;
37+
let f : &Foo<dyn Bar> = &f;
3838
let ptr2 : *const u8 = &f.b as *const _ as *const u8;
3939
assert_eq!(f.b.get(), 11);
4040

@@ -44,13 +44,13 @@ fn main() {
4444
// Test that nested DSTs work properly
4545
let f : Foo<Foo<usize>> = Foo { a: 0, b: Foo { a: 1, b: 17 }};
4646
assert_eq!(f.b.b.get(), 17);
47-
let f : &Foo<Foo<Bar>> = &f;
47+
let f : &Foo<Foo<dyn Bar>> = &f;
4848
assert_eq!(f.b.b.get(), 17);
4949

5050
// Test that get the pointer via destructuring works
5151

5252
let f : Foo<usize> = Foo { a: 0, b: 11 };
53-
let f : &Foo<Bar> = &f;
53+
let f : &Foo<dyn Bar> = &f;
5454
let &Foo { a: _, b: ref bar } = f;
5555
assert_eq!(bar.get(), 11);
5656

tests/run-pass/dst-raw.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ struct Foo<T: ?Sized> {
2121
pub fn main() {
2222
// raw trait object
2323
let x = A { f: 42 };
24-
let z: *const Trait = &x;
24+
let z: *const dyn Trait = &x;
2525
let r = unsafe {
2626
(&*z).foo()
2727
};
2828
assert_eq!(r, 42);
2929

3030
// raw DST struct
3131
let p = Foo {f: A { f: 42 }};
32-
let o: *const Foo<Trait> = &p;
32+
let o: *const Foo<dyn Trait> = &p;
3333
let r = unsafe {
3434
(&*o).f.foo()
3535
};
@@ -64,14 +64,14 @@ pub fn main() {
6464

6565
// all of the above with *mut
6666
let mut x = A { f: 42 };
67-
let z: *mut Trait = &mut x;
67+
let z: *mut dyn Trait = &mut x;
6868
let r = unsafe {
6969
(&*z).foo()
7070
};
7171
assert_eq!(r, 42);
7272

7373
let mut p = Foo {f: A { f: 42 }};
74-
let o: *mut Foo<Trait> = &mut p;
74+
let o: *mut Foo<dyn Trait> = &mut p;
7575
let r = unsafe {
7676
(&*o).f.foo()
7777
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn foo() {}
22

33
fn main() {
4-
let f: &Fn() = &foo;
4+
let f: &dyn Fn() = &foo;
55
f();
66
}

tests/run-pass/fn_item_with_args_as_closure_trait_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ fn foo(i: i32) {
33
}
44

55
fn main() {
6-
let f: &Fn(i32) = &foo;
6+
let f: &dyn Fn(i32) = &foo;
77
f(42);
88
}

0 commit comments

Comments
 (0)