From badbd57cee570f25ebf6b31ea4d596a162a87188 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 30 May 2019 10:58:30 +0200 Subject: [PATCH] update for rustc warning about missing dyn --- rust-version | 2 +- tests/run-pass/box_box_trait.rs | 6 +++--- tests/run-pass/call_drop_on_fat_ptr_array_elements.rs | 2 +- tests/run-pass/call_drop_through_trait_object.rs | 2 +- tests/run-pass/call_drop_through_trait_object_rc.rs | 2 +- tests/run-pass/cast-rfc0401-vtable-kinds.rs | 10 +++++----- tests/run-pass/dst-field-align.rs | 8 ++++---- tests/run-pass/dst-raw.rs | 8 ++++---- tests/run-pass/fn_item_as_closure_trait_object.rs | 2 +- .../fn_item_with_args_as_closure_trait_object.rs | 2 +- ..._item_with_multiple_args_as_closure_trait_object.rs | 4 ++-- tests/run-pass/fn_ptr_as_closure_trait_object.rs | 6 +++--- tests/run-pass/issue-20575.rs | 2 +- tests/run-pass/issue-23261.rs | 4 ++-- tests/run-pass/issue-26709.rs | 2 +- tests/run-pass/issue-30530.rs | 4 ++-- tests/run-pass/issue-33387.rs | 2 +- tests/run-pass/issue-35815.rs | 2 +- tests/run-pass/issue-3794.rs | 4 ++-- tests/run-pass/last-use-in-cap-clause.rs | 2 +- tests/run-pass/mir_coercions.rs | 10 +++++----- tests/run-pass/multi_arg_closure.rs | 2 +- tests/run-pass/non_capture_closure_to_fn_ptr.rs | 2 +- tests/run-pass/rc.rs | 4 ++-- tests/run-pass/regions-lifetime-nonfree-late-bound.rs | 8 ++++---- tests/run-pass/traits.rs | 8 ++++---- 26 files changed, 55 insertions(+), 55 deletions(-) diff --git a/rust-version b/rust-version index d93fb8b6950e..5504e77097b7 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -81970852e172c04322cbf8ba23effabeb491c83c +c28084ac16af4ab594b6860958df140e7c876a13 diff --git a/tests/run-pass/box_box_trait.rs b/tests/run-pass/box_box_trait.rs index 7fe568522d53..e7620cd42f70 100644 --- a/tests/run-pass/box_box_trait.rs +++ b/tests/run-pass/box_box_trait.rs @@ -14,10 +14,10 @@ trait MyTrait { fn dummy(&self) { } } impl MyTrait for Box {} #[allow(dead_code)] -struct Whatever { w: Box } +struct Whatever { w: Box } impl Whatever { - fn new(w: Box) -> Whatever { + fn new(w: Box) -> Whatever { Whatever { w: w } } } @@ -25,7 +25,7 @@ fn new(w: Box) -> Whatever { fn main() { { let f: Box<_> = box DroppableStruct; - let _a = Whatever::new(box f as Box); + let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); } diff --git a/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs b/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs index a1ab5c45e358..36162d320212 100644 --- a/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs +++ b/tests/run-pass/call_drop_on_fat_ptr_array_elements.rs @@ -13,7 +13,7 @@ fn drop(&mut self) { } fn main() { - let b: [Box; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)]; + let b: [Box; 4] = [Box::new(Bar), Box::new(Bar), Box::new(Bar), Box::new(Bar)]; assert_eq!(unsafe { DROP_COUNT }, 0); drop(b); assert_eq!(unsafe { DROP_COUNT }, 4); diff --git a/tests/run-pass/call_drop_through_trait_object.rs b/tests/run-pass/call_drop_through_trait_object.rs index 9b6acf0b1474..97ba69c9fe28 100644 --- a/tests/run-pass/call_drop_through_trait_object.rs +++ b/tests/run-pass/call_drop_through_trait_object.rs @@ -13,7 +13,7 @@ fn drop(&mut self) { impl Foo for Bar {} fn main() { - let b: Box = Box::new(Bar); + let b: Box = Box::new(Bar); assert!(unsafe { !DROP_CALLED }); drop(b); assert!(unsafe { DROP_CALLED }); diff --git a/tests/run-pass/call_drop_through_trait_object_rc.rs b/tests/run-pass/call_drop_through_trait_object_rc.rs index ce56ca6a1caf..172a4580dc10 100644 --- a/tests/run-pass/call_drop_through_trait_object_rc.rs +++ b/tests/run-pass/call_drop_through_trait_object_rc.rs @@ -15,7 +15,7 @@ impl Foo for Bar {} use std::rc::Rc; fn main() { - let b: Rc = Rc::new(Bar); + let b: Rc = Rc::new(Bar); assert!(unsafe { !DROP_CALLED }); drop(b); assert!(unsafe { DROP_CALLED }); diff --git a/tests/run-pass/cast-rfc0401-vtable-kinds.rs b/tests/run-pass/cast-rfc0401-vtable-kinds.rs index 6442eab30a13..544510be9bb0 100644 --- a/tests/run-pass/cast-rfc0401-vtable-kinds.rs +++ b/tests/run-pass/cast-rfc0401-vtable-kinds.rs @@ -13,9 +13,9 @@ impl Foo for () {} impl Foo for u32 { fn foo(&self, _: u32) -> u32 { self+43 } } impl Bar for () {} -unsafe fn round_trip_and_call<'a>(t: *const (Foo+'a)) -> u32 { - let foo_e : *const Foo = t as *const _; - let r_1 = foo_e as *mut Foo; +unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo+'a)) -> u32 { + let foo_e : *const dyn Foo = t as *const _; + let r_1 = foo_e as *mut dyn Foo; (&*r_1).foo(0) } @@ -31,8 +31,8 @@ fn foo_to_bar(u: *const FooS) -> *const BarS { fn main() { let x = 4u32; - let y : &Foo = &x; - let fl = unsafe { round_trip_and_call(y as *const Foo) }; + let y : &dyn Foo = &x; + let fl = unsafe { round_trip_and_call(y as *const dyn Foo) }; assert_eq!(fl, (43+4)); let s = FooS([0,1,2]); diff --git a/tests/run-pass/dst-field-align.rs b/tests/run-pass/dst-field-align.rs index b8e9815640c2..7cd0c851b638 100644 --- a/tests/run-pass/dst-field-align.rs +++ b/tests/run-pass/dst-field-align.rs @@ -26,7 +26,7 @@ fn main() { // Test that zero-offset works properly let b : Baz = Baz { a: 7 }; assert_eq!(b.a.get(), 7); - let b : &Baz = &b; + let b : &Baz = &b; assert_eq!(b.a.get(), 7); // Test that the field is aligned properly @@ -34,7 +34,7 @@ fn main() { assert_eq!(f.b.get(), 11); let ptr1 : *const u8 = &f.b as *const _ as *const u8; - let f : &Foo = &f; + let f : &Foo = &f; let ptr2 : *const u8 = &f.b as *const _ as *const u8; assert_eq!(f.b.get(), 11); @@ -44,13 +44,13 @@ fn main() { // Test that nested DSTs work properly let f : Foo> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; assert_eq!(f.b.b.get(), 17); - let f : &Foo> = &f; + let f : &Foo> = &f; assert_eq!(f.b.b.get(), 17); // Test that get the pointer via destructuring works let f : Foo = Foo { a: 0, b: 11 }; - let f : &Foo = &f; + let f : &Foo = &f; let &Foo { a: _, b: ref bar } = f; assert_eq!(bar.get(), 11); diff --git a/tests/run-pass/dst-raw.rs b/tests/run-pass/dst-raw.rs index a3ee982d19aa..0fe2b72b8c6a 100644 --- a/tests/run-pass/dst-raw.rs +++ b/tests/run-pass/dst-raw.rs @@ -21,7 +21,7 @@ struct Foo { pub fn main() { // raw trait object let x = A { f: 42 }; - let z: *const Trait = &x; + let z: *const dyn Trait = &x; let r = unsafe { (&*z).foo() }; @@ -29,7 +29,7 @@ pub fn main() { // raw DST struct let p = Foo {f: A { f: 42 }}; - let o: *const Foo = &p; + let o: *const Foo = &p; let r = unsafe { (&*o).f.foo() }; @@ -64,14 +64,14 @@ pub fn main() { // all of the above with *mut let mut x = A { f: 42 }; - let z: *mut Trait = &mut x; + let z: *mut dyn Trait = &mut x; let r = unsafe { (&*z).foo() }; assert_eq!(r, 42); let mut p = Foo {f: A { f: 42 }}; - let o: *mut Foo = &mut p; + let o: *mut Foo = &mut p; let r = unsafe { (&*o).f.foo() }; diff --git a/tests/run-pass/fn_item_as_closure_trait_object.rs b/tests/run-pass/fn_item_as_closure_trait_object.rs index 799f97a4f6fd..dcbbb5cb6a2c 100644 --- a/tests/run-pass/fn_item_as_closure_trait_object.rs +++ b/tests/run-pass/fn_item_as_closure_trait_object.rs @@ -1,6 +1,6 @@ fn foo() {} fn main() { - let f: &Fn() = &foo; + let f: &dyn Fn() = &foo; f(); } diff --git a/tests/run-pass/fn_item_with_args_as_closure_trait_object.rs b/tests/run-pass/fn_item_with_args_as_closure_trait_object.rs index 79ece75c773b..257028c4f0d8 100644 --- a/tests/run-pass/fn_item_with_args_as_closure_trait_object.rs +++ b/tests/run-pass/fn_item_with_args_as_closure_trait_object.rs @@ -3,6 +3,6 @@ fn foo(i: i32) { } fn main() { - let f: &Fn(i32) = &foo; + let f: &dyn Fn(i32) = &foo; f(42); } diff --git a/tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs b/tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs index f4b5b449aa58..98111f304c89 100644 --- a/tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs +++ b/tests/run-pass/fn_item_with_multiple_args_as_closure_trait_object.rs @@ -11,8 +11,8 @@ fn bar(i: i32, j: i32, k: f32) { fn main() { - let f: &Fn(i32, i32) = &foo; + let f: &dyn Fn(i32, i32) = &foo; f(42, 55); - let f: &Fn(i32, i32, f32) = &bar; + let f: &dyn Fn(i32, i32, f32) = &bar; f(42, 55, 3.14159); } diff --git a/tests/run-pass/fn_ptr_as_closure_trait_object.rs b/tests/run-pass/fn_ptr_as_closure_trait_object.rs index 24ae1f35bb60..89daed81507f 100644 --- a/tests/run-pass/fn_ptr_as_closure_trait_object.rs +++ b/tests/run-pass/fn_ptr_as_closure_trait_object.rs @@ -6,10 +6,10 @@ fn baa(u: u32, f: f32) { } fn main() { - let f: &Fn() = &(foo as fn()); + let f: &dyn Fn() = &(foo as fn()); f(); - let f: &Fn(u32) = &(bar as fn(u32)); + let f: &dyn Fn(u32) = &(bar as fn(u32)); f(42); - let f: &Fn(u32, f32) = &(baa as fn(u32, f32)); + let f: &dyn Fn(u32, f32) = &(baa as fn(u32, f32)); f(42, 3.141); } diff --git a/tests/run-pass/issue-20575.rs b/tests/run-pass/issue-20575.rs index 1443ec78fd75..19049b9add5c 100644 --- a/tests/run-pass/issue-20575.rs +++ b/tests/run-pass/issue-20575.rs @@ -1,7 +1,7 @@ // Test that overloaded calls work with zero arity closures fn main() { - let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; + let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; let _val: Option> = functions.iter().map(|f| (*f)()).collect(); } diff --git a/tests/run-pass/issue-23261.rs b/tests/run-pass/issue-23261.rs index 3e1aa295af1e..f3c2f58ddbca 100644 --- a/tests/run-pass/issue-23261.rs +++ b/tests/run-pass/issue-23261.rs @@ -40,7 +40,7 @@ fn check_both(val: &Foo<[u8]>) { } } -fn check_trait_obj(val: &Foo) { +fn check_trait_obj(val: &Foo) { match *val { Foo { a, ref inner } => { assert_eq!(a, 32); @@ -55,6 +55,6 @@ fn main() { check_dst_val(foo); check_both(foo); - let foo: &Foo = &Foo { a: 32, inner: 32 }; + let foo: &Foo = &Foo { a: 32, inner: 32 }; check_trait_obj(foo); } diff --git a/tests/run-pass/issue-26709.rs b/tests/run-pass/issue-26709.rs index a283d8743ccf..78f30e78db76 100644 --- a/tests/run-pass/issue-26709.rs +++ b/tests/run-pass/issue-26709.rs @@ -10,7 +10,7 @@ fn main() { let mut x = 0; { let wrapper = Box::new(Wrapper(&mut x, 123)); - let _val: Box> = wrapper; + let _val: Box> = wrapper; } assert_eq!(432, x) } diff --git a/tests/run-pass/issue-30530.rs b/tests/run-pass/issue-30530.rs index d5139c908bda..10dec30c64ca 100644 --- a/tests/run-pass/issue-30530.rs +++ b/tests/run-pass/issue-30530.rs @@ -17,7 +17,7 @@ pub enum Handler { Default, #[allow(dead_code)] - Custom(*mut Box), + Custom(*mut Box), } fn main() { @@ -25,7 +25,7 @@ fn main() { } #[inline(never)] -pub fn take(h: Handler, f: Box) -> Box { +pub fn take(h: Handler, f: Box) -> Box { unsafe { match h { Handler::Custom(ptr) => *Box::from_raw(ptr), diff --git a/tests/run-pass/issue-33387.rs b/tests/run-pass/issue-33387.rs index 2335f9c1b941..36b58c642d7d 100644 --- a/tests/run-pass/issue-33387.rs +++ b/tests/run-pass/issue-33387.rs @@ -5,5 +5,5 @@ trait Foo {} impl Foo for [u8; 2] {} fn main() { - let _val: Arc = Arc::new([3, 4]); + let _val: Arc = Arc::new([3, 4]); } diff --git a/tests/run-pass/issue-35815.rs b/tests/run-pass/issue-35815.rs index e17c37f92a50..fb0bd8e202ff 100644 --- a/tests/run-pass/issue-35815.rs +++ b/tests/run-pass/issue-35815.rs @@ -10,6 +10,6 @@ struct Foo { fn main() { let foo: &Foo = &Foo { a: 1, b: false, c: 2i32 }; - let foo_unsized: &Foo = foo; + let foo_unsized: &Foo = foo; assert_eq!(mem::size_of_val(foo), mem::size_of_val(foo_unsized)); } diff --git a/tests/run-pass/issue-3794.rs b/tests/run-pass/issue-3794.rs index 9161fefef30c..fb1c19b04e99 100644 --- a/tests/run-pass/issue-3794.rs +++ b/tests/run-pass/issue-3794.rs @@ -15,7 +15,7 @@ fn print(&self) { } } -fn print_t(t: &T) { +fn print_t(t: &dyn T) { t.print(); } @@ -26,6 +26,6 @@ fn print_s(s: &S) { pub fn main() { let s: Box = box S { s: 5 }; print_s(&*s); - let t: Box = s as Box; + let t: Box = s as Box; print_t(&*t); } diff --git a/tests/run-pass/last-use-in-cap-clause.rs b/tests/run-pass/last-use-in-cap-clause.rs index f75f00b87fd4..9d137f706bd3 100644 --- a/tests/run-pass/last-use-in-cap-clause.rs +++ b/tests/run-pass/last-use-in-cap-clause.rs @@ -3,7 +3,7 @@ #[allow(dead_code)] struct A { a: Box } -fn foo() -> Box isize + 'static> { +fn foo() -> Box isize + 'static> { let k: Box<_> = Box::new(22); let _u = A {a: k.clone()}; let result = || 22; diff --git a/tests/run-pass/mir_coercions.rs b/tests/run-pass/mir_coercions.rs index f3d8e519d23e..bfc821f799ee 100644 --- a/tests/run-pass/mir_coercions.rs +++ b/tests/run-pass/mir_coercions.rs @@ -3,12 +3,12 @@ use std::ops::CoerceUnsized; use std::marker::Unsize; -fn identity_coercion(x: &(Fn(u32)->u32 + Send)) -> &Fn(u32)->u32 { +fn identity_coercion(x: &(dyn Fn(u32)->u32 + Send)) -> &dyn Fn(u32)->u32 { x } fn fn_coercions(f: &fn(u32) -> u32) -> (unsafe fn(u32) -> u32, - &(Fn(u32) -> u32+Send)) + &(dyn Fn(u32) -> u32 + Send)) { (*f, f) } @@ -34,8 +34,8 @@ impl<'a, T: ?Sized+Unsize, U: ?Sized> p } -fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) - -> PtrWrapper u32> { +fn coerce_fat_ptr_wrapper(p: PtrWrapper u32 + Send>) + -> PtrWrapper u32> { p } @@ -67,7 +67,7 @@ fn main() { let z = coerce_fat_ptr_wrapper(PtrWrapper(2,3,(),&square_local)); assert_eq!((z.3)(6), 36); - let z: PtrWrapper u32> = + let z: PtrWrapper u32> = coerce_ptr_wrapper_poly(PtrWrapper(2,3,(),&square_local)); assert_eq!((z.3)(6), 36); } diff --git a/tests/run-pass/multi_arg_closure.rs b/tests/run-pass/multi_arg_closure.rs index 30cfb5b685b2..02d53540b83c 100644 --- a/tests/run-pass/multi_arg_closure.rs +++ b/tests/run-pass/multi_arg_closure.rs @@ -1,4 +1,4 @@ -fn foo(f: &mut FnMut(isize, isize) -> isize) -> isize { +fn foo(f: &mut dyn FnMut(isize, isize) -> isize) -> isize { f(1, 2) } diff --git a/tests/run-pass/non_capture_closure_to_fn_ptr.rs b/tests/run-pass/non_capture_closure_to_fn_ptr.rs index d48c4df45944..e6a5017847d4 100644 --- a/tests/run-pass/non_capture_closure_to_fn_ptr.rs +++ b/tests/run-pass/non_capture_closure_to_fn_ptr.rs @@ -12,7 +12,7 @@ fn main() { BAR(44, 45); let bar: unsafe fn(i32, i32) = BAR; unsafe { bar(46, 47) }; - let boo: &Fn(i32, i32) = &BAR; + let boo: &dyn Fn(i32, i32) = &BAR; boo(48, 49); let f = magic(||{}) as fn(); diff --git a/tests/run-pass/rc.rs b/tests/run-pass/rc.rs index 9b4d51ed376a..d731fe8fd4c3 100644 --- a/tests/run-pass/rc.rs +++ b/tests/run-pass/rc.rs @@ -64,8 +64,8 @@ fn rc_from() { } fn rc_fat_ptr_eq() { - let p = Rc::new(1) as Rc; - let a: *const Debug = &*p; + let p = Rc::new(1) as Rc; + let a: *const dyn Debug = &*p; let r = Rc::into_raw(p); assert!(a == r); drop(unsafe { Rc::from_raw(r) }); diff --git a/tests/run-pass/regions-lifetime-nonfree-late-bound.rs b/tests/run-pass/regions-lifetime-nonfree-late-bound.rs index 85a189007c3d..78aeea64814a 100644 --- a/tests/run-pass/regions-lifetime-nonfree-late-bound.rs +++ b/tests/run-pass/regions-lifetime-nonfree-late-bound.rs @@ -16,15 +16,15 @@ pub fn main() { fn explicit() { - fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} - test(Some(box |_f: Box FnMut(&'a isize)>| {})); + fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} + test(Some(box |_f: Box FnMut(&'a isize)>| {})); } // The code below is shorthand for the code above (and more likely // to represent what one encounters in practice). fn implicit() { - fn test(_x: Option>) where F: FnMut(Box< FnMut(& isize)>) {} - test(Some(box |_f: Box< FnMut(& isize)>| {})); + fn test(_x: Option>) where F: FnMut(Box) {} + test(Some(box |_f: Box| {})); } explicit(); diff --git a/tests/run-pass/traits.rs b/tests/run-pass/traits.rs index b2eae5d04f41..03d2db400f01 100644 --- a/tests/run-pass/traits.rs +++ b/tests/run-pass/traits.rs @@ -13,17 +13,17 @@ fn method(&self) { struct Foo(T); fn main() { - let y: &Trait = &Struct(42); + let y: &dyn Trait = &Struct(42); y.method(); let x: Foo = Foo(Struct(42)); - let y: &Foo = &x; + let y: &Foo = &x; y.0.method(); - let x: Box i32> = Box::new(|x| x * 2); + let x: Box i32> = Box::new(|x| x * 2); assert_eq!(x(21), 42); let mut i = 5; { - let mut x: Box = Box::new(|| i *= 2); + let mut x: Box = Box::new(|| i *= 2); x(); x(); } assert_eq!(i, 20);