]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #4155 - phansch:rustup_trait_obj, r=oli-obk
authorbors <bors@rust-lang.org>
Thu, 30 May 2019 07:29:28 +0000 (07:29 +0000)
committerbors <bors@rust-lang.org>
Thu, 30 May 2019 07:29:28 +0000 (07:29 +0000)
Rustup to https://github.com/rust-lang/rust/pull/61203

See https://github.com/rust-lang/rust/pull/61203

Migrates all trait objects to use `dyn` in our ui tests

changelog: none

16 files changed:
tests/ui/borrow_box.rs
tests/ui/box_vec.rs
tests/ui/escape_analysis.rs
tests/ui/eta.fixed
tests/ui/eta.rs
tests/ui/extra_unused_lifetimes.rs
tests/ui/len_zero.fixed
tests/ui/len_zero.rs
tests/ui/needless_borrow.rs
tests/ui/needless_lifetimes.rs
tests/ui/needless_lifetimes.stderr
tests/ui/non_copy_const.rs
tests/ui/unnecessary_clone.rs
tests/ui/unnecessary_clone.stderr
tests/ui/unused_unit.fixed
tests/ui/unused_unit.rs

index 3b53aab7e23f234650c6acafbf0c90903e3a8a19..b30f7290ffea6bea3bbc811e7f7be9724b029c11 100644 (file)
@@ -27,46 +27,46 @@ fn test4(a: &Box<bool>) {
 
 use std::any::Any;
 
-pub fn test5(foo: &mut Box<Any>) {
+pub fn test5(foo: &mut Box<dyn Any>) {
     println!("{:?}", foo)
 }
 
 pub fn test6() {
-    let foo: &Box<Any>;
+    let foo: &Box<dyn Any>;
 }
 
 struct Test7<'a> {
-    foo: &'a Box<Any>,
+    foo: &'a Box<dyn Any>,
 }
 
 trait Test8 {
-    fn test8(a: &Box<Any>);
+    fn test8(a: &Box<dyn Any>);
 }
 
 impl<'a> Test8 for Test7<'a> {
-    fn test8(a: &Box<Any>) {
+    fn test8(a: &Box<dyn Any>) {
         unimplemented!();
     }
 }
 
-pub fn test9(foo: &mut Box<Any + Send + Sync>) {
+pub fn test9(foo: &mut Box<dyn Any + Send + Sync>) {
     let _ = foo;
 }
 
 pub fn test10() {
-    let foo: &Box<Any + Send + 'static>;
+    let foo: &Box<dyn Any + Send + 'static>;
 }
 
 struct Test11<'a> {
-    foo: &'a Box<Any + Send>,
+    foo: &'a Box<dyn Any + Send>,
 }
 
 trait Test12 {
-    fn test4(a: &Box<Any + 'static>);
+    fn test4(a: &Box<dyn Any + 'static>);
 }
 
 impl<'a> Test12 for Test11<'a> {
-    fn test4(a: &Box<Any + 'static>) {
+    fn test4(a: &Box<dyn Any + 'static>) {
         unimplemented!();
     }
 }
@@ -74,8 +74,8 @@ fn test4(a: &Box<Any + 'static>) {
 fn main() {
     test1(&mut Box::new(false));
     test2();
-    test5(&mut (Box::new(false) as Box<Any>));
+    test5(&mut (Box::new(false) as Box<dyn Any>));
     test6();
-    test9(&mut (Box::new(false) as Box<Any + Send + Sync>));
+    test9(&mut (Box::new(false) as Box<dyn Any + Send + Sync>));
     test10();
 }
index af3ba5b4d353415ce8c7bf711c7d720f0ff5198f..87b67c23704c9e71ba4cec847a89cef943d8498e 100644 (file)
@@ -15,7 +15,7 @@ pub fn test(foo: Box<Vec<bool>>) {
     println!("{:?}", foo.get(0))
 }
 
-pub fn test2(foo: Box<Fn(Vec<u32>)>) {
+pub fn test2(foo: Box<dyn Fn(Vec<u32>)>) {
     // pass if #31 is fixed
     foo(vec![1, 2, 3])
 }
index e3f78182fd13edb48a8fce3b7786c42cf20d594c..78d332c7a31c9e48432fd98010f19afd11767ff9 100644 (file)
@@ -21,7 +21,7 @@ fn bar(&self) {
 
 fn main() {}
 
-fn ok_box_trait(boxed_trait: &Box<Z>) {
+fn ok_box_trait(boxed_trait: &Box<dyn Z>) {
     let boxed_local = boxed_trait;
     // done
 }
index a3e57956f35b4e5c8ba1b83bbaea7640a752bdd4..1ad836d25ff6630a7fdd1f657f8e820c26b7b292 100644 (file)
@@ -32,8 +32,8 @@ fn main() {
     let e = Some(1u8).map(generic);
     let e = Some(1u8).map(generic);
     // See #515
-    let a: Option<Box<::std::ops::Deref<Target = [i32]>>> =
-        Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref<Target = [i32]>> { Box::new(v) });
+    let a: Option<Box<dyn (::std::ops::Deref<Target = [i32]>)>> =
+        Some(vec![1i32, 2]).map(|v| -> Box<dyn (::std::ops::Deref<Target = [i32]>)> { Box::new(v) });
 }
 
 trait TestTrait {
@@ -108,7 +108,7 @@ fn test_redundant_closures_containing_method_calls() {
     let _: Vec<_> = arr.iter().map(|x| x.map_err(some.take().unwrap())).collect();
 }
 
-struct Thunk<T>(Box<FnMut() -> T>);
+struct Thunk<T>(Box<dyn FnMut() -> T>);
 
 impl<T> Thunk<T> {
     fn new<F: 'static + FnOnce() -> T>(f: F) -> Thunk<T> {
index 58adf21b1d5ed78125627f2e18ceab9eae864522..41a13d769a6771d0e3606bb9781d761b9d7518c3 100644 (file)
@@ -32,8 +32,8 @@ fn main() {
     let e = Some(1u8).map(|a| generic(a));
     let e = Some(1u8).map(generic);
     // See #515
-    let a: Option<Box<::std::ops::Deref<Target = [i32]>>> =
-        Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref<Target = [i32]>> { Box::new(v) });
+    let a: Option<Box<dyn (::std::ops::Deref<Target = [i32]>)>> =
+        Some(vec![1i32, 2]).map(|v| -> Box<dyn (::std::ops::Deref<Target = [i32]>)> { Box::new(v) });
 }
 
 trait TestTrait {
@@ -108,7 +108,7 @@ fn test_different_borrow_levels<T>(t: &[&T])
     let _: Vec<_> = arr.iter().map(|x| x.map_err(|e| some.take().unwrap()(e))).collect();
 }
 
-struct Thunk<T>(Box<FnMut() -> T>);
+struct Thunk<T>(Box<dyn FnMut() -> T>);
 
 impl<T> Thunk<T> {
     fn new<F: 'static + FnOnce() -> T>(f: F) -> Thunk<T> {
index ba7c42b3a90d4d80b8804e73efd0aa8263e46ee3..9f05f8c1ed026a28d2ae55346c389b5d7b601bc5 100644 (file)
@@ -25,7 +25,7 @@ fn lt_return_only<'a>() -> &'a u8 {
     panic!()
 }
 
-fn unused_lt_blergh<'a>(x: Option<Box<Send + 'a>>) {}
+fn unused_lt_blergh<'a>(x: Option<Box<dyn Send + 'a>>) {}
 
 trait Foo<'a> {
     fn x(&self, a: &'a u8);
index 56109a0fa5fbdc6ca1a3afcdcc60fb27b5fc0601..624e5ef8fcf13129184a1c5b1580ce50ad6c696c 100644 (file)
@@ -70,7 +70,7 @@ fn main() {
         println!("This should not happen either!");
     }
 
-    let z: &TraitsToo = &y;
+    let z: &dyn TraitsToo = &y;
     if z.len() > 0 {
         // No error; `TraitsToo` has no `.is_empty()` method.
         println!("Nor should this!");
@@ -125,7 +125,7 @@ fn main() {
     }
     assert!(!has_is_empty.is_empty());
 
-    let with_is_empty: &WithIsEmpty = &Wither;
+    let with_is_empty: &dyn WithIsEmpty = &Wither;
     if with_is_empty.is_empty() {
         println!("Or this!");
     }
index 0a77f1194621db3101fd0ed16416749349f6576f..7fba971cfd8876ebb0e2713cdd09e492586b473c 100644 (file)
@@ -70,7 +70,7 @@ fn main() {
         println!("This should not happen either!");
     }
 
-    let z: &TraitsToo = &y;
+    let z: &dyn TraitsToo = &y;
     if z.len() > 0 {
         // No error; `TraitsToo` has no `.is_empty()` method.
         println!("Nor should this!");
@@ -125,7 +125,7 @@ fn main() {
     }
     assert!(!has_is_empty.is_empty());
 
-    let with_is_empty: &WithIsEmpty = &Wither;
+    let with_is_empty: &dyn WithIsEmpty = &Wither;
     if with_is_empty.len() == 0 {
         println!("Or this!");
     }
index a59254625dce62222e287396ae4d1edeabbe7c9e..d4ac2b89854df471f2f4a1e79706f894540eaae0 100644 (file)
@@ -41,7 +41,7 @@ trait Trait {}
 
 impl<'a> Trait for &'a str {}
 
-fn h(_: &Trait) {}
+fn h(_: &dyn Trait) {}
 #[warn(clippy::needless_borrow)]
 #[allow(dead_code)]
 fn issue_1432() {
index e2d680ceaeb1938b1b996a84df7be2e068abe937..f585be2fd03ff41bdfc3ab9cc80e445e89285e82 100644 (file)
@@ -166,16 +166,16 @@ fn struct_with_lt4<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str {
 
 trait WithLifetime<'a> {}
 
-type WithLifetimeAlias<'a> = WithLifetime<'a>;
+type WithLifetimeAlias<'a> = dyn WithLifetime<'a>;
 
 // Should not warn because it won't build without the lifetime.
-fn trait_obj_elided<'a>(_arg: &'a WithLifetime) -> &'a str {
+fn trait_obj_elided<'a>(_arg: &'a dyn WithLifetime) -> &'a str {
     unimplemented!()
 }
 
 // Should warn because there is no lifetime on `Drop`, so this would be
 // unambiguous if we elided the lifetime.
-fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str {
+fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
     unimplemented!()
 }
 
@@ -226,7 +226,7 @@ struct Test {
 }
 
 impl Test {
-    fn iter<'a>(&'a self) -> Box<Iterator<Item = usize> + 'a> {
+    fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = usize> + 'a> {
         unimplemented!()
     }
 }
index 9334076fc71c2c041a8ffa651f9bd39391b4512c..bbb69aeda1c484b266bd2dc57432650fa0335f29 100644 (file)
@@ -81,7 +81,7 @@ LL | | }
 error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
   --> $DIR/needless_lifetimes.rs:178:1
    |
-LL | / fn trait_obj_elided2<'a>(_arg: &'a Drop) -> &'a str {
+LL | / fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
 LL | |     unimplemented!()
 LL | | }
    | |_^
index 00cbcaeacb9f7d56af93b2f8b675d1997ee3a05e..46cbb3fee35abeaa59a0ea42a19403abb1d3fdea 100644 (file)
@@ -27,7 +27,7 @@ macro_rules! declare_const {
 const COW: Cow<str> = Cow::Borrowed("abcdef");
 //^ note: a const item of Cow is used in the `postgres` package.
 
-const NO_ANN: &Display = &70;
+const NO_ANN: &dyn Display = &70;
 
 static STATIC_TUPLE: (AtomicUsize, String) = (ATOMIC, STRING);
 //^ there should be no lints on this line
index 570536d0a56f5cee0a544dcbb181f369151ccfe5..2e0fc122778191ccacd46317f734755d4ba236a3 100644 (file)
@@ -44,7 +44,7 @@ fn clone_on_ref_ptr() {
     sync::Weak::clone(&arc_weak);
 
     let x = Arc::new(SomeImpl);
-    let _: Arc<SomeTrait> = x.clone();
+    let _: Arc<dyn SomeTrait> = x.clone();
 }
 
 fn clone_on_copy_generic<T: Copy>(t: T) {
index a014478597fc3406fed86b6d30ac5e3c8909457d..8d5d54e7de678798a5b6f56c37cf9a5026060d15 100644 (file)
@@ -45,10 +45,10 @@ LL |     arc_weak.clone();
    |     ^^^^^^^^^^^^^^^^ help: try this: `Weak::<bool>::clone(&arc_weak)`
 
 error: using '.clone()' on a ref-counted pointer
-  --> $DIR/unnecessary_clone.rs:47:29
+  --> $DIR/unnecessary_clone.rs:47:33
    |
-LL |     let _: Arc<SomeTrait> = x.clone();
-   |                             ^^^^^^^^^ help: try this: `Arc::<SomeImpl>::clone(&x)`
+LL |     let _: Arc<dyn SomeTrait> = x.clone();
+   |                                 ^^^^^^^^^ help: try this: `Arc::<SomeImpl>::clone(&x)`
 
 error: using `clone` on a `Copy` type
   --> $DIR/unnecessary_clone.rs:51:5
index 641245896839daafc5224f8ecb224c69acb72463..3c9e91a19f9af2c0f83ffb4837a68ce3c443356c 100644 (file)
@@ -17,7 +17,7 @@ impl Unitter {
     #[allow(clippy::no_effect)]
     pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) 
     where G: Fn() -> () {
-        let _y: &Fn() -> () = &f;
+        let _y: &dyn Fn() -> () = &f;
         (); // this should not lint, as it's not in return type position
     }
 }
index 8e31385b70c9318f92c5dc5990704c617dede45e..1acd427be1eefd837070dcddd73762927cb08c06 100644 (file)
@@ -18,7 +18,7 @@ impl Unitter {
     pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) ->
         ()
     where G: Fn() -> () {
-        let _y: &Fn() -> () = &f;
+        let _y: &dyn Fn() -> () = &f;
         (); // this should not lint, as it's not in return type position
     }
 }