diff options
| author | memoryruins <memoryruinsmusic@gmail.com> | 2019-05-28 14:46:13 -0400 |
|---|---|---|
| committer | memoryruins <memoryruinsmusic@gmail.com> | 2019-05-29 00:57:31 -0400 |
| commit | eb4580a570069175e1290b294d91042a09f9fde3 (patch) | |
| tree | fdb0ef28968512495204bd7a3dc3253cdb20365a | |
| parent | a1d1d7a2c696c2afeff2ea206621a32d77fa49dc (diff) | |
| download | rust-eb4580a570069175e1290b294d91042a09f9fde3.tar.gz rust-eb4580a570069175e1290b294d91042a09f9fde3.zip | |
Update ui test suite to use dyn
529 files changed, 1620 insertions, 1605 deletions
diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.rs b/src/test/ui/anonymous-higher-ranked-lifetime.rs index 2e2a124db9a..8a1744ed5f8 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.rs +++ b/src/test/ui/anonymous-higher-ranked-lifetime.rs @@ -31,11 +31,11 @@ fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {} fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} // Nested -fn g1<F>(_: F) where F: Fn(&(), Box<Fn(&())>) {} +fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {} fn g2<F>(_: F) where F: Fn(&(), fn(&())) {} -fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<Fn(&())>) {} +fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {} fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} // Mixed -fn h1<F>(_: F) where F: Fn(&(), Box<Fn(&())>, &(), fn(&(), &())) {} -fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &())) {} +fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {} +fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {} diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index 86547303978..0ca3ca84374 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -149,8 +149,8 @@ LL | g1(|_: (), _: ()| {}); note: required by `g1` --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 | -LL | fn g1<F>(_: F) where F: Fn(&(), Box<Fn(&())>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:12:5 @@ -163,8 +163,8 @@ LL | g1(|_: (), _: ()| {}); note: required by `g1` --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 | -LL | fn g1<F>(_: F) where F: Fn(&(), Box<Fn(&())>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -205,8 +205,8 @@ LL | g3(|_: (), _: ()| {}); note: required by `g3` --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 | -LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<Fn(&())>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -219,8 +219,8 @@ LL | g3(|_: (), _: ()| {}); note: required by `g3` --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 | -LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<Fn(&())>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -261,8 +261,8 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); note: required by `h1` --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 | -LL | fn h1<F>(_: F) where F: Fn(&(), Box<Fn(&())>, &(), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -275,8 +275,8 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); note: required by `h1` --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 | -LL | fn h1<F>(_: F) where F: Fn(&(), Box<Fn(&())>, &(), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -289,8 +289,8 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); note: required by `h2` --> $DIR/anonymous-higher-ranked-lifetime.rs:41:1 | -LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -303,8 +303,8 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); note: required by `h2` --> $DIR/anonymous-higher-ranked-lifetime.rs:41:1 | -LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<Fn(&())>, &'t0 (), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 22 previous errors diff --git a/src/test/ui/associated-const/associated-const-in-trait.rs b/src/test/ui/associated-const/associated-const-in-trait.rs index 187708a60b4..cc3acd53956 100644 --- a/src/test/ui/associated-const/associated-const-in-trait.rs +++ b/src/test/ui/associated-const/associated-const-in-trait.rs @@ -6,7 +6,7 @@ trait Trait { const N: usize; } -impl Trait { +impl dyn Trait { //~^ ERROR the trait `Trait` cannot be made into an object [E0038] const fn n() -> usize { Self::N } } diff --git a/src/test/ui/associated-const/associated-const-in-trait.stderr b/src/test/ui/associated-const/associated-const-in-trait.stderr index 44a92639b5d..dff268a55c9 100644 --- a/src/test/ui/associated-const/associated-const-in-trait.stderr +++ b/src/test/ui/associated-const/associated-const-in-trait.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/associated-const-in-trait.rs:9:6 | -LL | impl Trait { - | ^^^^^ the trait `Trait` cannot be made into an object +LL | impl dyn Trait { + | ^^^^^^^^^ the trait `Trait` cannot be made into an object | = note: the trait cannot contain associated consts like `N` diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs index df9143d685f..7a678445796 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.rs @@ -20,7 +20,7 @@ fn dent<C:BoxCar>(c: C, color: C::Color) { //~^ ERROR ambiguous associated type `Color` in bounds of `C` } -fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) { +fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) { //~^ ERROR ambiguous associated type //~| ERROR the value of the associated type `Color` (from the trait `Vehicle`) must be specified } diff --git a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr index dd46ad64692..6118ebef125 100644 --- a/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr +++ b/src/test/ui/associated-type/associated-type-projection-from-multiple-supertraits.stderr @@ -11,7 +11,7 @@ LL | fn dent<C:BoxCar>(c: C, color: C::Color) { | ^^^^^^^^ ambiguous associated type `Color` error[E0221]: ambiguous associated type `Color` in bounds of `BoxCar` - --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:33 + --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:37 | LL | type Color; | ----------- ambiguous `Color` from `Vehicle` @@ -19,8 +19,8 @@ LL | type Color; LL | type Color; | ----------- ambiguous `Color` from `Box` ... -LL | fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) { - | ^^^^^^^^^^^ ambiguous associated type `Color` +LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) { + | ^^^^^^^^^^^ ambiguous associated type `Color` error[E0191]: the value of the associated type `Color` (from the trait `Vehicle`) must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:26 @@ -28,8 +28,8 @@ error[E0191]: the value of the associated type `Color` (from the trait `Vehicle` LL | type Color; | ----------- `Color` defined here ... -LL | fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) { - | ^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified +LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) { + | ^^^^^^^^^^^^^^^^^^^^^^^ associated type `Color` must be specified error[E0221]: ambiguous associated type `Color` in bounds of `C` --> $DIR/associated-type-projection-from-multiple-supertraits.rs:28:29 diff --git a/src/test/ui/associated-types/associated-types-eq-3.rs b/src/test/ui/associated-types/associated-types-eq-3.rs index 1a58dcca9e2..9366148b587 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.rs +++ b/src/test/ui/associated-types/associated-types-eq-3.rs @@ -28,7 +28,7 @@ fn foo2<I: Foo>(x: I) { } -pub fn baz(x: &Foo<A=Bar>) { +pub fn baz(x: &dyn Foo<A=Bar>) { let _: Bar = x.boo(); } diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.rs b/src/test/ui/associated-types/associated-types-incomplete-object.rs index c93f3bec4d7..4993b131215 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.rs +++ b/src/test/ui/associated-types/associated-types-incomplete-object.rs @@ -18,14 +18,14 @@ impl Foo for isize { } pub fn main() { - let a = &42isize as &Foo<A=usize, B=char>; + let a = &42isize as &dyn Foo<A=usize, B=char>; - let b = &42isize as &Foo<A=usize>; + let b = &42isize as &dyn Foo<A=usize>; //~^ ERROR the value of the associated type `B` (from the trait `Foo`) must be specified - let c = &42isize as &Foo<B=char>; + let c = &42isize as &dyn Foo<B=char>; //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified - let d = &42isize as &Foo; + let d = &42isize as &dyn Foo; //~^ ERROR the value of the associated types `A` (from the trait `Foo`), `B` (from the trait } diff --git a/src/test/ui/associated-types/associated-types-incomplete-object.stderr b/src/test/ui/associated-types/associated-types-incomplete-object.stderr index d152e028eb7..b4c08f4a4cc 100644 --- a/src/test/ui/associated-types/associated-types-incomplete-object.stderr +++ b/src/test/ui/associated-types/associated-types-incomplete-object.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `B` (from the trait `Foo`) must b LL | type B; | ------- `B` defined here ... -LL | let b = &42isize as &Foo<A=usize>; - | ^^^^^^^^^^^^ associated type `B` must be specified +LL | let b = &42isize as &dyn Foo<A=usize>; + | ^^^^^^^^^^^^^^^^ associated type `B` must be specified error[E0191]: the value of the associated type `A` (from the trait `Foo`) must be specified --> $DIR/associated-types-incomplete-object.rs:26:26 @@ -13,8 +13,8 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must b LL | type A; | ------- `A` defined here ... -LL | let c = &42isize as &Foo<B=char>; - | ^^^^^^^^^^^ associated type `A` must be specified +LL | let c = &42isize as &dyn Foo<B=char>; + | ^^^^^^^^^^^^^^^ associated type `A` must be specified error[E0191]: the value of the associated types `A` (from the trait `Foo`), `B` (from the trait `Foo`) must be specified --> $DIR/associated-types-incomplete-object.rs:29:26 @@ -24,8 +24,8 @@ LL | type A; LL | type B; | ------- `B` defined here ... -LL | let d = &42isize as &Foo; - | ^^^ +LL | let d = &42isize as &dyn Foo; + | ^^^^^^^ | | | associated type `A` must be specified | associated type `B` must be specified diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs index 7467f332047..109feb8e969 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.rs +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.rs @@ -3,6 +3,6 @@ trait I32Iterator = Iterator<Item = i32>; fn main() { - let _: &I32Iterator<Item = u32> = &vec![42].into_iter(); + let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter(); //~^ ERROR type mismatch } diff --git a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr index 85724cb7c6e..aff067c2891 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr +++ b/src/test/ui/associated-types/associated-types-overridden-binding-2.stderr @@ -1,8 +1,8 @@ error[E0271]: type mismatch resolving `<std::vec::IntoIter<u32> as std::iter::Iterator>::Item == i32` - --> $DIR/associated-types-overridden-binding-2.rs:6:39 + --> $DIR/associated-types-overridden-binding-2.rs:6:43 | -LL | let _: &I32Iterator<Item = u32> = &vec![42].into_iter(); - | ^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32 +LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter(); + | ^^^^^^^^^^^^^^^^^^^^^ expected u32, found i32 | = note: expected type `u32` found type `i32` diff --git a/src/test/ui/associated-types/associated-types-overridden-binding.rs b/src/test/ui/associated-types/associated-types-overridden-binding.rs index ea3a61b2bef..fa1889389fd 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding.rs +++ b/src/test/ui/associated-types/associated-types-overridden-binding.rs @@ -7,5 +7,5 @@ trait I32Iterator = Iterator<Item = i32>; trait U32Iterator = I32Iterator<Item = u32>; fn main() { - let _: &I32Iterator<Item = u32>; + let _: &dyn I32Iterator<Item = u32>; } diff --git a/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr b/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr index 9258854245c..36fa06cce4d 100644 --- a/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr +++ b/src/test/ui/associated-types/bound-lifetime-constrained.object.stderr @@ -1,14 +1,14 @@ error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-constrained.rs:28:56 + --> $DIR/bound-lifetime-constrained.rs:28:60 | -LL | fn object1(_: Box<for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32>) { - | ^^^^^^^ +LL | fn object1(_: Box<dyn for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32>) { + | ^^^^^^^ error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-constrained.rs:33:35 + --> $DIR/bound-lifetime-constrained.rs:33:39 | -LL | fn object2(_: Box<for<'a> Fn() -> <() as Foo<'a>>::Item>) { - | ^^^^^^^^^^^^^^^^^^^^^ +LL | fn object2(_: Box<dyn for<'a> Fn() -> <() as Foo<'a>>::Item>) { + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/bound-lifetime-constrained.rs b/src/test/ui/associated-types/bound-lifetime-constrained.rs index b590f88b60d..fb82b3fa666 100644 --- a/src/test/ui/associated-types/bound-lifetime-constrained.rs +++ b/src/test/ui/associated-types/bound-lifetime-constrained.rs @@ -25,12 +25,12 @@ fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) { } #[cfg(object)] -fn object1(_: Box<for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32>) { +fn object1(_: Box<dyn for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32>) { //[object]~^ ERROR E0582 } #[cfg(object)] -fn object2(_: Box<for<'a> Fn() -> <() as Foo<'a>>::Item>) { +fn object2(_: Box<dyn for<'a> Fn() -> <() as Foo<'a>>::Item>) { //[object]~^ ERROR E0582 } diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr index fee64c0f663..54f4bb9076b 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.angle.stderr @@ -17,10 +17,10 @@ LL | fn angle2<T>() where for<'a> T: Foo<Item=&'a i32> { | ^^^^^^^^^^^^ error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-in-binding-only.rs:27:27 + --> $DIR/bound-lifetime-in-binding-only.rs:27:31 | -LL | fn angle3(_: &for<'a> Foo<Item=&'a i32>) { - | ^^^^^^^^^^^^ +LL | fn angle3(_: &dyn for<'a> Foo<Item=&'a i32>) { + | ^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr index 8c9480027e6..74bc84c222a 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.paren.stderr @@ -17,10 +17,10 @@ LL | fn paren2<T>() where for<'a> T: Fn() -> &'a i32 { | ^^^^^^^ error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/bound-lifetime-in-binding-only.rs:47:31 + --> $DIR/bound-lifetime-in-binding-only.rs:47:35 | -LL | fn paren3(_: &for<'a> Fn() -> &'a i32) { - | ^^^^^^^ +LL | fn paren3(_: &dyn for<'a> Fn() -> &'a i32) { + | ^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs index e1989d35bbb..843f5f06195 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs @@ -24,7 +24,7 @@ fn angle2<T>() where for<'a> T: Foo<Item=&'a i32> { } #[cfg(angle)] -fn angle3(_: &for<'a> Foo<Item=&'a i32>) { +fn angle3(_: &dyn for<'a> Foo<Item=&'a i32>) { //[angle]~^ ERROR binding for associated type `Item` references lifetime `'a` } @@ -44,7 +44,7 @@ fn paren2<T>() where for<'a> T: Fn() -> &'a i32 { } #[cfg(paren)] -fn paren3(_: &for<'a> Fn() -> &'a i32) { +fn paren3(_: &dyn for<'a> Fn() -> &'a i32) { //[paren]~^ ERROR binding for associated type `Output` references lifetime `'a` } diff --git a/src/test/ui/associated-types/bound-lifetime-in-return-only.rs b/src/test/ui/associated-types/bound-lifetime-in-return-only.rs index 5a7e086fd47..9c0dc61494d 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-return-only.rs +++ b/src/test/ui/associated-types/bound-lifetime-in-return-only.rs @@ -38,11 +38,11 @@ fn elision(_: fn() -> &i32) { struct Parameterized<'a> { x: &'a str } #[cfg(ok)] -fn ok1(_: &for<'a> Fn(&Parameterized<'a>) -> &'a i32) { +fn ok1(_: &dyn for<'a> Fn(&Parameterized<'a>) -> &'a i32) { } #[cfg(ok)] -fn ok2(_: &for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { +fn ok2(_: &dyn for<'a,'b> Fn<(&'b Parameterized<'a>,), Output=&'a i32>) { } #[rustc_error] diff --git a/src/test/ui/async-await/async-with-closure.rs b/src/test/ui/async-await/async-with-closure.rs index 856a778078a..e94a5f0853d 100644 --- a/src/test/ui/async-await/async-with-closure.rs +++ b/src/test/ui/async-await/async-with-closure.rs @@ -19,7 +19,7 @@ struct MyStream<C: ?Sized + MyClosure> { async fn get_future<C: ?Sized + MyClosure>(_stream: MyStream<C>) {} async fn f() { - let messages: MyStream<FnMut()> = unimplemented!(); + let messages: MyStream<dyn FnMut()> = unimplemented!(); await!(get_future(messages)); } diff --git a/src/test/ui/async-await/issues/issue-53249.rs b/src/test/ui/async-await/issues/issue-53249.rs index 9e4ff43ecd1..2157cf7d4f7 100644 --- a/src/test/ui/async-await/issues/issue-53249.rs +++ b/src/test/ui/async-await/issues/issue-53249.rs @@ -35,7 +35,7 @@ impl<R, F> Future for Lazy<F> } async fn __receive<WantFn, Fut>(want: WantFn) -> () - where Fut: Future<Output = ()>, WantFn: Fn(&Box<Send + 'static>) -> Fut, + where Fut: Future<Output = ()>, WantFn: Fn(&Box<dyn Send + 'static>) -> Fut, { await!(lazy(|_| ())); } diff --git a/src/test/ui/async-await/issues/issue-54974.rs b/src/test/ui/async-await/issues/issue-54974.rs index d6f18875c9e..ad18f411875 100644 --- a/src/test/ui/async-await/issues/issue-54974.rs +++ b/src/test/ui/async-await/issues/issue-54974.rs @@ -9,7 +9,7 @@ trait SomeTrait: Send + Sync + 'static { fn do_something(&self); } -async fn my_task(obj: Arc<SomeTrait>) { +async fn my_task(obj: Arc<dyn SomeTrait>) { unimplemented!() } diff --git a/src/test/ui/bad/bad-sized.rs b/src/test/ui/bad/bad-sized.rs index 0da4e456f08..b899c59ff2e 100644 --- a/src/test/ui/bad/bad-sized.rs +++ b/src/test/ui/bad/bad-sized.rs @@ -1,7 +1,7 @@ trait Trait {} pub fn main() { - let x: Vec<Trait + Sized> = Vec::new(); + let x: Vec<dyn Trait + Sized> = Vec::new(); //~^ ERROR only auto traits can be used as additional traits in a trait object //~| ERROR the size for values of type //~| ERROR the size for values of type diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr index 6307af5d725..e9ded557281 100644 --- a/src/test/ui/bad/bad-sized.stderr +++ b/src/test/ui/bad/bad-sized.stderr @@ -1,29 +1,29 @@ error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/bad-sized.rs:4:24 + --> $DIR/bad-sized.rs:4:28 | -LL | let x: Vec<Trait + Sized> = Vec::new(); - | ----- ^^^^^ - | | | - | | additional non-auto trait - | | trait alias used in trait object type (additional use) - | first non-auto trait - | trait alias used in trait object type (first use) +LL | let x: Vec<dyn Trait + Sized> = Vec::new(); + | ----- ^^^^^ + | | | + | | additional non-auto trait + | | trait alias used in trait object type (additional use) + | first non-auto trait + | trait alias used in trait object type (first use) error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time --> $DIR/bad-sized.rs:4:12 | -LL | let x: Vec<Trait + Sized> = Vec::new(); - | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +LL | let x: Vec<dyn Trait + Sized> = Vec::new(); + | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: required by `std::vec::Vec` error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time - --> $DIR/bad-sized.rs:4:33 + --> $DIR/bad-sized.rs:4:37 | -LL | let x: Vec<Trait + Sized> = Vec::new(); - | ^^^^^^^^ doesn't have a size known at compile-time +LL | let x: Vec<dyn Trait + Sized> = Vec::new(); + | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs index 5e853afd38c..b4d85b60cd5 100644 --- a/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs +++ b/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.rs @@ -8,7 +8,7 @@ trait Foo { fn f2(&mut self); } -fn test(x: &mut Foo) { +fn test(x: &mut dyn Foo) { let y = x.f1(); x.f2(); //~ ERROR cannot borrow `*x` as mutable y.use_ref(); diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.rs b/src/test/ui/borrowck/borrowck-consume-upcast-box.rs index ed669c4d901..6b32d185b6f 100644 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.rs +++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.rs @@ -2,10 +2,10 @@ trait Foo { fn dummy(&self); } -fn consume(_: Box<Foo>) { +fn consume(_: Box<dyn Foo>) { } -fn foo(b: Box<Foo+Send>) { +fn foo(b: Box<dyn Foo + Send>) { consume(b); consume(b); //~ ERROR use of moved value } diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr index e8194ad6944..356cda01e29 100644 --- a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr +++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr @@ -1,7 +1,7 @@ error[E0382]: use of moved value: `b` --> $DIR/borrowck-consume-upcast-box.rs:10:13 | -LL | fn foo(b: Box<Foo+Send>) { +LL | fn foo(b: Box<dyn Foo + Send>) { | - move occurs because `b` has type `std::boxed::Box<dyn Foo + std::marker::Send>`, which does not implement the `Copy` trait LL | consume(b); | - value moved here diff --git a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs index a44e3031e25..b50d455637b 100644 --- a/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs +++ b/src/test/ui/borrowck/borrowck-escaping-closure-error-2.rs @@ -6,7 +6,7 @@ // closure may outlive the current function, but it borrows `books`, // which is owned by the current function -fn foo<'a>(x: &'a i32) -> Box<FnMut()+'a> { +fn foo<'a>(x: &'a i32) -> Box<dyn FnMut() + 'a> { let mut books = vec![1,2,3]; Box::new(|| books.push(4)) //~^ ERROR E0373 diff --git a/src/test/ui/borrowck/borrowck-in-static.rs b/src/test/ui/borrowck/borrowck-in-static.rs index 43bb652a024..c468740bc3b 100644 --- a/src/test/ui/borrowck/borrowck-in-static.rs +++ b/src/test/ui/borrowck/borrowck-in-static.rs @@ -1,6 +1,6 @@ // check that borrowck looks inside consts/statics -static FN : &'static (Fn() -> (Box<Fn()->Box<i32>>) + Sync) = &|| { +static FN : &'static (dyn Fn() -> (Box<dyn Fn()->Box<i32>>) + Sync) = &|| { let x = Box::new(0); Box::new(|| x) //~ ERROR cannot move out of captured variable in an `Fn` closure }; diff --git a/src/test/ui/borrowck/borrowck-object-lifetime.rs b/src/test/ui/borrowck/borrowck-object-lifetime.rs index 495516cf976..137a9adbc40 100644 --- a/src/test/ui/borrowck/borrowck-object-lifetime.rs +++ b/src/test/ui/borrowck/borrowck-object-lifetime.rs @@ -8,26 +8,26 @@ trait Foo { fn mut_borrowed(&mut self) -> &(); } -fn borrowed_receiver(x: &Foo) { +fn borrowed_receiver(x: &dyn Foo) { let y = x.borrowed(); let z = x.borrowed(); z.use_ref(); y.use_ref(); } -fn mut_borrowed_receiver(x: &mut Foo) { +fn mut_borrowed_receiver(x: &mut dyn Foo) { let y = x.borrowed(); let z = x.mut_borrowed(); //~ ERROR cannot borrow y.use_ref(); } -fn mut_owned_receiver(mut x: Box<Foo>) { +fn mut_owned_receiver(mut x: Box<dyn Foo>) { let y = x.borrowed(); let z = &mut x; //~ ERROR cannot borrow y.use_ref(); } -fn imm_owned_receiver(mut x: Box<Foo>) { +fn imm_owned_receiver(mut x: Box<dyn Foo>) { let y = x.borrowed(); let z = &x; z.use_ref(); diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs index 1e272372f6c..3ce72161814 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.rs @@ -6,5 +6,5 @@ impl Foo for i32 { } fn main() { let x: &i32; - let y = x as *const Foo; //~ ERROR [E0381] + let y = x as *const dyn Foo; //~ ERROR [E0381] } diff --git a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr index df610cbb561..2b80140c6b3 100644 --- a/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr +++ b/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.stderr @@ -1,7 +1,7 @@ error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13 | -LL | let y = x as *const Foo; +LL | let y = x as *const dyn Foo; | ^ use of possibly uninitialized `*x` error: aborting due to previous error diff --git a/src/test/ui/borrowck/regions-escape-unboxed-closure.rs b/src/test/ui/borrowck/regions-escape-unboxed-closure.rs index 62ddf4decfc..d8bef927fd7 100644 --- a/src/test/ui/borrowck/regions-escape-unboxed-closure.rs +++ b/src/test/ui/borrowck/regions-escape-unboxed-closure.rs @@ -1,4 +1,4 @@ -fn with_int(f: &mut FnMut(&isize)) { +fn with_int(f: &mut dyn FnMut(&isize)) { } fn main() { diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr index fca425da34d..baf122df5e2 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr @@ -29,7 +29,7 @@ LL | f(f(10)); error[E0382]: use of moved value: `f` --> $DIR/two-phase-nonrecv-autoref.rs:80:11 | -LL | fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) { +LL | fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) { | - move occurs because `f` has type `std::boxed::Box<dyn std::ops::FnOnce(i32) -> i32>`, which does not implement the `Copy` trait LL | f(f(10)); | - ^ value used here after move diff --git a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs index c0a117d6766..b29664e3d8c 100644 --- a/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/ui/borrowck/two-phase-nonrecv-autoref.rs @@ -68,15 +68,15 @@ fn overloaded_call_traits() { //[g2p]~^^ ERROR use of moved value: `f` } - fn twice_ten_om(f: &mut FnMut(i32) -> i32) { + fn twice_ten_om(f: &mut dyn FnMut(i32) -> i32) { f(f(10)); //[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time //[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time } - fn twice_ten_oi(f: &mut Fn(i32) -> i32) { + fn twice_ten_oi(f: &mut dyn Fn(i32) -> i32) { f(f(10)); } - fn twice_ten_oo(f: Box<FnOnce(i32) -> i32>) { + fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) { f(f(10)); //[nll]~^ ERROR use of moved value: `f` //[g2p]~^^ ERROR use of moved value: `f` diff --git a/src/test/ui/bounds-lifetime.rs b/src/test/ui/bounds-lifetime.rs index 8abfe3e4b76..31aa4011b91 100644 --- a/src/test/ui/bounds-lifetime.rs +++ b/src/test/ui/bounds-lifetime.rs @@ -2,6 +2,6 @@ type A = for<'b, 'a: 'b> fn(); //~ ERROR lifetime bounds cannot be used in this type B = for<'b, 'a: 'b,> fn(); //~ ERROR lifetime bounds cannot be used in this context type C = for<'b, 'a: 'b +> fn(); //~ ERROR lifetime bounds cannot be used in this context type D = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context -type E = for<T> Fn(); //~ ERROR only lifetime parameters can be used in this context +type E = dyn for<T> Fn(); //~ ERROR only lifetime parameters can be used in this context fn main() {} diff --git a/src/test/ui/bounds-lifetime.stderr b/src/test/ui/bounds-lifetime.stderr index 21a78146267..a0395ed4904 100644 --- a/src/test/ui/bounds-lifetime.stderr +++ b/src/test/ui/bounds-lifetime.stderr @@ -23,10 +23,10 @@ LL | type D = for<'a, T> fn(); | ^ error: only lifetime parameters can be used in this context - --> $DIR/bounds-lifetime.rs:5:14 + --> $DIR/bounds-lifetime.rs:5:18 | -LL | type E = for<T> Fn(); - | ^ +LL | type E = dyn for<T> Fn(); + | ^ error: aborting due to 5 previous errors diff --git a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs index ac859c51263..5342b595c7c 100644 --- a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs +++ b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.rs @@ -1,4 +1,4 @@ fn main() { - &1 as Send; //~ ERROR cast to unsized - Box::new(1) as Send; //~ ERROR cast to unsized + &1 as dyn Send; //~ ERROR cast to unsized + Box::new(1) as dyn Send; //~ ERROR cast to unsized } diff --git a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr index bd7a0e1834a..ffa02533d8b 100644 --- a/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr +++ b/src/test/ui/cast/cast-to-unsized-trait-object-suggestion.stderr @@ -1,18 +1,18 @@ error[E0620]: cast to unsized type: `&{integer}` as `dyn std::marker::Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:2:5 | -LL | &1 as Send; - | ^^^^^^---- +LL | &1 as dyn Send; + | ^^^^^^-------- | | - | help: try casting to a reference instead: `&Send` + | help: try casting to a reference instead: `&dyn Send` error[E0620]: cast to unsized type: `std::boxed::Box<{integer}>` as `dyn std::marker::Send` --> $DIR/cast-to-unsized-trait-object-suggestion.rs:3:5 | -LL | Box::new(1) as Send; - | ^^^^^^^^^^^^^^^---- +LL | Box::new(1) as dyn Send; + | ^^^^^^^^^^^^^^^-------- | | - | help: try casting to a `Box` instead: `Box<Send>` + | help: try casting to a `Box` instead: `Box<dyn Send>` error: aborting due to 2 previous errors diff --git a/src/test/ui/casts-differing-anon.rs b/src/test/ui/casts-differing-anon.rs index cba178104c9..d4a0f961305 100644 --- a/src/test/ui/casts-differing-anon.rs +++ b/src/test/ui/casts-differing-anon.rs @@ -5,7 +5,7 @@ fn foo() -> Box<impl fmt::Debug+?Sized> { x } fn bar() -> Box<impl fmt::Debug+?Sized> { - let y: Box<fmt::Debug> = Box::new([0]); + let y: Box<dyn fmt::Debug> = Box::new([0]); y } diff --git a/src/test/ui/class-cast-to-trait.rs b/src/test/ui/class-cast-to-trait.rs index 3ae4987254f..bb4c3fac938 100644 --- a/src/test/ui/class-cast-to-trait.rs +++ b/src/test/ui/class-cast-to-trait.rs @@ -49,6 +49,6 @@ fn cat(in_x : usize, in_y : isize, in_name: String) -> Cat { } fn main() { - let nyan: Box<Noisy> = box cat(0, 2, "nyan".to_string()) as Box<Noisy>; + let nyan: Box<dyn Noisy> = box cat(0, 2, "nyan".to_string()) as Box<dyn Noisy>; nyan.eat(); //~ ERROR no method named `eat` found } diff --git a/src/test/ui/closure_context/issue-26046-fn-mut.rs b/src/test/ui/closure_context/issue-26046-fn-mut.rs index e5840181e41..0a015ea1436 100644 --- a/src/test/ui/closure_context/issue-26046-fn-mut.rs +++ b/src/test/ui/closure_context/issue-26046-fn-mut.rs @@ -1,4 +1,4 @@ -fn foo() -> Box<Fn()> { +fn foo() -> Box<dyn Fn()> { let num = 5; let closure = || { //~ ERROR expected a closure that diff --git a/src/test/ui/closure_context/issue-26046-fn-once.rs b/src/test/ui/closure_context/issue-26046-fn-once.rs index d33420c52a0..511690e9dd4 100644 --- a/src/test/ui/closure_context/issue-26046-fn-once.rs +++ b/src/test/ui/closure_context/issue-26046-fn-once.rs @@ -1,4 +1,4 @@ -fn get_closure() -> Box<Fn() -> Vec<u8>> { +fn get_closure() -> Box<dyn Fn() -> Vec<u8>> { let vec = vec![1u8, 2u8]; let closure = move || { //~ ERROR expected a closure diff --git a/src/test/ui/closures/closure-immutable-outer-variable.fixed b/src/test/ui/closures/closure-immutable-outer-variable.fixed index 03240d4857c..102f1f94a36 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.fixed +++ b/src/test/ui/closures/closure-immutable-outer-variable.fixed @@ -2,7 +2,7 @@ // Point at the captured immutable outer variable -fn foo(mut f: Box<FnMut()>) { +fn foo(mut f: Box<dyn FnMut()>) { f(); } diff --git a/src/test/ui/closures/closure-immutable-outer-variable.rs b/src/test/ui/closures/closure-immutable-outer-variable.rs index 8fa9e44845d..6eb43b372c9 100644 --- a/src/test/ui/closures/closure-immutable-outer-variable.rs +++ b/src/test/ui/closures/closure-immutable-outer-variable.rs @@ -2,7 +2,7 @@ // Point at the captured immutable outer variable -fn foo(mut f: Box<FnMut()>) { +fn foo(mut f: Box<dyn FnMut()>) { f(); } diff --git a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs index f35fbad7cd6..414acfd84ce 100644 --- a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs +++ b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] trait C {} -impl C { fn f() {} } //~ ERROR duplicate -impl C { fn f() {} } +impl dyn C { fn f() {} } //~ ERROR duplicate +impl dyn C { fn f() {} } fn main() { } diff --git a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr index 16cdca774ba..a97161b131d 100644 --- a/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr +++ b/src/test/ui/codemap_tests/coherence-overlapping-inherent-impl-trait.stderr @@ -1,10 +1,10 @@ error[E0592]: duplicate definitions with name `f` - --> $DIR/coherence-overlapping-inherent-impl-trait.rs:4:10 + --> $DIR/coherence-overlapping-inherent-impl-trait.rs:4:14 | -LL | impl C { fn f() {} } - | ^^^^^^^^^ duplicate definitions for `f` -LL | impl C { fn f() {} } - | --------- other definition for `f` +LL | impl dyn C { fn f() {} } + | ^^^^^^^^^ duplicate definitions for `f` +LL | impl dyn C { fn f() {} } + | --------- other definition for `f` error: aborting due to previous error diff --git a/src/test/ui/codemap_tests/two_files_data.rs b/src/test/ui/codemap_tests/two_files_data.rs index db8ab14e673..b4d2f5d3c6d 100644 --- a/src/test/ui/codemap_tests/two_files_data.rs +++ b/src/test/ui/codemap_tests/two_files_data.rs @@ -2,4 +2,4 @@ trait Foo { } -type Bar = Foo; +type Bar = dyn Foo; diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs index 9a4e134cb39..c139e823c2a 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs @@ -10,23 +10,23 @@ pub fn main() { let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>; //~^ ERROR mismatched types - let _ = box { |x| (x as u8) }: Box<Fn(i32) -> _>; //~ ERROR mismatched types - let _ = box if true { false } else { true }: Box<Debug>; //~ ERROR mismatched types - let _ = box match true { true => 'a', false => 'b' }: Box<Debug>; //~ ERROR mismatched types + let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types + let _ = box if true { false } else { true }: Box<dyn Debug>; //~ ERROR mismatched types + let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>; //~ ERROR mismatched types let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; //~^ ERROR mismatched types - let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types - let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types - let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types + let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; //~ ERROR mismatched types + let _ = &if true { false } else { true }: &dyn Debug; //~ ERROR mismatched types + let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; //~ ERROR mismatched types let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types - let _ = Box::new(|x| (x as u8)): Box<Fn(i32) -> _>; //~ ERROR mismatched types + let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>; //~ ERROR mismatched types let _ = vec![ Box::new(|x| (x as u8)), box |x| (x as i16 as u8), - ]: Vec<Box<Fn(i32) -> _>>; + ]: Vec<Box<dyn Fn(i32) -> _>>; } diff --git a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr index be362c9a78b..3b81610a06e 100644 --- a/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/src/test/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -28,7 +28,7 @@ LL | let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:13:13 | -LL | let _ = box { |x| (x as u8) }: Box<Fn(i32) -> _>; +LL | let _ = box { |x| (x as u8) }: Box<dyn Fn(i32) -> _>; | ^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure | = note: expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> u8>` @@ -37,7 +37,7 @@ LL | let _ = box { |x| (x as u8) }: Box<Fn(i32) -> _>; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:14:13 | -LL | let _ = box if true { false } else { true }: Box<Debug>; +LL | let _ = box if true { false } else { true }: Box<dyn Debug>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool | = note: expected type `std::boxed::Box<dyn std::fmt::Debug>` @@ -46,7 +46,7 @@ LL | let _ = box if true { false } else { true }: Box<Debug>; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:15:13 | -LL | let _ = box match true { true => 'a', false => 'b' }: Box<Debug>; +LL | let _ = box match true { true => 'a', false => 'b' }: Box<dyn Debug>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char | = note: expected type `std::boxed::Box<dyn std::fmt::Debug>` @@ -82,7 +82,7 @@ LL | let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32]; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:21:13 | -LL | let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; +LL | let _ = &{ |x| (x as u8) }: &dyn Fn(i32) -> _; | ^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure | = note: expected type `&dyn std::ops::Fn(i32) -> u8` @@ -91,7 +91,7 @@ LL | let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:22:13 | -LL | let _ = &if true { false } else { true }: &Debug; +LL | let _ = &if true { false } else { true }: &dyn Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool | = note: expected type `&dyn std::fmt::Debug` @@ -100,7 +100,7 @@ LL | let _ = &if true { false } else { true }: &Debug; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:23:13 | -LL | let _ = &match true { true => 'a', false => 'b' }: &Debug; +LL | let _ = &match true { true => 'a', false => 'b' }: &dyn Debug; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char | = note: expected type `&dyn std::fmt::Debug` @@ -118,7 +118,7 @@ LL | let _ = Box::new([1, 2, 3]): Box<[i32]>; error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:26:13 | -LL | let _ = Box::new(|x| (x as u8)): Box<Fn(i32) -> _>; +LL | let _ = Box::new(|x| (x as u8)): Box<dyn Fn(i32) -> _>; | ^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure | = note: expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> _>` diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr index b48f6bbfb94..c38d7456a99 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 | -LL | impl NotObjectSafe for NotObjectSafe { } +LL | impl NotObjectSafe for dyn NotObjectSafe { } | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object | = note: method `eq` references the `Self` type in its arguments or return type diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr index b48f6bbfb94..c38d7456a99 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 | -LL | impl NotObjectSafe for NotObjectSafe { } +LL | impl NotObjectSafe for dyn NotObjectSafe { } | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object | = note: method `eq` references the `Self` type in its arguments or return type diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs index 803e8fc6bca..b4c88e93783 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs @@ -8,7 +8,7 @@ // If the trait is not object-safe, we give a more tailored message // because we're such schnuckels: trait NotObjectSafe { fn eq(&self, other: Self); } -impl NotObjectSafe for NotObjectSafe { } +impl NotObjectSafe for dyn NotObjectSafe { } //[old]~^ ERROR E0038 //[re]~^^ ERROR E0038 diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr index 324747603f9..4819ce9260e 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr @@ -1,20 +1,20 @@ error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` --> $DIR/coherence-impl-trait-for-trait.rs:13:1 | -LL | impl Foo for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` +LL | impl Foo for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` --> $DIR/coherence-impl-trait-for-trait.rs:16:1 | -LL | impl Bar for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` +LL | impl Bar for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` --> $DIR/coherence-impl-trait-for-trait.rs:19:1 | -LL | impl Baz for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` +LL | impl Baz for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr index 324747603f9..4819ce9260e 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr @@ -1,20 +1,20 @@ error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` --> $DIR/coherence-impl-trait-for-trait.rs:13:1 | -LL | impl Foo for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` +LL | impl Foo for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` --> $DIR/coherence-impl-trait-for-trait.rs:16:1 | -LL | impl Bar for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` +LL | impl Bar for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` --> $DIR/coherence-impl-trait-for-trait.rs:19:1 | -LL | impl Baz for Baz { } - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` +LL | impl Baz for dyn Baz { } + | ^^^^^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs index dcaf564fdec..3ce3dca0660 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs @@ -10,18 +10,18 @@ trait Bar: Foo { } trait Baz: Bar { } // Supertraits of Baz are not legal: -impl Foo for Baz { } +impl Foo for dyn Baz { } //[old]~^ ERROR E0371 //[re]~^^ ERROR E0371 -impl Bar for Baz { } +impl Bar for dyn Baz { } //[old]~^ ERROR E0371 //[re]~^^ ERROR E0371 -impl Baz for Baz { } +impl Baz for dyn Baz { } //[old]~^ ERROR E0371 //[re]~^^ ERROR E0371 // But other random traits are: trait Other { } -impl Other for Baz { } // OK, Other not a supertrait of Baz +impl Other for dyn Baz { } // OK, Other not a supertrait of Baz fn main() { } diff --git a/src/test/ui/confuse-field-and-method/issue-2392.rs b/src/test/ui/confuse-field-and-method/issue-2392.rs index c242b6c2c20..8aef091fe31 100644 --- a/src/test/ui/confuse-field-and-method/issue-2392.rs +++ b/src/test/ui/confuse-field-and-method/issue-2392.rs @@ -14,7 +14,7 @@ struct Obj<F> where F: FnOnce() -> u32 { } struct BoxedObj { - boxed_closure: Box<FnOnce() -> u32>, + boxed_closure: Box<dyn FnOnce() -> u32>, } struct Wrapper<F> where F: FnMut() -> u32 { @@ -25,8 +25,8 @@ fn func() -> u32 { 0 } -fn check_expression() -> Obj<Box<FnOnce() -> u32>> { - Obj { closure: Box::new(|| 42_u32) as Box<FnOnce() -> u32>, not_closure: 42 } +fn check_expression() -> Obj<Box<dyn FnOnce() -> u32>> { + Obj { closure: Box::new(|| 42_u32) as Box<dyn FnOnce() -> u32>, not_closure: 42 } } fn main() { @@ -44,7 +44,7 @@ fn main() { let boxed_fn = BoxedObj { boxed_closure: Box::new(func) }; boxed_fn.boxed_closure();//~ ERROR no method named `boxed_closure` found - let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<FnOnce() -> u32> }; + let boxed_closure = BoxedObj { boxed_closure: Box::new(|| 42_u32) as Box<dyn FnOnce() -> u32> }; boxed_closure.boxed_closure();//~ ERROR no method named `boxed_closure` found // test expression writing in the notes diff --git a/src/test/ui/confuse-field-and-method/issue-32128.rs b/src/test/ui/confuse-field-and-method/issue-32128.rs index 02c6838d419..5a024aa4b67 100644 --- a/src/test/ui/confuse-field-and-method/issue-32128.rs +++ b/src/test/ui/confuse-field-and-method/issue-32128.rs @@ -1,5 +1,5 @@ struct Example { - example: Box<Fn(i32) -> i32> + example: Box<dyn Fn(i32) -> i32> } fn main() { diff --git a/src/test/ui/consts/const-eval/const_transmute.rs b/src/test/ui/consts/const-eval/const_transmute.rs index e4f7fb155ab..4726f9dde3a 100644 --- a/src/test/ui/consts/const-eval/const_transmute.rs +++ b/src/test/ui/consts/const-eval/const_transmute.rs @@ -41,7 +41,7 @@ struct VTable { bar: for<'a> fn(&'a Foo) -> u32, } -const FOO: &Bar = &Foo { foo: 128, bar: false }; +const FOO: &dyn Bar = &Foo { foo: 128, bar: false }; const G: Fat = unsafe { Transmute { t: FOO }.u }; const F: Option<for<'a> fn(&'a mut Foo)> = G.1.drop; const H: for<'a> fn(&'a Foo) -> u32 = G.1.bar; diff --git a/src/test/ui/consts/const-eval/issue-53401.rs b/src/test/ui/consts/const-eval/issue-53401.rs index 89834aa94fc..e8ac5a90880 100644 --- a/src/test/ui/consts/const-eval/issue-53401.rs +++ b/src/test/ui/consts/const-eval/issue-53401.rs @@ -1,6 +1,6 @@ // compile-pass -pub const STATIC_TRAIT: &Test = &(); +pub const STATIC_TRAIT: &dyn Test = &(); fn main() {} diff --git a/src/test/ui/consts/const-eval/ub-upvars.rs b/src/test/ui/consts/const-eval/ub-upvars.rs index 9b7bca6b72d..0a427cd8857 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.rs +++ b/src/test/ui/consts/const-eval/ub-upvars.rs @@ -3,7 +3,7 @@ use std::mem; -const BAD_UPVAR: &FnOnce() = &{ //~ ERROR it is undefined behavior to use this value +const BAD_UPVAR: &dyn FnOnce() = &{ //~ ERROR it is undefined behavior to use this value let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; let another_var = 13; move || { let _ = bad_ref; let _ = another_var; } diff --git a/src/test/ui/consts/const-eval/ub-upvars.stderr b/src/test/ui/consts/const-eval/ub-upvars.stderr index 21d2847db1e..f8273ba902a 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.stderr +++ b/src/test/ui/consts/const-eval/ub-upvars.stderr @@ -1,7 +1,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-upvars.rs:6:1 | -LL | / const BAD_UPVAR: &FnOnce() = &{ +LL | / const BAD_UPVAR: &dyn FnOnce() = &{ LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; LL | | let another_var = 13; LL | | move || { let _ = bad_ref; let _ = another_var; } diff --git a/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs b/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs index 13489c50a12..d5405f3441f 100644 --- a/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs +++ b/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs @@ -59,7 +59,7 @@ union DynTransmute { repr: DynRepr, repr2: DynRepr2, bad: BadDynRepr, - rust: &'static Trait, + rust: &'static dyn Trait, } trait Trait {} @@ -94,17 +94,17 @@ const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: & //~^ ERROR it is undefined behavior to use this value // bad trait object -const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; +const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; //~^ ERROR it is undefined behavior to use this value // bad trait object -const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; +const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; //~^ ERROR it is undefined behavior to use this value // bad trait object -const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; +const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; //~^ ERROR it is undefined behavior to use this value // bad data *inside* the trait object -const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; +const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl }; //~^ ERROR it is undefined behavior to use this value // bad data *inside* the slice diff --git a/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr b/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr index 761a5fc4445..5048a97d195 100644 --- a/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr +++ b/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr @@ -41,32 +41,32 @@ LL | const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, l error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:97:1 | -LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable +LL | const D: &dyn Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:100:1 | -LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable +LL | const E: &dyn Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:103:1 | -LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-pointer vtable in fat pointer +LL | const F: &dyn Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-pointer vtable in fat pointer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: it is undefined behavior to use this value --> $DIR/union-ub-fat-ptr.rs:107:1 | -LL | const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.<dyn-downcast>, but expected something less or equal to 1 +LL | const G: &dyn Trait = &unsafe { BoolTransmute { val: 3 }.bl }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.<dyn-downcast>, but expected something less or equal to 1 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior diff --git a/src/test/ui/consts/const-unsized.rs b/src/test/ui/consts/const-unsized.rs index e20ded68ceb..319b8ef97de 100644 --- a/src/test/ui/consts/const-unsized.rs +++ b/src/test/ui/consts/const-unsized.rs @@ -1,12 +1,12 @@ use std::fmt::Debug; -const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); +const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type const CONST_FOO: str = *"foo"; //~^ ERROR the size for values of type -static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); +static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type static STATIC_BAR: str = *"bar"; diff --git a/src/test/ui/consts/const-unsized.stderr b/src/test/ui/consts/const-unsized.stderr index 0f996fcd943..beeea87bfb1 100644 --- a/src/test/ui/consts/const-unsized.stderr +++ b/src/test/ui/consts/const-unsized.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time --> $DIR/const-unsized.rs:3:16 | -LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); - | ^^^^^^^^^^ doesn't have a size known at compile-time +LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -19,8 +19,8 @@ LL | const CONST_FOO: str = *"foo"; error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time --> $DIR/const-unsized.rs:9:18 | -LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); - | ^^^^^^^^^^ doesn't have a size known at compile-time +LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr index 8d962384a12..7a10c469c51 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr @@ -298,8 +298,8 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable --> $DIR/min_const_fn.rs:144:41 | -LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add #![feature(const_fn)] to the crate attributes to enable diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index 783c79005ae..96b6057c8fd 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -141,7 +141,7 @@ const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } const fn no_unsafe() { unsafe {} } -const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } +const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } //~^ ERROR trait bounds other than `Sized` const fn no_fn_ptrs(_x: fn()) {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index 93b57bc24a8..e388b443d23 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -302,8 +302,8 @@ LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } error[E0723]: trait bounds other than `Sized` on const fn parameters are unstable --> $DIR/min_const_fn.rs:144:41 | -LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add #![feature(const_fn)] to the crate attributes to enable diff --git a/src/test/ui/cross/cross-borrow-trait.rs b/src/test/ui/cross/cross-borrow-trait.rs index d8d7537f24a..274cdad75ec 100644 --- a/src/test/ui/cross/cross-borrow-trait.rs +++ b/src/test/ui/cross/cross-borrow-trait.rs @@ -6,8 +6,8 @@ trait Trait { fn foo(&self) {} } impl Trait for Foo {} pub fn main() { - let x: Box<Trait> = Box::new(Foo); - let _y: &Trait = x; //~ ERROR E0308 - //~| expected type `&dyn Trait` - //~| found type `std::boxed::Box<dyn Trait>` + let x: Box<dyn Trait> = Box::new(Foo); + let _y: &dyn Trait = x; //~ ERROR E0308 + //~| expected type `&dyn Trait` + //~| found type `std::boxed::Box<dyn Trait>` } diff --git a/src/test/ui/cross/cross-borrow-trait.stderr b/src/test/ui/cross/cross-borrow-trait.stderr index b35f59658c0..ada1c0204eb 100644 --- a/src/test/ui/cross/cross-borrow-trait.stderr +++ b/src/test/ui/cross/cross-borrow-trait.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/cross-borrow-trait.rs:10:22 + --> $DIR/cross-borrow-trait.rs:10:26 | -LL | let _y: &Trait = x; - | ^ - | | - | expected &dyn Trait, found struct `std::boxed::Box` - | help: consider borrowing here: `&x` +LL | let _y: &dyn Trait = x; + | ^ + | | + | expected &dyn Trait, found struct `std::boxed::Box` + | help: consider borrowing here: `&x` | = note: expected type `&dyn Trait` found type `std::boxed::Box<dyn Trait>` diff --git a/src/test/ui/custom-test-frameworks-simple.rs b/src/test/ui/custom-test-frameworks-simple.rs index a8aac6ec142..aee0040ef4d 100644 --- a/src/test/ui/custom-test-frameworks-simple.rs +++ b/src/test/ui/custom-test-frameworks-simple.rs @@ -5,7 +5,7 @@ #![test_runner(crate::foo_runner)] #[cfg(test)] -fn foo_runner(ts: &[&Fn(usize)->()]) { +fn foo_runner(ts: &[&dyn Fn(usize)->()]) { for (i, t) in ts.iter().enumerate() { t(i); } diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs index d658753eb24..6175b7df110 100644 --- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs +++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.rs @@ -1,7 +1,7 @@ // Test a cycle where a type parameter on a trait has a default that // again references the trait. -trait Foo<X = Box<Foo>> { +trait Foo<X = Box<dyn Foo>> { //~^ ERROR cycle detected } diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr index aa45462a52e..e89d25742a0 100644 --- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr +++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr @@ -1,15 +1,15 @@ error[E0391]: cycle detected when processing `Foo::X` - --> $DIR/cycle-trait-default-type-trait.rs:4:19 + --> $DIR/cycle-trait-default-type-trait.rs:4:23 | -LL | trait Foo<X = Box<Foo>> { - | ^^^ +LL | trait Foo<X = Box<dyn Foo>> { + | ^^^ | = note: ...which again requires processing `Foo::X`, completing the cycle note: cycle used when collecting item types in top-level module --> $DIR/cycle-trait-default-type-trait.rs:4:1 | -LL | trait Foo<X = Box<Foo>> { - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Foo<X = Box<dyn Foo>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/destructure-trait-ref.rs b/src/test/ui/destructure-trait-ref.rs index 66be493cb1f..71cf37ca849 100644 --- a/src/test/ui/destructure-trait-ref.rs +++ b/src/test/ui/destructure-trait-ref.rs @@ -18,27 +18,28 @@ fn main() { // if n > m, it's a type mismatch error. // n < m - let &x = &(&1isize as &T); - let &x = &&(&1isize as &T); - let &&x = &&(&1isize as &T); + let &x = &(&1isize as &dyn T); + let &x = &&(&1isize as &dyn T); + let &&x = &&(&1isize as &dyn T); // n == m - let &x = &1isize as &T; //~ ERROR type `&dyn T` cannot be dereferenced - let &&x = &(&1isize as &T); //~ ERROR type `&dyn T` cannot be dereferenced - let box x = box 1isize as Box<T>; //~ ERROR type `std::boxed::Box<dyn T>` cannot be dereferenced + let &x = &1isize as &dyn T; //~ ERROR type `&dyn T` cannot be dereferenced + let &&x = &(&1isize as &dyn T); //~ ERROR type `&dyn T` cannot be dereferenced + let box x = box 1isize as Box<dyn T>; + //~^ ERROR type `std::boxed::Box<dyn T>` cannot be dereferenced // n > m - let &&x = &1isize as &T; + let &&x = &1isize as &dyn T; //~^ ERROR mismatched types //~| expected type `dyn T` //~| found type `&_` //~| expected trait T, found reference - let &&&x = &(&1isize as &T); + let &&&x = &(&1isize as &dyn T); //~^ ERROR mismatched types //~| expected type `dyn T` //~| found type `&_` //~| expected trait T, found reference - let box box x = box 1isize as Box<T>; + let box box x = box 1isize as Box<dyn T>; //~^ ERROR mismatched types //~| expected type `dyn T` //~| found type `std::boxed::Box<_>` diff --git a/src/test/ui/destructure-trait-ref.stderr b/src/test/ui/destructure-trait-ref.stderr index bc3013b78b3..d3ad21eb24f 100644 --- a/src/test/ui/destructure-trait-ref.stderr +++ b/src/test/ui/destructure-trait-ref.stderr @@ -1,25 +1,25 @@ error[E0033]: type `&dyn T` cannot be dereferenced --> $DIR/destructure-trait-ref.rs:26:9 | -LL | let &x = &1isize as &T; +LL | let &x = &1isize as &dyn T; | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `&dyn T` cannot be dereferenced --> $DIR/destructure-trait-ref.rs:27:10 | -LL | let &&x = &(&1isize as &T); +LL | let &&x = &(&1isize as &dyn T); | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `std::boxed::Box<dyn T>` cannot be dereferenced --> $DIR/destructure-trait-ref.rs:28:9 | -LL | let box x = box 1isize as Box<T>; +LL | let box x = box 1isize as Box<dyn T>; | ^^^^^ type `std::boxed::Box<dyn T>` cannot be dereferenced error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:31:10 + --> $DIR/destructure-trait-ref.rs:32:10 | -LL | let &&x = &1isize as &T; +LL | let &&x = &1isize as &dyn T; | ^^ | | | expected trait T, found reference @@ -29,9 +29,9 @@ LL | let &&x = &1isize as &T; found type `&_` error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:36:11 + --> $DIR/destructure-trait-ref.rs:37:11 | -LL | let &&&x = &(&1isize as &T); +LL | let &&&x = &(&1isize as &dyn T); | ^^ | | | expected trait T, found reference @@ -41,9 +41,9 @@ LL | let &&&x = &(&1isize as &T); found type `&_` error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:41:13 + --> $DIR/destructure-trait-ref.rs:42:13 | -LL | let box box x = box 1isize as Box<T>; +LL | let box box x = box 1isize as Box<dyn T>; | ^^^^^ expected trait T, found struct `std::boxed::Box` | = note: expected type `dyn T` diff --git a/src/test/ui/did_you_mean/E0178.rs b/src/test/ui/did_you_mean/E0178.rs index aad95dc2c20..095df640c38 100644 --- a/src/test/ui/did_you_mean/E0178.rs +++ b/src/test/ui/did_you_mean/E0178.rs @@ -1,3 +1,5 @@ +#![allow(bare_trait_objects)] + trait Foo {} struct Bar<'a> { diff --git a/src/test/ui/did_you_mean/E0178.stderr b/src/test/ui/did_you_mean/E0178.stderr index 44e6ddd0eac..58ac6e90823 100644 --- a/src/test/ui/did_you_mean/E0178.stderr +++ b/src/test/ui/did_you_mean/E0178.stderr @@ -1,23 +1,23 @@ error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo` - --> $DIR/E0178.rs:4:8 + --> $DIR/E0178.rs:6:8 | LL | w: &'a Foo + Copy, | ^^^^^^^^^^^^^^ help: try adding parentheses: `&'a (Foo + Copy)` error[E0178]: expected a path on the left-hand side of `+`, not `&'a Foo` - --> $DIR/E0178.rs:5:8 + --> $DIR/E0178.rs:7:8 | LL | x: &'a Foo + 'a, | ^^^^^^^^^^^^ help: try adding parentheses: `&'a (Foo + 'a)` error[E0178]: expected a path on the left-hand side of `+`, not `&'a mut Foo` - --> $DIR/E0178.rs:6:8 + --> $DIR/E0178.rs:8:8 | LL | y: &'a mut Foo + 'a, | ^^^^^^^^^^^^^^^^ help: try adding parentheses: `&'a mut (Foo + 'a)` error[E0178]: expected a path on the left-hand side of `+`, not `fn() -> Foo` - --> $DIR/E0178.rs:7:8 + --> $DIR/E0178.rs:9:8 | LL | z: fn() -> Foo + 'a, | ^^^^^^^^^^^^^^^^ perhaps you forgot parentheses? diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.rs b/src/test/ui/did_you_mean/bad-assoc-ty.rs index 85e36f887be..fccfb7911ce 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.rs +++ b/src/test/ui/did_you_mean/bad-assoc-ty.rs @@ -24,7 +24,7 @@ type F = &'static (u8)::AssocTy; // Qualified paths cannot appear in bounds, so the recovery // should apply to the whole sum and not `(Send)`. -type G = 'static + (Send)::AssocTy; +type G = dyn 'static + (Send)::AssocTy; //~^ ERROR missing angle brackets in associated item path //~| ERROR ambiguous associated type diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index 8c694f9d42b..0ae64edcc05 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -37,8 +37,8 @@ LL | type F = &'static (u8)::AssocTy; error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:27:10 | -LL | type G = 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<'static + (Send)>::AssocTy` +LL | type G = dyn 'static + (Send)::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<dyn 'static + (Send)>::AssocTy` error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:44:10 @@ -94,8 +94,8 @@ LL | type F = &'static (u8)::AssocTy; error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:27:10 | -LL | type G = 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` +LL | type G = dyn 'static + (Send)::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:33:10 diff --git a/src/test/ui/did_you_mean/issue-40006.rs b/src/test/ui/did_you_mean/issue-40006.rs index 75ea02b6a9d..a1184f757e2 100644 --- a/src/test/ui/did_you_mean/issue-40006.rs +++ b/src/test/ui/did_you_mean/issue-40006.rs @@ -1,4 +1,4 @@ -impl X { //~ ERROR cannot be made into an object +impl dyn X { //~ ERROR cannot be made into an object //~^ ERROR missing Y } diff --git a/src/test/ui/did_you_mean/issue-40006.stderr b/src/test/ui/did_you_mean/issue-40006.stderr index f6f7fe5fa38..87e48cd1e1c 100644 --- a/src/test/ui/did_you_mean/issue-40006.stderr +++ b/src/test/ui/did_you_mean/issue-40006.stderr @@ -1,8 +1,8 @@ error: missing `fn`, `type`, or `const` for impl-item declaration - --> $DIR/issue-40006.rs:1:9 + --> $DIR/issue-40006.rs:1:13 | -LL | impl X { - | _________^ +LL | impl dyn X { + | _____________^ LL | | LL | | Y | |____^ missing `fn`, `type`, or `const` @@ -59,8 +59,8 @@ LL | pub hello_method(&self) { error[E0038]: the trait `X` cannot be made into an object --> $DIR/issue-40006.rs:1:6 | -LL | impl X { - | ^ the trait `X` cannot be made into an object +LL | impl dyn X { + | ^^^^^ the trait `X` cannot be made into an object | = note: method `xxx` has no receiver diff --git a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs index a05227416cf..c9a097d3610 100644 --- a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs +++ b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs @@ -1,3 +1,5 @@ +#![allow(bare_trait_objects)] + fn main() { let _: &Copy + 'static; //~ ERROR expected a path //~^ ERROR cannot be made into an object diff --git a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr index de1efcd7e0f..8c6c33b1186 100644 --- a/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr +++ b/src/test/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr @@ -1,17 +1,17 @@ error[E0178]: expected a path on the left-hand side of `+`, not `&Copy` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:2:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 | LL | let _: &Copy + 'static; | ^^^^^^^^^^^^^^^ help: try adding parentheses: `&(Copy + 'static)` error[E0178]: expected a path on the left-hand side of `+`, not `&'static Copy` - --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:6:12 | LL | let _: &'static Copy + 'static; | ^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&'static (Copy + 'static)` error[E0038]: the trait `std::marker::Copy` cannot be made into an object - --> $DIR/trait-object-reference-without-parens-suggestion.rs:2:12 + --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12 | LL | let _: &Copy + 'static; | ^^^^^ the trait `std::marker::Copy` cannot be made into an object diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.rs b/src/test/ui/dropck/dropck_trait_cycle_checked.rs index 128bbb04ee0..bea77dc9f5c 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.rs +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.rs @@ -63,14 +63,14 @@ impl<T:HasId> Drop for CheckId<T> { } trait Obj<'a> : HasId { - fn set0(&self, b: &'a Box<Obj<'a>>); - fn set1(&self, b: &'a Box<Obj<'a>>); + fn set0(&self, b: &'a Box<dyn Obj<'a>>); + fn set1(&self, b: &'a Box<dyn Obj<'a>>); } struct O<'a> { id: Id, - obj0: CheckId<Cell<Option<&'a Box<Obj<'a>>>>>, - obj1: CheckId<Cell<Option<&'a Box<Obj<'a>>>>>, + obj0: CheckId<Cell<Option<&'a Box<dyn Obj<'a>>>>>, + obj1: CheckId<Cell<Option<&'a Box<dyn Obj<'a>>>>>, } impl<'a> HasId for O<'a> { @@ -87,7 +87,7 @@ impl<'a> O<'a> { } } -impl<'a> HasId for Cell<Option<&'a Box<Obj<'a>>>> { +impl<'a> HasId for Cell<Option<&'a Box<dyn Obj<'a>>>> { fn count(&self) -> usize { match self.get() { None => 1, @@ -97,17 +97,17 @@ impl<'a> HasId for Cell<Option<&'a Box<Obj<'a>>>> { } impl<'a> Obj<'a> for O<'a> { - fn set0(&self, b: &'a Box<Obj<'a>>) { + fn set0(&self, b: &'a Box<dyn Obj<'a>>) { self.obj0.v.set(Some(b)) } - fn set1(&self, b: &'a Box<Obj<'a>>) { + fn set1(&self, b: &'a Box<dyn Obj<'a>>) { self.obj1.v.set(Some(b)) } } fn f() { - let (o1, o2, o3): (Box<Obj>, Box<Obj>, Box<Obj>) = (O::new(), O::new(), O::new()); + let (o1, o2, o3): (Box<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (O::new(), O::new(), O::new()); o1.set0(&o2); //~ ERROR `o2` does not live long enough o1.set1(&o3); //~ ERROR `o3` does not live long enough o2.set0(&o2); //~ ERROR `o2` does not live long enough diff --git a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr index 8c669b597c3..1e779208e58 100644 --- a/src/test/ui/dropck/dropck_trait_cycle_checked.stderr +++ b/src/test/ui/dropck/dropck_trait_cycle_checked.stderr @@ -1,8 +1,8 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:111:13 | -LL | let (o1, o2, o3): (Box<Obj>, Box<Obj>, Box<Obj>) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` +LL | let (o1, o2, o3): (Box<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` LL | o1.set0(&o2); | ^^^ borrowed value does not live long enough ... @@ -12,8 +12,8 @@ LL | } error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:112:13 | -LL | let (o1, o2, o3): (Box<Obj>, Box<Obj>, Box<Obj>) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` +LL | let (o1, o2, o3): (Box<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` LL | o1.set0(&o2); LL | o1.set1(&o3); | ^^^ borrowed value does not live long enough @@ -24,8 +24,8 @@ LL | } error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:113:13 | -LL | let (o1, o2, o3): (Box<Obj>, Box<Obj>, Box<Obj>) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` +LL | let (o1, o2, o3): (Box<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` ... LL | o2.set0(&o2); | ^^^ borrowed value does not live long enough @@ -36,8 +36,8 @@ LL | } error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:114:13 | -LL | let (o1, o2, o3): (Box<Obj>, Box<Obj>, Box<Obj>) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o3` is borrowed for `'static` +LL | let (o1, o2, o3): (Box<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` ... LL | o2.set1(&o3); | ^^^ borrowed value does not live long enough @@ -48,8 +48,8 @@ LL | } error[E0597]: `o1` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:115:13 | -LL | let (o1, o2, o3): (Box<Obj>, Box<Obj>, Box<Obj>) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o1` is borrowed for `'static` +LL | let (o1, o2, o3): (Box<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o1` is borrowed for `'static` ... LL | o3.set0(&o1); | ^^^ borrowed value does not live long enough @@ -60,8 +60,8 @@ LL | } error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:116:13 | -LL | let (o1, o2, o3): (Box<Obj>, Box<Obj>, Box<Obj>) = (O::new(), O::new(), O::new()); - | -------- cast requires that `o2` is borrowed for `'static` +LL | let (o1, o2, o3): (Box<dyn Obj>, Box<dyn Obj>, Box<dyn Obj>) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` ... LL | o3.set1(&o2); | ^^^ borrowed value does not live long enough diff --git a/src/test/ui/dst/dst-bad-assign-2.rs b/src/test/ui/dst/dst-bad-assign-2.rs index b4f72d034f5..7ba31bf2e51 100644 --- a/src/test/ui/dst/dst-bad-assign-2.rs +++ b/src/test/ui/dst/dst-bad-assign-2.rs @@ -30,8 +30,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. - let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box<ToBar> = Box::new(Bar1 {f: 36}); + let f5: &mut Fat<dyn ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let z: Box<dyn ToBar> = Box::new(Bar1 {f: 36}); f5.ptr = *z; //~^ ERROR the size for values of type diff --git a/src/test/ui/dst/dst-bad-assign-3.rs b/src/test/ui/dst/dst-bad-assign-3.rs index 5124abc7d82..691909a2317 100644 --- a/src/test/ui/dst/dst-bad-assign-3.rs +++ b/src/test/ui/dst/dst-bad-assign-3.rs @@ -28,8 +28,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. - let f5: &mut Fat<ToBar> = &mut (5, "some str", Bar1 {f :42}); - let z: Box<ToBar> = Box::new(Bar1 {f: 36}); + let f5: &mut Fat<dyn ToBar> = &mut (5, "some str", Bar1 {f :42}); + let z: Box<dyn ToBar> = Box::new(Bar1 {f: 36}); f5.2 = Bar1 {f: 36}; //~^ ERROR mismatched types //~| expected type `dyn ToBar` diff --git a/src/test/ui/dst/dst-bad-assign.rs b/src/test/ui/dst/dst-bad-assign.rs index 003c80b4dc4..4f2648653f0 100644 --- a/src/test/ui/dst/dst-bad-assign.rs +++ b/src/test/ui/dst/dst-bad-assign.rs @@ -30,8 +30,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. - let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box<ToBar> = Box::new(Bar1 {f: 36}); + let f5: &mut Fat<dyn ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + let z: Box<dyn ToBar> = Box::new(Bar1 {f: 36}); f5.ptr = Bar1 {f: 36}; //~^ ERROR mismatched types //~| expected type `dyn ToBar` diff --git a/src/test/ui/dst/dst-bad-coerce1.rs b/src/test/ui/dst/dst-bad-coerce1.rs index 8ca34234c03..7ef237e39e3 100644 --- a/src/test/ui/dst/dst-bad-coerce1.rs +++ b/src/test/ui/dst/dst-bad-coerce1.rs @@ -19,7 +19,7 @@ pub fn main() { // With a trait. let f1 = Fat { ptr: Foo }; let f2: &Fat<Foo> = &f1; - let f3: &Fat<Bar> = f2; + let f3: &Fat<dyn Bar> = f2; //~^ ERROR `Foo: Bar` is not satisfied // Tuple with a vec of isize. @@ -31,6 +31,6 @@ pub fn main() { // Tuple with a trait. let f1 = (Foo,); let f2: &(Foo,) = &f1; - let f3: &(Bar,) = f2; + let f3: &(dyn Bar,) = f2; //~^ ERROR `Foo: Bar` is not satisfied } diff --git a/src/test/ui/dst/dst-bad-coerce1.stderr b/src/test/ui/dst/dst-bad-coerce1.stderr index 3776ce71c61..a48f37b20be 100644 --- a/src/test/ui/dst/dst-bad-coerce1.stderr +++ b/src/test/ui/dst/dst-bad-coerce1.stderr @@ -8,10 +8,10 @@ LL | let f3: &Fat<[usize]> = f2; found type `&Fat<[isize; 3]>` error[E0277]: the trait bound `Foo: Bar` is not satisfied - --> $DIR/dst-bad-coerce1.rs:22:25 + --> $DIR/dst-bad-coerce1.rs:22:29 | -LL | let f3: &Fat<Bar> = f2; - | ^^ the trait `Bar` is not implemented for `Foo` +LL | let f3: &Fat<dyn Bar> = f2; + | ^^ the trait `Bar` is not implemented for `Foo` | = note: required for the cast to the object type `dyn Bar` @@ -25,10 +25,10 @@ LL | let f3: &([usize],) = f2; found type `&([isize; 3],)` error[E0277]: the trait bound `Foo: Bar` is not satisfied - --> $DIR/dst-bad-coerce1.rs:34:23 + --> $DIR/dst-bad-coerce1.rs:34:27 | -LL | let f3: &(Bar,) = f2; - | ^^ the trait `Bar` is not implemented for `Foo` +LL | let f3: &(dyn Bar,) = f2; + | ^^ the trait `Bar` is not implemented for `Foo` | = note: required for the cast to the object type `dyn Bar` diff --git a/src/test/ui/dst/dst-bad-coerce2.rs b/src/test/ui/dst/dst-bad-coerce2.rs index 2bc7ecced0a..e7ce20b8958 100644 --- a/src/test/ui/dst/dst-bad-coerce2.rs +++ b/src/test/ui/dst/dst-bad-coerce2.rs @@ -17,7 +17,7 @@ pub fn main() { // With a trait. let f1 = Fat { ptr: Foo }; let f2: &Fat<Foo> = &f1; - let f3: &mut Fat<Bar> = f2; //~ ERROR mismatched types + let f3: &mut Fat<dyn Bar> = f2; //~ ERROR mismatched types // Tuple with a vec of ints. let f1 = ([1, 2, 3],); @@ -27,5 +27,5 @@ pub fn main() { // Tuple with a trait. let f1 = (Foo,); let f2: &(Foo,) = &f1; - let f3: &mut (Bar,) = f2; //~ ERROR mismatched types + let f3: &mut (dyn Bar,) = f2; //~ ERROR mismatched types } diff --git a/src/test/ui/dst/dst-bad-coerce2.stderr b/src/test/ui/dst/dst-bad-coerce2.stderr index cae4ec51c37..d1da9b6ca07 100644 --- a/src/test/ui/dst/dst-bad-coerce2.stderr +++ b/src/test/ui/dst/dst-bad-coerce2.stderr @@ -8,10 +8,10 @@ LL | let f3: &mut Fat<[isize]> = f2; found type `&Fat<[isize; 3]>` error[E0308]: mismatched types - --> $DIR/dst-bad-coerce2.rs:20:29 + --> $DIR/dst-bad-coerce2.rs:20:33 | -LL | let f3: &mut Fat<Bar> = f2; - | ^^ types differ in mutability +LL | let f3: &mut Fat<dyn Bar> = f2; + | ^^ types differ in mutability | = note: expected type `&mut Fat<dyn Bar>` found type `&Fat<Foo>` @@ -26,10 +26,10 @@ LL | let f3: &mut ([isize],) = f2; found type `&([isize; 3],)` error[E0308]: mismatched types - --> $DIR/dst-bad-coerce2.rs:30:27 + --> $DIR/dst-bad-coerce2.rs:30:31 | -LL | let f3: &mut (Bar,) = f2; - | ^^ types differ in mutability +LL | let f3: &mut (dyn Bar,) = f2; + | ^^ types differ in mutability | = note: expected type `&mut (dyn Bar,)` found type `&(Foo,)` diff --git a/src/test/ui/dst/dst-bad-coerce3.rs b/src/test/ui/dst/dst-bad-coerce3.rs index 58c988520eb..fd5ee3b57bb 100644 --- a/src/test/ui/dst/dst-bad-coerce3.rs +++ b/src/test/ui/dst/dst-bad-coerce3.rs @@ -19,7 +19,7 @@ fn baz<'a>() { // With a trait. let f1 = Fat { ptr: Foo }; let f2: &Fat<Foo> = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a Fat<Bar> = f2; + let f3: &'a Fat<dyn Bar> = f2; // Tuple with a vec of ints. let f1 = ([1, 2, 3],); @@ -29,7 +29,7 @@ fn baz<'a>() { // Tuple with a trait. let f1 = (Foo,); let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough - let f3: &'a (Bar,) = f2; + let f3: &'a (dyn Bar,) = f2; } pub fn main() { diff --git a/src/test/ui/dst/dst-bad-coerce3.stderr b/src/test/ui/dst/dst-bad-coerce3.stderr index 289d451f02a..957e98bbeee 100644 --- a/src/test/ui/dst/dst-bad-coerce3.stderr +++ b/src/test/ui/dst/dst-bad-coerce3.stderr @@ -20,8 +20,8 @@ LL | fn baz<'a>() { ... LL | let f2: &Fat<Foo> = &f1; | ^^^ borrowed value does not live long enough -LL | let f3: &'a Fat<Bar> = f2; - | ------------ type annotation requires that `f1` is borrowed for `'a` +LL | let f3: &'a Fat<dyn Bar> = f2; + | ---------------- type annotation requires that `f1` is borrowed for `'a` ... LL | } | - `f1` dropped here while still borrowed @@ -48,8 +48,8 @@ LL | fn baz<'a>() { ... LL | let f2: &(Foo,) = &f1; | ^^^ borrowed value does not live long enough -LL | let f3: &'a (Bar,) = f2; - | ---------- type annotation requires that `f1` is borrowed for `'a` +LL | let f3: &'a (dyn Bar,) = f2; + | -------------- type annotation requires that `f1` is borrowed for `'a` LL | } | - `f1` dropped here while still borrowed diff --git a/src/test/ui/dst/dst-bad-coercions.rs b/src/test/ui/dst/dst-bad-coercions.rs index 9aa697225d5..bffef378c92 100644 --- a/src/test/ui/dst/dst-bad-coercions.rs +++ b/src/test/ui/dst/dst-bad-coercions.rs @@ -12,15 +12,15 @@ pub fn main() { // Test that we cannot convert from *-ptr to &S and &T let x: *const S = &S; let y: &S = x; //~ ERROR mismatched types - let y: &T = x; //~ ERROR mismatched types + let y: &dyn T = x; //~ ERROR mismatched types // Test that we cannot convert from *-ptr to &S and &T (mut version) let x: *mut S = &mut S; let y: &S = x; //~ ERROR mismatched types - let y: &T = x; //~ ERROR mismatched types + let y: &dyn T = x; //~ ERROR mismatched types // Test that we cannot convert an immutable ptr to a mutable one using *-ptrs - let x: &mut T = &S; //~ ERROR mismatched types - let x: *mut T = &S; //~ ERROR mismatched types + let x: &mut dyn T = &S; //~ ERROR mismatched types + let x: *mut dyn T = &S; //~ ERROR mismatched types let x: *mut S = &S; //~ ERROR mismatched types } diff --git a/src/test/ui/dst/dst-bad-coercions.stderr b/src/test/ui/dst/dst-bad-coercions.stderr index 27016829a07..e4bc6ee0010 100644 --- a/src/test/ui/dst/dst-bad-coercions.stderr +++ b/src/test/ui/dst/dst-bad-coercions.stderr @@ -8,13 +8,13 @@ LL | let y: &S = x; found type `*const S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:15:17 + --> $DIR/dst-bad-coercions.rs:15:21 | -LL | let y: &T = x; - | ^ - | | - | expected &dyn T, found *-ptr - | help: consider borrowing here: `&x` +LL | let y: &dyn T = x; + | ^ + | | + | expected &dyn T, found *-ptr + | help: consider borrowing here: `&x` | = note: expected type `&dyn T` found type `*const S` @@ -29,31 +29,31 @@ LL | let y: &S = x; found type `*mut S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:20:17 + --> $DIR/dst-bad-coercions.rs:20:21 | -LL | let y: &T = x; - | ^ - | | - | expected &dyn T, found *-ptr - | help: consider borrowing here: `&x` +LL | let y: &dyn T = x; + | ^ + | | + | expected &dyn T, found *-ptr + | help: consider borrowing here: `&x` | = note: expected type `&dyn T` found type `*mut S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:23:21 + --> $DIR/dst-bad-coercions.rs:23:25 | -LL | let x: &mut T = &S; - | ^^ types differ in mutability +LL | let x: &mut dyn T = &S; + | ^^ types differ in mutability | = note: expected type `&mut dyn T` found type `&S` error[E0308]: mismatched types - --> $DIR/dst-bad-coercions.rs:24:21 + --> $DIR/dst-bad-coercions.rs:24:25 | -LL | let x: *mut T = &S; - | ^^ types differ in mutability +LL | let x: *mut dyn T = &S; + | ^^ types differ in mutability | = note: expected type `*mut dyn T` found type `&S` diff --git a/src/test/ui/dst/dst-index.rs b/src/test/ui/dst/dst-index.rs index 71ff067bbd9..fced3144eb8 100644 --- a/src/test/ui/dst/dst-index.rs +++ b/src/test/ui/dst/dst-index.rs @@ -19,9 +19,9 @@ impl Index<usize> for S { struct T; impl Index<usize> for T { - type Output = Debug + 'static; + type Output = dyn Debug + 'static; - fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) { + fn index<'a>(&'a self, idx: usize) -> &'a (dyn Debug + 'static) { static x: usize = 42; &x } diff --git a/src/test/ui/dst/dst-object-from-unsized-type.rs b/src/test/ui/dst/dst-object-from-unsized-type.rs index f4ee1783a2e..3cd5b1ed6f4 100644 --- a/src/test/ui/dst/dst-object-from-unsized-type.rs +++ b/src/test/ui/dst/dst-object-from-unsized-type.rs @@ -5,22 +5,22 @@ impl Foo for str {} impl Foo for [u8] {} fn test1<T: ?Sized + Foo>(t: &T) { - let u: &Foo = t; + let u: &dyn Foo = t; //~^ ERROR the size for values of type } fn test2<T: ?Sized + Foo>(t: &T) { - let v: &Foo = t as &Foo; + let v: &dyn Foo = t as &dyn Foo; //~^ ERROR the size for values of type } fn test3() { - let _: &[&Foo] = &["hi"]; + let _: &[&dyn Foo] = &["hi"]; //~^ ERROR the size for values of type } fn test4(x: &[u8]) { - let _: &Foo = x as &Foo; + let _: &dyn Foo = x as &dyn Foo; //~^ ERROR the size for values of type } diff --git a/src/test/ui/dst/dst-object-from-unsized-type.stderr b/src/test/ui/dst/dst-object-from-unsized-type.stderr index 4851ca10828..55ac625fc98 100644 --- a/src/test/ui/dst/dst-object-from-unsized-type.stderr +++ b/src/test/ui/dst/dst-object-from-unsized-type.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:8:19 + --> $DIR/dst-object-from-unsized-type.rs:8:23 | -LL | let u: &Foo = t; - | ^ doesn't have a size known at compile-time +LL | let u: &dyn Foo = t; + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -10,10 +10,10 @@ LL | let u: &Foo = t; = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:13:19 + --> $DIR/dst-object-from-unsized-type.rs:13:23 | -LL | let v: &Foo = t as &Foo; - | ^ doesn't have a size known at compile-time +LL | let v: &dyn Foo = t as &dyn Foo; + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -21,20 +21,20 @@ LL | let v: &Foo = t as &Foo; = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:18:24 + --> $DIR/dst-object-from-unsized-type.rs:18:28 | -LL | let _: &[&Foo] = &["hi"]; - | ^^^^ doesn't have a size known at compile-time +LL | let _: &[&dyn Foo] = &["hi"]; + | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/dst-object-from-unsized-type.rs:23:19 + --> $DIR/dst-object-from-unsized-type.rs:23:23 | -LL | let _: &Foo = x as &Foo; - | ^ doesn't have a size known at compile-time +LL | let _: &dyn Foo = x as &dyn Foo; + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/elide-errors-on-mismatched-tuple.rs b/src/test/ui/elide-errors-on-mismatched-tuple.rs index e68358fd978..7d87b0a7756 100644 --- a/src/test/ui/elide-errors-on-mismatched-tuple.rs +++ b/src/test/ui/elide-errors-on-mismatched-tuple.rs @@ -13,6 +13,6 @@ impl A { fn main() { let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three //~^ ERROR mismatched types - let ts: Vec<&T> = vec![&a, &b, &c]; + let ts: Vec<&dyn T> = vec![&a, &b, &c]; // There is no E0277 error above, as `a`, `b` and `c` are `TyErr` } diff --git a/src/test/ui/error-codes/E0033-teach.rs b/src/test/ui/error-codes/E0033-teach.rs index 0f0b8d864dc..6a27b07fa8b 100644 --- a/src/test/ui/error-codes/E0033-teach.rs +++ b/src/test/ui/error-codes/E0033-teach.rs @@ -5,7 +5,7 @@ trait SomeTrait { } fn main() { - let trait_obj: &SomeTrait = SomeTrait; + let trait_obj: &dyn SomeTrait = SomeTrait; //~^ ERROR expected value, found trait `SomeTrait` //~| ERROR E0038 //~| method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0033-teach.stderr b/src/test/ui/error-codes/E0033-teach.stderr index 1b78820cae0..fb630de7fc1 100644 --- a/src/test/ui/error-codes/E0033-teach.stderr +++ b/src/test/ui/error-codes/E0033-teach.stderr @@ -1,14 +1,14 @@ error[E0423]: expected value, found trait `SomeTrait` - --> $DIR/E0033-teach.rs:8:33 + --> $DIR/E0033-teach.rs:8:37 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^ not a value +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^ not a value error[E0038]: the trait `SomeTrait` cannot be made into an object --> $DIR/E0033-teach.rs:8:20 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0033.rs b/src/test/ui/error-codes/E0033.rs index 5a4f3cbce60..582600e110b 100644 --- a/src/test/ui/error-codes/E0033.rs +++ b/src/test/ui/error-codes/E0033.rs @@ -3,7 +3,7 @@ trait SomeTrait { } fn main() { - let trait_obj: &SomeTrait = SomeTrait; + let trait_obj: &dyn SomeTrait = SomeTrait; //~^ ERROR expected value, found trait `SomeTrait` //~| ERROR E0038 //~| method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0033.stderr b/src/test/ui/error-codes/E0033.stderr index 976b0e0286f..fe9f45d86a6 100644 --- a/src/test/ui/error-codes/E0033.stderr +++ b/src/test/ui/error-codes/E0033.stderr @@ -1,14 +1,14 @@ error[E0423]: expected value, found trait `SomeTrait` - --> $DIR/E0033.rs:6:33 + --> $DIR/E0033.rs:6:37 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^ not a value +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^ not a value error[E0038]: the trait `SomeTrait` cannot be made into an object --> $DIR/E0033.rs:6:20 | -LL | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object +LL | let trait_obj: &dyn SomeTrait = SomeTrait; + | ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/error-codes/E0038.rs b/src/test/ui/error-codes/E0038.rs index b2226803da7..9757e2ab10c 100644 --- a/src/test/ui/error-codes/E0038.rs +++ b/src/test/ui/error-codes/E0038.rs @@ -2,7 +2,7 @@ trait Trait { fn foo(&self) -> Self; } -fn call_foo(x: Box<Trait>) { +fn call_foo(x: Box<dyn Trait>) { //~^ ERROR E0038 let y = x.foo(); } diff --git a/src/test/ui/error-codes/E0038.stderr b/src/test/ui/error-codes/E0038.stderr index 74b77338c85..e3d7593e42a 100644 --- a/src/test/ui/error-codes/E0038.stderr +++ b/src/test/ui/error-codes/E0038.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/E0038.rs:5:1 | -LL | fn call_foo(x: Box<Trait>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object +LL | fn call_foo(x: Box<dyn Trait>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object | = note: method `foo` references the `Self` type in its arguments or return type diff --git a/src/test/ui/error-codes/E0120.rs b/src/test/ui/error-codes/E0120.rs index 049707415e5..287a4088183 100644 --- a/src/test/ui/error-codes/E0120.rs +++ b/src/test/ui/error-codes/E0120.rs @@ -1,6 +1,6 @@ trait MyTrait { fn foo() {} } -impl Drop for MyTrait { +impl Drop for dyn MyTrait { //~^ ERROR E0120 fn drop(&mut self) {} } diff --git a/src/test/ui/error-codes/E0120.stderr b/src/test/ui/error-codes/E0120.stderr index 9b6603dbaca..68ca7d800d5 100644 --- a/src/test/ui/error-codes/E0120.stderr +++ b/src/test/ui/error-codes/E0120.stderr @@ -1,8 +1,8 @@ error[E0120]: the Drop trait may only be implemented on structures --> $DIR/E0120.rs:3:15 | -LL | impl Drop for MyTrait { - | ^^^^^^^ implementing Drop requires a struct +LL | impl Drop for dyn MyTrait { + | ^^^^^^^^^^^ implementing Drop requires a struct error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0191.rs b/src/test/ui/error-codes/E0191.rs index 356110671e7..22f739b9e76 100644 --- a/src/test/ui/error-codes/E0191.rs +++ b/src/test/ui/error-codes/E0191.rs @@ -2,6 +2,6 @@ trait Trait { type Bar; } -type Foo = Trait; //~ ERROR E0191 +type Foo = dyn Trait; //~ ERROR E0191 fn main() {} diff --git a/src/test/ui/error-codes/E0191.stderr b/src/test/ui/error-codes/E0191.stderr index 2d9fdfe5d29..92fa85bca0e 100644 --- a/src/test/ui/error-codes/E0191.stderr +++ b/src/test/ui/error-codes/E0191.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) mu LL | type Bar; | --------- `Bar` defined here ... -LL | type Foo = Trait; - | ^^^^^ associated type `Bar` must be specified +LL | type Foo = dyn Trait; + | ^^^^^^^^^ associated type `Bar` must be specified error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0220.rs b/src/test/ui/error-codes/E0220.rs index f4798042538..e11a570df79 100644 --- a/src/test/ui/error-codes/E0220.rs +++ b/src/test/ui/error-codes/E0220.rs @@ -2,7 +2,7 @@ trait Trait { type Bar; } -type Foo = Trait<F=i32>; //~ ERROR E0220 - //~| ERROR E0191 +type Foo = dyn Trait<F=i32>; //~ ERROR E0220 + //~| ERROR E0191 fn main() { } diff --git a/src/test/ui/error-codes/E0220.stderr b/src/test/ui/error-codes/E0220.stderr index bd2205fb752..5da302748cd 100644 --- a/src/test/ui/error-codes/E0220.stderr +++ b/src/test/ui/error-codes/E0220.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `F` not found for `Trait` - --> $DIR/E0220.rs:5:18 + --> $DIR/E0220.rs:5:22 | -LL | type Foo = Trait<F=i32>; - | ^^^^^ associated type `F` not found +LL | type Foo = dyn Trait<F=i32>; + | ^^^^^ associated type `F` not found error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified --> $DIR/E0220.rs:5:12 @@ -10,8 +10,8 @@ error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) mu LL | type Bar; | --------- `Bar` defined here ... -LL | type Foo = Trait<F=i32>; - | ^^^^^^^^^^^^ associated type `Bar` must be specified +LL | type Foo = dyn Trait<F=i32>; + | ^^^^^^^^^^^^^^^^ associated type `Bar` must be specified error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0393.rs b/src/test/ui/error-codes/E0393.rs index bdd4deafc83..0c1a369806d 100644 --- a/src/test/ui/error-codes/E0393.rs +++ b/src/test/ui/error-codes/E0393.rs @@ -1,6 +1,6 @@ trait A<T=Self> {} -fn together_we_will_rule_the_galaxy(son: &A) {} +fn together_we_will_rule_the_galaxy(son: &dyn A) {} //~^ ERROR E0393 fn main() { diff --git a/src/test/ui/error-codes/E0393.stderr b/src/test/ui/error-codes/E0393.stderr index bf564ef1021..543e3213633 100644 --- a/src/test/ui/error-codes/E0393.stderr +++ b/src/test/ui/error-codes/E0393.stderr @@ -1,8 +1,8 @@ error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/E0393.rs:3:43 + --> $DIR/E0393.rs:3:47 | -LL | fn together_we_will_rule_the_galaxy(son: &A) {} - | ^ missing reference to `T` +LL | fn together_we_will_rule_the_galaxy(son: &dyn A) {} + | ^ missing reference to `T` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/error-codes/E0478.rs b/src/test/ui/error-codes/E0478.rs index 1b5ca09d5a6..b1562dc0a8b 100644 --- a/src/test/ui/error-codes/E0478.rs +++ b/src/test/ui/error-codes/E0478.rs @@ -1,7 +1,7 @@ trait Wedding<'t>: 't { } struct Prince<'kiss, 'SnowWhite> { - child: Box<Wedding<'kiss> + 'SnowWhite>, //~ ERROR E0478 + child: Box<dyn Wedding<'kiss> + 'SnowWhite>, //~ ERROR E0478 } fn main() { diff --git a/src/test/ui/error-codes/E0478.stderr b/src/test/ui/error-codes/E0478.stderr index 71e490364d7..587125fdc33 100644 --- a/src/test/ui/error-codes/E0478.stderr +++ b/src/test/ui/error-codes/E0478.stderr @@ -1,8 +1,8 @@ error[E0478]: lifetime bound not satisfied --> $DIR/E0478.rs:4:5 | -LL | child: Box<Wedding<'kiss> + 'SnowWhite>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | child: Box<dyn Wedding<'kiss> + 'SnowWhite>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime 'SnowWhite as defined on the struct at 3:22 --> $DIR/E0478.rs:3:22 diff --git a/src/test/ui/error-codes/E0719.rs b/src/test/ui/error-codes/E0719.rs index 6b572f49cee..3311e190937 100644 --- a/src/test/ui/error-codes/E0719.rs +++ b/src/test/ui/error-codes/E0719.rs @@ -3,12 +3,12 @@ trait Foo: Iterator<Item = i32, Item = i32> {} type Unit = (); -fn test() -> Box<Iterator<Item = (), Item = Unit>> { +fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> { //~^ ERROR is already specified Box::new(None.into_iter()) } fn main() { - let _: &Iterator<Item = i32, Item = i32>; + let _: &dyn Iterator<Item = i32, Item = i32>; test(); } diff --git a/src/test/ui/error-codes/E0719.stderr b/src/test/ui/error-codes/E0719.stderr index 5854cd7e143..c5b9a71c659 100644 --- a/src/test/ui/error-codes/E0719.stderr +++ b/src/test/ui/error-codes/E0719.stderr @@ -7,12 +7,12 @@ LL | trait Foo: Iterator<Item = i32, Item = i32> {} | `Item` bound here first error[E0719]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) is already specified - --> $DIR/E0719.rs:6:38 + --> $DIR/E0719.rs:6:42 | -LL | fn test() -> Box<Iterator<Item = (), Item = Unit>> { - | --------- ^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first +LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> { + | --------- ^^^^^^^^^^^ re-bound here + | | + | `Item` bound here first error: aborting due to 2 previous errors diff --git a/src/test/ui/fat-ptr-cast.rs b/src/test/ui/fat-ptr-cast.rs index eb419ba2036..a0fad583a16 100644 --- a/src/test/ui/fat-ptr-cast.rs +++ b/src/test/ui/fat-ptr-cast.rs @@ -19,6 +19,6 @@ fn main() { q as *const [i32]; //~ ERROR cannot cast // #21397 - let t: *mut (Trait + 'static) = 0 as *mut _; //~ ERROR casting + let t: *mut (dyn Trait + 'static) = 0 as *mut _; //~ ERROR casting let mut fail: *const str = 0 as *const str; //~ ERROR casting } diff --git a/src/test/ui/fat-ptr-cast.stderr b/src/test/ui/fat-ptr-cast.stderr index bb7a4d3ff7f..93e1471838f 100644 --- a/src/test/ui/fat-ptr-cast.stderr +++ b/src/test/ui/fat-ptr-cast.stderr @@ -53,10 +53,10 @@ LL | q as *const [i32]; | ^^^^^^^^^^^^^^^^^ error[E0606]: casting `usize` as `*mut (dyn Trait + 'static)` is invalid - --> $DIR/fat-ptr-cast.rs:22:37 + --> $DIR/fat-ptr-cast.rs:22:41 | -LL | let t: *mut (Trait + 'static) = 0 as *mut _; - | ^^^^^^^^^^^ +LL | let t: *mut (dyn Trait + 'static) = 0 as *mut _; + | ^^^^^^^^^^^ error[E0606]: casting `usize` as `*const str` is invalid --> $DIR/fat-ptr-cast.rs:23:32 diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs index e5028f2f8aa..3dbaf5dea25 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs @@ -52,8 +52,8 @@ struct Dst<X: ?Sized> { struct TwoStrs(str, str) where str: Sized; //~ ERROR -fn unsized_local() where Dst<A>: Sized { //~ ERROR - let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>); +fn unsized_local() where Dst<dyn A>: Sized { //~ ERROR + let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>); } fn return_str() -> str where str: Sized { //~ ERROR diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index b04a6e4d671..1d346fd42ff 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -102,8 +102,8 @@ LL | struct TwoStrs(str, str) where str: Sized; error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time --> $DIR/feature-gate-trivial_bounds.rs:55:1 | -LL | / fn unsized_local() where Dst<A>: Sized { -LL | | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>); +LL | / fn unsized_local() where Dst<dyn A>: Sized { +LL | | let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>); LL | | } | |_^ doesn't have a size known at compile-time | diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.rs b/src/test/ui/feature-gates/feature-gate-unsized_locals.rs index a8f81f3f113..3686e7b37f4 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.rs +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.rs @@ -1,4 +1,4 @@ -fn f(f: FnOnce()) {} +fn f(f: dyn FnOnce()) {} //~^ ERROR E0277 fn main() { diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr index bde39cbeaeb..d20b9e2981e 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -1,7 +1,7 @@ error[E0277]: the size for values of type `(dyn std::ops::FnOnce() + 'static)` cannot be known at compilation time --> $DIR/feature-gate-unsized_locals.rs:1:6 | -LL | fn f(f: FnOnce()) {} +LL | fn f(f: dyn FnOnce()) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::FnOnce() + 'static)` diff --git a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs index f781bc9aedd..c3d62a231e5 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs +++ b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs @@ -1,4 +1,4 @@ fn main() { - let _ : &(Send,) = &((),); + let _ : &(dyn Send,) = &((),); //~^ ERROR unsized tuple coercion is not stable enough } diff --git a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr index 669e87ceada..5b93c889db1 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_tuple_coercion.stderr @@ -1,8 +1,8 @@ error[E0658]: unsized tuple coercion is not stable enough for use and is subject to change - --> $DIR/feature-gate-unsized_tuple_coercion.rs:2:24 + --> $DIR/feature-gate-unsized_tuple_coercion.rs:2:28 | -LL | let _ : &(Send,) = &((),); - | ^^^^^^ +LL | let _ : &(dyn Send,) = &((),); + | ^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/42877 = help: add #![feature(unsized_tuple_coercion)] to the crate attributes to enable diff --git a/src/test/ui/fn/fn-trait-formatting.rs b/src/test/ui/fn/fn-trait-formatting.rs index 21da39dd400..5c16c1a7e88 100644 --- a/src/test/ui/fn/fn-trait-formatting.rs +++ b/src/test/ui/fn/fn-trait-formatting.rs @@ -3,15 +3,15 @@ fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {} fn main() { - let _: () = (box |_: isize| {}) as Box<FnOnce(isize)>; + let _: () = (box |_: isize| {}) as Box<dyn FnOnce(isize)>; //~^ ERROR mismatched types //~| expected type `()` //~| found type `std::boxed::Box<dyn std::ops::FnOnce(isize)>` - let _: () = (box |_: isize, isize| {}) as Box<Fn(isize, isize)>; + let _: () = (box |_: isize, isize| {}) as Box<dyn Fn(isize, isize)>; //~^ ERROR mismatched types //~| expected type `()` //~| found type `std::boxed::Box<dyn std::ops::Fn(isize, isize)>` - let _: () = (box || -> isize { unimplemented!() }) as Box<FnMut() -> isize>; + let _: () = (box || -> isize { unimplemented!() }) as Box<dyn FnMut() -> isize>; //~^ ERROR mismatched types //~| expected type `()` //~| found type `std::boxed::Box<dyn std::ops::FnMut() -> isize>` diff --git a/src/test/ui/fn/fn-trait-formatting.stderr b/src/test/ui/fn/fn-trait-formatting.stderr index 6b76a6c914f..504bc2605ec 100644 --- a/src/test/ui/fn/fn-trait-formatting.stderr +++ b/src/test/ui/fn/fn-trait-formatting.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:6:17 | -LL | let _: () = (box |_: isize| {}) as Box<FnOnce(isize)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` +LL | let _: () = (box |_: isize| {}) as Box<dyn FnOnce(isize)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` | = note: expected type `()` found type `std::boxed::Box<dyn std::ops::FnOnce(isize)>` @@ -10,8 +10,8 @@ LL | let _: () = (box |_: isize| {}) as Box<FnOnce(isize)>; error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:10:17 | -LL | let _: () = (box |_: isize, isize| {}) as Box<Fn(isize, isize)>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` +LL | let _: () = (box |_: isize, isize| {}) as Box<dyn Fn(isize, isize)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` | = note: expected type `()` found type `std::boxed::Box<dyn std::ops::Fn(isize, isize)>` @@ -19,8 +19,8 @@ LL | let _: () = (box |_: isize, isize| {}) as Box<Fn(isize, isize)>; error[E0308]: mismatched types --> $DIR/fn-trait-formatting.rs:14:17 | -LL | let _: () = (box || -> isize { unimplemented!() }) as Box<FnMut() -> isize>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` +LL | let _: () = (box || -> isize { unimplemented!() }) as Box<dyn FnMut() -> isize>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `std::boxed::Box` | = note: expected type `()` found type `std::boxed::Box<dyn std::ops::FnMut() -> isize>` diff --git a/src/test/ui/higher-lifetime-bounds.rs b/src/test/ui/higher-lifetime-bounds.rs index 546f4d43663..f3393347d90 100644 --- a/src/test/ui/higher-lifetime-bounds.rs +++ b/src/test/ui/higher-lifetime-bounds.rs @@ -58,12 +58,12 @@ struct S3<F>(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); //~^ ERROR lifetime bounds cannot be used in this context -type T1 = Box<for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>; +type T1 = Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>; //~^ ERROR lifetime bounds cannot be used in this context fn main() { let _ : Option<for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32> = None; //~^ ERROR lifetime bounds cannot be used in this context - let _ : Option<Box<for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + let _ : Option<Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; //~^ ERROR lifetime bounds cannot be used in this context } diff --git a/src/test/ui/higher-lifetime-bounds.stderr b/src/test/ui/higher-lifetime-bounds.stderr index 431a89f5eb8..bc6d2288cdf 100644 --- a/src/test/ui/higher-lifetime-bounds.stderr +++ b/src/test/ui/higher-lifetime-bounds.stderr @@ -47,10 +47,10 @@ LL | struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); | ^^^ error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:61:29 + --> $DIR/higher-lifetime-bounds.rs:61:33 | -LL | type T1 = Box<for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>; - | ^^^ +LL | type T1 = Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>; + | ^^^ error: lifetime bounds cannot be used in this context --> $DIR/higher-lifetime-bounds.rs:65:34 @@ -59,10 +59,10 @@ LL | let _ : Option<for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32> = | ^^^ error: lifetime bounds cannot be used in this context - --> $DIR/higher-lifetime-bounds.rs:67:38 + --> $DIR/higher-lifetime-bounds.rs:67:42 | -LL | let _ : Option<Box<for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; - | ^^^ +LL | let _ : Option<Box<dyn for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + | ^^^ error: aborting due to 11 previous errors diff --git a/src/test/ui/imports/extern-crate-used.rs b/src/test/ui/imports/extern-crate-used.rs index 26150c7d4a1..8198c1816a1 100644 --- a/src/test/ui/imports/extern-crate-used.rs +++ b/src/test/ui/imports/extern-crate-used.rs @@ -20,13 +20,13 @@ extern crate core; //~ ERROR unused extern crate mod m { use iso1::any as are_you_okay1; use ::iso2::any as are_you_okay2; - type AreYouOkay1 = iso3::any::Any; - type AreYouOkay2 = ::iso4::any::Any; + type AreYouOkay1 = dyn iso3::any::Any; + type AreYouOkay2 = dyn (::iso4::any::Any); use core::any as are_you_okay3; use ::core::any as are_you_okay4; - type AreYouOkay3 = core::any::Any; - type AreYouOkay4 = ::core::any::Any; + type AreYouOkay3 = dyn core::any::Any; + type AreYouOkay4 = dyn (::core::any::Any); } fn main() {} diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs index d4535ac4425..d131a944721 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs @@ -4,8 +4,8 @@ trait Trait {} struct Struct; impl Deref for Struct { - type Target = Trait; - fn deref(&self) -> &Trait { + type Target = dyn Trait; + fn deref(&self) -> &dyn Trait { unimplemented!(); } } diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr index e56a56e2dae..b50a926c637 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr @@ -1,13 +1,13 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements --> $DIR/mismatched_trait_impl-2.rs:8:5 | -LL | fn deref(&self) -> &Trait { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn deref(&self) -> &dyn Trait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 8:5... --> $DIR/mismatched_trait_impl-2.rs:8:5 | -LL | / fn deref(&self) -> &Trait { +LL | / fn deref(&self) -> &dyn Trait { LL | | unimplemented!(); LL | | } | |_____^ diff --git a/src/test/ui/issues/issue-10291.nll.stderr b/src/test/ui/issues/issue-10291.nll.stderr index 45f29fd7956..a7b827d27a8 100644 --- a/src/test/ui/issues/issue-10291.nll.stderr +++ b/src/test/ui/issues/issue-10291.nll.stderr @@ -3,7 +3,7 @@ error: lifetime may not live long enough | LL | fn test<'x>(x: &'x isize) { | -- lifetime `'x` defined here -LL | drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { +LL | drop::<Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { LL | x | ^ returning this value requires that `'x` must outlive `'static` diff --git a/src/test/ui/issues/issue-10291.rs b/src/test/ui/issues/issue-10291.rs index 877b0aba473..559c5fcac95 100644 --- a/src/test/ui/issues/issue-10291.rs +++ b/src/test/ui/issues/issue-10291.rs @@ -1,5 +1,5 @@ fn test<'x>(x: &'x isize) { - drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + drop::<Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { x //~ ERROR E0312 })); } diff --git a/src/test/ui/issues/issue-10291.stderr b/src/test/ui/issues/issue-10291.stderr index 0d653e6ced1..5e63469da59 100644 --- a/src/test/ui/issues/issue-10291.stderr +++ b/src/test/ui/issues/issue-10291.stderr @@ -4,11 +4,11 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | x | ^ | -note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 2:65... - --> $DIR/issue-10291.rs:2:65 +note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 2:69... + --> $DIR/issue-10291.rs:2:69 | -LL | drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | _________________________________________________________________^ +LL | drop::<Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | _____________________________________________________________________^ LL | | x LL | | })); | |_____^ diff --git a/src/test/ui/issues/issue-10902.rs b/src/test/ui/issues/issue-10902.rs index 672386bc8a6..5e7f8ed7fd5 100644 --- a/src/test/ui/issues/issue-10902.rs +++ b/src/test/ui/issues/issue-10902.rs @@ -4,16 +4,16 @@ pub mod two_tuple { pub trait T { fn dummy(&self) { } } - pub struct P<'a>(&'a (T + 'a), &'a (T + 'a)); - pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { + pub struct P<'a>(&'a (dyn T + 'a), &'a (dyn T + 'a)); + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { P(car, cdr) } } pub mod two_fields { pub trait T { fn dummy(&self) { } } - pub struct P<'a> { car: &'a (T + 'a), cdr: &'a (T + 'a) } - pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { + pub struct P<'a> { car: &'a (dyn T + 'a), cdr: &'a (dyn T + 'a) } + pub fn f<'a>(car: &'a dyn T, cdr: &'a dyn T) -> P<'a> { P{ car: car, cdr: cdr } } } diff --git a/src/test/ui/issues/issue-11374.rs b/src/test/ui/issues/issue-11374.rs index f00da0acf81..7519ba2826e 100644 --- a/src/test/ui/issues/issue-11374.rs +++ b/src/test/ui/issues/issue-11374.rs @@ -2,11 +2,11 @@ use std::io::{self, Read}; use std::vec; pub struct Container<'a> { - reader: &'a mut Read + reader: &'a mut dyn Read } impl<'a> Container<'a> { - pub fn wrap<'s>(reader: &'s mut io::Read) -> Container<'s> { + pub fn wrap<'s>(reader: &'s mut dyn io::Read) -> Container<'s> { Container { reader: reader } } @@ -17,7 +17,7 @@ impl<'a> Container<'a> { pub fn for_stdin<'a>() -> Container<'a> { let mut r = io::stdin(); - Container::wrap(&mut r as &mut io::Read) + Container::wrap(&mut r as &mut dyn io::Read) } fn main() { diff --git a/src/test/ui/issues/issue-11515.rs b/src/test/ui/issues/issue-11515.rs index 7eab2a26178..a7671b9282a 100644 --- a/src/test/ui/issues/issue-11515.rs +++ b/src/test/ui/issues/issue-11515.rs @@ -1,10 +1,10 @@ #![feature(box_syntax)] struct Test { - func: Box<FnMut()+'static> + func: Box<dyn FnMut() + 'static> } fn main() { - let closure: Box<Fn()+'static> = Box::new(|| ()); + let closure: Box<dyn Fn() + 'static> = Box::new(|| ()); let test = box Test { func: closure }; //~ ERROR mismatched types } diff --git a/src/test/ui/issues/issue-11612.rs b/src/test/ui/issues/issue-11612.rs index 4d6f4656d58..fd4fb2443cb 100644 --- a/src/test/ui/issues/issue-11612.rs +++ b/src/test/ui/issues/issue-11612.rs @@ -14,11 +14,11 @@ struct B<'a, T:'a> { impl<'a, T> A for B<'a, T> {} -fn foo(_: &A) {} +fn foo(_: &dyn A) {} fn bar<G>(b: &B<G>) { foo(b); // Coercion should work - foo(b as &A); // Explicit cast should work as well + foo(b as &dyn A); // Explicit cast should work as well } fn main() {} diff --git a/src/test/ui/issues/issue-12470.rs b/src/test/ui/issues/issue-12470.rs index 77b78c8a1f7..0ade359923a 100644 --- a/src/test/ui/issues/issue-12470.rs +++ b/src/test/ui/issues/issue-12470.rs @@ -16,10 +16,10 @@ impl X for B { } struct A<'a> { - p: &'a (X+'a) + p: &'a (dyn X + 'a) } -fn make_a<'a>(p: &'a X) -> A<'a> { +fn make_a<'a>(p: &'a dyn X) -> A<'a> { A { p: p } } diff --git a/src/test/ui/issues/issue-13033.rs b/src/test/ui/issues/issue-13033.rs index a6c9e9712c0..e5274eb823d 100644 --- a/src/test/ui/issues/issue-13033.rs +++ b/src/test/ui/issues/issue-13033.rs @@ -1,11 +1,11 @@ trait Foo { - fn bar(&mut self, other: &mut Foo); + fn bar(&mut self, other: &mut dyn Foo); } struct Baz; impl Foo for Baz { - fn bar(&mut self, other: &Foo) {} + fn bar(&mut self, other: &dyn Foo) {} //~^ ERROR method `bar` has an incompatible type for trait //~| expected type `fn(&mut Baz, &mut dyn Foo)` //~| found type `fn(&mut Baz, &dyn Foo)` diff --git a/src/test/ui/issues/issue-13033.stderr b/src/test/ui/issues/issue-13033.stderr index d1e8eb31c88..195d0c39b29 100644 --- a/src/test/ui/issues/issue-13033.stderr +++ b/src/test/ui/issues/issue-13033.stderr @@ -1,18 +1,18 @@ error[E0053]: method `bar` has an incompatible type for trait --> $DIR/issue-13033.rs:8:30 | -LL | fn bar(&mut self, other: &mut Foo); - | -------- type in trait +LL | fn bar(&mut self, other: &mut dyn Foo); + | ------------ type in trait ... -LL | fn bar(&mut self, other: &Foo) {} - | ^^^^ types differ in mutability +LL | fn bar(&mut self, other: &dyn Foo) {} + | ^^^^^^^^ types differ in mutability | = note: expected type `fn(&mut Baz, &mut dyn Foo)` found type `fn(&mut Baz, &dyn Foo)` help: consider change the type to match the mutability in trait | -LL | fn bar(&mut self, other: &mut Foo) {} - | ^^^^^^^^ +LL | fn bar(&mut self, other: &mut dyn Foo) {} + | ^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-13352.rs b/src/test/ui/issues/issue-13352.rs index c711e3b713f..e6995be27d2 100644 --- a/src/test/ui/issues/issue-13352.rs +++ b/src/test/ui/issues/issue-13352.rs @@ -1,6 +1,6 @@ // ignore-cloudabi no std::process -fn foo(_: Box<FnMut()>) {} +fn foo(_: Box<dyn FnMut()>) {} fn main() { foo(loop { diff --git a/src/test/ui/issues/issue-13853-2.rs b/src/test/ui/issues/issue-13853-2.rs index b58f2bd3b3b..27319c98d6e 100644 --- a/src/test/ui/issues/issue-13853-2.rs +++ b/src/test/ui/issues/issue-13853-2.rs @@ -2,5 +2,5 @@ trait FromStructReader<'a> { } trait ResponseHook { fn get(&self); } -fn foo(res : Box<ResponseHook>) { res.get } //~ ERROR attempted to take value of method +fn foo(res : Box<dyn ResponseHook>) { res.get } //~ ERROR attempted to take value of method fn main() {} diff --git a/src/test/ui/issues/issue-13853-2.stderr b/src/test/ui/issues/issue-13853-2.stderr index 0853f5cffb7..ea3b38940cf 100644 --- a/src/test/ui/issues/issue-13853-2.stderr +++ b/src/test/ui/issues/issue-13853-2.stderr @@ -1,8 +1,8 @@ error[E0615]: attempted to take value of method `get` on type `std::boxed::Box<(dyn ResponseHook + 'static)>` - --> $DIR/issue-13853-2.rs:5:39 + --> $DIR/issue-13853-2.rs:5:43 | -LL | fn foo(res : Box<ResponseHook>) { res.get } - | ^^^ help: use parentheses to call the method: `get()` +LL | fn foo(res : Box<dyn ResponseHook>) { res.get } + | ^^^ help: use parentheses to call the method: `get()` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-14285.rs b/src/test/ui/issues/issue-14285.rs index 934d72a67ca..2ba9ff71773 100644 --- a/src/test/ui/issues/issue-14285.rs +++ b/src/test/ui/issues/issue-14285.rs @@ -6,9 +6,9 @@ struct A; impl Foo for A {} -struct B<'a>(&'a (Foo+'a)); +struct B<'a>(&'a (dyn Foo + 'a)); -fn foo<'a>(a: &Foo) -> B<'a> { +fn foo<'a>(a: &dyn Foo) -> B<'a> { B(a) //~ ERROR explicit lifetime required in the type of `a` [E0621] } diff --git a/src/test/ui/issues/issue-14285.stderr b/src/test/ui/issues/issue-14285.stderr index c180ed03e54..5c07066018e 100644 --- a/src/test/ui/issues/issue-14285.stderr +++ b/src/test/ui/issues/issue-14285.stderr @@ -1,8 +1,8 @@ error[E0621]: explicit lifetime required in the type of `a` --> $DIR/issue-14285.rs:12:5 | -LL | fn foo<'a>(a: &Foo) -> B<'a> { - | ---- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)` +LL | fn foo<'a>(a: &dyn Foo) -> B<'a> { + | -------- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)` LL | B(a) | ^^^^ lifetime `'a` required diff --git a/src/test/ui/issues/issue-14366.rs b/src/test/ui/issues/issue-14366.rs index a6298f25d47..bb338860d8b 100644 --- a/src/test/ui/issues/issue-14366.rs +++ b/src/test/ui/issues/issue-14366.rs @@ -1,4 +1,4 @@ fn main() { - let _x = "test" as &::std::any::Any; + let _x = "test" as &dyn (::std::any::Any); //~^ ERROR the size for values of type } diff --git a/src/test/ui/issues/issue-14366.stderr b/src/test/ui/issues/issue-14366.stderr index a3588bb8ebe..542d8a904c4 100644 --- a/src/test/ui/issues/issue-14366.stderr +++ b/src/test/ui/issues/issue-14366.stderr @@ -1,7 +1,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/issue-14366.rs:2:14 | -LL | let _x = "test" as &::std::any::Any; +LL | let _x = "test" as &dyn (::std::any::Any); | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` diff --git a/src/test/ui/issues/issue-14901.rs b/src/test/ui/issues/issue-14901.rs index 61b2b64ddf0..9b89c1631df 100644 --- a/src/test/ui/issues/issue-14901.rs +++ b/src/test/ui/issues/issue-14901.rs @@ -2,7 +2,7 @@ pub trait Reader {} enum Wrapper<'a> { - WrapReader(&'a (Reader + 'a)) + WrapReader(&'a (dyn Reader + 'a)) } trait Wrap<'a> { @@ -11,7 +11,7 @@ trait Wrap<'a> { impl<'a, R: Reader> Wrap<'a> for &'a mut R { fn wrap(self) -> Wrapper<'a> { - Wrapper::WrapReader(self as &'a mut Reader) + Wrapper::WrapReader(self as &'a mut dyn Reader) } } diff --git a/src/test/ui/issues/issue-14959.rs b/src/test/ui/issues/issue-14959.rs index 78ae21e2837..60daaafbcc8 100644 --- a/src/test/ui/issues/issue-14959.rs +++ b/src/test/ui/issues/issue-14959.rs @@ -26,20 +26,20 @@ impl Alloy { } } -impl<'b> Fn<(&'b mut (Response+'b),)> for SendFile { - extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {} +impl<'b> Fn<(&'b mut (dyn Response + 'b),)> for SendFile { + extern "rust-call" fn call(&self, (_res,): (&'b mut (dyn Response + 'b),)) {} } -impl<'b> FnMut<(&'b mut (Response+'b),)> for SendFile { - extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (Response+'b),)) { +impl<'b> FnMut<(&'b mut (dyn Response + 'b),)> for SendFile { + extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (dyn Response+'b),)) { self.call((_res,)) } } -impl<'b> FnOnce<(&'b mut (Response+'b),)> for SendFile { +impl<'b> FnOnce<(&'b mut (dyn Response + 'b),)> for SendFile { type Output = (); - extern "rust-call" fn call_once(self, (_res,): (&'b mut (Response+'b),)) { + extern "rust-call" fn call_once(self, (_res,): (&'b mut (dyn Response+'b),)) { self.call((_res,)) } } diff --git a/src/test/ui/issues/issue-16668.rs b/src/test/ui/issues/issue-16668.rs index f69ca4677c9..b570a2ced67 100644 --- a/src/test/ui/issues/issue-16668.rs +++ b/src/test/ui/issues/issue-16668.rs @@ -1,7 +1,7 @@ // compile-pass #![allow(dead_code)] struct Parser<'a, I, O> { - parse: Box<FnMut(I) -> Result<O, String> + 'a> + parse: Box<dyn FnMut(I) -> Result<O, String> + 'a> } impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { diff --git a/src/test/ui/issues/issue-16922.rs b/src/test/ui/issues/issue-16922.rs index 1e865515c4b..10a5cccbcee 100644 --- a/src/test/ui/issues/issue-16922.rs +++ b/src/test/ui/issues/issue-16922.rs @@ -1,7 +1,7 @@ use std::any::Any; -fn foo<T: Any>(value: &T) -> Box<Any> { - Box::new(value) as Box<Any> +fn foo<T: Any>(value: &T) -> Box<dyn Any> { + Box::new(value) as Box<dyn Any> //~^ ERROR explicit lifetime required in the type of `value` [E0621] } diff --git a/src/test/ui/issues/issue-16922.stderr b/src/test/ui/issues/issue-16922.stderr index 1f3b3fe739c..4e3d3ecb9c0 100644 --- a/src/test/ui/issues/issue-16922.stderr +++ b/src/test/ui/issues/issue-16922.stderr @@ -1,9 +1,9 @@ error[E0621]: explicit lifetime required in the type of `value` --> $DIR/issue-16922.rs:4:5 | -LL | fn foo<T: Any>(value: &T) -> Box<Any> { +LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> { | -- help: add explicit lifetime `'static` to the type of `value`: `&'static T` -LL | Box::new(value) as Box<Any> +LL | Box::new(value) as Box<dyn Any> | ^^^^^^^^^^^^^^^ lifetime `'static` required error: aborting due to previous error diff --git a/src/test/ui/issues/issue-16994.rs b/src/test/ui/issues/issue-16994.rs index d356ce8a4da..d5f1b1310eb 100644 --- a/src/test/ui/issues/issue-16994.rs +++ b/src/test/ui/issues/issue-16994.rs @@ -1,6 +1,6 @@ // compile-pass // skip-codegen -fn cb<'a,T>(_x: Box<Fn((&'a i32, &'a (Vec<&'static i32>, bool))) -> T>) -> T { +fn cb<'a,T>(_x: Box<dyn Fn((&'a i32, &'a (Vec<&'static i32>, bool))) -> T>) -> T { panic!() } diff --git a/src/test/ui/issues/issue-17441.rs b/src/test/ui/issues/issue-17441.rs index cfb2fe674ed..b9813ef1eef 100644 --- a/src/test/ui/issues/issue-17441.rs +++ b/src/test/ui/issues/issue-17441.rs @@ -2,10 +2,10 @@ fn main() { let _foo = &[1_usize, 2] as [usize]; //~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]` - let _bar = Box::new(1_usize) as std::fmt::Debug; + let _bar = Box::new(1_usize) as dyn std::fmt::Debug; //~^ ERROR cast to unsized type: `std::boxed::Box<usize>` as `dyn std::fmt::Debug` - let _baz = 1_usize as std::fmt::Debug; + let _baz = 1_usize as dyn std::fmt::Debug; //~^ ERROR cast to unsized type: `usize` as `dyn std::fmt::Debug` let _quux = [1_usize, 2] as [usize]; diff --git a/src/test/ui/issues/issue-17441.stderr b/src/test/ui/issues/issue-17441.stderr index 436ee7325f8..0ab035515a0 100644 --- a/src/test/ui/issues/issue-17441.stderr +++ b/src/test/ui/issues/issue-17441.stderr @@ -13,21 +13,21 @@ LL | let _foo = &[1_usize, 2] as [usize]; error[E0620]: cast to unsized type: `std::boxed::Box<usize>` as `dyn std::fmt::Debug` --> $DIR/issue-17441.rs:5:16 | -LL | let _bar = Box::new(1_usize) as std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^--------------- +LL | let _bar = Box::new(1_usize) as dyn std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^------------------- | | - | help: try casting to a `Box` instead: `Box<std::fmt::Debug>` + | help: try casting to a `Box` instead: `Box<dyn std::fmt::Debug>` error[E0620]: cast to unsized type: `usize` as `dyn std::fmt::Debug` --> $DIR/issue-17441.rs:8:16 | -LL | let _baz = 1_usize as std::fmt::Debug; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _baz = 1_usize as dyn std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider using a box or reference as appropriate --> $DIR/issue-17441.rs:8:16 | -LL | let _baz = 1_usize as std::fmt::Debug; +LL | let _baz = 1_usize as dyn std::fmt::Debug; | ^^^^^^^ error[E0620]: cast to unsized type: `[usize; 2]` as `[usize]` diff --git a/src/test/ui/issues/issue-17959.rs b/src/test/ui/issues/issue-17959.rs index d56f346ecd4..73865ae2d2e 100644 --- a/src/test/ui/issues/issue-17959.rs +++ b/src/test/ui/issues/issue-17959.rs @@ -17,5 +17,5 @@ impl<T> Drop for G<T> { } fn main() { - let x:G<Bar>; + let x:G<dyn Bar>; } diff --git a/src/test/ui/issues/issue-18107.rs b/src/test/ui/issues/issue-18107.rs index 184d122d5cd..122940f1c17 100644 --- a/src/test/ui/issues/issue-18107.rs +++ b/src/test/ui/issues/issue-18107.rs @@ -1,7 +1,7 @@ pub trait AbstractRenderer {} fn _create_render(_: &()) -> - AbstractRenderer + dyn AbstractRenderer //~^ ERROR the size for values of type { match 0 { diff --git a/src/test/ui/issues/issue-18107.stderr b/src/test/ui/issues/issue-18107.stderr index 23b58c3f6df..9bdf470413b 100644 --- a/src/test/ui/issues/issue-18107.stderr +++ b/src/test/ui/issues/issue-18107.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn AbstractRenderer + 'static)` cannot be known at compilation time --> $DIR/issue-18107.rs:4:5 | -LL | AbstractRenderer - | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +LL | dyn AbstractRenderer + | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn AbstractRenderer + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/issues/issue-18188.rs b/src/test/ui/issues/issue-18188.rs index 8e39dc15597..4d0c4464759 100644 --- a/src/test/ui/issues/issue-18188.rs +++ b/src/test/ui/issues/issue-18188.rs @@ -5,7 +5,7 @@ pub trait Promisable: Send + Sync {} impl<T: Send + Sync> Promisable for T {} pub fn propagate<'a, T, E, F, G>(mut action: F) - -> Box<FnMut(Result<T, E>) -> Result<T, E> + 'a> + -> Box<dyn FnMut(Result<T, E>) -> Result<T, E> + 'a> where T: Promisable + Clone + 'a, E: Promisable + Clone + 'a, diff --git a/src/test/ui/issues/issue-18446-2.rs b/src/test/ui/issues/issue-18446-2.rs index 2f05ece3197..3e04a914d45 100644 --- a/src/test/ui/issues/issue-18446-2.rs +++ b/src/test/ui/issues/issue-18446-2.rs @@ -6,7 +6,7 @@ trait T { fn foo(&self) -> i32 { 0 } } -impl<'a> T + 'a { +impl<'a> dyn T + 'a { fn foo(&self) -> i32 { 1 } } diff --git a/src/test/ui/issues/issue-18446.rs b/src/test/ui/issues/issue-18446.rs index 64c89df3868..a2e238da03a 100644 --- a/src/test/ui/issues/issue-18446.rs +++ b/src/test/ui/issues/issue-18446.rs @@ -5,7 +5,7 @@ trait T { fn foo(&self); } -impl<'a> T + 'a { +impl<'a> dyn T + 'a { fn foo(&self) {} } @@ -14,6 +14,6 @@ impl T for i32 { } fn main() { - let x: &T = &0i32; + let x: &dyn T = &0i32; x.foo(); //~ ERROR multiple applicable items in scope [E0034] } diff --git a/src/test/ui/issues/issue-18783.rs b/src/test/ui/issues/issue-18783.rs index b84a1adb425..d4851ac1418 100644 --- a/src/test/ui/issues/issue-18783.rs +++ b/src/test/ui/issues/issue-18783.rs @@ -18,11 +18,11 @@ fn ufcs() { } trait Push<'c> { - fn push<'f: 'c>(&self, push: Box<FnMut() + 'f>); + fn push<'f: 'c>(&self, push: Box<dyn FnMut() + 'f>); } -impl<'c> Push<'c> for RefCell<Vec<Box<FnMut() + 'c>>> { - fn push<'f: 'c>(&self, fun: Box<FnMut() + 'f>) { +impl<'c> Push<'c> for RefCell<Vec<Box<dyn FnMut() + 'c>>> { + fn push<'f: 'c>(&self, fun: Box<dyn FnMut() + 'f>) { self.borrow_mut().push(fun) } } diff --git a/src/test/ui/issues/issue-18819.rs b/src/test/ui/issues/issue-18819.rs index 80db056e7dd..e634c55f824 100644 --- a/src/test/ui/issues/issue-18819.rs +++ b/src/test/ui/issues/issue-18819.rs @@ -8,7 +8,7 @@ impl Foo for X { type Item = bool; } -fn print_x(_: &Foo<Item=bool>, extra: &str) { +fn print_x(_: &dyn Foo<Item=bool>, extra: &str) { println!("{}", extra); } diff --git a/src/test/ui/issues/issue-18819.stderr b/src/test/ui/issues/issue-18819.stderr index eb7e4ad405f..41e8470ecd0 100644 --- a/src/test/ui/issues/issue-18819.stderr +++ b/src/test/ui/issues/issue-18819.stderr @@ -1,8 +1,8 @@ error[E0061]: this function takes 2 parameters but 1 parameter was supplied --> $DIR/issue-18819.rs:16:5 | -LL | fn print_x(_: &Foo<Item=bool>, extra: &str) { - | ------------------------------------------- defined here +LL | fn print_x(_: &dyn Foo<Item=bool>, extra: &str) { + | ----------------------------------------------- defined here ... LL | print_x(X); | ^^^^^^^^^^ expected 2 parameters diff --git a/src/test/ui/issues/issue-18919.rs b/src/test/ui/issues/issue-18919.rs index 9db30849182..91fbb13cd69 100644 --- a/src/test/ui/issues/issue-18919.rs +++ b/src/test/ui/issues/issue-18919.rs @@ -1,4 +1,4 @@ -type FuncType<'f> = Fn(&isize) -> isize + 'f; +type FuncType<'f> = dyn Fn(&isize) -> isize + 'f; fn ho_func(f: Option<FuncType>) { //~^ ERROR the size for values of type diff --git a/src/test/ui/issues/issue-18937.rs b/src/test/ui/issues/issue-18937.rs index f3824765f23..ab4c9c736d8 100644 --- a/src/test/ui/issues/issue-18937.rs +++ b/src/test/ui/issues/issue-18937.rs @@ -6,7 +6,7 @@ use std::fmt; struct MyString<'a>(&'a String); struct B { - list: Vec<Box<fmt::Debug>>, + list: Vec<Box<dyn fmt::Debug>>, } trait A<'a> { diff --git a/src/test/ui/issues/issue-18959.rs b/src/test/ui/issues/issue-18959.rs index b07800928bc..4b6f04e251b 100644 --- a/src/test/ui/issues/issue-18959.rs +++ b/src/test/ui/issues/issue-18959.rs @@ -8,13 +8,13 @@ impl Foo for Thing { } #[inline(never)] -fn foo(b: &Bar) { +fn foo(b: &dyn Bar) { //~^ ERROR E0038 b.foo(&0) } fn main() { let mut thing = Thing; - let test: &Bar = &mut thing; + let test: &dyn Bar = &mut thing; foo(test); } diff --git a/src/test/ui/issues/issue-18959.stderr b/src/test/ui/issues/issue-18959.stderr index 939390102c3..63c33b7f447 100644 --- a/src/test/ui/issues/issue-18959.stderr +++ b/src/test/ui/issues/issue-18959.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-18959.rs:11:1 | -LL | fn foo(b: &Bar) { - | ^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn foo(b: &dyn Bar) { + | ^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `foo` has generic type parameters diff --git a/src/test/ui/issues/issue-18988.rs b/src/test/ui/issues/issue-18988.rs index e0393486649..7fe662e907d 100644 --- a/src/test/ui/issues/issue-18988.rs +++ b/src/test/ui/issues/issue-18988.rs @@ -3,7 +3,7 @@ pub trait Foo : Send { } pub struct MyFoo { - children: Vec<Box<Foo>>, + children: Vec<Box<dyn Foo>>, } impl Foo for MyFoo { } diff --git a/src/test/ui/issues/issue-19380.rs b/src/test/ui/issues/issue-19380.rs index efbc5a0346a..5c10e2067e4 100644 --- a/src/test/ui/issues/issue-19380.rs +++ b/src/test/ui/issues/issue-19380.rs @@ -8,7 +8,7 @@ impl Qiz for Foo { } struct Bar { - foos: &'static [&'static (Qiz + 'static)] + foos: &'static [&'static (dyn Qiz + 'static)] //~^ ERROR E0038 } diff --git a/src/test/ui/issues/issue-19380.stderr b/src/test/ui/issues/issue-19380.stderr index 060e160f2e4..27e3ff57bf9 100644 --- a/src/test/ui/issues/issue-19380.stderr +++ b/src/test/ui/issues/issue-19380.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Qiz` cannot be made into an object --> $DIR/issue-19380.rs:11:3 | -LL | foos: &'static [&'static (Qiz + 'static)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object +LL | foos: &'static [&'static (dyn Qiz + 'static)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Qiz` cannot be made into an object | = note: method `qiz` has no receiver diff --git a/src/test/ui/issues/issue-19404.rs b/src/test/ui/issues/issue-19404.rs index cdec74fe968..59544393bae 100644 --- a/src/test/ui/issues/issue-19404.rs +++ b/src/test/ui/issues/issue-19404.rs @@ -12,10 +12,10 @@ trait Component: 'static {} impl Component for Engine {} trait Env { - fn get_component_type_id(&self, type_id: TypeId) -> Option<Fp<Component>>; + fn get_component_type_id(&self, type_id: TypeId) -> Option<Fp<dyn Component>>; } -impl<'a> Env+'a { +impl<'a> dyn Env + 'a { fn get_component<T: Component>(&self) -> Option<Fp<T>> { let x = self.get_component_type_id(TypeId::of::<T>()); None @@ -23,13 +23,13 @@ impl<'a> Env+'a { } trait Figment { - fn init(&mut self, env: &Env); + fn init(&mut self, env: &dyn Env); } struct MyFigment; impl Figment for MyFigment { - fn init(&mut self, env: &Env) { + fn init(&mut self, env: &dyn Env) { let engine = env.get_component::<Engine>(); } } diff --git a/src/test/ui/issues/issue-19482.rs b/src/test/ui/issues/issue-19482.rs index 6ba33490549..9e4b77d87f8 100644 --- a/src/test/ui/issues/issue-19482.rs +++ b/src/test/ui/issues/issue-19482.rs @@ -7,7 +7,7 @@ trait Foo { fn dummy(&self) { } } -fn bar(x: &Foo) {} +fn bar(x: &dyn Foo) {} //~^ ERROR the associated type `A` (from the trait `Foo`) must be specified pub fn main() {} diff --git a/src/test/ui/issues/issue-19482.stderr b/src/test/ui/issues/issue-19482.stderr index a8894f84e74..f1e5419c712 100644 --- a/src/test/ui/issues/issue-19482.stderr +++ b/src/test/ui/issues/issue-19482.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must b LL | type A; | ------- `A` defined here ... -LL | fn bar(x: &Foo) {} - | ^^^ associated type `A` must be specified +LL | fn bar(x: &dyn Foo) {} + | ^^^^^^^ associated type `A` must be specified error: aborting due to previous error diff --git a/src/test/ui/issues/issue-19538.rs b/src/test/ui/issues/issue-19538.rs index 9f0b08d6c35..7054ef41b1c 100644 --- a/src/test/ui/issues/issue-19538.rs +++ b/src/test/ui/issues/issue-19538.rs @@ -14,7 +14,7 @@ impl Bar for Thing { } fn main() { let mut thing = Thing; - let test: &mut Bar = &mut thing; + let test: &mut dyn Bar = &mut thing; //~^ ERROR E0038 //~| ERROR E0038 } diff --git a/src/test/ui/issues/issue-19538.stderr b/src/test/ui/issues/issue-19538.stderr index d0f05a41d4d..e5da0a9b0da 100644 --- a/src/test/ui/issues/issue-19538.stderr +++ b/src/test/ui/issues/issue-19538.stderr @@ -1,16 +1,16 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-19538.rs:17:15 | -LL | let test: &mut Bar = &mut thing; - | ^^^^^^^^ the trait `Bar` cannot be made into an object +LL | let test: &mut dyn Bar = &mut thing; + | ^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `foo` has generic type parameters error[E0038]: the trait `Bar` cannot be made into an object - --> $DIR/issue-19538.rs:17:26 + --> $DIR/issue-19538.rs:17:30 | -LL | let test: &mut Bar = &mut thing; - | ^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | let test: &mut dyn Bar = &mut thing; + | ^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `foo` has generic type parameters = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&mut dyn Bar>` for `&mut Thing` diff --git a/src/test/ui/issues/issue-20396.rs b/src/test/ui/issues/issue-20396.rs index b6dfffbd69e..0e69b7f3d1e 100644 --- a/src/test/ui/issues/issue-20396.rs +++ b/src/test/ui/issues/issue-20396.rs @@ -10,7 +10,7 @@ trait Foo<T> { enum Bar<T> { Bla(T) } struct Baz<'a> { - inner: for<'b> Foo<Bar<&'b ()>> + 'a, + inner: dyn for<'b> Foo<Bar<&'b ()>> + 'a, } fn main() {} diff --git a/src/test/ui/issues/issue-20605.rs b/src/test/ui/issues/issue-20605.rs index 11a2a573ea6..17b7d32ebf5 100644 --- a/src/test/ui/issues/issue-20605.rs +++ b/src/test/ui/issues/issue-20605.rs @@ -1,4 +1,4 @@ -fn changer<'a>(mut things: Box<Iterator<Item=&'a mut u8>>) { +fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) { for item in *things { *item = 0 } //~^ ERROR the size for values of type } diff --git a/src/test/ui/issues/issue-20692.rs b/src/test/ui/issues/issue-20692.rs index ea89bca78d0..2a05bba7b16 100644 --- a/src/test/ui/issues/issue-20692.rs +++ b/src/test/ui/issues/issue-20692.rs @@ -4,7 +4,7 @@ fn f<T: Array>(x: &T) { let _ = x //~^ ERROR `Array` cannot be made into an object as - &Array; + &dyn Array; //~^ ERROR `Array` cannot be made into an object } diff --git a/src/test/ui/issues/issue-20692.stderr b/src/test/ui/issues/issue-20692.stderr index acc223c0b2d..66309394a42 100644 --- a/src/test/ui/issues/issue-20692.stderr +++ b/src/test/ui/issues/issue-20692.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Array` cannot be made into an object --> $DIR/issue-20692.rs:7:5 | -LL | &Array; - | ^^^^^^ the trait `Array` cannot be made into an object +LL | &dyn Array; + | ^^^^^^^^^^ the trait `Array` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/issues/issue-20831-debruijn.rs b/src/test/ui/issues/issue-20831-debruijn.rs index 6d3c7331a45..ef4b1581fd8 100644 --- a/src/test/ui/issues/issue-20831-debruijn.rs +++ b/src/test/ui/issues/issue-20831-debruijn.rs @@ -12,7 +12,7 @@ pub trait Subscriber { pub trait Publisher<'a> { type Output; - fn subscribe(&mut self, _: Box<Subscriber<Input=Self::Output> + 'a>); + fn subscribe(&mut self, _: Box<dyn Subscriber<Input=Self::Output> + 'a>); } pub trait Processor<'a> : Subscriber + Publisher<'a> { } @@ -20,12 +20,12 @@ pub trait Processor<'a> : Subscriber + Publisher<'a> { } impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { } struct MyStruct<'a> { - sub: Box<Subscriber<Input=u64> + 'a> + sub: Box<dyn Subscriber<Input=u64> + 'a> } impl<'a> Publisher<'a> for MyStruct<'a> { type Output = u64; - fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { + fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { // Not obvious, but there is an implicit lifetime here -------^ //~^^ ERROR cannot infer //~| ERROR mismatched types diff --git a/src/test/ui/issues/issue-20831-debruijn.stderr b/src/test/ui/issues/issue-20831-debruijn.stderr index 70a395d0b89..64e3cdc64c1 100644 --- a/src/test/ui/issues/issue-20831-debruijn.stderr +++ b/src/test/ui/issues/issue-20831-debruijn.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -15,7 +15,7 @@ LL | | } note: the anonymous lifetime #2 defined on the method body at 28:5... --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -32,7 +32,7 @@ LL | impl<'a> Publisher<'a> for MyStruct<'a> { error[E0308]: mismatched types --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -51,7 +51,7 @@ LL | impl<'a> Publisher<'a> for MyStruct<'a> { note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 28:5 --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -63,7 +63,7 @@ LL | | } error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | @@ -75,7 +75,7 @@ LL | | } note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 28:5... --> $DIR/issue-20831-debruijn.rs:28:5 | -LL | / fn subscribe(&mut self, t : Box<Subscriber<Input=<Self as Publisher>::Output> + 'a>) { +LL | / fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) { LL | | // Not obvious, but there is an implicit lifetime here -------^ LL | | LL | | diff --git a/src/test/ui/issues/issue-20939.rs b/src/test/ui/issues/issue-20939.rs index 259fff2e6c2..c0c22297897 100644 --- a/src/test/ui/issues/issue-20939.rs +++ b/src/test/ui/issues/issue-20939.rs @@ -1,6 +1,6 @@ trait Foo {} -impl<'a> Foo for Foo+'a {} +impl<'a> Foo for dyn Foo + 'a {} //~^ ERROR the object type `(dyn Foo + 'a)` automatically implements the trait `Foo` fn main() {} diff --git a/src/test/ui/issues/issue-20939.stderr b/src/test/ui/issues/issue-20939.stderr index d15a5196667..3819a21a2cf 100644 --- a/src/test/ui/issues/issue-20939.stderr +++ b/src/test/ui/issues/issue-20939.stderr @@ -1,8 +1,8 @@ error[E0371]: the object type `(dyn Foo + 'a)` automatically implements the trait `Foo` --> $DIR/issue-20939.rs:3:1 | -LL | impl<'a> Foo for Foo+'a {} - | ^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Foo + 'a)` automatically implements trait `Foo` +LL | impl<'a> Foo for dyn Foo + 'a {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Foo + 'a)` automatically implements trait `Foo` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21363.rs b/src/test/ui/issues/issue-21363.rs index 5e30db17c6d..12efce9496e 100644 --- a/src/test/ui/issues/issue-21363.rs +++ b/src/test/ui/issues/issue-21363.rs @@ -8,7 +8,7 @@ trait Iterator { fn dummy(&self) { } } -impl<'a, T> Iterator for &'a mut (Iterator<Item=T> + 'a) { +impl<'a, T> Iterator for &'a mut (dyn Iterator<Item=T> + 'a) { type Item = T; } diff --git a/src/test/ui/issues/issue-21950.rs b/src/test/ui/issues/issue-21950.rs index b902893bf82..0bc87824cce 100644 --- a/src/test/ui/issues/issue-21950.rs +++ b/src/test/ui/issues/issue-21950.rs @@ -2,7 +2,7 @@ use std::ops::Add; fn main() { let x = &10 as - &Add; + &dyn Add; //~^ ERROR E0393 //~| ERROR E0191 } diff --git a/src/test/ui/issues/issue-21950.stderr b/src/test/ui/issues/issue-21950.stderr index 7655e0811e0..9be7b052da3 100644 --- a/src/test/ui/issues/issue-21950.stderr +++ b/src/test/ui/issues/issue-21950.stderr @@ -1,16 +1,16 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-21950.rs:5:14 + --> $DIR/issue-21950.rs:5:18 | -LL | &Add; - | ^^^ missing reference to `Rhs` +LL | &dyn Add; + | ^^^ missing reference to `Rhs` | = note: because of the default `Self` reference, type parameters must be specified on object types error[E0191]: the value of the associated type `Output` (from the trait `std::ops::Add`) must be specified --> $DIR/issue-21950.rs:5:14 | -LL | &Add; - | ^^^ associated type `Output` must be specified +LL | &dyn Add; + | ^^^^^^^ associated type `Output` must be specified error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-22034.rs b/src/test/ui/issues/issue-22034.rs index 75ac78ad24f..508c9c91b04 100644 --- a/src/test/ui/issues/issue-22034.rs +++ b/src/test/ui/issues/issue-22034.rs @@ -4,8 +4,8 @@ extern crate libc; fn main() { let ptr: *mut () = 0 as *mut _; - let _: &mut Fn() = unsafe { - &mut *(ptr as *mut Fn()) + let _: &mut dyn Fn() = unsafe { + &mut *(ptr as *mut dyn Fn()) //~^ ERROR expected a `std::ops::Fn<()>` closure, found `()` }; } diff --git a/src/test/ui/issues/issue-22034.stderr b/src/test/ui/issues/issue-22034.stderr index de2d315ff5c..19fb080154a 100644 --- a/src/test/ui/issues/issue-22034.stderr +++ b/src/test/ui/issues/issue-22034.stderr @@ -1,7 +1,7 @@ error[E0277]: expected a `std::ops::Fn<()>` closure, found `()` --> $DIR/issue-22034.rs:8:16 | -LL | &mut *(ptr as *mut Fn()) +LL | &mut *(ptr as *mut dyn Fn()) | ^^^ expected an `Fn<()>` closure, found `()` | = help: the trait `std::ops::Fn<()>` is not implemented for `()` diff --git a/src/test/ui/issues/issue-22289.rs b/src/test/ui/issues/issue-22289.rs index b683834de44..e1b3dfe5b61 100644 --- a/src/test/ui/issues/issue-22289.rs +++ b/src/test/ui/issues/issue-22289.rs @@ -1,3 +1,3 @@ fn main() { - 0 as &std::any::Any; //~ ERROR non-primitive cast + 0 as &dyn std::any::Any; //~ ERROR non-primitive cast } diff --git a/src/test/ui/issues/issue-22289.stderr b/src/test/ui/issues/issue-22289.stderr index e9846b848f4..cc7ace30cab 100644 --- a/src/test/ui/issues/issue-22289.stderr +++ b/src/test/ui/issues/issue-22289.stderr @@ -1,8 +1,8 @@ error[E0605]: non-primitive cast: `i32` as `&(dyn std::any::Any + 'static)` --> $DIR/issue-22289.rs:2:5 | -LL | 0 as &std::any::Any; - | ^^^^^^^^^^^^^^^^^^^ +LL | 0 as &dyn std::any::Any; + | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait diff --git a/src/test/ui/issues/issue-22312.rs b/src/test/ui/issues/issue-22312.rs index f7ebdb0372a..250fec25887 100644 --- a/src/test/ui/issues/issue-22312.rs +++ b/src/test/ui/issues/issue-22312.rs @@ -8,7 +8,7 @@ pub trait Array2D: Index<usize> { return None; } let i = y * self.columns() + x; - let indexer = &(*self as &Index<usize, Output = <Self as Index<usize>>::Output>); + let indexer = &(*self as &dyn Index<usize, Output = <Self as Index<usize>>::Output>); //~^ERROR non-primitive cast Some(indexer.index(i)) } diff --git a/src/test/ui/issues/issue-22312.stderr b/src/test/ui/issues/issue-22312.stderr index 6a012b214c5..fc32fd376b7 100644 --- a/src/test/ui/issues/issue-22312.stderr +++ b/src/test/ui/issues/issue-22312.stderr @@ -1,8 +1,8 @@ error[E0605]: non-primitive cast: `Self` as `&dyn std::ops::Index<usize, Output = <Self as std::ops::Index<usize>>::Output>` --> $DIR/issue-22312.rs:11:24 | -LL | let indexer = &(*self as &Index<usize, Output = <Self as Index<usize>>::Output>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let indexer = &(*self as &dyn Index<usize, Output = <Self as Index<usize>>::Output>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait diff --git a/src/test/ui/issues/issue-22370.rs b/src/test/ui/issues/issue-22370.rs index 90912cfda0d..bab0469c011 100644 --- a/src/test/ui/issues/issue-22370.rs +++ b/src/test/ui/issues/issue-22370.rs @@ -1,6 +1,6 @@ trait A<T=Self> {} -fn f(a: &A) {} +fn f(a: &dyn A) {} //~^ ERROR E0393 fn main() {} diff --git a/src/test/ui/issues/issue-22370.stderr b/src/test/ui/issues/issue-22370.stderr index f21551a55bc..3ce164e9548 100644 --- a/src/test/ui/issues/issue-22370.stderr +++ b/src/test/ui/issues/issue-22370.stderr @@ -1,8 +1,8 @@ error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/issue-22370.rs:3:10 + --> $DIR/issue-22370.rs:3:14 | -LL | fn f(a: &A) {} - | ^ missing reference to `T` +LL | fn f(a: &dyn A) {} + | ^ missing reference to `T` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/issues/issue-22434.rs b/src/test/ui/issues/issue-22434.rs index 0d7d67cbc1b..3e800a2b61d 100644 --- a/src/test/ui/issues/issue-22434.rs +++ b/src/test/ui/issues/issue-22434.rs @@ -2,7 +2,7 @@ pub trait Foo { type A; } -type I<'a> = &'a (Foo + 'a); +type I<'a> = &'a (dyn Foo + 'a); //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified fn main() {} diff --git a/src/test/ui/issues/issue-22434.stderr b/src/test/ui/issues/issue-22434.stderr index bbdbeb6ae98..eb78c4fc311 100644 --- a/src/test/ui/issues/issue-22434.stderr +++ b/src/test/ui/issues/issue-22434.stderr @@ -4,8 +4,8 @@ error[E0191]: the value of the associated type `A` (from the trait `Foo`) must b LL | type A; | ------- `A` defined here ... -LL | type I<'a> = &'a (Foo + 'a); - | ^^^^^^^^ associated type `A` must be specified +LL | type I<'a> = &'a (dyn Foo + 'a); + | ^^^^^^^^^^^^ associated type `A` must be specified error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22560.rs b/src/test/ui/issues/issue-22560.rs index 4b8e3aa9eb3..acee99dbedc 100644 --- a/src/test/ui/issues/issue-22560.rs +++ b/src/test/ui/issues/issue-22560.rs @@ -1,6 +1,6 @@ use std::ops::{Add, Sub}; -type Test = Add + +type Test = dyn Add + //~^ ERROR E0393 //~| ERROR E0191 Sub; diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr index 322136d35ca..5b58adb197c 100644 --- a/src/test/ui/issues/issue-22560.stderr +++ b/src/test/ui/issues/issue-22560.stderr @@ -7,21 +7,21 @@ LL | Sub; = note: because of the default `Self` reference, type parameters must be specified on object types error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:3:13 + --> $DIR/issue-22560.rs:3:17 | -LL | type Test = Add + - | ^^^ missing reference to `Rhs` +LL | type Test = dyn Add + + | ^^^ missing reference to `Rhs` | = note: because of the default `Self` reference, type parameters must be specified on object types error[E0225]: only auto traits can be used as additional traits in a trait object --> $DIR/issue-22560.rs:6:13 | -LL | type Test = Add + - | --- - | | - | first non-auto trait - | trait alias used in trait object type (first use) +LL | type Test = dyn Add + + | --- + | | + | first non-auto trait + | trait alias used in trait object type (first use) ... LL | Sub; | ^^^ @@ -32,7 +32,7 @@ LL | Sub; error[E0191]: the value of the associated types `Output` (from the trait `std::ops::Add`), `Output` (from the trait `std::ops::Sub`) must be specified --> $DIR/issue-22560.rs:3:13 | -LL | type Test = Add + +LL | type Test = dyn Add + | _____________^ | |_____________| | | diff --git a/src/test/ui/issues/issue-22781.rs b/src/test/ui/issues/issue-22781.rs index 5df3d88b168..a7b94c106a4 100644 --- a/src/test/ui/issues/issue-22781.rs +++ b/src/test/ui/issues/issue-22781.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use std::collections::hash_map::Entry::Vacant; pub fn foo() { - type F = Box<Fn(&()) + 'static>; + type F = Box<dyn Fn(&()) + 'static>; let mut map: HashMap<(), F> = HashMap::new(); let x: &mut F = match map.entry(()) { Vacant(_) => unimplemented!(), diff --git a/src/test/ui/issues/issue-22872.rs b/src/test/ui/issues/issue-22872.rs index 8ef4af15bd4..5db2891e65e 100644 --- a/src/test/ui/issues/issue-22872.rs +++ b/src/test/ui/issues/issue-22872.rs @@ -17,7 +17,7 @@ pub trait Process<'a> { } fn push_process<P>(process: P) where P: Process<'static> { - let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process)); + let _: Box<dyn for<'b> Wrap<'b>> = Box::new(Wrapper(process)); //~^ ERROR is not an iterator } diff --git a/src/test/ui/issues/issue-22872.stderr b/src/test/ui/issues/issue-22872.stderr index ebd096f1dde..fc5de23752b 100644 --- a/src/test/ui/issues/issue-22872.stderr +++ b/src/test/ui/issues/issue-22872.stderr @@ -1,8 +1,8 @@ error[E0277]: `<P as Process<'_>>::Item` is not an iterator - --> $DIR/issue-22872.rs:20:36 + --> $DIR/issue-22872.rs:20:40 | -LL | let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `<P as Process<'_>>::Item` is not an iterator +LL | let _: Box<dyn for<'b> Wrap<'b>> = Box::new(Wrapper(process)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `<P as Process<'_>>::Item` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `<P as Process<'_>>::Item` = help: consider adding a `where <P as Process<'_>>::Item: std::iter::Iterator` bound diff --git a/src/test/ui/issues/issue-23024.rs b/src/test/ui/issues/issue-23024.rs index 0639ce30aa0..2638e15f0ea 100644 --- a/src/test/ui/issues/issue-23024.rs +++ b/src/test/ui/issues/issue-23024.rs @@ -4,9 +4,9 @@ use std::any::Any; fn main() { fn h(x:i32) -> i32 {3*x} - let mut vfnfer:Vec<Box<Any>> = vec![]; + let mut vfnfer:Vec<Box<dyn Any>> = vec![]; vfnfer.push(box h); - println!("{:?}",(vfnfer[0] as Fn)(3)); + println!("{:?}",(vfnfer[0] as dyn Fn)(3)); //~^ ERROR the precise format of `Fn`-family traits' //~| ERROR wrong number of type arguments: expected 1, found 0 [E0107] //~| ERROR the value of the associated type `Output` (from the trait `std::ops::FnOnce`) diff --git a/src/test/ui/issues/issue-23024.stderr b/src/test/ui/issues/issue-23024.stderr index fbefbe4f56e..e99854539de 100644 --- a/src/test/ui/issues/issue-23024.stderr +++ b/src/test/ui/issues/issue-23024.stderr @@ -1,23 +1,23 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead - --> $DIR/issue-23024.rs:9:35 + --> $DIR/issue-23024.rs:9:39 | -LL | println!("{:?}",(vfnfer[0] as Fn)(3)); - | ^^ +LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); + | ^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0107]: wrong number of type arguments: expected 1, found 0 - --> $DIR/issue-23024.rs:9:35 + --> $DIR/issue-23024.rs:9:39 | -LL | println!("{:?}",(vfnfer[0] as Fn)(3)); - | ^^ expected 1 type argument +LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); + | ^^ expected 1 type argument error[E0191]: the value of the associated type `Output` (from the trait `std::ops::FnOnce`) must be specified --> $DIR/issue-23024.rs:9:35 | -LL | println!("{:?}",(vfnfer[0] as Fn)(3)); - | ^^ associated type `Output` must be specified +LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); + | ^^^^^^ associated type `Output` must be specified error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-23041.rs b/src/test/ui/issues/issue-23041.rs index a18e85806d9..a1371521a0a 100644 --- a/src/test/ui/issues/issue-23041.rs +++ b/src/test/ui/issues/issue-23041.rs @@ -2,6 +2,6 @@ use std::any::Any; fn main() { fn bar(x:i32) ->i32 { 3*x }; - let b:Box<Any> = Box::new(bar as fn(_)->_); + let b:Box<dyn Any> = Box::new(bar as fn(_)->_); b.downcast_ref::<fn(_)->_>(); //~ ERROR E0282 } diff --git a/src/test/ui/issues/issue-23046.rs b/src/test/ui/issues/issue-23046.rs index 898654b7b59..a68369616d8 100644 --- a/src/test/ui/issues/issue-23046.rs +++ b/src/test/ui/issues/issue-23046.rs @@ -1,6 +1,6 @@ pub enum Expr<'var, VAR> { Let(Box<Expr<'var, VAR>>, - Box<for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>) + Box<dyn for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>) } pub fn add<'var, VAR> diff --git a/src/test/ui/issues/issue-23281.rs b/src/test/ui/issues/issue-23281.rs index 2b457a57d3e..d5f74728862 100644 --- a/src/test/ui/issues/issue-23281.rs +++ b/src/test/ui/issues/issue-23281.rs @@ -1,7 +1,7 @@ pub struct Struct; impl Struct { - pub fn function(funs: Vec<Fn() -> ()>) {} + pub fn function(funs: Vec<dyn Fn() -> ()>) {} //~^ ERROR the size for values of type } diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index e540d4e8192..f1def474583 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn() + 'static)` cannot be known at compilation time --> $DIR/issue-23281.rs:4:5 | -LL | pub fn function(funs: Vec<Fn() -> ()>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +LL | pub fn function(funs: Vec<dyn Fn() -> ()>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/issues/issue-24446.rs b/src/test/ui/issues/issue-24446.rs index c5e1b49e5ed..ffd6dfabc28 100644 --- a/src/test/ui/issues/issue-24446.rs +++ b/src/test/ui/issues/issue-24446.rs @@ -1,5 +1,5 @@ fn main() { - static foo: Fn() -> u32 = || -> u32 { + static foo: dyn Fn() -> u32 = || -> u32 { //~^ ERROR the size for values of type 0 }; diff --git a/src/test/ui/issues/issue-24446.stderr b/src/test/ui/issues/issue-24446.stderr index ffec73b1ab4..344443e7830 100644 --- a/src/test/ui/issues/issue-24446.stderr +++ b/src/test/ui/issues/issue-24446.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn() -> u32 + 'static)` cannot be known at compilation time --> $DIR/issue-24446.rs:2:17 | -LL | static foo: Fn() -> u32 = || -> u32 { - | ^^^^^^^^^^^ doesn't have a size known at compile-time +LL | static foo: dyn Fn() -> u32 = || -> u32 { + | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() -> u32 + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/issues/issue-25180.rs b/src/test/ui/issues/issue-25180.rs index 739d571d727..297f403c05e 100644 --- a/src/test/ui/issues/issue-25180.rs +++ b/src/test/ui/issues/issue-25180.rs @@ -2,6 +2,6 @@ #![allow(dead_code)] #![allow(non_upper_case_globals)] -const x: &'static Fn() = &|| println!("ICE here"); +const x: &'static dyn Fn() = &|| println!("ICE here"); fn main() {} diff --git a/src/test/ui/issues/issue-26056.rs b/src/test/ui/issues/issue-26056.rs index 0d9973b4548..99d43ec792b 100644 --- a/src/test/ui/issues/issue-26056.rs +++ b/src/test/ui/issues/issue-26056.rs @@ -17,6 +17,6 @@ impl<K> Map for K { fn main() { let _ = &() - as &Map<Key=u32,MapValue=u32>; + as &dyn Map<Key=u32,MapValue=u32>; //~^ ERROR E0038 } diff --git a/src/test/ui/issues/issue-26056.stderr b/src/test/ui/issues/issue-26056.stderr index 44fabd0db19..9c4cf0b18ac 100644 --- a/src/test/ui/issues/issue-26056.stderr +++ b/src/test/ui/issues/issue-26056.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Map` cannot be made into an object --> $DIR/issue-26056.rs:20:13 | -LL | as &Map<Key=u32,MapValue=u32>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Map` cannot be made into an object +LL | as &dyn Map<Key=u32,MapValue=u32>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Map` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/issues/issue-26638.rs b/src/test/ui/issues/issue-26638.rs index 0f5ed5caa74..72fe4286a06 100644 --- a/src/test/ui/issues/issue-26638.rs +++ b/src/test/ui/issues/issue-26638.rs @@ -1,4 +1,4 @@ -fn parse_type(iter: Box<Iterator<Item=&str>+'static>) -> &str { iter.next() } +fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() } //~^ ERROR missing lifetime specifier [E0106] fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } diff --git a/src/test/ui/issues/issue-26638.stderr b/src/test/ui/issues/issue-26638.stderr index 64c2cd43264..6d7c1b0c43f 100644 --- a/src/test/ui/issues/issue-26638.stderr +++ b/src/test/ui/issues/issue-26638.stderr @@ -1,8 +1,8 @@ error[E0106]: missing lifetime specifier - --> $DIR/issue-26638.rs:1:58 + --> $DIR/issue-26638.rs:1:62 | -LL | fn parse_type(iter: Box<Iterator<Item=&str>+'static>) -> &str { iter.next() } - | ^ expected lifetime parameter +LL | fn parse_type(iter: Box<dyn Iterator<Item=&str>+'static>) -> &str { iter.next() } + | ^ expected lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say which one of `iter`'s 2 lifetimes it is borrowed from diff --git a/src/test/ui/issues/issue-26905.rs b/src/test/ui/issues/issue-26905.rs index efd06219c3d..4c5c67d58bc 100644 --- a/src/test/ui/issues/issue-26905.rs +++ b/src/test/ui/issues/issue-26905.rs @@ -19,5 +19,5 @@ fn main() { let data = [1, 2, 3]; let iter = data.iter(); let x = MyRc { _ptr: &iter, _boo: NotPhantomData(PhantomData) }; - let _y: MyRc<Iterator<Item=&u32>> = x; + let _y: MyRc<dyn Iterator<Item=&u32>> = x; } diff --git a/src/test/ui/issues/issue-27105.rs b/src/test/ui/issues/issue-27105.rs index 5f0dff12aec..1aafa11768f 100644 --- a/src/test/ui/issues/issue-27105.rs +++ b/src/test/ui/issues/issue-27105.rs @@ -3,7 +3,7 @@ use std::cell::RefCell; use std::rc::Rc; pub struct Callbacks { - callbacks: Vec<Rc<RefCell<FnMut(i32)>>>, + callbacks: Vec<Rc<RefCell<dyn FnMut(i32)>>>, } impl Callbacks { diff --git a/src/test/ui/issues/issue-28279.rs b/src/test/ui/issues/issue-28279.rs index c770c509859..fab91160a88 100644 --- a/src/test/ui/issues/issue-28279.rs +++ b/src/test/ui/issues/issue-28279.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] use std::rc::Rc; -fn test1() -> Rc<for<'a> Fn(&'a usize) + 'static> { +fn test1() -> Rc<dyn for<'a> Fn(&'a usize) + 'static> { if let Some(_) = Some(1) { loop{} } else { @@ -10,7 +10,7 @@ fn test1() -> Rc<for<'a> Fn(&'a usize) + 'static> { } } -fn test2() -> *mut (for<'a> Fn(&'a usize) + 'static) { +fn test2() -> *mut (dyn for<'a> Fn(&'a usize) + 'static) { if let Some(_) = Some(1) { loop{} } else { diff --git a/src/test/ui/issues/issue-28576.rs b/src/test/ui/issues/issue-28576.rs index de665d5aa16..972c839b648 100644 --- a/src/test/ui/issues/issue-28576.rs +++ b/src/test/ui/issues/issue-28576.rs @@ -4,7 +4,7 @@ pub trait Foo<RHS=Self> { pub trait Bar: Foo<Assoc=()> { fn new(&self, b: & - Bar //~ ERROR the trait `Bar` cannot be made into an object + dyn Bar //~ ERROR the trait `Bar` cannot be made into an object <Assoc=()> ); } diff --git a/src/test/ui/issues/issue-28576.stderr b/src/test/ui/issues/issue-28576.stderr index cf6174ba857..3249d76e69b 100644 --- a/src/test/ui/issues/issue-28576.stderr +++ b/src/test/ui/issues/issue-28576.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-28576.rs:7:12 | -LL | / Bar +LL | / dyn Bar LL | | <Assoc=()> | |________________________^ the trait `Bar` cannot be made into an object | diff --git a/src/test/ui/issues/issue-2904.rs b/src/test/ui/issues/issue-2904.rs index 7755b7ecee3..42f71a1b096 100644 --- a/src/test/ui/issues/issue-2904.rs +++ b/src/test/ui/issues/issue-2904.rs @@ -55,7 +55,7 @@ fn square_from_char(c: char) -> square { fn read_board_grid<rdr:'static + Read>(mut input: rdr) -> Vec<Vec<square>> { - let mut input: &mut Read = &mut input; + let mut input: &mut dyn Read = &mut input; let mut grid = Vec::new(); let mut line = [0; 10]; input.read(&mut line); diff --git a/src/test/ui/issues/issue-32963.rs b/src/test/ui/issues/issue-32963.rs index be59d3522b8..ee099069f02 100644 --- a/src/test/ui/issues/issue-32963.rs +++ b/src/test/ui/issues/issue-32963.rs @@ -5,7 +5,7 @@ trait Misc {} fn size_of_copy<T: Copy+?Sized>() -> usize { mem::size_of::<T>() } fn main() { - size_of_copy::<Misc+Copy>(); + size_of_copy::<dyn Misc + Copy>(); //~^ ERROR only auto traits can be used as additional traits in a trait object //~| ERROR the trait bound `dyn Misc: std::marker::Copy` is not satisfied } diff --git a/src/test/ui/issues/issue-32963.stderr b/src/test/ui/issues/issue-32963.stderr index cde4123dc3f..a31a74a07f4 100644 --- a/src/test/ui/issues/issue-32963.stderr +++ b/src/test/ui/issues/issue-32963.stderr @@ -1,19 +1,19 @@ error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/issue-32963.rs:8:25 + --> $DIR/issue-32963.rs:8:31 | -LL | size_of_copy::<Misc+Copy>(); - | ---- ^^^^ - | | | - | | additional non-auto trait - | | trait alias used in trait object type (additional use) - | first non-auto trait - | trait alias used in trait object type (first use) +LL | size_of_copy::<dyn Misc + Copy>(); + | ---- ^^^^ + | | | + | | additional non-auto trait + | | trait alias used in trait object type (additional use) + | first non-auto trait + | trait alias used in trait object type (first use) error[E0277]: the trait bound `dyn Misc: std::marker::Copy` is not satisfied --> $DIR/issue-32963.rs:8:5 | -LL | size_of_copy::<Misc+Copy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `dyn Misc` +LL | size_of_copy::<dyn Misc + Copy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `dyn Misc` | note: required by `size_of_copy` --> $DIR/issue-32963.rs:5:1 diff --git a/src/test/ui/issues/issue-32995.rs b/src/test/ui/issues/issue-32995.rs index c32fb63f1e5..3526deffc79 100644 --- a/src/test/ui/issues/issue-32995.rs +++ b/src/test/ui/issues/issue-32995.rs @@ -17,11 +17,11 @@ fn main() { //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait //~| WARN previously accepted - let o : Box<::std::marker()::Send> = Box::new(1); + let o : Box<dyn (::std::marker()::Send)> = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait //~| WARN previously accepted - let o : Box<Send + ::std::marker()::Sync> = Box::new(1); + let o : Box<dyn Send + ::std::marker()::Sync> = Box::new(1); //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait //~| WARN previously accepted } diff --git a/src/test/ui/issues/issue-32995.stderr b/src/test/ui/issues/issue-32995.stderr index 97b4b7fa76c..f97d86f6522 100644 --- a/src/test/ui/issues/issue-32995.stderr +++ b/src/test/ui/issues/issue-32995.stderr @@ -36,19 +36,19 @@ LL | let p = ::std::str::from_utf8::()(b"foo").unwrap(); = note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238> error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:20:30 + --> $DIR/issue-32995.rs:20:35 | -LL | let o : Box<::std::marker()::Send> = Box::new(1); - | ^^ +LL | let o : Box<dyn (::std::marker()::Send)> = Box::new(1); + | ^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238> error: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-32995.rs:24:37 + --> $DIR/issue-32995.rs:24:41 | -LL | let o : Box<Send + ::std::marker()::Sync> = Box::new(1); - | ^^ +LL | let o : Box<dyn Send + ::std::marker()::Sync> = Box::new(1); + | ^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42238 <https://github.com/rust-lang/rust/issues/42238> diff --git a/src/test/ui/issues/issue-33140-traitobject-crate.rs b/src/test/ui/issues/issue-33140-traitobject-crate.rs index 2b644817df1..078f3f3dd2c 100644 --- a/src/test/ui/issues/issue-33140-traitobject-crate.rs +++ b/src/test/ui/issues/issue-33140-traitobject-crate.rs @@ -13,85 +13,85 @@ /// Implementations for all traits in std are provided. pub unsafe trait Trait {} -unsafe impl Trait for ::std::any::Any + Send { } -unsafe impl Trait for ::std::any::Any + Sync { } -unsafe impl Trait for ::std::any::Any + Send + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::borrow::Borrow<T> + Send { } -unsafe impl<T: ?Sized> Trait for ::std::borrow::Borrow<T> + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::borrow::Borrow<T> + Send + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::borrow::BorrowMut<T> + Send { } -unsafe impl<T: ?Sized> Trait for ::std::borrow::BorrowMut<T> + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::borrow::BorrowMut<T> + Send + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::convert::AsMut<T> + Send { } -unsafe impl<T: ?Sized> Trait for ::std::convert::AsMut<T> + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::convert::AsMut<T> + Send + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::convert::AsRef<T> + Send { } -unsafe impl<T: ?Sized> Trait for ::std::convert::AsRef<T> + Sync { } -unsafe impl<T: ?Sized> Trait for ::std::convert::AsRef<T> + Send + Sync { } -unsafe impl Trait for ::std::error::Error + Send { } -unsafe impl Trait for ::std::error::Error + Sync { } -unsafe impl Trait for ::std::error::Error + Send + Sync { } -unsafe impl Trait for ::std::fmt::Binary + Send { } -unsafe impl Trait for ::std::fmt::Binary + Sync { } -unsafe impl Trait for ::std::fmt::Binary + Send + Sync { } -unsafe impl Trait for ::std::fmt::Debug + Send { } -unsafe impl Trait for ::std::fmt::Debug + Sync { } -unsafe impl Trait for ::std::fmt::Debug + Send + Sync { } -unsafe impl Trait for ::std::fmt::Display + Send { } -unsafe impl Trait for ::std::fmt::Display + Sync { } -unsafe impl Trait for ::std::fmt::Display + Send + Sync { } -unsafe impl Trait for ::std::fmt::LowerExp + Send { } -unsafe impl Trait for ::std::fmt::LowerExp + Sync { } -unsafe impl Trait for ::std::fmt::LowerExp + Send + Sync { } -unsafe impl Trait for ::std::fmt::LowerHex + Send { } -unsafe impl Trait for ::std::fmt::LowerHex + Sync { } -unsafe impl Trait for ::std::fmt::LowerHex + Send + Sync { } -unsafe impl Trait for ::std::fmt::Octal + Send { } -unsafe impl Trait for ::std::fmt::Octal + Sync { } -unsafe impl Trait for ::std::fmt::Octal + Send + Sync { } -unsafe impl Trait for ::std::fmt::Pointer + Send { } -unsafe impl Trait for ::std::fmt::Pointer + Sync { } -unsafe impl Trait for ::std::fmt::Pointer + Send + Sync { } -unsafe impl Trait for ::std::fmt::UpperExp + Send { } -unsafe impl Trait for ::std::fmt::UpperExp + Sync { } -unsafe impl Trait for ::std::fmt::UpperExp + Send + Sync { } -unsafe impl Trait for ::std::fmt::UpperHex + Send { } -unsafe impl Trait for ::std::fmt::UpperHex + Sync { } -unsafe impl Trait for ::std::fmt::UpperHex + Send + Sync { } -unsafe impl Trait for ::std::fmt::Write + Send { } -unsafe impl Trait for ::std::fmt::Write + Sync { } -unsafe impl Trait for ::std::fmt::Write + Send + Sync { } -unsafe impl Trait for ::std::hash::Hasher + Send { } -unsafe impl Trait for ::std::hash::Hasher + Sync { } -unsafe impl Trait for ::std::hash::Hasher + Send + Sync { } -unsafe impl Trait for ::std::io::BufRead + Send { } -unsafe impl Trait for ::std::io::BufRead + Sync { } -unsafe impl Trait for ::std::io::BufRead + Send + Sync { } -unsafe impl Trait for ::std::io::Read + Send { } -unsafe impl Trait for ::std::io::Read + Sync { } -unsafe impl Trait for ::std::io::Read + Send + Sync { } -unsafe impl Trait for ::std::io::Seek + Send { } -unsafe impl Trait for ::std::io::Seek + Sync { } -unsafe impl Trait for ::std::io::Seek + Send + Sync { } -unsafe impl Trait for ::std::io::Write + Send { } -unsafe impl Trait for ::std::io::Write + Sync { } -unsafe impl Trait for ::std::io::Write + Send + Sync { } -unsafe impl<T, I> Trait for ::std::iter::IntoIterator<IntoIter=I, Item=T> { } -unsafe impl<T> Trait for ::std::iter::Iterator<Item=T> + Send { } -unsafe impl<T> Trait for ::std::iter::Iterator<Item=T> + Sync { } -unsafe impl<T> Trait for ::std::iter::Iterator<Item=T> + Send + Sync { } -unsafe impl Trait for ::std::marker::Send + Send { } -unsafe impl Trait for ::std::marker::Send + Sync { } -unsafe impl Trait for ::std::marker::Send + Send + Sync { } -unsafe impl Trait for ::std::marker::Sync + Send { } -unsafe impl Trait for ::std::marker::Sync + Sync { } -unsafe impl Trait for ::std::marker::Sync + Send + Sync { } -unsafe impl Trait for ::std::ops::Drop + Send { } -unsafe impl Trait for ::std::ops::Drop + Sync { } -unsafe impl Trait for ::std::ops::Drop + Send + Sync { } -unsafe impl Trait for ::std::string::ToString + Send { } -unsafe impl Trait for ::std::string::ToString + Sync { } -unsafe impl Trait for ::std::string::ToString + Send + Sync { } +unsafe impl Trait for dyn (::std::any::Any) + Send { } +unsafe impl Trait for dyn (::std::any::Any) + Sync { } +unsafe impl Trait for dyn (::std::any::Any) + Send + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::borrow::Borrow<T>) + Send { } +unsafe impl<T: ?Sized> Trait for dyn (::std::borrow::Borrow<T>) + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::borrow::Borrow<T>) + Send + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::borrow::BorrowMut<T>) + Send { } +unsafe impl<T: ?Sized> Trait for dyn (::std::borrow::BorrowMut<T>) + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::borrow::BorrowMut<T>) + Send + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::convert::AsMut<T>) + Send { } +unsafe impl<T: ?Sized> Trait for dyn (::std::convert::AsMut<T>) + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::convert::AsMut<T>) + Send + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::convert::AsRef<T>) + Send { } +unsafe impl<T: ?Sized> Trait for dyn (::std::convert::AsRef<T>) + Sync { } +unsafe impl<T: ?Sized> Trait for dyn (::std::convert::AsRef<T>) + Send + Sync { } +unsafe impl Trait for dyn (::std::error::Error) + Send { } +unsafe impl Trait for dyn (::std::error::Error) + Sync { } +unsafe impl Trait for dyn (::std::error::Error) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Binary) + Send { } +unsafe impl Trait for dyn (::std::fmt::Binary) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Binary) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Debug) + Send { } +unsafe impl Trait for dyn (::std::fmt::Debug) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Debug) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Display) + Send { } +unsafe impl Trait for dyn (::std::fmt::Display) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Display) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerExp) + Send { } +unsafe impl Trait for dyn (::std::fmt::LowerExp) + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerExp) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerHex) + Send { } +unsafe impl Trait for dyn (::std::fmt::LowerHex) + Sync { } +unsafe impl Trait for dyn (::std::fmt::LowerHex) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Octal) + Send { } +unsafe impl Trait for dyn (::std::fmt::Octal) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Octal) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Pointer) + Send { } +unsafe impl Trait for dyn (::std::fmt::Pointer) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Pointer) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperExp) + Send { } +unsafe impl Trait for dyn (::std::fmt::UpperExp) + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperExp) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperHex) + Send { } +unsafe impl Trait for dyn (::std::fmt::UpperHex) + Sync { } +unsafe impl Trait for dyn (::std::fmt::UpperHex) + Send + Sync { } +unsafe impl Trait for dyn (::std::fmt::Write) + Send { } +unsafe impl Trait for dyn (::std::fmt::Write) + Sync { } +unsafe impl Trait for dyn (::std::fmt::Write) + Send + Sync { } +unsafe impl Trait for dyn (::std::hash::Hasher) + Send { } +unsafe impl Trait for dyn (::std::hash::Hasher) + Sync { } +unsafe impl Trait for dyn (::std::hash::Hasher) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::BufRead) + Send { } +unsafe impl Trait for dyn (::std::io::BufRead) + Sync { } +unsafe impl Trait for dyn (::std::io::BufRead) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::Read) + Send { } +unsafe impl Trait for dyn (::std::io::Read) + Sync { } +unsafe impl Trait for dyn (::std::io::Read) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::Seek) + Send { } +unsafe impl Trait for dyn (::std::io::Seek) + Sync { } +unsafe impl Trait for dyn (::std::io::Seek) + Send + Sync { } +unsafe impl Trait for dyn (::std::io::Write) + Send { } +unsafe impl Trait for dyn (::std::io::Write) + Sync { } +unsafe impl Trait for dyn (::std::io::Write) + Send + Sync { } +unsafe impl<T, I> Trait for dyn (::std::iter::IntoIterator<IntoIter=I, Item=T>) { } +unsafe impl<T> Trait for dyn (::std::iter::Iterator<Item=T>) + Send { } +unsafe impl<T> Trait for dyn (::std::iter::Iterator<Item=T>) + Sync { } +unsafe impl<T> Trait for dyn (::std::iter::Iterator<Item=T>) + Send + Sync { } +unsafe impl Trait for dyn (::std::marker::Send) + Send { } +unsafe impl Trait for dyn (::std::marker::Send) + Sync { } +unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } +unsafe impl Trait for dyn (::std::marker::Sync) + Send { } +unsafe impl Trait for dyn (::std::marker::Sync) + Sync { } +unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } +unsafe impl Trait for dyn (::std::ops::Drop) + Send { } +unsafe impl Trait for dyn (::std::ops::Drop) + Sync { } +unsafe impl Trait for dyn (::std::ops::Drop) + Send + Sync { } +unsafe impl Trait for dyn (::std::string::ToString) + Send { } +unsafe impl Trait for dyn (::std::string::ToString) + Sync { } +unsafe impl Trait for dyn (::std::string::ToString) + Send + Sync { } fn assert_trait<T: Trait + ?Sized>() {} fn main() { diff --git a/src/test/ui/issues/issue-33140-traitobject-crate.stderr b/src/test/ui/issues/issue-33140-traitobject-crate.stderr index 6f71e79d0ee..76db98aa38b 100644 --- a/src/test/ui/issues/issue-33140-traitobject-crate.stderr +++ b/src/test/ui/issues/issue-33140-traitobject-crate.stderr @@ -1,10 +1,10 @@ warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:85:1 | -LL | unsafe impl Trait for ::std::marker::Send + Sync { } - | ------------------------------------------------ first implementation here -LL | unsafe impl Trait for ::std::marker::Send + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` +LL | unsafe impl Trait for dyn (::std::marker::Send) + Sync { } + | ------------------------------------------------------ first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` | note: lint level defined here --> $DIR/issue-33140-traitobject-crate.rs:3:9 @@ -17,10 +17,10 @@ LL | #![warn(order_dependent_trait_objects)] warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:86:1 | -LL | unsafe impl Trait for ::std::marker::Send + Send + Sync { } - | ------------------------------------------------------- first implementation here -LL | unsafe impl Trait for ::std::marker::Sync + Send { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` +LL | unsafe impl Trait for dyn (::std::marker::Send) + Send + Sync { } + | ------------------------------------------------------------- first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> @@ -28,11 +28,11 @@ LL | unsafe impl Trait for ::std::marker::Sync + Send { } warning: conflicting implementations of trait `Trait` for type `(dyn std::marker::Send + std::marker::Sync + 'static)`: (E0119) --> $DIR/issue-33140-traitobject-crate.rs:88:1 | -LL | unsafe impl Trait for ::std::marker::Sync + Send { } - | ------------------------------------------------ first implementation here -LL | unsafe impl Trait for ::std::marker::Sync + Sync { } -LL | unsafe impl Trait for ::std::marker::Sync + Send + Sync { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send { } + | ------------------------------------------------------ first implementation here +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Sync { } +LL | unsafe impl Trait for dyn (::std::marker::Sync) + Send + Sync { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn std::marker::Send + std::marker::Sync + 'static)` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #56484 <https://github.com/rust-lang/rust/issues/56484> diff --git a/src/test/ui/issues/issue-33140.rs b/src/test/ui/issues/issue-33140.rs index 930e24218ac..9bdac4b8375 100644 --- a/src/test/ui/issues/issue-33140.rs +++ b/src/test/ui/issues/issue-33140.rs @@ -38,10 +38,10 @@ impl Foo<dyn Sync + Send> { } fn main() { - assert_eq!(<Send+Sync>::xyz(), false); - assert_eq!(<Sync+Send>::xyz(), true); - assert_eq!(<Send+Sync>::uvw(), false); - assert_eq!(<Sync+Send+Sync>::uvw(), true); - assert_eq!(<Foo<Send+Sync>>::abc(), false); - assert_eq!(<Foo<Sync+Send>>::abc(), true); + assert_eq!(<dyn Send + Sync>::xyz(), false); + assert_eq!(<dyn Sync + Send>::xyz(), true); + assert_eq!(<dyn Send + Sync>::uvw(), false); + assert_eq!(<dyn Sync + Send+ Sync>::uvw(), true); + assert_eq!(<Foo<dyn Send + Sync>>::abc(), false); + assert_eq!(<Foo<dyn Sync + Send>>::abc(), true); } diff --git a/src/test/ui/issues/issue-33241.rs b/src/test/ui/issues/issue-33241.rs index 4c5052a60d3..4d6204cb288 100644 --- a/src/test/ui/issues/issue-33241.rs +++ b/src/test/ui/issues/issue-33241.rs @@ -9,6 +9,6 @@ fn any<T>() -> T { unreachable!() } fn main() { - let t: &(u8, fmt::Debug) = any(); + let t: &(u8, dyn fmt::Debug) = any(); println!("{:?}", &t.1); } diff --git a/src/test/ui/issues/issue-3424.rs b/src/test/ui/issues/issue-3424.rs index a9ba5f5408b..19f9f13e144 100644 --- a/src/test/ui/issues/issue-3424.rs +++ b/src/test/ui/issues/issue-3424.rs @@ -5,7 +5,7 @@ pub struct Path; -type rsrc_loader = Box<FnMut(&Path) -> Result<String, String>>; +type rsrc_loader = Box<dyn FnMut(&Path) -> Result<String, String>>; fn tester() { diff --git a/src/test/ui/issues/issue-35139.rs b/src/test/ui/issues/issue-35139.rs index 1ee00fc7ec2..e462f354373 100644 --- a/src/test/ui/issues/issue-35139.rs +++ b/src/test/ui/issues/issue-35139.rs @@ -7,14 +7,14 @@ pub trait MethodType { pub struct MTFn; impl<'a> MethodType for MTFn { //~ ERROR E0207 - type GetProp = fmt::Debug + 'a; + type GetProp = dyn fmt::Debug + 'a; } -fn bad(a: Box<<MTFn as MethodType>::GetProp>) -> Box<fmt::Debug+'static> { +fn bad(a: Box<<MTFn as MethodType>::GetProp>) -> Box<dyn fmt::Debug+'static> { a } -fn dangling(a: &str) -> Box<fmt::Debug> { +fn dangling(a: &str) -> Box<dyn fmt::Debug> { bad(Box::new(a)) } diff --git a/src/test/ui/issues/issue-35546.rs b/src/test/ui/issues/issue-35546.rs index 19c0491e4bc..500ba48e0b7 100644 --- a/src/test/ui/issues/issue-35546.rs +++ b/src/test/ui/issues/issue-35546.rs @@ -6,11 +6,11 @@ // `value` field of `Node<Send>`). struct Node<T: ?Sized + Send> { - next: Option<Box<Node<Send>>>, + next: Option<Box<Node<dyn Send>>>, value: T, } -fn clear(head: &mut Option<Box<Node<Send>>>) { +fn clear(head: &mut Option<Box<Node<dyn Send>>>) { match head.take() { Some(node) => *head = node.next, None => (), diff --git a/src/test/ui/issues/issue-35570.rs b/src/test/ui/issues/issue-35570.rs index e809b46bcdc..9bb9db63951 100644 --- a/src/test/ui/issues/issue-35570.rs +++ b/src/test/ui/issues/issue-35570.rs @@ -8,7 +8,7 @@ trait Trait2<'a> { type Ty; } -fn _ice(param: Box<for <'a> Trait1<<() as Trait2<'a>>::Ty>>) { +fn _ice(param: Box<dyn for <'a> Trait1<<() as Trait2<'a>>::Ty>>) { let _e: (usize, usize) = unsafe{mem::transmute(param)}; } diff --git a/src/test/ui/issues/issue-35976.rs b/src/test/ui/issues/issue-35976.rs index 95c0cc95bb2..d075794d994 100644 --- a/src/test/ui/issues/issue-35976.rs +++ b/src/test/ui/issues/issue-35976.rs @@ -3,14 +3,14 @@ mod private { fn wait(&self) where Self: Sized; } - impl Future for Box<Future> { + impl Future for Box<dyn Future> { fn wait(&self) { } } } //use private::Future; -fn bar(arg: Box<private::Future>) { +fn bar(arg: Box<dyn private::Future>) { arg.wait(); //~^ ERROR the `wait` method cannot be invoked on a trait object } diff --git a/src/test/ui/issues/issue-3609.rs b/src/test/ui/issues/issue-3609.rs index c76c183821e..9bccb2a21e3 100644 --- a/src/test/ui/issues/issue-3609.rs +++ b/src/test/ui/issues/issue-3609.rs @@ -6,7 +6,7 @@ use std::thread; use std::sync::mpsc::Sender; type RingBuffer = Vec<f64> ; -type SamplesFn = Box<FnMut(&RingBuffer) + Send>; +type SamplesFn = Box<dyn FnMut(&RingBuffer) + Send>; enum Msg { diff --git a/src/test/ui/issues/issue-36839.rs b/src/test/ui/issues/issue-36839.rs index 0944d07896e..a660368f401 100644 --- a/src/test/ui/issues/issue-36839.rs +++ b/src/test/ui/issues/issue-36839.rs @@ -19,5 +19,5 @@ impl<T> Broken for T { fn main() { - let _m: &Broken<Assoc=()> = &(); + let _m: &dyn Broken<Assoc=()> = &(); } diff --git a/src/test/ui/issues/issue-3702-2.rs b/src/test/ui/issues/issue-3702-2.rs index c3a92a23cef..d47f6d248f7 100644 --- a/src/test/ui/issues/issue-3702-2.rs +++ b/src/test/ui/issues/issue-3702-2.rs @@ -7,12 +7,12 @@ impl ToPrimitive for isize {} trait Add { fn to_int(&self) -> isize; - fn add_dynamic(&self, other: &Add) -> isize; + fn add_dynamic(&self, other: &dyn Add) -> isize; } impl Add for isize { fn to_int(&self) -> isize { *self } - fn add_dynamic(&self, other: &Add) -> isize { + fn add_dynamic(&self, other: &dyn Add) -> isize { self.to_int() + other.to_int() //~ ERROR multiple applicable items in scope } } diff --git a/src/test/ui/issues/issue-37515.rs b/src/test/ui/issues/issue-37515.rs index 090b9bbf1ec..cc07bd1d915 100644 --- a/src/test/ui/issues/issue-37515.rs +++ b/src/test/ui/issues/issue-37515.rs @@ -2,7 +2,7 @@ // compile-pass #![warn(unused)] -type Z = for<'x> Send; +type Z = dyn for<'x> Send; //~^ WARN type alias is never used diff --git a/src/test/ui/issues/issue-37515.stderr b/src/test/ui/issues/issue-37515.stderr index 1b496559484..1476d17cdc6 100644 --- a/src/test/ui/issues/issue-37515.stderr +++ b/src/test/ui/issues/issue-37515.stderr @@ -1,8 +1,8 @@ warning: type alias is never used: `Z` --> $DIR/issue-37515.rs:5:1 | -LL | type Z = for<'x> Send; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | type Z = dyn for<'x> Send; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here --> $DIR/issue-37515.rs:3:9 diff --git a/src/test/ui/issues/issue-38404.rs b/src/test/ui/issues/issue-38404.rs index cddd75e267c..1a92acc3404 100644 --- a/src/test/ui/issues/issue-38404.rs +++ b/src/test/ui/issues/issue-38404.rs @@ -1,6 +1,6 @@ trait A<T>: std::ops::Add<Self> + Sized {} trait B<T>: A<T> {} -trait C<T>: A<B<T, Output=usize>> {} +trait C<T>: A<dyn B<T, Output=usize>> {} //~^ ERROR the trait `B` cannot be made into an object fn main() {} diff --git a/src/test/ui/issues/issue-38404.stderr b/src/test/ui/issues/issue-38404.stderr index 06bcf220f18..d18a26b3a76 100644 --- a/src/test/ui/issues/issue-38404.stderr +++ b/src/test/ui/issues/issue-38404.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `B` cannot be made into an object --> $DIR/issue-38404.rs:3:15 | -LL | trait C<T>: A<B<T, Output=usize>> {} - | ^^^^^^^^^^^^^^^^^^ the trait `B` cannot be made into an object +LL | trait C<T>: A<dyn B<T, Output=usize>> {} + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `B` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/issues/issue-38604.rs b/src/test/ui/issues/issue-38604.rs index c172595a245..002a3c43fcb 100644 --- a/src/test/ui/issues/issue-38604.rs +++ b/src/test/ui/issues/issue-38604.rs @@ -11,6 +11,6 @@ impl Foo for () { } fn main() { - let _f: Box<Foo> = //~ ERROR `Foo` cannot be made into an object + let _f: Box<dyn Foo> = //~ ERROR `Foo` cannot be made into an object Box::new(()); //~ ERROR `Foo` cannot be made into an object } diff --git a/src/test/ui/issues/issue-38604.stderr b/src/test/ui/issues/issue-38604.stderr index 77b42b80613..8ef7d346cb3 100644 --- a/src/test/ui/issues/issue-38604.stderr +++ b/src/test/ui/issues/issue-38604.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/issue-38604.rs:14:13 | -LL | let _f: Box<Foo> = - | ^^^^^^^^ the trait `Foo` cannot be made into an object +LL | let _f: Box<dyn Foo> = + | ^^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/issues/issue-40000.rs b/src/test/ui/issues/issue-40000.rs index 320992c0764..9d5ef481afc 100644 --- a/src/test/ui/issues/issue-40000.rs +++ b/src/test/ui/issues/issue-40000.rs @@ -1,7 +1,7 @@ fn main() { let bar: fn(&mut u32) = |_| {}; - fn foo(x: Box<Fn(&i32)>) {} - let bar = Box::new(|x: &i32| {}) as Box<Fn(_)>; + fn foo(x: Box<dyn Fn(&i32)>) {} + let bar = Box::new(|x: &i32| {}) as Box<dyn Fn(_)>; foo(bar); //~ ERROR E0308 } diff --git a/src/test/ui/issues/issue-41139.rs b/src/test/ui/issues/issue-41139.rs index f3e6c44ecb9..4814232607c 100644 --- a/src/test/ui/issues/issue-41139.rs +++ b/src/test/ui/issues/issue-41139.rs @@ -1,8 +1,8 @@ trait Trait {} -fn get_function<'a>() -> &'a Fn() -> Trait { panic!("") } +fn get_function<'a>() -> &'a dyn Fn() -> dyn Trait { panic!("") } fn main() { - let t : &Trait = &get_function()(); + let t : &dyn Trait = &get_function()(); //~^ ERROR cannot move a value of type dyn Trait } diff --git a/src/test/ui/issues/issue-41139.stderr b/src/test/ui/issues/issue-41139.stderr index 4dd017b0a91..829d0cfa72c 100644 --- a/src/test/ui/issues/issue-41139.stderr +++ b/src/test/ui/issues/issue-41139.stderr @@ -1,8 +1,8 @@ error[E0161]: cannot move a value of type dyn Trait: the size of dyn Trait cannot be statically determined - --> $DIR/issue-41139.rs:6:23 + --> $DIR/issue-41139.rs:6:27 | -LL | let t : &Trait = &get_function()(); - | ^^^^^^^^^^^^^^^^ +LL | let t : &dyn Trait = &get_function()(); + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-42312.rs b/src/test/ui/issues/issue-42312.rs index b1c651f665b..426efcbf9b1 100644 --- a/src/test/ui/issues/issue-42312.rs +++ b/src/test/ui/issues/issue-42312.rs @@ -5,7 +5,7 @@ pub trait Foo { //~^ ERROR the size for values of type } -pub fn f(_: ToString) {} +pub fn f(_: dyn ToString) {} //~^ ERROR the size for values of type fn main() { } diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index 20c8d085cbc..bfdc4272fb3 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -11,10 +11,10 @@ LL | fn baz(_: Self::Target) where Self: Deref {} = help: unsized locals are gated as an unstable feature error[E0277]: the size for values of type `(dyn std::string::ToString + 'static)` cannot be known at compilation time - --> $DIR/issue-42312.rs:8:23 + --> $DIR/issue-42312.rs:8:27 | -LL | pub fn f(_: ToString) {} - | ^ doesn't have a size known at compile-time +LL | pub fn f(_: dyn ToString) {} + | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/issues/issue-4335.rs b/src/test/ui/issues/issue-4335.rs index d3c9954cdb0..a10ae9a1243 100644 --- a/src/test/ui/issues/issue-4335.rs +++ b/src/test/ui/issues/issue-4335.rs @@ -2,7 +2,7 @@ fn id<T>(t: T) -> T { t } -fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> { +fn f<'r, T>(v: &'r T) -> Box<dyn FnMut() -> T + 'r> { id(Box::new(|| *v)) //~^ ERROR E0373 //~| ERROR E0507 diff --git a/src/test/ui/issues/issue-4335.stderr b/src/test/ui/issues/issue-4335.stderr index 1b5cab24929..f1b6e475949 100644 --- a/src/test/ui/issues/issue-4335.stderr +++ b/src/test/ui/issues/issue-4335.stderr @@ -1,7 +1,7 @@ error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/issue-4335.rs:6:20 | -LL | fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> { +LL | fn f<'r, T>(v: &'r T) -> Box<dyn FnMut() -> T + 'r> { | - captured outer variable LL | id(Box::new(|| *v)) | ^^ cannot move out of captured variable in an `FnMut` closure diff --git a/src/test/ui/issues/issue-45730.rs b/src/test/ui/issues/issue-45730.rs index 5709125e5f0..3776759fe07 100644 --- a/src/test/ui/issues/issue-45730.rs +++ b/src/test/ui/issues/issue-45730.rs @@ -3,7 +3,7 @@ fn main() { let x: *const _ = 0 as _; //~ ERROR cannot cast let x: *const _ = 0 as *const _; //~ ERROR cannot cast - let y: Option<*const fmt::Debug> = Some(x) as _; + let y: Option<*const dyn fmt::Debug> = Some(x) as _; let x = 0 as *const i32 as *const _ as *mut _; //~ ERROR cannot cast } diff --git a/src/test/ui/issues/issue-4972.rs b/src/test/ui/issues/issue-4972.rs index 9c95a979476..fab258f137e 100644 --- a/src/test/ui/issues/issue-4972.rs +++ b/src/test/ui/issues/issue-4972.rs @@ -6,10 +6,10 @@ trait MyTrait { } pub enum TraitWrapper { - A(Box<MyTrait+'static>), + A(Box<dyn MyTrait + 'static>), } -fn get_tw_map(tw: &TraitWrapper) -> &MyTrait { +fn get_tw_map(tw: &TraitWrapper) -> &dyn MyTrait { match *tw { TraitWrapper::A(box ref map) => map, //~ ERROR cannot be dereferenced } diff --git a/src/test/ui/issues/issue-50761.rs b/src/test/ui/issues/issue-50761.rs index bcf3ebcd60a..70b4bc8b755 100644 --- a/src/test/ui/issues/issue-50761.rs +++ b/src/test/ui/issues/issue-50761.rs @@ -14,7 +14,7 @@ mod b { } impl Builder { - pub fn with_a(&mut self, _a: fn() -> ::a::A) {} + pub fn with_a(&mut self, _a: fn() -> dyn (::a::A)) {} } } diff --git a/src/test/ui/issues/issue-50781.rs b/src/test/ui/issues/issue-50781.rs index edf8d82b480..3c5e5a9f69a 100644 --- a/src/test/ui/issues/issue-50781.rs +++ b/src/test/ui/issues/issue-50781.rs @@ -15,5 +15,5 @@ impl Trait for dyn X {} pub fn main() { // Check that this does not segfault. - <X as X>::foo(&()); + <dyn X as X>::foo(&()); } diff --git a/src/test/ui/issues/issue-5153.rs b/src/test/ui/issues/issue-5153.rs index 551880ae009..e6737662088 100644 --- a/src/test/ui/issues/issue-5153.rs +++ b/src/test/ui/issues/issue-5153.rs @@ -7,6 +7,6 @@ impl Foo for isize { } fn main() { - (&5isize as &Foo).foo(); + (&5isize as &dyn Foo).foo(); //~^ ERROR: no method named `foo` found for type `&dyn Foo` in the current scope } diff --git a/src/test/ui/issues/issue-5153.stderr b/src/test/ui/issues/issue-5153.stderr index 48adfee0dec..97214fbdc52 100644 --- a/src/test/ui/issues/issue-5153.stderr +++ b/src/test/ui/issues/issue-5153.stderr @@ -1,8 +1,8 @@ error[E0599]: no method named `foo` found for type `&dyn Foo` in the current scope - --> $DIR/issue-5153.rs:10:23 + --> $DIR/issue-5153.rs:10:27 | -LL | (&5isize as &Foo).foo(); - | ^^^ +LL | (&5isize as &dyn Foo).foo(); + | ^^^ | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `foo`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-5216.rs b/src/test/ui/issues/issue-5216.rs index fd490884fa1..35b343edfbd 100644 --- a/src/test/ui/issues/issue-5216.rs +++ b/src/test/ui/issues/issue-5216.rs @@ -1,10 +1,10 @@ fn f() { } -struct S(Box<FnMut()>); +struct S(Box<dyn FnMut()>); pub static C: S = S(f); //~ ERROR mismatched types fn g() { } -type T = Box<FnMut()>; +type T = Box<dyn FnMut()>; pub static D: T = g; //~ ERROR mismatched types fn main() {} diff --git a/src/test/ui/issues/issue-53419.rs b/src/test/ui/issues/issue-53419.rs index 52149cf486d..bf6791734d4 100644 --- a/src/test/ui/issues/issue-53419.rs +++ b/src/test/ui/issues/issue-53419.rs @@ -1,7 +1,7 @@ //compile-pass struct Foo { - bar: for<'r> Fn(usize, &'r FnMut()) + bar: dyn for<'r> Fn(usize, &'r dyn FnMut()) } fn main() { diff --git a/src/test/ui/issues/issue-54582.rs b/src/test/ui/issues/issue-54582.rs index c2dbf361911..8c50cac67f8 100644 --- a/src/test/ui/issues/issue-54582.rs +++ b/src/test/ui/issues/issue-54582.rs @@ -9,7 +9,7 @@ pub enum Enum { impl Stage for Enum {} -pub static ARRAY: [(&Stage, &str); 1] = [ +pub static ARRAY: [(&dyn Stage, &str); 1] = [ (&Enum::A, ""), ]; diff --git a/src/test/ui/issues/issue-55796.rs b/src/test/ui/issues/issue-55796.rs index efdea5c9b1e..088d4301c51 100644 --- a/src/test/ui/issues/issue-55796.rs +++ b/src/test/ui/issues/issue-55796.rs @@ -12,12 +12,12 @@ pub trait Graph<'a> { fn out_edges(&'a self, u: &Self::Node) -> Self::EdgesIter; fn in_edges(&'a self, u: &Self::Node) -> Self::EdgesIter; - fn out_neighbors(&'a self, u: &Self::Node) -> Box<Iterator<Item = Self::Node>> { + fn out_neighbors(&'a self, u: &Self::Node) -> Box<dyn Iterator<Item = Self::Node>> { Box::new(self.out_edges(u).map(|e| e.target())) //~^ ERROR cannot infer } - fn in_neighbors(&'a self, u: &Self::Node) -> Box<Iterator<Item = Self::Node>> { + fn in_neighbors(&'a self, u: &Self::Node) -> Box<dyn Iterator<Item = Self::Node>> { Box::new(self.in_edges(u).map(|e| e.target())) //~^ ERROR cannot infer } diff --git a/src/test/ui/issues/issue-5883.rs b/src/test/ui/issues/issue-5883.rs index b4a73ba99c5..0de53502397 100644 --- a/src/test/ui/issues/issue-5883.rs +++ b/src/test/ui/issues/issue-5883.rs @@ -1,10 +1,10 @@ trait A {} struct Struct { - r: A+'static + r: dyn A + 'static } -fn new_struct(r: A+'static) +fn new_struct(r: dyn A + 'static) -> Struct { //~^ ERROR the size for values of type //~^ ERROR the size for values of type Struct { r: r } diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 7753881f736..c2de1d09550 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -1,7 +1,7 @@ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time --> $DIR/issue-5883.rs:7:15 | -LL | fn new_struct(r: A+'static) +LL | fn new_struct(r: dyn A + 'static) | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` diff --git a/src/test/ui/issues/issue-60989.rs b/src/test/ui/issues/issue-60989.rs index 930e98bedce..6dae1e1347b 100644 --- a/src/test/ui/issues/issue-60989.rs +++ b/src/test/ui/issues/issue-60989.rs @@ -13,6 +13,6 @@ fn main() { //~^ ERROR type arguments are not allowed for this type let c1 = A {}; - c1::<Into<B>>; + c1::<dyn Into<B>>; //~^ ERROR type arguments are not allowed for this type } diff --git a/src/test/ui/issues/issue-60989.stderr b/src/test/ui/issues/issue-60989.stderr index 55a0b9626df..5d2d9e83c9b 100644 --- a/src/test/ui/issues/issue-60989.stderr +++ b/src/test/ui/issues/issue-60989.stderr @@ -7,8 +7,8 @@ LL | c1::<()>; error[E0109]: type arguments are not allowed for this type --> $DIR/issue-60989.rs:16:10 | -LL | c1::<Into<B>>; - | ^^^^^^^ type argument not allowed +LL | c1::<dyn Into<B>>; + | ^^^^^^^^^^^ type argument not allowed error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-7013.rs b/src/test/ui/issues/issue-7013.rs index ee68aa8623b..3d72b67e391 100644 --- a/src/test/ui/issues/issue-7013.rs +++ b/src/test/ui/issues/issue-7013.rs @@ -19,10 +19,10 @@ impl Foo for B { } struct A { - v: Box<Foo + Send>, + v: Box<dyn Foo + Send>, } fn main() { - let a = A {v: box B{v: None} as Box<Foo+Send>}; + let a = A {v: box B{v: None} as Box<dyn Foo + Send>}; //~^ ERROR `std::rc::Rc<std::cell::RefCell<A>>` cannot be sent between threads safely } diff --git a/src/test/ui/issues/issue-7013.stderr b/src/test/ui/issues/issue-7013.stderr index 22185c7da34..f2668d33122 100644 --- a/src/test/ui/issues/issue-7013.stderr +++ b/src/test/ui/issues/issue-7013.stderr @@ -1,7 +1,7 @@ error[E0277]: `std::rc::Rc<std::cell::RefCell<A>>` cannot be sent between threads safely --> $DIR/issue-7013.rs:26:19 | -LL | let a = A {v: box B{v: None} as Box<Foo+Send>}; +LL | let a = A {v: box B{v: None} as Box<dyn Foo + Send>}; | ^^^^^^^^^^^^^^ `std::rc::Rc<std::cell::RefCell<A>>` cannot be sent between threads safely | = help: within `B`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<std::cell::RefCell<A>>` diff --git a/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs b/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs index 7dd6b07177f..619256c7871 100644 --- a/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs @@ -18,5 +18,5 @@ trait A { impl<T: 'static> A for T {} -fn owned2<T: 'static>(a: Box<T>) { a as Box<A>; } -fn owned3<T: 'static>(a: Box<T>) { box a as Box<A>; } +fn owned2<T: 'static>(a: Box<T>) { a as Box<dyn A>; } +fn owned3<T: 'static>(a: Box<T>) { box a as Box<dyn A>; } diff --git a/src/test/ui/issues/issue-8398.rs b/src/test/ui/issues/issue-8398.rs index bd37b8582b2..a65c667b08e 100644 --- a/src/test/ui/issues/issue-8398.rs +++ b/src/test/ui/issues/issue-8398.rs @@ -6,7 +6,7 @@ pub trait Writer { fn write(&mut self, b: &[u8]) -> Result<(), ()>; } -fn foo(a: &mut Writer) { +fn foo(a: &mut dyn Writer) { a.write(&[]).unwrap(); } diff --git a/src/test/ui/issues/issue-9719.rs b/src/test/ui/issues/issue-9719.rs index 96865344e74..1e38ab9c6c2 100644 --- a/src/test/ui/issues/issue-9719.rs +++ b/src/test/ui/issues/issue-9719.rs @@ -12,8 +12,8 @@ mod a { } impl X for isize {} - pub struct Z<'a>(Enum<&'a (X+'a)>); - fn foo() { let x: isize = 42; let z = Z(Enum::A(&x as &X)); let _ = z; } + pub struct Z<'a>(Enum<&'a (dyn X + 'a)>); + fn foo() { let x: isize = 42; let z = Z(Enum::A(&x as &dyn X)); let _ = z; } } mod b { @@ -22,20 +22,20 @@ mod b { } impl X for isize {} struct Y<'a>{ - x:Option<&'a (X+'a)>, + x:Option<&'a (dyn X + 'a)>, } fn bar() { let x: isize = 42; - let _y = Y { x: Some(&x as &X) }; + let _y = Y { x: Some(&x as &dyn X) }; } } mod c { pub trait X { fn f(&self); } impl X for isize { fn f(&self) {} } - pub struct Z<'a>(Option<&'a (X+'a)>); - fn main() { let x: isize = 42; let z = Z(Some(&x as &X)); let _ = z; } + pub struct Z<'a>(Option<&'a (dyn X + 'a)>); + fn main() { let x: isize = 42; let z = Z(Some(&x as &dyn X)); let _ = z; } } pub fn main() {} diff --git a/src/test/ui/kindck/kindck-copy.rs b/src/test/ui/kindck/kindck-copy.rs index dadeb956964..eb18613682f 100644 --- a/src/test/ui/kindck/kindck-copy.rs +++ b/src/test/ui/kindck/kindck-copy.rs @@ -34,16 +34,16 @@ fn test<'a,T,U:Copy>(_: &'a isize) { assert_copy::<Box<&'a mut isize>>(); //~ ERROR : std::marker::Copy` is not satisfied // borrowed object types are generally ok - assert_copy::<&'a Dummy>(); - assert_copy::<&'a (Dummy+Send)>(); - assert_copy::<&'static (Dummy+Send)>(); + assert_copy::<&'a dyn Dummy>(); + assert_copy::<&'a (dyn Dummy + Send)>(); + assert_copy::<&'static (dyn Dummy + Send)>(); // owned object types are not ok - assert_copy::<Box<Dummy>>(); //~ ERROR : std::marker::Copy` is not satisfied - assert_copy::<Box<Dummy+Send>>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::<Box<dyn Dummy>>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::<Box<dyn Dummy + Send>>(); //~ ERROR : std::marker::Copy` is not satisfied // mutable object types are not ok - assert_copy::<&'a mut (Dummy+Send)>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::<&'a mut (dyn Dummy + Send)>(); //~ ERROR : std::marker::Copy` is not satisfied // unsafe ptrs are ok assert_copy::<*const isize>(); diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 2680cb7c012..929a8076562 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -77,8 +77,8 @@ LL | fn assert_copy<T:Copy>() { } error[E0277]: the trait bound `std::boxed::Box<dyn Dummy>: std::marker::Copy` is not satisfied --> $DIR/kindck-copy.rs:42:5 | -LL | assert_copy::<Box<Dummy>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<dyn Dummy>` +LL | assert_copy::<Box<dyn Dummy>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<dyn Dummy>` | note: required by `assert_copy` --> $DIR/kindck-copy.rs:5:1 @@ -89,8 +89,8 @@ LL | fn assert_copy<T:Copy>() { } error[E0277]: the trait bound `std::boxed::Box<dyn Dummy + std::marker::Send>: std::marker::Copy` is not satisfied --> $DIR/kindck-copy.rs:43:5 | -LL | assert_copy::<Box<Dummy+Send>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<dyn Dummy + std::marker::Send>` +LL | assert_copy::<Box<dyn Dummy + Send>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<dyn Dummy + std::marker::Send>` | note: required by `assert_copy` --> $DIR/kindck-copy.rs:5:1 @@ -101,8 +101,8 @@ LL | fn assert_copy<T:Copy>() { } error[E0277]: the trait bound `&'a mut (dyn Dummy + std::marker::Send + 'a): std::marker::Copy` is not satisfied --> $DIR/kindck-copy.rs:46:5 | -LL | assert_copy::<&'a mut (Dummy+Send)>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` +LL | assert_copy::<&'a mut (dyn Dummy + Send)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` | note: required by `assert_copy` --> $DIR/kindck-copy.rs:5:1 diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr index c1f662fda61..25d0e74187f 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr @@ -1,7 +1,7 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable<T>; +LL | let a = &t as &dyn Gettable<T>; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` @@ -12,7 +12,7 @@ LL | let a = &t as &Gettable<T>; error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable<T>; +LL | let a = &t as &dyn Gettable<T>; | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound @@ -20,10 +20,10 @@ LL | let a = &t as &Gettable<T>; = note: required for the cast to the object type `dyn Gettable<T>` error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable<T> = &t; - | ^^ `T` cannot be sent between threads safely +LL | let a: &dyn Gettable<T> = &t; + | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` = help: consider adding a `where T: std::marker::Send` bound @@ -31,10 +31,10 @@ LL | let a: &Gettable<T> = &t; = note: required for the cast to the object type `dyn Gettable<T>` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable<T> = &t; - | ^^ the trait `std::marker::Copy` is not implemented for `T` +LL | let a: &dyn Gettable<T> = &t; + | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound = note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` @@ -43,17 +43,17 @@ LL | let a: &Gettable<T> = &t; error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:38:13 | -LL | let a = t as Box<Gettable<String>>; +LL | let a = t as Box<dyn Gettable<String>>; | ^ the trait `std::marker::Copy` is not implemented for `std::string::String` | = note: required because of the requirements on the impl of `Gettable<std::string::String>` for `S<std::string::String>` = note: required for the cast to the object type `dyn Gettable<std::string::String>` error[E0277]: the trait bound `foo3::Foo: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:33 + --> $DIR/kindck-impl-type-params.rs:46:37 | -LL | let a: Box<Gettable<Foo>> = t; - | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` +LL | let a: Box<dyn Gettable<Foo>> = t; + | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` | = note: required because of the requirements on the impl of `Gettable<foo3::Foo>` for `S<foo3::Foo>` = note: required for the cast to the object type `dyn Gettable<foo3::Foo>` diff --git a/src/test/ui/kindck/kindck-impl-type-params.rs b/src/test/ui/kindck/kindck-impl-type-params.rs index a47e418709d..c4f90f36acf 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.rs +++ b/src/test/ui/kindck/kindck-impl-type-params.rs @@ -15,27 +15,27 @@ impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} fn f<T>(val: T) { let t: S<T> = S(marker::PhantomData); - let a = &t as &Gettable<T>; + let a = &t as &dyn Gettable<T>; //~^ ERROR `T` cannot be sent between threads safely //~| ERROR : std::marker::Copy` is not satisfied } fn g<T>(val: T) { let t: S<T> = S(marker::PhantomData); - let a: &Gettable<T> = &t; + let a: &dyn Gettable<T> = &t; //~^ ERROR `T` cannot be sent between threads safely //~| ERROR : std::marker::Copy` is not satisfied } fn foo<'a>() { let t: S<&'a isize> = S(marker::PhantomData); - let a = &t as &Gettable<&'a isize>; + let a = &t as &dyn Gettable<&'a isize>; //~^ ERROR does not fulfill } fn foo2<'a>() { let t: Box<S<String>> = box S(marker::PhantomData); - let a = t as Box<Gettable<String>>; + let a = t as Box<dyn Gettable<String>>; //~^ ERROR : std::marker::Copy` is not satisfied } @@ -43,7 +43,7 @@ fn foo3<'a>() { struct Foo; // does not impl Copy let t: Box<S<Foo>> = box S(marker::PhantomData); - let a: Box<Gettable<Foo>> = t; + let a: Box<dyn Gettable<Foo>> = t; //~^ ERROR : std::marker::Copy` is not satisfied } diff --git a/src/test/ui/kindck/kindck-impl-type-params.stderr b/src/test/ui/kindck/kindck-impl-type-params.stderr index 8580e6812b4..e6f7088bd46 100644 --- a/src/test/ui/kindck/kindck-impl-type-params.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params.stderr @@ -1,7 +1,7 @@ error[E0277]: `T` cannot be sent between threads safely --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable<T>; +LL | let a = &t as &dyn Gettable<T>; | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` @@ -12,7 +12,7 @@ LL | let a = &t as &Gettable<T>; error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:18:13 | -LL | let a = &t as &Gettable<T>; +LL | let a = &t as &dyn Gettable<T>; | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound @@ -20,10 +20,10 @@ LL | let a = &t as &Gettable<T>; = note: required for the cast to the object type `dyn Gettable<T>` error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable<T> = &t; - | ^^ `T` cannot be sent between threads safely +LL | let a: &dyn Gettable<T> = &t; + | ^^ `T` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `T` = help: consider adding a `where T: std::marker::Send` bound @@ -31,10 +31,10 @@ LL | let a: &Gettable<T> = &t; = note: required for the cast to the object type `dyn Gettable<T>` error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:25:27 + --> $DIR/kindck-impl-type-params.rs:25:31 | -LL | let a: &Gettable<T> = &t; - | ^^ the trait `std::marker::Copy` is not implemented for `T` +LL | let a: &dyn Gettable<T> = &t; + | ^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound = note: required because of the requirements on the impl of `Gettable<T>` for `S<T>` @@ -43,7 +43,7 @@ LL | let a: &Gettable<T> = &t; error[E0477]: the type `&'a isize` does not fulfill the required lifetime --> $DIR/kindck-impl-type-params.rs:32:13 | -LL | let a = &t as &Gettable<&'a isize>; +LL | let a = &t as &dyn Gettable<&'a isize>; | ^^ | = note: type must satisfy the static lifetime @@ -51,17 +51,17 @@ LL | let a = &t as &Gettable<&'a isize>; error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied --> $DIR/kindck-impl-type-params.rs:38:13 | -LL | let a = t as Box<Gettable<String>>; +LL | let a = t as Box<dyn Gettable<String>>; | ^ the trait `std::marker::Copy` is not implemented for `std::string::String` | = note: required because of the requirements on the impl of `Gettable<std::string::String>` for `S<std::string::String>` = note: required for the cast to the object type `dyn Gettable<std::string::String>` error[E0277]: the trait bound `foo3::Foo: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:46:33 + --> $DIR/kindck-impl-type-params.rs:46:37 | -LL | let a: Box<Gettable<Foo>> = t; - | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` +LL | let a: Box<dyn Gettable<Foo>> = t; + | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` | = note: required because of the requirements on the impl of `Gettable<foo3::Foo>` for `S<foo3::Foo>` = note: required for the cast to the object type `dyn Gettable<foo3::Foo>` diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.rs b/src/test/ui/kindck/kindck-inherited-copy-bound.rs index 0134636fa0d..61e72908248 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.rs +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.rs @@ -21,7 +21,7 @@ fn a() { fn b() { let x: Box<_> = box 3; let y = &x; - let z = &x as &Foo; + let z = &x as &dyn Foo; //~^ ERROR E0038 //~| ERROR E0038 } diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.stderr index 0ed2da46fba..1e719e26084 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.stderr @@ -14,15 +14,15 @@ LL | fn take_param<T:Foo>(foo: &T) { } error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/kindck-inherited-copy-bound.rs:24:19 | -LL | let z = &x as &Foo; - | ^^^^ the trait `Foo` cannot be made into an object +LL | let z = &x as &dyn Foo; + | ^^^^^^^^ the trait `Foo` cannot be made into an object | = note: the trait cannot require that `Self : Sized` error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/kindck-inherited-copy-bound.rs:24:13 | -LL | let z = &x as &Foo; +LL | let z = &x as &dyn Foo; | ^^ the trait `Foo` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/kindck/kindck-send-object.rs b/src/test/ui/kindck/kindck-send-object.rs index 97f46c3953d..6411e688b4a 100644 --- a/src/test/ui/kindck/kindck-send-object.rs +++ b/src/test/ui/kindck/kindck-send-object.rs @@ -9,18 +9,18 @@ trait Message : Send { } // careful with object types, who knows what they close over... fn object_ref_with_static_bound_not_ok() { - assert_send::<&'static (Dummy+'static)>(); + assert_send::<&'static (dyn Dummy + 'static)>(); //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] } fn box_object_with_no_bound_not_ok<'a>() { - assert_send::<Box<Dummy>>(); + assert_send::<Box<dyn Dummy>>(); //~^ ERROR `dyn Dummy` cannot be sent between threads safely } fn object_with_send_bound_ok() { - assert_send::<&'static (Dummy+Sync)>(); - assert_send::<Box<Dummy+Send>>(); + assert_send::<&'static (dyn Dummy + Sync)>(); + assert_send::<Box<dyn Dummy + Send>>(); } fn main() { } diff --git a/src/test/ui/kindck/kindck-send-object.stderr b/src/test/ui/kindck/kindck-send-object.stderr index 8d993566029..c9aadd85a53 100644 --- a/src/test/ui/kindck/kindck-send-object.stderr +++ b/src/test/ui/kindck/kindck-send-object.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object.rs:12:5 | -LL | assert_send::<&'static (Dummy+'static)>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely +LL | assert_send::<&'static (dyn Dummy + 'static)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'static)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'static (dyn Dummy + 'static)` @@ -15,8 +15,8 @@ LL | fn assert_send<T:Send>() { } error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object.rs:17:5 | -LL | assert_send::<Box<Dummy>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely +LL | assert_send::<Box<dyn Dummy>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `dyn Dummy` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<dyn Dummy>` diff --git a/src/test/ui/kindck/kindck-send-object1.nll.stderr b/src/test/ui/kindck/kindck-send-object1.nll.stderr index 1df7412132b..998dc90456f 100644 --- a/src/test/ui/kindck/kindck-send-object1.nll.stderr +++ b/src/test/ui/kindck/kindck-send-object1.nll.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | -LL | assert_send::<&'a Dummy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely +LL | assert_send::<&'a dyn Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'a (dyn Dummy + 'a)` @@ -15,8 +15,8 @@ LL | fn assert_send<T:Send+'static>() { } error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | -LL | assert_send::<Box<Dummy+'a>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely +LL | assert_send::<Box<dyn Dummy + 'a>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn Dummy + 'a)>` diff --git a/src/test/ui/kindck/kindck-send-object1.rs b/src/test/ui/kindck/kindck-send-object1.rs index 341985467de..0e198395c26 100644 --- a/src/test/ui/kindck/kindck-send-object1.rs +++ b/src/test/ui/kindck/kindck-send-object1.rs @@ -7,26 +7,26 @@ trait Dummy { } // careful with object types, who knows what they close over... fn test51<'a>() { - assert_send::<&'a Dummy>(); + assert_send::<&'a dyn Dummy>(); //~^ ERROR `(dyn Dummy + 'a)` cannot be shared between threads safely [E0277] } fn test52<'a>() { - assert_send::<&'a (Dummy+Sync)>(); + assert_send::<&'a (dyn Dummy + Sync)>(); //~^ ERROR does not fulfill the required lifetime } // ...unless they are properly bounded fn test60() { - assert_send::<&'static (Dummy+Sync)>(); + assert_send::<&'static (dyn Dummy + Sync)>(); } fn test61() { - assert_send::<Box<Dummy+Send>>(); + assert_send::<Box<dyn Dummy + Send>>(); } // closure and object types can have lifetime bounds which make // them not ok fn test_71<'a>() { - assert_send::<Box<Dummy+'a>>(); + assert_send::<Box<dyn Dummy + 'a>>(); //~^ ERROR `(dyn Dummy + 'a)` cannot be sent between threads safely } diff --git a/src/test/ui/kindck/kindck-send-object1.stderr b/src/test/ui/kindck/kindck-send-object1.stderr index a4b908e4101..757b41ab6cb 100644 --- a/src/test/ui/kindck/kindck-send-object1.stderr +++ b/src/test/ui/kindck/kindck-send-object1.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | -LL | assert_send::<&'a Dummy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely +LL | assert_send::<&'a dyn Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'a (dyn Dummy + 'a)` @@ -15,16 +15,16 @@ LL | fn assert_send<T:Send+'static>() { } error[E0477]: the type `&'a (dyn Dummy + std::marker::Sync + 'a)` does not fulfill the required lifetime --> $DIR/kindck-send-object1.rs:14:5 | -LL | assert_send::<&'a (Dummy+Sync)>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | assert_send::<&'a (dyn Dummy + Sync)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: type must satisfy the static lifetime error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | -LL | assert_send::<Box<Dummy+'a>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely +LL | assert_send::<Box<dyn Dummy + 'a>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `(dyn Dummy + 'a)` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn Dummy + 'a)>` diff --git a/src/test/ui/kindck/kindck-send-object2.rs b/src/test/ui/kindck/kindck-send-object2.rs index 911ad988081..b797588e446 100644 --- a/src/test/ui/kindck/kindck-send-object2.rs +++ b/src/test/ui/kindck/kindck-send-object2.rs @@ -4,21 +4,21 @@ fn assert_send<T:Send>() { } trait Dummy { } fn test50() { - assert_send::<&'static Dummy>(); + assert_send::<&'static dyn Dummy>(); //~^ ERROR `(dyn Dummy + 'static)` cannot be shared between threads safely [E0277] } fn test53() { - assert_send::<Box<Dummy>>(); + assert_send::<Box<dyn Dummy>>(); //~^ ERROR `dyn Dummy` cannot be sent between threads safely } // ...unless they are properly bounded fn test60() { - assert_send::<&'static (Dummy+Sync)>(); + assert_send::<&'static (dyn Dummy + Sync)>(); } fn test61() { - assert_send::<Box<Dummy+Send>>(); + assert_send::<Box<dyn Dummy + Send>>(); } fn main() { } diff --git a/src/test/ui/kindck/kindck-send-object2.stderr b/src/test/ui/kindck/kindck-send-object2.stderr index db79989dc5f..c1c9db9da83 100644 --- a/src/test/ui/kindck/kindck-send-object2.stderr +++ b/src/test/ui/kindck/kindck-send-object2.stderr @@ -1,8 +1,8 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object2.rs:7:5 | -LL | assert_send::<&'static Dummy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely +LL | assert_send::<&'static dyn Dummy>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely | = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'static)` = note: required because of the requirements on the impl of `std::marker::Send` for `&'static (dyn Dummy + 'static)` @@ -15,8 +15,8 @@ LL | fn assert_send<T:Send>() { } error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object2.rs:12:5 | -LL | assert_send::<Box<Dummy>>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely +LL | assert_send::<Box<dyn Dummy>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely | = help: the trait `std::marker::Send` is not implemented for `dyn Dummy` = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<dyn Dummy>` diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr index 8b24563e920..f2cf19abdac 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr @@ -1,7 +1,7 @@ error[E0521]: borrowed data escapes outside of function --> $DIR/lifetime-bound-will-change-warning.rs:34:5 | -LL | fn test2<'a>(x: &'a Box<Fn()+'a>) { +LL | fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) { | - `x` is a reference that is only valid in the function body LL | // but ref_obj will not, so warn. LL | ref_obj(x) @@ -10,7 +10,7 @@ LL | ref_obj(x) error[E0521]: borrowed data escapes outside of function --> $DIR/lifetime-bound-will-change-warning.rs:39:5 | -LL | fn test2cc<'a>(x: &'a Box<Fn()+'a>) { +LL | fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) { | - `x` is a reference that is only valid in the function body LL | // same as test2, but cross crate LL | lib::ref_obj(x) diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs index 5461f875af6..3c6d92234c4 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.rs @@ -9,42 +9,42 @@ extern crate lifetime_bound_will_change_warning_lib as lib; -fn just_ref(x: &Fn()) { +fn just_ref(x: &dyn Fn()) { } -fn ref_obj(x: &Box<Fn()>) { +fn ref_obj(x: &Box<dyn Fn()>) { // this will change to &Box<Fn()+'static>... // Note: no warning is issued here, because the type of `x` will change to 'static if false { ref_obj(x); } } -fn test1<'a>(x: &'a Box<Fn()+'a>) { +fn test1<'a>(x: &'a Box<dyn Fn() + 'a>) { // just_ref will stay the same. just_ref(&**x) } -fn test1cc<'a>(x: &'a Box<Fn()+'a>) { +fn test1cc<'a>(x: &'a Box<dyn Fn() + 'a>) { // same as test1, but cross-crate lib::just_ref(&**x) } -fn test2<'a>(x: &'a Box<Fn()+'a>) { +fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) { // but ref_obj will not, so warn. ref_obj(x) //~ ERROR mismatched types } -fn test2cc<'a>(x: &'a Box<Fn()+'a>) { +fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) { // same as test2, but cross crate lib::ref_obj(x) //~ ERROR mismatched types } -fn test3<'a>(x: &'a Box<Fn()+'static>) { +fn test3<'a>(x: &'a Box<dyn Fn() + 'static>) { // here, we have a 'static bound, so even when ref_obj changes, no error results ref_obj(x) } -fn test3cc<'a>(x: &'a Box<Fn()+'static>) { +fn test3cc<'a>(x: &'a Box<dyn Fn() + 'static>) { // same as test3, but cross crate lib::ref_obj(x) } diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr index 1af4bd501ba..35d63c17276 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.stderr @@ -9,7 +9,7 @@ LL | ref_obj(x) note: the lifetime 'a as defined on the function body at 32:10... --> $DIR/lifetime-bound-will-change-warning.rs:32:10 | -LL | fn test2<'a>(x: &'a Box<Fn()+'a>) { +LL | fn test2<'a>(x: &'a Box<dyn Fn() + 'a>) { | ^^ = note: ...does not necessarily outlive the static lifetime @@ -24,7 +24,7 @@ LL | lib::ref_obj(x) note: the lifetime 'a as defined on the function body at 37:12... --> $DIR/lifetime-bound-will-change-warning.rs:37:12 | -LL | fn test2cc<'a>(x: &'a Box<Fn()+'a>) { +LL | fn test2cc<'a>(x: &'a Box<dyn Fn() + 'a>) { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs index 1c288a7e44f..2370084b072 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs @@ -5,7 +5,7 @@ trait Future { use std::error::Error; -fn foo() -> impl Future<Item=(), Error=Box<Error>> { +fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> { //~^ ERROR missing lifetime Ok(()) } diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr index b2a3d9a9436..06b317ce952 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr @@ -1,8 +1,8 @@ error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-trait.rs:8:44 | -LL | fn foo() -> impl Future<Item=(), Error=Box<Error>> { - | ^^^^^ help: consider giving it a 'static lifetime: `Error + 'static` +LL | fn foo() -> impl Future<Item=(), Error=Box<dyn Error>> { + | ^^^^^^^^^ help: consider giving it a 'static lifetime: `dyn Error + 'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr index c4e7ff90069..3c95be95db0 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr @@ -1,18 +1,18 @@ error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 | -LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { - | - help: consider changing this to be mutable: `mut y` +LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { + | - help: consider changing this to be mutable: `mut y` LL | y.push(z); | ^ cannot borrow as mutable error: lifetime may not live long enough --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:3 | -LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` +LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { + | - - let's call the lifetime of this reference `'1` + | | + | let's call the lifetime of this reference `'2` LL | y.push(z); | ^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs index 324a5846c94..6625d41c7de 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.rs @@ -1,4 +1,4 @@ -fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { +fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { y.push(z); //~ ERROR lifetime mismatch } diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr index 6cd175b8a61..bfecb4d3393 100644 --- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.stderr @@ -1,8 +1,8 @@ error[E0623]: lifetime mismatch --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:2:10 | -LL | fn foo(x:Box<Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { - | --- --- these two types are declared with different lifetimes... +LL | fn foo(x:Box<dyn Fn(&u8, &u8)> , y: Vec<&u8>, z: &u8) { + | --- --- these two types are declared with different lifetimes... LL | y.push(z); | ^ ...but data from `z` flows into `y` here diff --git a/src/test/ui/lint/lint-ctypes.rs b/src/test/ui/lint/lint-ctypes.rs index 816177abdea..a3d9b6febdb 100644 --- a/src/test/ui/lint/lint-ctypes.rs +++ b/src/test/ui/lint/lint-ctypes.rs @@ -51,7 +51,7 @@ extern { pub fn char_type(p: char); //~ ERROR uses type `char` pub fn i128_type(p: i128); //~ ERROR uses type `i128` pub fn u128_type(p: u128); //~ ERROR uses type `u128` - pub fn trait_type(p: &Clone); //~ ERROR uses type `dyn std::clone::Clone` + pub fn trait_type(p: &dyn Clone); //~ ERROR uses type `dyn std::clone::Clone` pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` pub fn zero_size(p: ZeroSize); //~ ERROR struct has no fields diff --git a/src/test/ui/lint/lint-ctypes.stderr b/src/test/ui/lint/lint-ctypes.stderr index 67ba30a81c5..03c18e4530b 100644 --- a/src/test/ui/lint/lint-ctypes.stderr +++ b/src/test/ui/lint/lint-ctypes.stderr @@ -76,8 +76,8 @@ LL | pub fn u128_type(p: u128); error: `extern` block uses type `dyn std::clone::Clone` which is not FFI-safe: trait objects have no C equivalent --> $DIR/lint-ctypes.rs:54:26 | -LL | pub fn trait_type(p: &Clone); - | ^^^^^^ +LL | pub fn trait_type(p: &dyn Clone); + | ^^^^^^^^^^ error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout --> $DIR/lint-ctypes.rs:55:26 diff --git a/src/test/ui/lint/lint-dead-code-3.rs b/src/test/ui/lint/lint-dead-code-3.rs index 00b250f83dd..4397522f3f3 100644 --- a/src/test/ui/lint/lint-dead-code-3.rs +++ b/src/test/ui/lint/lint-dead-code-3.rs @@ -73,6 +73,6 @@ mod inner { } pub fn foo() { - let a: &inner::Trait = &1_isize; + let a: &dyn inner::Trait = &1_isize; a.f(); } diff --git a/src/test/ui/lint/lint-stability-2.rs b/src/test/ui/lint/lint-stability-2.rs index 12e7b086d35..53eee35a9ca 100644 --- a/src/test/ui/lint/lint-stability-2.rs +++ b/src/test/ui/lint/lint-stability-2.rs @@ -148,7 +148,7 @@ mod cross_crate { <Foo as Trait>::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_deprecated_unstable(); @@ -373,7 +373,7 @@ mod this_crate { <Foo as Trait>::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_unstable(); diff --git a/src/test/ui/lint/lint-stability-deprecated.rs b/src/test/ui/lint/lint-stability-deprecated.rs index bf574d7144d..a2031c2189a 100644 --- a/src/test/ui/lint/lint-stability-deprecated.rs +++ b/src/test/ui/lint/lint-stability-deprecated.rs @@ -98,7 +98,7 @@ mod cross_crate { struct S1<T: TraitWithAssociatedTypes>(T::TypeUnstable); struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated); //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated': text - type A = TraitWithAssociatedTypes< + type A = dyn TraitWithAssociatedTypes< TypeUnstable = u8, TypeDeprecated = u16, //~^ WARN use of deprecated item 'lint_stability::TraitWithAssociatedTypes::TypeDeprecated' @@ -170,7 +170,7 @@ mod cross_crate { <Foo as Trait>::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated' foo.trait_deprecated_text(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_text': text foo.trait_deprecated_unstable(); //~ WARN use of deprecated item 'lint_stability::Trait::trait_deprecated_unstable' @@ -423,7 +423,7 @@ mod this_crate { <Foo as Trait>::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated' foo.trait_deprecated_text(); //~ WARN use of deprecated item 'this_crate::Trait::trait_deprecated_text': text foo.trait_unstable(); diff --git a/src/test/ui/lint/lint-stability.rs b/src/test/ui/lint/lint-stability.rs index 3e4a3874d2c..fde27eec7d3 100644 --- a/src/test/ui/lint/lint-stability.rs +++ b/src/test/ui/lint/lint-stability.rs @@ -88,7 +88,7 @@ mod cross_crate { struct S1<T: TraitWithAssociatedTypes>(T::TypeUnstable); //~^ ERROR use of unstable library feature struct S2<T: TraitWithAssociatedTypes>(T::TypeDeprecated); - type A = TraitWithAssociatedTypes< + type A = dyn TraitWithAssociatedTypes< TypeUnstable = u8, //~ ERROR use of unstable library feature TypeDeprecated = u16, >; @@ -161,7 +161,7 @@ mod cross_crate { <Foo as Trait>::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_stable(); @@ -414,7 +414,7 @@ mod this_crate { <Foo as Trait>::trait_stable(&foo); } - fn test_method_object(foo: &Trait) { + fn test_method_object(foo: &dyn Trait) { foo.trait_deprecated(); foo.trait_deprecated_text(); foo.trait_unstable(); diff --git a/src/test/ui/lint/lint-unconditional-recursion.rs b/src/test/ui/lint/lint-unconditional-recursion.rs index 44af1179097..ab60a326cd2 100644 --- a/src/test/ui/lint/lint-unconditional-recursion.rs +++ b/src/test/ui/lint/lint-unconditional-recursion.rs @@ -39,7 +39,7 @@ trait Foo { } } -impl Foo for Box<Foo+'static> { +impl Foo for Box<dyn Foo + 'static> { fn bar(&self) { //~ ERROR function cannot return without recursing loop { self.bar() @@ -67,7 +67,7 @@ trait Foo2 { } } -impl Foo2 for Box<Foo2+'static> { +impl Foo2 for Box<dyn Foo2 + 'static> { fn bar(&self) { //~ ERROR function cannot return without recursing loop { Foo2::bar(self) diff --git a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs index f48e9848456..656ed6576e2 100644 --- a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs +++ b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.rs @@ -18,7 +18,7 @@ fn foo() { let z = 3_i8; 'a: loop { - let b = Box::new(|x: &i8| *x) as Box<for <'a> Fn(&'a i8) -> i8>; + let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; //~^ WARN lifetime name `'a` shadows a label name that is already in scope assert_eq!((*b)(&z), z); break 'a; diff --git a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr index 4c4d9218ec9..e5d376675c6 100644 --- a/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr +++ b/src/test/ui/loops/loops-reject-lifetime-shadowing-label.stderr @@ -1,8 +1,8 @@ warning: lifetime name `'a` shadows a label name that is already in scope - --> $DIR/loops-reject-lifetime-shadowing-label.rs:21:51 + --> $DIR/loops-reject-lifetime-shadowing-label.rs:21:55 | LL | 'a: loop { | -- first declared here -LL | let b = Box::new(|x: &i8| *x) as Box<for <'a> Fn(&'a i8) -> i8>; - | ^^ lifetime 'a already in scope +LL | let b = Box::new(|x: &i8| *x) as Box<dyn for <'a> Fn(&'a i8) -> i8>; + | ^^ lifetime 'a already in scope diff --git a/src/test/ui/lub-glb/old-lub-glb-object.rs b/src/test/ui/lub-glb/old-lub-glb-object.rs index dcd604a5157..f303c07e6d7 100644 --- a/src/test/ui/lub-glb/old-lub-glb-object.rs +++ b/src/test/ui/lub-glb/old-lub-glb-object.rs @@ -4,8 +4,8 @@ trait Foo<T, U> { } fn foo( - x: &for<'a, 'b> Foo<&'a u8, &'b u8>, - y: &for<'a> Foo<&'a u8, &'a u8>, + x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, + y: &dyn for<'a> Foo<&'a u8, &'a u8>, ) { let z = match 22 { 0 => x, @@ -14,12 +14,12 @@ fn foo( } fn bar( - x: &for<'a, 'b> Foo<&'a u8, &'b u8>, - y: &for<'a> Foo<&'a u8, &'a u8>, + x: &dyn for<'a, 'b> Foo<&'a u8, &'b u8>, + y: &dyn for<'a> Foo<&'a u8, &'a u8>, ) { // Accepted with explicit case: let z = match 22 { - 0 => x as &for<'a> Foo<&'a u8, &'a u8>, + 0 => x as &dyn for<'a> Foo<&'a u8, &'a u8>, _ => y, }; } diff --git a/src/test/ui/map-types.rs b/src/test/ui/map-types.rs index dab7863415f..c355a0e420f 100644 --- a/src/test/ui/map-types.rs +++ b/src/test/ui/map-types.rs @@ -13,7 +13,7 @@ impl<K, V> Map<K, V> for HashMap<K, V> {} fn main() { let x: Box<HashMap<isize, isize>> = box HashMap::new(); - let x: Box<Map<isize, isize>> = x; - let y: Box<Map<usize, isize>> = Box::new(x); + let x: Box<dyn Map<isize, isize>> = x; + let y: Box<dyn Map<usize, isize>> = Box::new(x); //~^ ERROR `std::boxed::Box<dyn Map<isize, isize>>: Map<usize, isize>` is not satisfied } diff --git a/src/test/ui/map-types.stderr b/src/test/ui/map-types.stderr index 9aa98044242..21dac1ab1ed 100644 --- a/src/test/ui/map-types.stderr +++ b/src/test/ui/map-types.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `std::boxed::Box<dyn Map<isize, isize>>: Map<usize, isize>` is not satisfied - --> $DIR/map-types.rs:17:37 + --> $DIR/map-types.rs:17:41 | -LL | let y: Box<Map<usize, isize>> = Box::new(x); - | ^^^^^^^^^^^ the trait `Map<usize, isize>` is not implemented for `std::boxed::Box<dyn Map<isize, isize>>` +LL | let y: Box<dyn Map<usize, isize>> = Box::new(x); + | ^^^^^^^^^^^ the trait `Map<usize, isize>` is not implemented for `std::boxed::Box<dyn Map<isize, isize>>` | = note: required for the cast to the object type `dyn Map<usize, isize>` diff --git a/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs b/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs index 36a1a2fda69..23893911eab 100644 --- a/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs +++ b/src/test/ui/methods/method-call-lifetime-args-lint-fail.rs @@ -11,10 +11,10 @@ impl S { // 'late lifetimes here belong to nested types not to the tested functions. fn early_tricky_explicit<'a>(_: for<'late> fn(&'late u8), - _: Box<for<'late> Fn(&'late u8)>) + _: Box<dyn for<'late> Fn(&'late u8)>) -> &'a u8 { loop {} } fn early_tricky_implicit<'a>(_: fn(&u8), - _: Box<Fn(&u8)>) + _: Box<dyn Fn(&u8)>) -> &'a u8 { loop {} } } diff --git a/src/test/ui/mismatched_types/cast-rfc0401.rs b/src/test/ui/mismatched_types/cast-rfc0401.rs index a5e03a18e6a..2f88c6496c4 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.rs +++ b/src/test/ui/mismatched_types/cast-rfc0401.rs @@ -24,7 +24,7 @@ fn main() let v = 0 as *const u8; let fat_v : *const [u8] = unsafe { &*(0 as *const [u8; 1])}; let fat_sv : *const [i8] = unsafe { &*(0 as *const [i8; 1])}; - let foo: &Foo = &f; + let foo: &dyn Foo = &f; let _ = v as &u8; //~ ERROR non-primitive cast let _ = v as E; //~ ERROR non-primitive cast @@ -50,7 +50,7 @@ fn main() let _ = 42usize as *const [u8]; //~ ERROR is invalid let _ = v as *const [u8]; //~ ERROR cannot cast - let _ = fat_v as *const Foo; //~ ERROR the size for values of type + let _ = fat_v as *const dyn Foo; //~ ERROR the size for values of type let _ = foo as *const str; //~ ERROR is invalid let _ = foo as *mut str; //~ ERROR is invalid let _ = main as *mut str; //~ ERROR is invalid @@ -59,14 +59,14 @@ fn main() let _ = fat_sv as usize; //~ ERROR is invalid let a : *const str = "hello"; - let _ = a as *const Foo; //~ ERROR the size for values of type + let _ = a as *const dyn Foo; //~ ERROR the size for values of type // check no error cascade let _ = main.f as *const u32; //~ ERROR no field - let cf: *const Foo = &0; + let cf: *const dyn Foo = &0; let _ = cf as *const [u16]; //~ ERROR is invalid - let _ = cf as *const Bar; //~ ERROR is invalid + let _ = cf as *const dyn Bar; //~ ERROR is invalid vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid } diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index 0e0bb8da81e..f94dfd100a6 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -207,15 +207,15 @@ LL | let _ = cf as *const [u16]; error[E0606]: casting `*const dyn Foo` as `*const dyn Bar` is invalid --> $DIR/cast-rfc0401.rs:69:13 | -LL | let _ = cf as *const Bar; - | ^^^^^^^^^^^^^^^^ +LL | let _ = cf as *const dyn Bar; + | ^^^^^^^^^^^^^^^^^^^^ | = note: vtable kinds may not match error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/cast-rfc0401.rs:53:13 | -LL | let _ = fat_v as *const Foo; +LL | let _ = fat_v as *const dyn Foo; | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` @@ -225,7 +225,7 @@ LL | let _ = fat_v as *const Foo; error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/cast-rfc0401.rs:62:13 | -LL | let _ = a as *const Foo; +LL | let _ = a as *const dyn Foo; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` diff --git a/src/test/ui/mismatched_types/issue-19109.rs b/src/test/ui/mismatched_types/issue-19109.rs index 030b7a40ca6..eae6a87905b 100644 --- a/src/test/ui/mismatched_types/issue-19109.rs +++ b/src/test/ui/mismatched_types/issue-19109.rs @@ -1,7 +1,7 @@ trait Trait { } -fn function(t: &mut Trait) { - t as *mut Trait +fn function(t: &mut dyn Trait) { + t as *mut dyn Trait //~^ ERROR: mismatched types } diff --git a/src/test/ui/mismatched_types/issue-19109.stderr b/src/test/ui/mismatched_types/issue-19109.stderr index db2d484edff..b826ca66c68 100644 --- a/src/test/ui/mismatched_types/issue-19109.stderr +++ b/src/test/ui/mismatched_types/issue-19109.stderr @@ -1,10 +1,10 @@ error[E0308]: mismatched types --> $DIR/issue-19109.rs:4:5 | -LL | fn function(t: &mut Trait) { - | - help: try adding a return type: `-> *mut dyn Trait` -LL | t as *mut Trait - | ^^^^^^^^^^^^^^^ expected (), found *-ptr +LL | fn function(t: &mut dyn Trait) { + | - help: try adding a return type: `-> *mut dyn Trait` +LL | t as *mut dyn Trait + | ^^^^^^^^^^^^^^^^^^^ expected (), found *-ptr | = note: expected type `()` found type `*mut dyn Trait` diff --git a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs index be5fab871b4..882533992bd 100644 --- a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs +++ b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs @@ -2,14 +2,14 @@ trait Foo { fn dummy(&self) { } } -fn a(_x: Box<Foo+Send>) { +fn a(_x: Box<dyn Foo + Send>) { } -fn c(x: Box<Foo+Sync+Send>) { +fn c(x: Box<dyn Foo + Sync + Send>) { a(x); } -fn d(x: Box<Foo>) { +fn d(x: Box<dyn Foo>) { a(x); //~ ERROR mismatched types [E0308] } diff --git a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs index 3fa11878629..0385a120ce2 100644 --- a/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.rs @@ -6,7 +6,7 @@ struct R<'a> { // This struct is needed to create the // otherwise infinite type of a fn that // accepts itself as argument: - c: Box<FnMut(&mut R, bool) + 'a> + c: Box<dyn FnMut(&mut R, bool) + 'a> } fn innocent_looking_victim() { diff --git a/src/test/ui/nll/issue-52663-trait-object.rs b/src/test/ui/nll/issue-52663-trait-object.rs index e8e571aadc3..a7be365bde4 100644 --- a/src/test/ui/nll/issue-52663-trait-object.rs +++ b/src/test/ui/nll/issue-52663-trait-object.rs @@ -10,7 +10,7 @@ fn main() { let _ = { let tmp0 = 3; let tmp1 = &tmp0; - box tmp1 as Box<Foo + '_> + box tmp1 as Box<dyn Foo + '_> }; //~^^^ ERROR `tmp0` does not live long enough } diff --git a/src/test/ui/nll/issue-52663-trait-object.stderr b/src/test/ui/nll/issue-52663-trait-object.stderr index 9262117f397..b71893de7f8 100644 --- a/src/test/ui/nll/issue-52663-trait-object.stderr +++ b/src/test/ui/nll/issue-52663-trait-object.stderr @@ -3,8 +3,8 @@ error[E0597]: `tmp0` does not live long enough | LL | let tmp1 = &tmp0; | ^^^^^ borrowed value does not live long enough -LL | box tmp1 as Box<Foo + '_> - | ------------------------- borrow later captured here by trait object +LL | box tmp1 as Box<dyn Foo + '_> + | ----------------------------- borrow later captured here by trait object LL | }; | - `tmp0` dropped here while still borrowed diff --git a/src/test/ui/nll/issue-53570.rs b/src/test/ui/nll/issue-53570.rs index cea458dcb65..81c50edfed1 100644 --- a/src/test/ui/nll/issue-53570.rs +++ b/src/test/ui/nll/issue-53570.rs @@ -14,11 +14,11 @@ trait AnyVec<'a> { } trait GenericVec<T> { - fn unwrap<'a, 'b>(vec: &'b AnyVec<'a>) -> &'b [T] where T: 'a; + fn unwrap<'a, 'b>(vec: &'b dyn AnyVec<'a>) -> &'b [T] where T: 'a; } struct Scratchpad<'a> { - buffers: RefCell<Box<AnyVec<'a>>>, + buffers: RefCell<Box<dyn AnyVec<'a>>>, } impl<'a> Scratchpad<'a> { diff --git a/src/test/ui/object-does-not-impl-trait.rs b/src/test/ui/object-does-not-impl-trait.rs index 2d72b4588f7..104e7b2e215 100644 --- a/src/test/ui/object-does-not-impl-trait.rs +++ b/src/test/ui/object-does-not-impl-trait.rs @@ -3,6 +3,6 @@ trait Foo {} fn take_foo<F:Foo>(f: F) {} -fn take_object(f: Box<Foo>) { take_foo(f); } +fn take_object(f: Box<dyn Foo>) { take_foo(f); } //~^ ERROR `std::boxed::Box<dyn Foo>: Foo` is not satisfied fn main() {} diff --git a/src/test/ui/object-does-not-impl-trait.stderr b/src/test/ui/object-does-not-impl-trait.stderr index 0e28875ced6..288ce9682c2 100644 --- a/src/test/ui/object-does-not-impl-trait.stderr +++ b/src/test/ui/object-does-not-impl-trait.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `std::boxed::Box<dyn Foo>: Foo` is not satisfied - --> $DIR/object-does-not-impl-trait.rs:6:31 + --> $DIR/object-does-not-impl-trait.rs:6:35 | -LL | fn take_object(f: Box<Foo>) { take_foo(f); } - | ^^^^^^^^ the trait `Foo` is not implemented for `std::boxed::Box<dyn Foo>` +LL | fn take_object(f: Box<dyn Foo>) { take_foo(f); } + | ^^^^^^^^ the trait `Foo` is not implemented for `std::boxed::Box<dyn Foo>` | note: required by `take_foo` --> $DIR/object-does-not-impl-trait.rs:5:1 diff --git a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs index d14351aef9a..5dae92fee5f 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.rs @@ -20,27 +20,27 @@ struct Ref2<'a,'b:'a,T:'a+'b+?Sized> { r: &'a &'b T } -fn a<'a,'b>(t: Ref2<'a,'b,Test>) { +fn a<'a,'b>(t: Ref2<'a,'b, dyn Test>) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } -fn b(t: Ref2<Test>) { +fn b(t: Ref2<dyn Test>) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } -fn c(t: Ref2<&Test>) { +fn c(t: Ref2<&dyn Test>) { // In this case, the &'a overrides. } -fn d(t: Ref2<Ref1<Test>>) { +fn d(t: Ref2<Ref1<dyn Test>>) { // In this case, the lifetime parameter from the Ref1 overrides. } -fn e(t: Ref2<Ref0<Test>>) { +fn e(t: Ref2<Ref0<dyn Test>>) { // In this case, Ref2 is ambiguous, but Ref0 overrides with 'static. } -fn f(t: &Ref2<Test>) { +fn f(t: &Ref2<dyn Test>) { //~^ ERROR lifetime bound for this object type cannot be deduced from context } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr index 0319c7bfbe2..0c3dbffeea6 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-ambiguous.stderr @@ -1,20 +1,20 @@ error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound - --> $DIR/object-lifetime-default-ambiguous.rs:23:27 + --> $DIR/object-lifetime-default-ambiguous.rs:23:28 | -LL | fn a<'a,'b>(t: Ref2<'a,'b,Test>) { - | ^^^^ +LL | fn a<'a,'b>(t: Ref2<'a,'b, dyn Test>) { + | ^^^^^^^^ error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-ambiguous.rs:27:14 | -LL | fn b(t: Ref2<Test>) { - | ^^^^ +LL | fn b(t: Ref2<dyn Test>) { + | ^^^^^^^^ error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound --> $DIR/object-lifetime-default-ambiguous.rs:43:15 | -LL | fn f(t: &Ref2<Test>) { - | ^^^^ +LL | fn f(t: &Ref2<dyn Test>) { + | ^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr index 19cdd66ef75..e94f2a92125 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-elision.rs:71:5 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs index cf15a4e8676..dc42edfba2c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.rs @@ -8,7 +8,7 @@ trait SomeTrait { } struct SomeStruct<'a> { - r: Box<SomeTrait+'a> + r: Box<dyn SomeTrait+'a> } fn deref<T>(ss: &T) -> T { @@ -17,7 +17,7 @@ fn deref<T>(ss: &T) -> T { loop { } } -fn load0<'a>(ss: &'a Box<SomeTrait>) -> Box<SomeTrait> { +fn load0<'a>(ss: &'a Box<dyn SomeTrait>) -> Box<dyn SomeTrait> { // Under old rules, the fully elaborated types of input/output were: // // for<'a,'b> fn(&'a Box<SomeTrait+'b>) -> Box<SomeTrait+'a> @@ -31,7 +31,7 @@ fn load0<'a>(ss: &'a Box<SomeTrait>) -> Box<SomeTrait> { deref(ss) } -fn load1(ss: &SomeTrait) -> &SomeTrait { +fn load1(ss: &dyn SomeTrait) -> &dyn SomeTrait { // Under old rules, the fully elaborated types of input/output were: // // for<'a,'b> fn(&'a (SomeTrait+'b)) -> &'a (SomeTrait+'a) @@ -45,13 +45,13 @@ fn load1(ss: &SomeTrait) -> &SomeTrait { ss } -fn load2<'a>(ss: &'a SomeTrait) -> &SomeTrait { +fn load2<'a>(ss: &'a dyn SomeTrait) -> &dyn SomeTrait { // Same as `load1` but with an explicit name thrown in for fun. ss } -fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { // Under old rules, the fully elaborated types of input/output were: // // for<'a,'b,'c>fn(&'a (SomeTrait+'c)) -> &'b (SomeTrait+'a) diff --git a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr b/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr index dcb07a1706f..2cdd6c5d890 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr @@ -7,7 +7,7 @@ LL | ss note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 54:10... --> $DIR/object-lifetime-default-elision.rs:54:10 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/object-lifetime-default-elision.rs:71:5 @@ -17,7 +17,7 @@ LL | ss note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 54:13... --> $DIR/object-lifetime-default-elision.rs:54:13 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ = note: ...so that the expression is assignable: expected &'b (dyn SomeTrait + 'b) @@ -32,7 +32,7 @@ LL | ss note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 54:10... --> $DIR/object-lifetime-default-elision.rs:54:10 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied --> $DIR/object-lifetime-default-elision.rs:71:5 @@ -42,7 +42,7 @@ LL | ss note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 54:13... --> $DIR/object-lifetime-default-elision.rs:54:13 | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { +LL | fn load3<'a,'b>(ss: &'a dyn SomeTrait) -> &'b dyn SomeTrait { | ^^ = note: ...so that the expression is assignable: expected &'b (dyn SomeTrait + 'b) diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr index 9e68647214c..17fb7c4acdf 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr @@ -1,7 +1,7 @@ error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:18:5 | -LL | fn load(ss: &mut SomeStruct) -> Box<SomeTrait> { +LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | --------------- help: add explicit lifetime `'static` to the type of `ss`: `&mut SomeStruct<'static>` ... LL | ss.r @@ -16,7 +16,7 @@ LL | ss.r error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:31:5 | -LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<SomeTrait+'b>) { +LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` ... LL | ss.r = b; diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs index b6d72f1fce3..587aab1edce 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.rs @@ -8,24 +8,24 @@ trait SomeTrait { } struct SomeStruct<'a> { - r: Box<SomeTrait+'a> + r: Box<dyn SomeTrait+'a> } -fn load(ss: &mut SomeStruct) -> Box<SomeTrait> { +fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { // `Box<SomeTrait>` defaults to a `'static` bound, so this return // is illegal. ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] } -fn store(ss: &mut SomeStruct, b: Box<SomeTrait>) { +fn store(ss: &mut SomeStruct, b: Box<dyn SomeTrait>) { // No error: b is bounded by 'static which outlives the // (anonymous) lifetime on the struct. ss.r = b; } -fn store1<'b>(ss: &mut SomeStruct, b: Box<SomeTrait+'b>) { +fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) { // Here we override the lifetimes explicitly, and so naturally we get an error. ss.r = b; //~ ERROR explicit lifetime required in the type of `ss` [E0621] diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr index 0077c95139f..78e4bdd374d 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.stderr @@ -1,7 +1,7 @@ error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:18:5 | -LL | fn load(ss: &mut SomeStruct) -> Box<SomeTrait> { +LL | fn load(ss: &mut SomeStruct) -> Box<dyn SomeTrait> { | --------------- help: add explicit lifetime `'static` to the type of `ss`: `&mut SomeStruct<'static>` ... LL | ss.r @@ -10,7 +10,7 @@ LL | ss.r error[E0621]: explicit lifetime required in the type of `ss` --> $DIR/object-lifetime-default-from-box-error.rs:31:12 | -LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<SomeTrait+'b>) { +LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) { | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` ... LL | ss.r = b; diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr index 6d183ddf22d..7d6f9f39d13 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-from-rptr-box-error.rs:15:5 | -LL | fn c<'a>(t: &'a Box<Test+'a>, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here LL | ss.t = t; | ^^^^^^^^ assignment requires that `'a` must outlive `'static` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs index 91b384e0071..bf9e0beb57c 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.rs @@ -8,10 +8,10 @@ trait Test { } struct SomeStruct<'a> { - t: &'a Box<Test>, + t: &'a Box<dyn Test>, } -fn c<'a>(t: &'a Box<Test+'a>, mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.t = t; //~ ERROR mismatched types } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr index d7e3a171333..4f9cef12c5e 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.stderr @@ -9,7 +9,7 @@ LL | ss.t = t; note: the lifetime 'a as defined on the function body at 14:6... --> $DIR/object-lifetime-default-from-rptr-box-error.rs:14:6 | -LL | fn c<'a>(t: &'a Box<Test+'a>, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a Box<dyn Test+'a>, mut ss: SomeStruct<'a>) { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr index fe3b21fa39c..6df54638ce0 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:21:5 | -LL | fn c<'a>(t: &'a MyBox<Test+'a>, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { | -- lifetime `'a` defined here LL | ss.t = t; | ^^^^^^^^ assignment requires that `'a` must outlive `'static` diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs index 6a84621f59e..ae2878539cf 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.rs @@ -9,15 +9,15 @@ trait Test { } struct SomeStruct<'a> { - t: &'a MyBox<Test>, - u: &'a MyBox<Test+'a>, + t: &'a MyBox<dyn Test>, + u: &'a MyBox<dyn Test + 'a>, } struct MyBox<T:?Sized> { b: Box<T> } -fn c<'a>(t: &'a MyBox<Test+'a>, mut ss: SomeStruct<'a>) { +fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { ss.t = t; //~ ERROR mismatched types } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr index 4d082530dc5..3b7faee68aa 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.stderr @@ -9,7 +9,7 @@ LL | ss.t = t; note: the lifetime 'a as defined on the function body at 20:6... --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:20:6 | -LL | fn c<'a>(t: &'a MyBox<Test+'a>, mut ss: SomeStruct<'a>) { +LL | fn c<'a>(t: &'a MyBox<dyn Test+'a>, mut ss: SomeStruct<'a>) { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr index 448fe9e5510..cdfbf0fc878 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/object-lifetime-default-mybox.rs:27:5 | -LL | fn load1<'a,'b>(a: &'a MyBox<SomeTrait>, +LL | fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here @@ -12,7 +12,7 @@ LL | a error[E0521]: borrowed data escapes outside of function --> $DIR/object-lifetime-default-mybox.rs:31:5 | -LL | fn load2<'a>(ss: &MyBox<SomeTrait+'a>) -> MyBox<SomeTrait+'a> { +LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { | -- `ss` is a reference that is only valid in the function body LL | load0(ss) | ^^^^^^^^^ `ss` escapes the function body here diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs index c94df82a177..eb27fe90f47 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.rs @@ -16,18 +16,18 @@ fn deref<T>(ss: &T) -> T { loop { } } -fn load0(ss: &MyBox<SomeTrait>) -> MyBox<SomeTrait> { +fn load0(ss: &MyBox<dyn SomeTrait>) -> MyBox<dyn SomeTrait> { deref(ss) } -fn load1<'a,'b>(a: &'a MyBox<SomeTrait>, - b: &'b MyBox<SomeTrait>) - -> &'b MyBox<SomeTrait> +fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, + b: &'b MyBox<dyn SomeTrait>) + -> &'b MyBox<dyn SomeTrait> { a //~ ERROR lifetime mismatch } -fn load2<'a>(ss: &MyBox<SomeTrait+'a>) -> MyBox<SomeTrait+'a> { +fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { load0(ss) //~ ERROR mismatched types } diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr index 4c23f867be8..928b9201982 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.stderr @@ -1,11 +1,11 @@ error[E0623]: lifetime mismatch --> $DIR/object-lifetime-default-mybox.rs:27:5 | -LL | fn load1<'a,'b>(a: &'a MyBox<SomeTrait>, - | -------------------- this parameter and the return type are declared with different lifetimes... -LL | b: &'b MyBox<SomeTrait>) -LL | -> &'b MyBox<SomeTrait> - | -------------------- +LL | fn load1<'a,'b>(a: &'a MyBox<dyn SomeTrait>, + | ------------------------ this parameter and the return type are declared with different lifetimes... +LL | b: &'b MyBox<dyn SomeTrait>) +LL | -> &'b MyBox<dyn SomeTrait> + | ------------------------ LL | { LL | a | ^ ...but data from `a` is returned here @@ -21,7 +21,7 @@ LL | load0(ss) note: the lifetime 'a as defined on the function body at 30:10... --> $DIR/object-lifetime-default-mybox.rs:30:10 | -LL | fn load2<'a>(ss: &MyBox<SomeTrait+'a>) -> MyBox<SomeTrait+'a> { +LL | fn load2<'a>(ss: &MyBox<dyn SomeTrait + 'a>) -> MyBox<dyn SomeTrait + 'a> { | ^^ = note: ...does not necessarily outlive the static lifetime diff --git a/src/test/ui/object-pointer-types.rs b/src/test/ui/object-pointer-types.rs index a8a482fb5a6..760a50e5b79 100644 --- a/src/test/ui/object-pointer-types.rs +++ b/src/test/ui/object-pointer-types.rs @@ -5,19 +5,19 @@ trait Foo { fn owned(self: Box<Self>); } -fn borrowed_receiver(x: &Foo) { +fn borrowed_receiver(x: &dyn Foo) { x.borrowed(); x.borrowed_mut(); // See [1] x.owned(); //~ ERROR no method named `owned` found } -fn borrowed_mut_receiver(x: &mut Foo) { +fn borrowed_mut_receiver(x: &mut dyn Foo) { x.borrowed(); x.borrowed_mut(); x.owned(); //~ ERROR no method named `owned` found } -fn owned_receiver(x: Box<Foo>) { +fn owned_receiver(x: Box<dyn Foo>) { x.borrowed(); x.borrowed_mut(); // See [1] x.managed(); //~ ERROR no method named `managed` found diff --git a/src/test/ui/object-safety/object-safety-associated-consts.rs b/src/test/ui/object-safety/object-safety-associated-consts.rs index 79b7e541af8..5900019ea91 100644 --- a/src/test/ui/object-safety/object-safety-associated-consts.rs +++ b/src/test/ui/object-safety/object-safety-associated-consts.rs @@ -6,7 +6,7 @@ trait Bar { const X: usize; } -fn make_bar<T:Bar>(t: &T) -> &Bar { +fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t } diff --git a/src/test/ui/object-safety/object-safety-associated-consts.stderr b/src/test/ui/object-safety/object-safety-associated-consts.stderr index 96962c10720..55f9e3f9f13 100644 --- a/src/test/ui/object-safety/object-safety-associated-consts.stderr +++ b/src/test/ui/object-safety/object-safety-associated-consts.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-associated-consts.rs:9:1 | -LL | fn make_bar<T:Bar>(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: the trait cannot contain associated consts like `X` diff --git a/src/test/ui/object-safety/object-safety-by-value-self-use.rs b/src/test/ui/object-safety/object-safety-by-value-self-use.rs index 0b70c8ad45e..f903f26c090 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self-use.rs +++ b/src/test/ui/object-safety/object-safety-by-value-self-use.rs @@ -11,7 +11,7 @@ trait Baz { fn baz(self: Self); } -fn use_bar(t: Box<Bar>) { +fn use_bar(t: Box<dyn Bar>) { t.bar() //~ ERROR cannot move a value of type dyn Bar } diff --git a/src/test/ui/object-safety/object-safety-by-value-self.rs b/src/test/ui/object-safety/object-safety-by-value-self.rs index dee31f6e370..a8b1ddfaba7 100644 --- a/src/test/ui/object-safety/object-safety-by-value-self.rs +++ b/src/test/ui/object-safety/object-safety-by-value-self.rs @@ -17,28 +17,28 @@ trait Quux { fn baz(self: Self) where Self : Sized; } -fn make_bar<T:Bar>(t: &T) -> &Bar { +fn make_bar<T:Bar>(t: &T) -> &dyn Bar { t // legal } -fn make_bar_explicit<T:Bar>(t: &T) -> &Bar { - t as &Bar // legal +fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar { + t as &dyn Bar // legal } -fn make_baz<T:Baz>(t: &T) -> &Baz { +fn make_baz<T:Baz>(t: &T) -> &dyn Baz { t // legal } -fn make_baz_explicit<T:Baz>(t: &T) -> &Baz { - t as &Baz // legal +fn make_baz_explicit<T:Baz>(t: &T) -> &dyn Baz { + t as &dyn Baz // legal } -fn make_quux<T:Quux>(t: &T) -> &Quux { +fn make_quux<T:Quux>(t: &T) -> &dyn Quux { t } -fn make_quux_explicit<T:Quux>(t: &T) -> &Quux { - t as &Quux +fn make_quux_explicit<T:Quux>(t: &T) -> &dyn Quux { + t as &dyn Quux } diff --git a/src/test/ui/object-safety/object-safety-generics.rs b/src/test/ui/object-safety/object-safety-generics.rs index 5f4aabf5469..d63ea28c8f2 100644 --- a/src/test/ui/object-safety/object-safety-generics.rs +++ b/src/test/ui/object-safety/object-safety-generics.rs @@ -11,22 +11,22 @@ trait Quux { where Self : Sized; } -fn make_bar<T:Bar>(t: &T) -> &Bar { +fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t } -fn make_bar_explicit<T:Bar>(t: &T) -> &Bar { +fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 - t as &Bar + t as &dyn Bar } -fn make_quux<T:Quux>(t: &T) -> &Quux { +fn make_quux<T:Quux>(t: &T) -> &dyn Quux { t } -fn make_quux_explicit<T:Quux>(t: &T) -> &Quux { - t as &Quux +fn make_quux_explicit<T:Quux>(t: &T) -> &dyn Quux { + t as &dyn Quux } fn main() { diff --git a/src/test/ui/object-safety/object-safety-generics.stderr b/src/test/ui/object-safety/object-safety-generics.stderr index 7ae44794ceb..d66cdb98448 100644 --- a/src/test/ui/object-safety/object-safety-generics.stderr +++ b/src/test/ui/object-safety/object-safety-generics.stderr @@ -1,16 +1,16 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-generics.rs:14:1 | -LL | fn make_bar<T:Bar>(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `bar` has generic type parameters error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-generics.rs:19:1 | -LL | fn make_bar_explicit<T:Bar>(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `bar` has generic type parameters diff --git a/src/test/ui/object-safety/object-safety-issue-22040.rs b/src/test/ui/object-safety/object-safety-issue-22040.rs index eb28fcf0d5a..1fc5c5442c2 100644 --- a/src/test/ui/object-safety/object-safety-issue-22040.rs +++ b/src/test/ui/object-safety/object-safety-issue-22040.rs @@ -9,7 +9,7 @@ trait Expr: Debug + PartialEq { //#[derive(PartialEq)] #[derive(Debug)] struct SExpr<'x> { - elements: Vec<Box<Expr+ 'x>>, + elements: Vec<Box<dyn Expr + 'x>>, //~^ ERROR E0038 } @@ -35,8 +35,8 @@ impl <'x> Expr for SExpr<'x> { } fn main() { - let a: Box<Expr> = Box::new(SExpr::new()); - let b: Box<Expr> = Box::new(SExpr::new()); + let a: Box<dyn Expr> = Box::new(SExpr::new()); + let b: Box<dyn Expr> = Box::new(SExpr::new()); // assert_eq!(a , b); } diff --git a/src/test/ui/object-safety/object-safety-issue-22040.stderr b/src/test/ui/object-safety/object-safety-issue-22040.stderr index 85721f1a5f8..1f5c472ddc2 100644 --- a/src/test/ui/object-safety/object-safety-issue-22040.stderr +++ b/src/test/ui/object-safety/object-safety-issue-22040.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Expr` cannot be made into an object --> $DIR/object-safety-issue-22040.rs:12:23 | -LL | elements: Vec<Box<Expr+ 'x>>, - | ^^^^^^^^ the trait `Expr` cannot be made into an object +LL | elements: Vec<Box<dyn Expr + 'x>>, + | ^^^^^^^^^^^^^ the trait `Expr` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.rs b/src/test/ui/object-safety/object-safety-mentions-Self.rs index 8e1bd83cec0..f13ffe53626 100644 --- a/src/test/ui/object-safety/object-safety-mentions-Self.rs +++ b/src/test/ui/object-safety/object-safety-mentions-Self.rs @@ -14,22 +14,22 @@ trait Quux { fn get(&self, s: &Self) -> Self where Self : Sized; } -fn make_bar<T:Bar>(t: &T) -> &Bar { +fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 loop { } } -fn make_baz<T:Baz>(t: &T) -> &Baz { +fn make_baz<T:Baz>(t: &T) -> &dyn Baz { //~^ ERROR E0038 t } -fn make_quux<T:Quux>(t: &T) -> &Quux { +fn make_quux<T:Quux>(t: &T) -> &dyn Quux { t } -fn make_quux_explicit<T:Quux>(t: &T) -> &Quux { - t as &Quux +fn make_quux_explicit<T:Quux>(t: &T) -> &dyn Quux { + t as &dyn Quux } fn main() { diff --git a/src/test/ui/object-safety/object-safety-mentions-Self.stderr b/src/test/ui/object-safety/object-safety-mentions-Self.stderr index ed3aed983cf..c0c471c2b1e 100644 --- a/src/test/ui/object-safety/object-safety-mentions-Self.stderr +++ b/src/test/ui/object-safety/object-safety-mentions-Self.stderr @@ -1,16 +1,16 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-mentions-Self.rs:17:1 | -LL | fn make_bar<T:Bar>(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: method `bar` references the `Self` type in its arguments or return type error[E0038]: the trait `Baz` cannot be made into an object --> $DIR/object-safety-mentions-Self.rs:22:1 | -LL | fn make_baz<T:Baz>(t: &T) -> &Baz { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object +LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Baz` cannot be made into an object | = note: method `bar` references the `Self` type in its arguments or return type diff --git a/src/test/ui/object-safety/object-safety-no-static.rs b/src/test/ui/object-safety/object-safety-no-static.rs index 4faf9386f9a..55d31ce8087 100644 --- a/src/test/ui/object-safety/object-safety-no-static.rs +++ b/src/test/ui/object-safety/object-safety-no-static.rs @@ -5,7 +5,7 @@ trait Foo { fn foo(); } -fn foo_implicit<T:Foo+'static>(b: Box<T>) -> Box<Foo+'static> { +fn foo_implicit<T:Foo+'static>(b: Box<T>) -> Box<dyn Foo + 'static> { //~^ ERROR E0038 loop { } } diff --git a/src/test/ui/object-safety/object-safety-no-static.stderr b/src/test/ui/object-safety/object-safety-no-static.stderr index 3b8ccb594c1..da8dd657c2a 100644 --- a/src/test/ui/object-safety/object-safety-no-static.stderr +++ b/src/test/ui/object-safety/object-safety-no-static.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety-no-static.rs:8:1 | -LL | fn foo_implicit<T:Foo+'static>(b: Box<T>) -> Box<Foo+'static> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object +LL | fn foo_implicit<T:Foo+'static>(b: Box<T>) -> Box<dyn Foo + 'static> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/object-safety/object-safety-phantom-fn.rs b/src/test/ui/object-safety/object-safety-phantom-fn.rs index f8875e4995b..59ed12c78f0 100644 --- a/src/test/ui/object-safety/object-safety-phantom-fn.rs +++ b/src/test/ui/object-safety/object-safety-phantom-fn.rs @@ -9,11 +9,11 @@ trait Baz { trait Bar<T> { } -fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> { +fn make_bar<T:Bar<u32>>(t: &T) -> &dyn Bar<u32> { t } -fn make_baz<T:Baz>(t: &T) -> &Baz { +fn make_baz<T:Baz>(t: &T) -> &dyn Baz { t } diff --git a/src/test/ui/object-safety/object-safety-sized-2.rs b/src/test/ui/object-safety/object-safety-sized-2.rs index baeb3734677..7235b22404e 100644 --- a/src/test/ui/object-safety/object-safety-sized-2.rs +++ b/src/test/ui/object-safety/object-safety-sized-2.rs @@ -7,7 +7,7 @@ trait Bar fn bar<T>(&self, t: T); } -fn make_bar<T:Bar>(t: &T) -> &Bar { +fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 loop { } } diff --git a/src/test/ui/object-safety/object-safety-sized-2.stderr b/src/test/ui/object-safety/object-safety-sized-2.stderr index 2b8bfa341d7..dcaf2ff0bc2 100644 --- a/src/test/ui/object-safety/object-safety-sized-2.stderr +++ b/src/test/ui/object-safety/object-safety-sized-2.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-sized-2.rs:10:1 | -LL | fn make_bar<T:Bar>(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/object-safety/object-safety-sized.rs b/src/test/ui/object-safety/object-safety-sized.rs index 77dc7390aff..1312bb34717 100644 --- a/src/test/ui/object-safety/object-safety-sized.rs +++ b/src/test/ui/object-safety/object-safety-sized.rs @@ -5,7 +5,7 @@ trait Bar : Sized { fn bar<T>(&self, t: T); } -fn make_bar<T:Bar>(t: &T) -> &Bar { +fn make_bar<T:Bar>(t: &T) -> &dyn Bar { //~^ ERROR E0038 t } diff --git a/src/test/ui/object-safety/object-safety-sized.stderr b/src/test/ui/object-safety/object-safety-sized.stderr index ba98e2f1ef6..98bc73e38d4 100644 --- a/src/test/ui/object-safety/object-safety-sized.stderr +++ b/src/test/ui/object-safety/object-safety-sized.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/object-safety-sized.rs:8:1 | -LL | fn make_bar<T:Bar>(t: &T) -> &Bar { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs index 9d0da4e327c..2445b33c814 100644 --- a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs +++ b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.rs @@ -8,11 +8,11 @@ trait Bar<T> { trait Baz : Bar<Self> { } -fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> { +fn make_bar<T:Bar<u32>>(t: &T) -> &dyn Bar<u32> { t } -fn make_baz<T:Baz>(t: &T) -> &Baz { +fn make_baz<T:Baz>(t: &T) -> &dyn Baz { //~^ ERROR E0038 t } diff --git a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr index 5db34a23fff..8ae89832703 100644 --- a/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr +++ b/src/test/ui/object-safety/object-safety-supertrait-mentions-Self.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Baz` cannot be made into an object --> $DIR/object-safety-supertrait-mentions-Self.rs:15:31 | -LL | fn make_baz<T:Baz>(t: &T) -> &Baz { - | ^^^ the trait `Baz` cannot be made into an object +LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz { + | ^^^^^^^ the trait `Baz` cannot be made into an object | = note: the trait cannot use `Self` as a type parameter in the supertraits or where-clauses diff --git a/src/test/ui/privacy/private-in-public-non-principal-2.rs b/src/test/ui/privacy/private-in-public-non-principal-2.rs index 02fd92aa7a4..8a59073fa6c 100644 --- a/src/test/ui/privacy/private-in-public-non-principal-2.rs +++ b/src/test/ui/privacy/private-in-public-non-principal-2.rs @@ -4,7 +4,7 @@ mod m { pub trait PubPrincipal {} auto trait PrivNonPrincipal {} - pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} } + pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} } } fn main() { diff --git a/src/test/ui/privacy/private-in-public-non-principal.rs b/src/test/ui/privacy/private-in-public-non-principal.rs index 5de5a685208..5d89d8105b1 100644 --- a/src/test/ui/privacy/private-in-public-non-principal.rs +++ b/src/test/ui/privacy/private-in-public-non-principal.rs @@ -3,7 +3,7 @@ pub trait PubPrincipal {} auto trait PrivNonPrincipal {} -pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} } +pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} } //~^ WARN private trait `PrivNonPrincipal` in public interface //~| WARN this was previously accepted diff --git a/src/test/ui/privacy/private-in-public-non-principal.stderr b/src/test/ui/privacy/private-in-public-non-principal.stderr index 729b94ed892..578f4380b42 100644 --- a/src/test/ui/privacy/private-in-public-non-principal.stderr +++ b/src/test/ui/privacy/private-in-public-non-principal.stderr @@ -1,8 +1,8 @@ warning: private trait `PrivNonPrincipal` in public interface (error E0445) --> $DIR/private-in-public-non-principal.rs:6:1 | -LL | pub fn leak_dyn_nonprincipal() -> Box<PubPrincipal + PrivNonPrincipal> { loop {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(private_in_public)] on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/src/test/ui/privacy/private-inferred-type.rs b/src/test/ui/privacy/private-inferred-type.rs index d9bb421b53f..dab440b2d99 100644 --- a/src/test/ui/privacy/private-inferred-type.rs +++ b/src/test/ui/privacy/private-inferred-type.rs @@ -65,9 +65,9 @@ mod m { pub fn leak_anon2() -> impl TraitWithTyParam<Alias> { 0 } pub fn leak_anon3() -> impl TraitWithAssocTy<AssocTy = Alias> { 0 } - pub fn leak_dyn1() -> Box<Trait + 'static> { Box::new(0) } - pub fn leak_dyn2() -> Box<TraitWithTyParam<Alias>> { Box::new(0) } - pub fn leak_dyn3() -> Box<TraitWithAssocTy<AssocTy = Alias>> { Box::new(0) } + pub fn leak_dyn1() -> Box<dyn Trait + 'static> { Box::new(0) } + pub fn leak_dyn2() -> Box<dyn TraitWithTyParam<Alias>> { Box::new(0) } + pub fn leak_dyn3() -> Box<dyn TraitWithAssocTy<AssocTy = Alias>> { Box::new(0) } } mod adjust { diff --git a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs index a1ccf667671..5f1c2ed08f6 100644 --- a/src/test/ui/regions/region-borrow-params-issue-29793-small.rs +++ b/src/test/ui/regions/region-borrow-params-issue-29793-small.rs @@ -51,7 +51,7 @@ fn ok_borrow_of_fn_params(a: usize, b:usize) { // TOP-LEVEL FN'S fn escaping_borrow_of_fn_params_1() { - fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -62,7 +62,7 @@ fn escaping_borrow_of_fn_params_1() { } fn escaping_borrow_of_fn_params_2() { - fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -73,7 +73,7 @@ fn escaping_borrow_of_fn_params_2() { } fn move_of_fn_params() { - fn g<'a>(x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); }; @@ -86,7 +86,7 @@ fn move_of_fn_params() { fn escaping_borrow_of_method_params_1() { struct S; impl S { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -100,7 +100,7 @@ fn escaping_borrow_of_method_params_1() { fn escaping_borrow_of_method_params_2() { struct S; impl S { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -113,7 +113,7 @@ fn escaping_borrow_of_method_params_2() { fn move_of_method_params() { struct S; impl S { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); } @@ -125,10 +125,10 @@ fn move_of_method_params() { // TRAIT IMPL METHODS fn escaping_borrow_of_trait_impl_params_1() { - trait T { fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a>; } + trait T { fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a>; } struct S; impl T for S { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -140,10 +140,10 @@ fn escaping_borrow_of_trait_impl_params_1() { } fn escaping_borrow_of_trait_impl_params_2() { - trait T { fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a>; } + trait T { fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a>; } struct S; impl T for S { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -154,10 +154,10 @@ fn escaping_borrow_of_trait_impl_params_2() { } fn move_of_trait_impl_params() { - trait T { fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a>; } + trait T { fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a>; } struct S; impl T for S { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); } @@ -171,7 +171,7 @@ fn move_of_trait_impl_params() { fn escaping_borrow_of_trait_default_params_1() { struct S; trait T { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -185,7 +185,7 @@ fn escaping_borrow_of_trait_default_params_1() { fn escaping_borrow_of_trait_default_params_2() { struct S; trait T { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) //~^ ERROR E0373 //~| ERROR E0373 @@ -199,7 +199,7 @@ fn escaping_borrow_of_trait_default_params_2() { fn move_of_trait_default_params() { struct S; trait T { - fn g<'a>(&self, x: usize, y:usize) -> Box<Fn(bool) -> usize + 'a> { + fn g<'a>(&self, x: usize, y:usize) -> Box<dyn Fn(bool) -> usize + 'a> { let f = move |t: bool| if t { x } else { y }; return Box::new(f); } diff --git a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs index 3a211b04636..40d2b740b43 100644 --- a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs +++ b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.rs @@ -10,15 +10,15 @@ trait SomeTrait { } struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used // All of these are ok, because we can derive exactly one bound: - a: Box<IsStatic>, - b: Box<Is<'static>>, - c: Box<Is<'a>>, - d: Box<IsSend>, - e: Box<Is<'a>+Send>, // we can derive two bounds, but one is 'static, so ok - f: Box<SomeTrait>, // OK, defaults to 'static due to RFC 599. - g: Box<SomeTrait+'a>, + a: Box<dyn IsStatic>, + b: Box<dyn Is<'static>>, + c: Box<dyn Is<'a>>, + d: Box<dyn IsSend>, + e: Box<dyn Is<'a>+Send>, // we can derive two bounds, but one is 'static, so ok + f: Box<dyn SomeTrait>, // OK, defaults to 'static due to RFC 599. + g: Box<dyn SomeTrait+'a>, - z: Box<Is<'a>+'b+'c>, + z: Box<dyn Is<'a>+'b+'c>, //~^ ERROR only a single explicit lifetime bound is permitted //~| ERROR lifetime bound not satisfied } diff --git a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr index 8bcb2da4577..003dd0699d3 100644 --- a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr +++ b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr @@ -1,14 +1,14 @@ error[E0226]: only a single explicit lifetime bound is permitted - --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:22 + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:26 | -LL | z: Box<Is<'a>+'b+'c>, - | ^^ +LL | z: Box<dyn Is<'a>+'b+'c>, + | ^^ error[E0478]: lifetime bound not satisfied --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:5 | -LL | z: Box<Is<'a>+'b+'c>, - | ^^^^^^^^^^^^^^^^^^^^ +LL | z: Box<dyn Is<'a>+'b+'c>, + | ^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime 'b as defined on the struct at 11:15 --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:15 diff --git a/src/test/ui/regions/region-object-lifetime-2.nll.stderr b/src/test/ui/regions/region-object-lifetime-2.nll.stderr index 56e8c40c99f..60084773466 100644 --- a/src/test/ui/regions/region-object-lifetime-2.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/region-object-lifetime-2.rs:10:5 | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/region-object-lifetime-2.rs b/src/test/ui/regions/region-object-lifetime-2.rs index 92c85020e9a..42798487893 100644 --- a/src/test/ui/regions/region-object-lifetime-2.rs +++ b/src/test/ui/regions/region-object-lifetime-2.rs @@ -6,7 +6,7 @@ trait Foo { } // Borrowed receiver but two distinct lifetimes, we get an error. -fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { x.borrowed() //~ ERROR cannot infer } diff --git a/src/test/ui/regions/region-object-lifetime-2.stderr b/src/test/ui/regions/region-object-lifetime-2.stderr index d3552ab0c4b..0c5e22ebae2 100644 --- a/src/test/ui/regions/region-object-lifetime-2.stderr +++ b/src/test/ui/regions/region-object-lifetime-2.stderr @@ -7,7 +7,7 @@ LL | x.borrowed() note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 9:42... --> $DIR/region-object-lifetime-2.rs:9:42 | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-2.rs:10:5 @@ -17,7 +17,7 @@ LL | x.borrowed() note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 9:45... --> $DIR/region-object-lifetime-2.rs:9:45 | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { +LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-2.rs:10:5 diff --git a/src/test/ui/regions/region-object-lifetime-4.nll.stderr b/src/test/ui/regions/region-object-lifetime-4.nll.stderr index aa91c371f41..75b049dae21 100644 --- a/src/test/ui/regions/region-object-lifetime-4.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/region-object-lifetime-4.rs:12:5 | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/region-object-lifetime-4.rs b/src/test/ui/regions/region-object-lifetime-4.rs index d2ab617ebb7..4fe12b2acfc 100644 --- a/src/test/ui/regions/region-object-lifetime-4.rs +++ b/src/test/ui/regions/region-object-lifetime-4.rs @@ -8,7 +8,7 @@ trait Foo { // Here we have two distinct lifetimes, but we try to return a pointer // with the longer lifetime when (from the signature) we only know // that it lives as long as the shorter lifetime. Therefore, error. -fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { x.borrowed() //~ ERROR cannot infer } diff --git a/src/test/ui/regions/region-object-lifetime-4.stderr b/src/test/ui/regions/region-object-lifetime-4.stderr index 75b26ffc6d5..e737d27d560 100644 --- a/src/test/ui/regions/region-object-lifetime-4.stderr +++ b/src/test/ui/regions/region-object-lifetime-4.stderr @@ -7,7 +7,7 @@ LL | x.borrowed() note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 11:41... --> $DIR/region-object-lifetime-4.rs:11:41 | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-4.rs:12:5 @@ -17,7 +17,7 @@ LL | x.borrowed() note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 11:44... --> $DIR/region-object-lifetime-4.rs:11:44 | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { +LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-4.rs:12:5 diff --git a/src/test/ui/regions/region-object-lifetime-5.rs b/src/test/ui/regions/region-object-lifetime-5.rs index bd68aebbeeb..307bbcbd58d 100644 --- a/src/test/ui/regions/region-object-lifetime-5.rs +++ b/src/test/ui/regions/region-object-lifetime-5.rs @@ -7,7 +7,7 @@ trait Foo { // Here, the object is bounded by an anonymous lifetime and returned // as `&'static`, so you get an error. -fn owned_receiver(x: Box<Foo>) -> &'static () { +fn owned_receiver(x: Box<dyn Foo>) -> &'static () { x.borrowed() //~ ERROR cannot return value referencing local data `*x` } diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr index a54f8f5faab..43acbfd412d 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr @@ -1,15 +1,15 @@ error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:8:12 | -LL | fn a(v: &[u8]) -> Box<Foo + 'static> { +LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` -LL | let x: Box<Foo + 'static> = Box::new(v); - | ^^^^^^^^^^^^^^^^^^ lifetime `'static` required +LL | let x: Box<dyn Foo + 'static> = Box::new(v); + | ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:14:5 | -LL | fn b(v: &[u8]) -> Box<Foo + 'static> { +LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` LL | Box::new(v) | ^^^^^^^^^^^ lifetime `'static` required @@ -17,7 +17,7 @@ LL | Box::new(v) error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:21:5 | -LL | fn c(v: &[u8]) -> Box<Foo> { +LL | fn c(v: &[u8]) -> Box<dyn Foo> { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` ... LL | Box::new(v) @@ -26,7 +26,7 @@ LL | Box::new(v) error: lifetime may not live long enough --> $DIR/region-object-lifetime-in-coercion.rs:26:5 | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> { +LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.rs b/src/test/ui/regions/region-object-lifetime-in-coercion.rs index dfba04b0d25..2dc67599913 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.rs +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.rs @@ -4,30 +4,30 @@ trait Foo {} impl<'a> Foo for &'a [u8] {} -fn a(v: &[u8]) -> Box<Foo + 'static> { - let x: Box<Foo + 'static> = Box::new(v); +fn a(v: &[u8]) -> Box<dyn Foo + 'static> { + let x: Box<dyn Foo + 'static> = Box::new(v); //~^ ERROR explicit lifetime required in the type of `v` [E0621] x } -fn b(v: &[u8]) -> Box<Foo + 'static> { +fn b(v: &[u8]) -> Box<dyn Foo + 'static> { Box::new(v) //~^ ERROR explicit lifetime required in the type of `v` [E0621] } -fn c(v: &[u8]) -> Box<Foo> { +fn c(v: &[u8]) -> Box<dyn Foo> { // same as previous case due to RFC 599 Box::new(v) //~^ ERROR explicit lifetime required in the type of `v` [E0621] } -fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> { +fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> { Box::new(v) //~^ ERROR cannot infer an appropriate lifetime due to conflicting } -fn e<'a:'b,'b>(v: &'a [u8]) -> Box<Foo+'b> { +fn e<'a:'b,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> { Box::new(v) // OK, thanks to 'a:'b } diff --git a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr index c94a25ce604..8209fa1840d 100644 --- a/src/test/ui/regions/region-object-lifetime-in-coercion.stderr +++ b/src/test/ui/regions/region-object-lifetime-in-coercion.stderr @@ -1,15 +1,15 @@ error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/region-object-lifetime-in-coercion.rs:8:33 + --> $DIR/region-object-lifetime-in-coercion.rs:8:37 | -LL | fn a(v: &[u8]) -> Box<Foo + 'static> { +LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` -LL | let x: Box<Foo + 'static> = Box::new(v); - | ^^^^^^^^^^^ lifetime `'static` required +LL | let x: Box<dyn Foo + 'static> = Box::new(v); + | ^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:14:5 | -LL | fn b(v: &[u8]) -> Box<Foo + 'static> { +LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` LL | Box::new(v) | ^^^^^^^^^^^ lifetime `'static` required @@ -17,7 +17,7 @@ LL | Box::new(v) error[E0621]: explicit lifetime required in the type of `v` --> $DIR/region-object-lifetime-in-coercion.rs:21:5 | -LL | fn c(v: &[u8]) -> Box<Foo> { +LL | fn c(v: &[u8]) -> Box<dyn Foo> { | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` ... LL | Box::new(v) @@ -32,7 +32,7 @@ LL | Box::new(v) note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 25:6... --> $DIR/region-object-lifetime-in-coercion.rs:25:6 | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> { +LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> { | ^^ = note: ...so that the expression is assignable: expected &[u8] @@ -40,7 +40,7 @@ LL | fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> { note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 25:9... --> $DIR/region-object-lifetime-in-coercion.rs:25:9 | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> { +LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> { | ^^ = note: ...so that the expression is assignable: expected std::boxed::Box<(dyn Foo + 'b)> diff --git a/src/test/ui/regions/regions-close-associated-type-into-object.rs b/src/test/ui/regions/regions-close-associated-type-into-object.rs index 853d9611387..0cbdc828c50 100644 --- a/src/test/ui/regions/regions-close-associated-type-into-object.rs +++ b/src/test/ui/regions/regions-close-associated-type-into-object.rs @@ -9,54 +9,54 @@ trait Iter { fn as_item(&self) -> &Self::Item; } -fn bad1<T: Iter>(v: T) -> Box<X+'static> +fn bad1<T: Iter>(v: T) -> Box<dyn X + 'static> { let item = v.into_item(); Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough } -fn bad2<T: Iter>(v: T) -> Box<X+'static> +fn bad2<T: Iter>(v: T) -> Box<dyn X + 'static> where Box<T::Item> : X { let item: Box<_> = box v.into_item(); Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough } -fn bad3<'a, T: Iter>(v: T) -> Box<X+'a> +fn bad3<'a, T: Iter>(v: T) -> Box<dyn X + 'a> { let item = v.into_item(); Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough } -fn bad4<'a, T: Iter>(v: T) -> Box<X+'a> +fn bad4<'a, T: Iter>(v: T) -> Box<dyn X + 'a> where Box<T::Item> : X { let item: Box<_> = box v.into_item(); Box::new(item) //~ ERROR associated type `<T as Iter>::Item` may not live long enough } -fn ok1<'a, T: Iter>(v: T) -> Box<X+'a> +fn ok1<'a, T: Iter>(v: T) -> Box<dyn X + 'a> where T::Item : 'a { let item = v.into_item(); Box::new(item) // OK, T::Item : 'a is declared } -fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box<X+'a> +fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box<dyn X + 'a> where T::Item : Clone { let item = Clone::clone(w); Box::new(item) // OK, T::Item : 'a is implied } -fn ok3<'a, T: Iter>(v: &'a T) -> Box<X+'a> +fn ok3<'a, T: Iter>(v: &'a T) -> Box<dyn X + 'a> where T::Item : Clone + 'a { let item = Clone::clone(v.as_item()); Box::new(item) // OK, T::Item : 'a was declared } -fn meh1<'a, T: Iter>(v: &'a T) -> Box<X+'a> +fn meh1<'a, T: Iter>(v: &'a T) -> Box<dyn X + 'a> where T::Item : Clone { // This case is kind of interesting. It's the same as `ok3` but diff --git a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr index 42df9b1c49f..806a3ca8242 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr @@ -1,16 +1,16 @@ error: lifetime may not live long enough --> $DIR/regions-close-object-into-object-2.rs:10:5 | -LL | fn g<'a, T: 'static>(v: Box<A<T>+'a>) -> Box<X+'static> { +LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> { | -- lifetime `'a` defined here -LL | box B(&*v) as Box<X> - | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` +LL | box B(&*v) as Box<dyn X> + | ^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` --> $DIR/regions-close-object-into-object-2.rs:10:5 | -LL | box B(&*v) as Box<X> - | ^^^^^^---^^^^^^^^^^^ +LL | box B(&*v) as Box<dyn X> + | ^^^^^^---^^^^^^^^^^^^^^^ | | | | | `*v` is borrowed here | returns a value referencing data owned by the current function diff --git a/src/test/ui/regions/regions-close-object-into-object-2.rs b/src/test/ui/regions/regions-close-object-into-object-2.rs index cebb4ac68cb..2364ba27286 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.rs +++ b/src/test/ui/regions/regions-close-object-into-object-2.rs @@ -1,13 +1,13 @@ #![feature(box_syntax)] trait A<T> { } -struct B<'a, T:'a>(&'a (A<T>+'a)); +struct B<'a, T:'a>(&'a (dyn A<T> + 'a)); trait X { } impl<'a, T> X for B<'a, T> {} -fn g<'a, T: 'static>(v: Box<A<T>+'a>) -> Box<X+'static> { - box B(&*v) as Box<X> //~ ERROR cannot infer +fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> { + box B(&*v) as Box<dyn X> //~ ERROR cannot infer } fn main() { } diff --git a/src/test/ui/regions/regions-close-object-into-object-2.stderr b/src/test/ui/regions/regions-close-object-into-object-2.stderr index b5b03e618e1..fa203debb3a 100644 --- a/src/test/ui/regions/regions-close-object-into-object-2.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-2.stderr @@ -1,18 +1,18 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements --> $DIR/regions-close-object-into-object-2.rs:10:11 | -LL | box B(&*v) as Box<X> +LL | box B(&*v) as Box<dyn X> | ^^^ | note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 9:6... --> $DIR/regions-close-object-into-object-2.rs:9:6 | -LL | fn g<'a, T: 'static>(v: Box<A<T>+'a>) -> Box<X+'static> { +LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> { | ^^ note: ...so that the type `(dyn A<T> + 'a)` is not borrowed for too long --> $DIR/regions-close-object-into-object-2.rs:10:11 | -LL | box B(&*v) as Box<X> +LL | box B(&*v) as Box<dyn X> | ^^^ = note: but, the lifetime must be valid for the static lifetime... = note: ...so that the expression is assignable: diff --git a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr index 8af94fa7e79..1e57023bc23 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr @@ -1,7 +1,7 @@ error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:10:5 | -LL | box B(&*v) as Box<X> +LL | box B(&*v) as Box<dyn X> | ^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `U: 'static`... @@ -9,16 +9,16 @@ LL | box B(&*v) as Box<X> error: lifetime may not live long enough --> $DIR/regions-close-object-into-object-4.rs:10:5 | -LL | fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> { +LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { | -- lifetime `'a` defined here -LL | box B(&*v) as Box<X> - | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` +LL | box B(&*v) as Box<dyn X> + | ^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error[E0515]: cannot return value referencing local data `*v` --> $DIR/regions-close-object-into-object-4.rs:10:5 | -LL | box B(&*v) as Box<X> - | ^^^^^^---^^^^^^^^^^^ +LL | box B(&*v) as Box<dyn X> + | ^^^^^^---^^^^^^^^^^^^^^^ | | | | | `*v` is borrowed here | returns a value referencing data owned by the current function @@ -26,7 +26,7 @@ LL | box B(&*v) as Box<X> error[E0310]: the parameter type `U` may not live long enough --> $DIR/regions-close-object-into-object-4.rs:10:9 | -LL | box B(&*v) as Box<X> +LL | box B(&*v) as Box<dyn X> | ^^^^^^ | = help: consider adding an explicit lifetime bound `U: 'static`... diff --git a/src/test/ui/regions/regions-close-object-into-object-4.rs b/src/test/ui/regions/regions-close-object-into-object-4.rs index 91aab057bb9..d5310770436 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.rs +++ b/src/test/ui/regions/regions-close-object-into-object-4.rs @@ -1,13 +1,13 @@ #![feature(box_syntax)] trait A<T> { } -struct B<'a, T:'a>(&'a (A<T>+'a)); +struct B<'a, T:'a>(&'a (dyn A<T> + 'a)); trait X { } impl<'a, T> X for B<'a, T> {} -fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> { - box B(&*v) as Box<X> //~ ERROR cannot infer +fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { + box B(&*v) as Box<dyn X> //~ ERROR cannot infer } fn main() {} diff --git a/src/test/ui/regions/regions-close-object-into-object-4.stderr b/src/test/ui/regions/regions-close-object-into-object-4.stderr index 20cbcbb841f..f5e66f84a9e 100644 --- a/src/test/ui/regions/regions-close-object-into-object-4.stderr +++ b/src/test/ui/regions/regions-close-object-into-object-4.stderr @@ -1,18 +1,18 @@ error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements --> $DIR/regions-close-object-into-object-4.rs:10:11 | -LL | box B(&*v) as Box<X> +LL | box B(&*v) as Box<dyn X> | ^^^ | note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 9:6... --> $DIR/regions-close-object-into-object-4.rs:9:6 | -LL | fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> { +LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> { | ^^ note: ...so that the type `(dyn A<U> + 'a)` is not borrowed for too long --> $DIR/regions-close-object-into-object-4.rs:10:11 | -LL | box B(&*v) as Box<X> +LL | box B(&*v) as Box<dyn X> | ^^^ = note: but, the lifetime must be valid for the static lifetime... = note: ...so that the expression is assignable: diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr index 30fdb820e36..7d3d51bdb43 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr @@ -1,7 +1,7 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | box v as Box<SomeTrait+'static> +LL | box v as Box<dyn SomeTrait + 'static> | ^^^^^ | = help: consider adding an explicit lifetime bound `A: 'static`... @@ -9,7 +9,7 @@ LL | box v as Box<SomeTrait+'static> error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | box v as Box<SomeTrait+'b> +LL | box v as Box<dyn SomeTrait + 'b> | ^^^^^ | = help: consider adding an explicit lifetime bound `A: 'b`... diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.rs b/src/test/ui/regions/regions-close-over-type-parameter-1.rs index 9aee9663e8f..6a9aa66a446 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.rs @@ -6,18 +6,18 @@ trait SomeTrait { fn get(&self) -> isize; } -fn make_object1<A:SomeTrait>(v: A) -> Box<SomeTrait+'static> { - box v as Box<SomeTrait+'static> +fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> { + box v as Box<dyn SomeTrait + 'static> //~^ ERROR the parameter type `A` may not live long enough //~| ERROR the parameter type `A` may not live long enough } -fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'a> { - box v as Box<SomeTrait+'a> +fn make_object2<'a,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'a> { + box v as Box<dyn SomeTrait + 'a> } -fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'b> { - box v as Box<SomeTrait+'b> +fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'b> { + box v as Box<dyn SomeTrait + 'b> //~^ ERROR the parameter type `A` may not live long enough //~| ERROR the parameter type `A` may not live long enough } diff --git a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr b/src/test/ui/regions/regions-close-over-type-parameter-1.stderr index 615c55d9da3..81534b7b770 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-1.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-1.stderr @@ -1,58 +1,58 @@ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | fn make_object1<A:SomeTrait>(v: A) -> Box<SomeTrait+'static> { +LL | fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> { | -- help: consider adding an explicit lifetime bound `A: 'static`... -LL | box v as Box<SomeTrait+'static> +LL | box v as Box<dyn SomeTrait + 'static> | ^^^^^ | note: ...so that the type `A` will meet its required lifetime bounds --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | box v as Box<SomeTrait+'static> +LL | box v as Box<dyn SomeTrait + 'static> | ^^^^^ error[E0310]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | fn make_object1<A:SomeTrait>(v: A) -> Box<SomeTrait+'static> { +LL | fn make_object1<A:SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> { | -- help: consider adding an explicit lifetime bound `A: 'static`... -LL | box v as Box<SomeTrait+'static> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box<dyn SomeTrait + 'static> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that it can be closed over into an object --> $DIR/regions-close-over-type-parameter-1.rs:10:5 | -LL | box v as Box<SomeTrait+'static> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box<dyn SomeTrait + 'static> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'b> { +LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'b> { | -- help: consider adding an explicit lifetime bound `A: 'b`... -LL | box v as Box<SomeTrait+'b> +LL | box v as Box<dyn SomeTrait + 'b> | ^^^^^ | note: ...so that the type `A` will meet its required lifetime bounds --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | box v as Box<SomeTrait+'b> +LL | box v as Box<dyn SomeTrait + 'b> | ^^^^^ error[E0309]: the parameter type `A` may not live long enough --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<SomeTrait+'b> { +LL | fn make_object3<'a,'b,A:SomeTrait+'a>(v: A) -> Box<dyn SomeTrait + 'b> { | -- help: consider adding an explicit lifetime bound `A: 'b`... -LL | box v as Box<SomeTrait+'b> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box<dyn SomeTrait + 'b> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that it can be closed over into an object --> $DIR/regions-close-over-type-parameter-1.rs:20:5 | -LL | box v as Box<SomeTrait+'b> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box<dyn SomeTrait + 'b> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr index 001ed7fe4c5..88d6abd1428 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr @@ -1,13 +1,13 @@ error: lifetime may not live long enough --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'c> { +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> { | -- -- lifetime `'c` defined here | | | lifetime `'a` defined here LL | // A outlives 'a AND 'b...but not 'c. -LL | box v as Box<SomeTrait+'a> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'c` +LL | box v as Box<dyn SomeTrait + 'a> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'c` error: aborting due to previous error diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs index defbc5d9f23..26643e08985 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.rs @@ -5,19 +5,19 @@ trait SomeTrait { fn get(&self) -> isize; } -fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'a> { +fn make_object_good1<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'a> { // A outlives 'a AND 'b... - box v as Box<SomeTrait+'a> // ...hence this type is safe. + box v as Box<dyn SomeTrait + 'a> // ...hence this type is safe. } -fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'b> { +fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'b> { // A outlives 'a AND 'b... - box v as Box<SomeTrait+'b> // ...hence this type is safe. + box v as Box<dyn SomeTrait + 'b> // ...hence this type is safe. } -fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'c> { +fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> { // A outlives 'a AND 'b...but not 'c. - box v as Box<SomeTrait+'a> //~ ERROR cannot infer an appropriate lifetime + box v as Box<dyn SomeTrait + 'a> //~ ERROR cannot infer an appropriate lifetime } fn main() { diff --git a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr b/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr index 96e6a329e7d..8b3dbc8b649 100644 --- a/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr +++ b/src/test/ui/regions/regions-close-over-type-parameter-multiple.stderr @@ -1,23 +1,23 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 | -LL | box v as Box<SomeTrait+'a> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box<dyn SomeTrait + 'a> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 18:20... --> $DIR/regions-close-over-type-parameter-multiple.rs:18:20 | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'c> { +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> { | ^^ note: ...so that the declared lifetime parameter bounds are satisfied --> $DIR/regions-close-over-type-parameter-multiple.rs:20:5 | -LL | box v as Box<SomeTrait+'a> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | box v as Box<dyn SomeTrait + 'a> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: but, the lifetime must be valid for the lifetime 'c as defined on the function body at 18:26... --> $DIR/regions-close-over-type-parameter-multiple.rs:18:26 | -LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<SomeTrait+'c> { +LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> { | ^^ = note: ...so that the expression is assignable: expected std::boxed::Box<(dyn SomeTrait + 'c)> diff --git a/src/test/ui/regions/regions-close-param-into-object.rs b/src/test/ui/regions/regions-close-param-into-object.rs index 86590748cb2..2760e5eed95 100644 --- a/src/test/ui/regions/regions-close-param-into-object.rs +++ b/src/test/ui/regions/regions-close-param-into-object.rs @@ -1,24 +1,24 @@ trait X { fn foo(&self) {} } -fn p1<T>(v: T) -> Box<X+'static> +fn p1<T>(v: T) -> Box<dyn X + 'static> where T : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough } -fn p2<T>(v: Box<T>) -> Box<X+'static> +fn p2<T>(v: Box<T>) -> Box<dyn X + 'static> where Box<T> : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough } -fn p3<'a,T>(v: T) -> Box<X+'a> +fn p3<'a,T>(v: T) -> Box<dyn X + 'a> where T : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough } -fn p4<'a,T>(v: Box<T>) -> Box<X+'a> +fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a> where Box<T> : X { Box::new(v) //~ ERROR parameter type `T` may not live long enough diff --git a/src/test/ui/regions/regions-close-param-into-object.stderr b/src/test/ui/regions/regions-close-param-into-object.stderr index ef226073de6..7f2c646c121 100644 --- a/src/test/ui/regions/regions-close-param-into-object.stderr +++ b/src/test/ui/regions/regions-close-param-into-object.stderr @@ -1,7 +1,7 @@ error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:6:5 | -LL | fn p1<T>(v: T) -> Box<X+'static> +LL | fn p1<T>(v: T) -> Box<dyn X + 'static> | - help: consider adding an explicit lifetime bound `T: 'static`... ... LL | Box::new(v) @@ -16,7 +16,7 @@ LL | Box::new(v) error[E0310]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:12:5 | -LL | fn p2<T>(v: Box<T>) -> Box<X+'static> +LL | fn p2<T>(v: Box<T>) -> Box<dyn X + 'static> | - help: consider adding an explicit lifetime bound `T: 'static`... ... LL | Box::new(v) @@ -31,7 +31,7 @@ LL | Box::new(v) error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:18:5 | -LL | fn p3<'a,T>(v: T) -> Box<X+'a> +LL | fn p3<'a,T>(v: T) -> Box<dyn X + 'a> | - help: consider adding an explicit lifetime bound `T: 'a`... ... LL | Box::new(v) @@ -46,7 +46,7 @@ LL | Box::new(v) error[E0309]: the parameter type `T` may not live long enough --> $DIR/regions-close-param-into-object.rs:24:5 | -LL | fn p4<'a,T>(v: Box<T>) -> Box<X+'a> +LL | fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a> | - help: consider adding an explicit lifetime bound `T: 'a`... ... LL | Box::new(v) diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs index 7e04b6782eb..a4272802af5 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.rs @@ -18,7 +18,7 @@ trait Trait2<'a, 'b> { // this argument `t` is not automatically considered well-formed, // since for it to be WF, we would need to know that `'y: 'x`, but we // do not infer that. -fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) +fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) //~^ ERROR reference has a longer lifetime than the data it references { } diff --git a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr index ca86eb7edae..b3390bcc4d5 100644 --- a/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr +++ b/src/test/ui/regions/regions-implied-bounds-projection-gap-hr-1.stderr @@ -1,7 +1,7 @@ error[E0491]: in type `&'x (dyn for<'z> Trait1<<T as Trait2<'y, 'z>>::Foo> + 'x)`, reference has a longer lifetime than the data it references --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:1 | -LL | / fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) +LL | / fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) LL | | LL | | { LL | | } @@ -10,12 +10,12 @@ LL | | } note: the pointer is valid for the lifetime 'x as defined on the function body at 21:11 --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:11 | -LL | fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) +LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) | ^^ note: but the referenced data is only valid for the lifetime 'y as defined on the function body at 21:15 --> $DIR/regions-implied-bounds-projection-gap-hr-1.rs:21:15 | -LL | fn callee<'x, 'y, T>(t: &'x for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) +LL | fn callee<'x, 'y, T>(t: &'x dyn for<'z> Trait1< <T as Trait2<'y, 'z>>::Foo >) | ^^ error: aborting due to previous error diff --git a/src/test/ui/regions/regions-infer-at-fn-not-param.rs b/src/test/ui/regions/regions-infer-at-fn-not-param.rs index 0fd734d57b5..fb9c5d5c210 100644 --- a/src/test/ui/regions/regions-infer-at-fn-not-param.rs +++ b/src/test/ui/regions/regions-infer-at-fn-not-param.rs @@ -1,13 +1,13 @@ struct Parameterized1<'a> { - g: Box<FnMut() + 'a> + g: Box<dyn FnMut() + 'a> } struct NotParameterized1 { - g: Box<FnMut() + 'static> + g: Box<dyn FnMut() + 'static> } struct NotParameterized2 { - g: Box<FnMut() + 'static> + g: Box<dyn FnMut() + 'static> } fn take1<'a>(p: Parameterized1) -> Parameterized1<'a> { p } diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs index 168bf0284a1..5843598ab48 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.rs @@ -1,5 +1,5 @@ struct Invariant<'a> { - f: Box<FnOnce(&mut &'a isize) + 'static>, + f: Box<dyn FnOnce(&mut &'a isize) + 'static>, } fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { diff --git a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs index 90c86cebce3..f0af18cf618 100644 --- a/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.rs @@ -1,5 +1,5 @@ struct Invariant<'a> { - f: Box<FnOnce() -> *mut &'a isize + 'static>, + f: Box<dyn FnOnce() -> *mut &'a isize + 'static>, } fn to_same_lifetime<'r>(b_isize: Invariant<'r>) { diff --git a/src/test/ui/regions/regions-infer-not-param.rs b/src/test/ui/regions/regions-infer-not-param.rs index 214402952a3..d1744f8a51e 100644 --- a/src/test/ui/regions/regions-infer-not-param.rs +++ b/src/test/ui/regions/regions-infer-not-param.rs @@ -4,12 +4,12 @@ struct Direct<'a> { struct Indirect1 { // Here the lifetime parameter of direct is bound by the fn() - g: Box<FnOnce(Direct) + 'static> + g: Box<dyn FnOnce(Direct) + 'static> } struct Indirect2<'a> { // But here it is set to 'a - g: Box<FnOnce(Direct<'a>) + 'static> + g: Box<dyn FnOnce(Direct<'a>) + 'static> } fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } //~ ERROR mismatched types diff --git a/src/test/ui/regions/regions-name-undeclared.rs b/src/test/ui/regions/regions-name-undeclared.rs index 230a97a04b6..044c6889772 100644 --- a/src/test/ui/regions/regions-name-undeclared.rs +++ b/src/test/ui/regions/regions-name-undeclared.rs @@ -33,14 +33,14 @@ fn bar<'a>(x: &'a isize) { // &'a CAN be declared on functions and used then: fn g<'a>(a: &'a isize) { } // OK - fn h(a: Box<for<'a> FnOnce(&'a isize)>) { } // OK + fn h(a: Box<dyn for<'a> FnOnce(&'a isize)>) { } // OK } // Test nesting of lifetimes in fn type declarations fn fn_types(a: &'a isize, //~ ERROR undeclared lifetime - b: Box<for<'a> FnOnce(&'a isize, + b: Box<dyn for<'a> FnOnce(&'a isize, &'b isize, //~ ERROR undeclared lifetime - Box<for<'b> FnOnce(&'a isize, + Box<dyn for<'b> FnOnce(&'a isize, &'b isize)>, &'b isize)>, //~ ERROR undeclared lifetime c: &'a isize) //~ ERROR undeclared lifetime diff --git a/src/test/ui/regions/regions-nested-fns.nll.stderr b/src/test/ui/regions/regions-nested-fns.nll.stderr index c11c09b6d0d..97650636cb6 100644 --- a/src/test/ui/regions/regions-nested-fns.nll.stderr +++ b/src/test/ui/regions/regions-nested-fns.nll.stderr @@ -4,8 +4,8 @@ error[E0521]: borrowed data escapes outside of closure LL | let mut ay = &y; | ------ `ay` is declared here, outside of the closure body LL | -LL | ignore::<Box<for<'z> FnMut(&'z isize)>>(Box::new(|z| { - | - `z` is a reference that is only valid in the closure body +LL | ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| { + | - `z` is a reference that is only valid in the closure body ... LL | ay = z; | ^^^^^^ `z` escapes the closure body here @@ -25,8 +25,8 @@ LL | } error[E0597]: `y` does not live long enough --> $DIR/regions-nested-fns.rs:9:15 | -LL | ignore::<Box<for<'z> FnMut(&'z isize)>>(Box::new(|z| { - | --- value captured here +LL | ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| { + | --- value captured here LL | ay = x; LL | ay = &y; | ^ borrowed value does not live long enough diff --git a/src/test/ui/regions/regions-nested-fns.rs b/src/test/ui/regions/regions-nested-fns.rs index 161d812f016..c02d4e0ce45 100644 --- a/src/test/ui/regions/regions-nested-fns.rs +++ b/src/test/ui/regions/regions-nested-fns.rs @@ -4,13 +4,13 @@ fn nested<'x>(x: &'x isize) { let y = 3; let mut ay = &y; //~ ERROR E0495 - ignore::<Box<for<'z> FnMut(&'z isize)>>(Box::new(|z| { + ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| { ay = x; ay = &y; ay = z; })); - ignore::< Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { if false { return x; } //~ ERROR E0312 if false { return ay; } return z; diff --git a/src/test/ui/regions/regions-nested-fns.stderr b/src/test/ui/regions/regions-nested-fns.stderr index 702254a0ac4..15c9c9ca4dd 100644 --- a/src/test/ui/regions/regions-nested-fns.stderr +++ b/src/test/ui/regions/regions-nested-fns.stderr @@ -4,11 +4,11 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requiremen LL | let mut ay = &y; | ^^ | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:54... - --> $DIR/regions-nested-fns.rs:7:54 +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 7:58... + --> $DIR/regions-nested-fns.rs:7:58 | -LL | ignore::<Box<for<'z> FnMut(&'z isize)>>(Box::new(|z| { - | ______________________________________________________^ +LL | ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| { + | __________________________________________________________^ LL | | ay = x; LL | | ay = &y; LL | | ay = z; @@ -19,11 +19,11 @@ note: ...so that reference does not outlive borrowed content | LL | ay = z; | ^ -note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the body at 13:68... - --> $DIR/regions-nested-fns.rs:13:68 +note: but, the lifetime must be valid for the anonymous lifetime #2 defined on the body at 13:72... + --> $DIR/regions-nested-fns.rs:13:72 | -LL | ignore::< Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ____________________________________________________________________^ +LL | ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ________________________________________________________________________^ LL | | if false { return x; } LL | | if false { return ay; } LL | | return z; @@ -39,11 +39,11 @@ error[E0312]: lifetime of reference outlives lifetime of borrowed content... LL | if false { return x; } | ^ | -note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 13:68... - --> $DIR/regions-nested-fns.rs:13:68 +note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 13:72... + --> $DIR/regions-nested-fns.rs:13:72 | -LL | ignore::< Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ____________________________________________________________________^ +LL | ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { + | ________________________________________________________________________^ LL | | if false { return x; } LL | | if false { return ay; } LL | | return z; diff --git a/src/test/ui/regions/regions-proc-bound-capture.rs b/src/test/ui/regions/regions-proc-bound-capture.rs index f2010dbe62d..0c903b73849 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.rs +++ b/src/test/ui/regions/regions-proc-bound-capture.rs @@ -1,10 +1,10 @@ -fn borrowed_proc<'a>(x: &'a isize) -> Box<FnMut()->(isize) + 'a> { +fn borrowed_proc<'a>(x: &'a isize) -> Box<dyn FnMut()->(isize) + 'a> { // This is legal, because the region bound on `proc` // states that it captures `x`. Box::new(move|| { *x }) } -fn static_proc(x: &isize) -> Box<FnMut()->(isize) + 'static> { +fn static_proc(x: &isize) -> Box<dyn FnMut()->(isize) + 'static> { // This is illegal, because the region bound on `proc` is 'static. Box::new(move|| { *x }) //~ ERROR explicit lifetime required in the type of `x` [E0621] } diff --git a/src/test/ui/regions/regions-proc-bound-capture.stderr b/src/test/ui/regions/regions-proc-bound-capture.stderr index aea7347d53c..c53af34456e 100644 --- a/src/test/ui/regions/regions-proc-bound-capture.stderr +++ b/src/test/ui/regions/regions-proc-bound-capture.stderr @@ -1,7 +1,7 @@ error[E0621]: explicit lifetime required in the type of `x` --> $DIR/regions-proc-bound-capture.rs:9:5 | -LL | fn static_proc(x: &isize) -> Box<FnMut()->(isize) + 'static> { +LL | fn static_proc(x: &isize) -> Box<dyn FnMut()->(isize) + 'static> { | ------ help: add explicit lifetime `'static` to the type of `x`: `&'static isize` LL | // This is illegal, because the region bound on `proc` is 'static. LL | Box::new(move|| { *x }) diff --git a/src/test/ui/regions/regions-steal-closure.rs b/src/test/ui/regions/regions-steal-closure.rs index e6b34510bb5..83e93522c94 100644 --- a/src/test/ui/regions/regions-steal-closure.rs +++ b/src/test/ui/regions/regions-steal-closure.rs @@ -1,10 +1,10 @@ #![feature(fn_traits)] struct ClosureBox<'a> { - cl: Box<FnMut() + 'a>, + cl: Box<dyn FnMut() + 'a>, } -fn box_it<'r>(x: Box<FnMut() + 'r>) -> ClosureBox<'r> { +fn box_it<'r>(x: Box<dyn FnMut() + 'r>) -> ClosureBox<'r> { ClosureBox {cl: x} } diff --git a/src/test/ui/regions/regions-trait-1.rs b/src/test/ui/regions/regions-trait-1.rs index 72738871936..0da8ac53695 100644 --- a/src/test/ui/regions/regions-trait-1.rs +++ b/src/test/ui/regions/regions-trait-1.rs @@ -19,12 +19,12 @@ impl<'a> GetCtxt for HasCtxt<'a> { } -fn get_v(gc: Box<GetCtxt>) -> usize { +fn get_v(gc: Box<dyn GetCtxt>) -> usize { gc.get_ctxt().v } fn main() { let ctxt = Ctxt { v: 22 }; let hc = HasCtxt { c: &ctxt }; - assert_eq!(get_v(box hc as Box<GetCtxt>), 22); + assert_eq!(get_v(box hc as Box<dyn GetCtxt>), 22); } diff --git a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr index eccf1b5e8cf..f4b1a89db9a 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/regions-trait-object-subtyping.rs:15:5 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here @@ -12,7 +12,7 @@ LL | x error: lifetime may not live long enough --> $DIR/regions-trait-object-subtyping.rs:22:5 | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here diff --git a/src/test/ui/regions/regions-trait-object-subtyping.rs b/src/test/ui/regions/regions-trait-object-subtyping.rs index eb262354456..5b36194870e 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.rs +++ b/src/test/ui/regions/regions-trait-object-subtyping.rs @@ -1,23 +1,23 @@ trait Dummy { fn dummy(&self); } -fn foo1<'a:'b,'b>(x: &'a mut (Dummy+'a)) -> &'b mut (Dummy+'b) { +fn foo1<'a:'b,'b>(x: &'a mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { // Here, we are able to coerce x } -fn foo2<'a:'b,'b>(x: &'b mut (Dummy+'a)) -> &'b mut (Dummy+'b) { +fn foo2<'a:'b,'b>(x: &'b mut (dyn Dummy+'a)) -> &'b mut (dyn Dummy+'b) { // Here, we are able to coerce x } -fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { // Without knowing 'a:'b, we can't coerce x //~ ERROR lifetime bound not satisfied //~^ ERROR cannot infer an appropriate lifetime } struct Wrapper<T>(T); -fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { // We can't coerce because it is packed in `Wrapper` x //~ ERROR mismatched types } diff --git a/src/test/ui/regions/regions-trait-object-subtyping.stderr b/src/test/ui/regions/regions-trait-object-subtyping.stderr index f2d2b37d907..6de92f13840 100644 --- a/src/test/ui/regions/regions-trait-object-subtyping.stderr +++ b/src/test/ui/regions/regions-trait-object-subtyping.stderr @@ -7,12 +7,12 @@ LL | x note: lifetime parameter instantiated with the lifetime 'a as defined on the function body at 13:9 --> $DIR/regions-trait-object-subtyping.rs:13:9 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ note: but lifetime parameter must outlive the lifetime 'b as defined on the function body at 13:12 --> $DIR/regions-trait-object-subtyping.rs:13:12 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ error[E0495]: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements @@ -24,7 +24,7 @@ LL | x note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 13:9... --> $DIR/regions-trait-object-subtyping.rs:13:9 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ note: ...so that reference does not outlive borrowed content --> $DIR/regions-trait-object-subtyping.rs:15:5 @@ -34,7 +34,7 @@ LL | x note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 13:12... --> $DIR/regions-trait-object-subtyping.rs:13:12 | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { +LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy { | ^^ = note: ...so that the expression is assignable: expected &'b mut (dyn Dummy + 'b) @@ -51,12 +51,12 @@ LL | x note: the lifetime 'b as defined on the function body at 20:15... --> $DIR/regions-trait-object-subtyping.rs:20:15 | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | ^^ note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 20:9 --> $DIR/regions-trait-object-subtyping.rs:20:9 | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { +LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> { | ^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/regions/regions-trait-variance.rs b/src/test/ui/regions/regions-trait-variance.rs index 73baa84ec90..9169d457d40 100644 --- a/src/test/ui/regions/regions-trait-variance.rs +++ b/src/test/ui/regions/regions-trait-variance.rs @@ -23,10 +23,10 @@ impl Drop for B { } struct A<'r> { - p: &'r (X+'r) + p: &'r (dyn X + 'r) } -fn make_a(p:&X) -> A { +fn make_a(p: &dyn X) -> A { A{p:p} } diff --git a/src/test/ui/regions/regions-wf-trait-object.rs b/src/test/ui/regions/regions-wf-trait-object.rs index 61bab359f9a..d0053b20234 100644 --- a/src/test/ui/regions/regions-wf-trait-object.rs +++ b/src/test/ui/regions/regions-wf-trait-object.rs @@ -4,7 +4,7 @@ trait TheTrait<'t>: 't { } struct Foo<'a,'b> { - x: Box<TheTrait<'a>+'b> //~ ERROR E0478 + x: Box<dyn TheTrait<'a>+'b> //~ ERROR E0478 } fn main() { } diff --git a/src/test/ui/regions/regions-wf-trait-object.stderr b/src/test/ui/regions/regions-wf-trait-object.stderr index 3dc1c4dcd22..4e12478c36d 100644 --- a/src/test/ui/regions/regions-wf-trait-object.stderr +++ b/src/test/ui/regions/regions-wf-trait-object.stderr @@ -1,8 +1,8 @@ error[E0478]: lifetime bound not satisfied --> $DIR/regions-wf-trait-object.rs:7:5 | -LL | x: Box<TheTrait<'a>+'b> - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | x: Box<dyn TheTrait<'a>+'b> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: lifetime parameter instantiated with the lifetime 'b as defined on the struct at 6:15 --> $DIR/regions-wf-trait-object.rs:6:15 diff --git a/src/test/ui/resolve/issue-23305.rs b/src/test/ui/resolve/issue-23305.rs index af335acd41b..95635e12a63 100644 --- a/src/test/ui/resolve/issue-23305.rs +++ b/src/test/ui/resolve/issue-23305.rs @@ -2,7 +2,7 @@ pub trait ToNbt<T> { fn new(val: T) -> Self; } -impl ToNbt<Self> {} +impl dyn ToNbt<Self> {} //~^ ERROR cycle detected fn main() {} diff --git a/src/test/ui/resolve/issue-23305.stderr b/src/test/ui/resolve/issue-23305.stderr index 1da56ad05d2..0ed3af81d56 100644 --- a/src/test/ui/resolve/issue-23305.stderr +++ b/src/test/ui/resolve/issue-23305.stderr @@ -1,10 +1,10 @@ -error[E0391]: cycle detected when processing `<impl at $DIR/issue-23305.rs:5:1: 5:20>` - --> $DIR/issue-23305.rs:5:12 +error[E0391]: cycle detected when processing `<impl at $DIR/issue-23305.rs:5:1: 5:24>` + --> $DIR/issue-23305.rs:5:16 | -LL | impl ToNbt<Self> {} - | ^^^^ +LL | impl dyn ToNbt<Self> {} + | ^^^^ | - = note: ...which again requires processing `<impl at $DIR/issue-23305.rs:5:1: 5:20>`, completing the cycle + = note: ...which again requires processing `<impl at $DIR/issue-23305.rs:5:1: 5:24>`, completing the cycle note: cycle used when collecting item types in top-level module --> $DIR/issue-23305.rs:1:1 | diff --git a/src/test/ui/resolve/issue-33876.rs b/src/test/ui/resolve/issue-33876.rs index dd31fc231cf..e233ec631cc 100644 --- a/src/test/ui/resolve/issue-33876.rs +++ b/src/test/ui/resolve/issue-33876.rs @@ -7,6 +7,6 @@ trait Bar {} impl Bar for Foo {} fn main() { - let any: &Any = &Bar; //~ ERROR expected value, found trait `Bar` + let any: &dyn Any = &Bar; //~ ERROR expected value, found trait `Bar` if any.is::<u32>() { println!("u32"); } } diff --git a/src/test/ui/resolve/issue-33876.stderr b/src/test/ui/resolve/issue-33876.stderr index 29a63fdd11f..52308f2a7f0 100644 --- a/src/test/ui/resolve/issue-33876.stderr +++ b/src/test/ui/resolve/issue-33876.stderr @@ -1,8 +1,8 @@ error[E0423]: expected value, found trait `Bar` - --> $DIR/issue-33876.rs:10:22 + --> $DIR/issue-33876.rs:10:26 | -LL | let any: &Any = &Bar; - | ^^^ not a value +LL | let any: &dyn Any = &Bar; + | ^^^ not a value error: aborting due to previous error diff --git a/src/test/ui/resolve/issue-3907-2.rs b/src/test/ui/resolve/issue-3907-2.rs index dc9624698df..46f145e63e1 100644 --- a/src/test/ui/resolve/issue-3907-2.rs +++ b/src/test/ui/resolve/issue-3907-2.rs @@ -2,7 +2,7 @@ extern crate issue_3907; -type Foo = issue_3907::Foo+'static; +type Foo = dyn issue_3907::Foo + 'static; struct S { name: isize diff --git a/src/test/ui/resolve/issue-3907.rs b/src/test/ui/resolve/issue-3907.rs index 87e465489a4..6211de42717 100644 --- a/src/test/ui/resolve/issue-3907.rs +++ b/src/test/ui/resolve/issue-3907.rs @@ -2,7 +2,7 @@ extern crate issue_3907; -type Foo = issue_3907::Foo; +type Foo = dyn issue_3907::Foo; struct S { name: isize diff --git a/src/test/ui/resolve/issue-5035-2.rs b/src/test/ui/resolve/issue-5035-2.rs index f88a2375a43..b831bb4be34 100644 --- a/src/test/ui/resolve/issue-5035-2.rs +++ b/src/test/ui/resolve/issue-5035-2.rs @@ -1,5 +1,5 @@ trait I {} -type K = I+'static; +type K = dyn I + 'static; fn foo(_x: K) {} //~^ ERROR the size for values of type diff --git a/src/test/ui/resolve/issue-5035.rs b/src/test/ui/resolve/issue-5035.rs index c00567a75b7..49fa312f9d2 100644 --- a/src/test/ui/resolve/issue-5035.rs +++ b/src/test/ui/resolve/issue-5035.rs @@ -1,5 +1,5 @@ trait I {} -type K = I; +type K = dyn I; impl K for isize {} //~ ERROR expected trait, found type alias `K` use ImportError; //~ ERROR unresolved import `ImportError` [E0432] diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs index d2550a99e81..8f2d29d6f17 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs @@ -2,7 +2,7 @@ #[rustc_outlives] struct Foo<'a, 'b, T> { //~ ERROR rustc_outlives - field1: Bar<'a, 'b, T> + field1: dyn Bar<'a, 'b, T> } trait Bar<'x, 's, U> diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr index 9ae05dab74d..b32c9743e9e 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr @@ -2,7 +2,7 @@ error: rustc_outlives --> $DIR/self-structs.rs:4:1 | LL | / struct Foo<'a, 'b, T> { -LL | | field1: Bar<'a, 'b, T> +LL | | field1: dyn Bar<'a, 'b, T> LL | | } | |_^ | diff --git a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs index b0d1fa1a74f..01daf307c00 100644 --- a/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs +++ b/src/test/ui/rfc1598-generic-associated-types/generic-associated-types-where.rs @@ -9,7 +9,7 @@ trait Foo { type Assoc where Self: Sized; type Assoc2<T> where T: Display; type Assoc3<T>; - type WithDefault<T> where T: Debug = Iterator<Item=T>; + type WithDefault<T> where T: Debug = dyn Iterator<Item=T>; type NoGenerics; } @@ -19,7 +19,7 @@ impl Foo for Bar { type Assoc = usize; type Assoc2<T> = Vec<T>; type Assoc3<T> where T: Iterator = Vec<T>; - type WithDefault<'a, T> = &'a Iterator<T>; + type WithDefault<'a, T> = &'a dyn Iterator<T>; type NoGenerics = ::std::cell::Cell<i32>; } diff --git a/src/test/ui/rfc1623.rs b/src/test/ui/rfc1623.rs index 5920446dbc2..ebb4d56af9e 100644 --- a/src/test/ui/rfc1623.rs +++ b/src/test/ui/rfc1623.rs @@ -13,7 +13,7 @@ static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = struct SomeStruct<'x, 'y, 'z: 'x> { foo: &'x Foo<'z>, bar: &'x Bar<'z>, - f: &'y for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>, + f: &'y dyn for<'a, 'b> Fn(&'a Foo<'b>) -> &'a Bar<'b>, } fn id<T>(t: T) -> T { diff --git a/src/test/ui/save-analysis/issue-59134-0.rs b/src/test/ui/save-analysis/issue-59134-0.rs index 3158328b3ff..a0871ca1809 100644 --- a/src/test/ui/save-analysis/issue-59134-0.rs +++ b/src/test/ui/save-analysis/issue-59134-0.rs @@ -4,7 +4,7 @@ pub fn f() { trait Trait {} - impl Trait { + impl dyn Trait { const FLAG: u32 = bogus.field; //~ ERROR cannot find value `bogus` } } diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.rs b/src/test/ui/self/arbitrary-self-types-not-object-safe.rs index 2c1fd937a65..7443d888c9e 100644 --- a/src/test/ui/self/arbitrary-self-types-not-object-safe.rs +++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.rs @@ -28,13 +28,13 @@ impl Bar for usize { } fn make_foo() { - let x = Rc::new(5usize) as Rc<Foo>; + let x = Rc::new(5usize) as Rc<dyn Foo>; //~^ ERROR E0038 //~| ERROR E0038 } fn make_bar() { - let x = Rc::new(5usize) as Rc<Bar>; + let x = Rc::new(5usize) as Rc<dyn Bar>; x.bar(); } diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr index dacab1222ab..e45bc2657f1 100644 --- a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr +++ b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr @@ -1,15 +1,15 @@ error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/arbitrary-self-types-not-object-safe.rs:31:32 | -LL | let x = Rc::new(5usize) as Rc<Foo>; - | ^^^^^^^ the trait `Foo` cannot be made into an object +LL | let x = Rc::new(5usize) as Rc<dyn Foo>; + | ^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: method `foo`'s receiver cannot be dispatched on error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/arbitrary-self-types-not-object-safe.rs:31:13 | -LL | let x = Rc::new(5usize) as Rc<Foo>; +LL | let x = Rc::new(5usize) as Rc<dyn Foo>; | ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object | = note: method `foo`'s receiver cannot be dispatched on diff --git a/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs b/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs index acbe896eebe..0a9370e6f5a 100644 --- a/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs +++ b/src/test/ui/self/arbitrary_self_types_raw_pointer_trait.rs @@ -34,8 +34,8 @@ impl Foo for u32 { } fn main() { - let null_i32 = ptr::null::<i32>() as *const Foo; - let null_u32 = ptr::null::<u32>() as *const Foo; + let null_i32 = ptr::null::<i32>() as *const dyn Foo; + let null_u32 = ptr::null::<u32>() as *const dyn Foo; assert_eq!("I'm an i32!", null_i32.foo()); assert_eq!("I'm a u32!", null_u32.foo()); @@ -45,7 +45,7 @@ fn main() { assert_eq!("I'm an i32!", valid_i32_thin.foo()); assert_eq!(5, unsafe { valid_i32_thin.bar() }); assert_eq!(5, unsafe { (&valid_i32_thin as *const *const i32).complicated() }); - let valid_i32_fat = valid_i32_thin as *const Foo; + let valid_i32_fat = valid_i32_thin as *const dyn Foo; assert_eq!("I'm an i32!", valid_i32_fat.foo()); assert_eq!(5, unsafe { valid_i32_fat.bar() }); @@ -54,7 +54,7 @@ fn main() { assert_eq!("I'm a u32!", valid_u32_thin.foo()); assert_eq!(18, unsafe { valid_u32_thin.bar() }); assert_eq!(18, unsafe { (&valid_u32_thin as *const *const u32).complicated() }); - let valid_u32_fat = valid_u32_thin as *const Foo; + let valid_u32_fat = valid_u32_thin as *const dyn Foo; assert_eq!("I'm a u32!", valid_u32_fat.foo()); assert_eq!(18, unsafe { valid_u32_fat.bar() }); diff --git a/src/test/ui/self/explicit-self-objects-uniq.rs b/src/test/ui/self/explicit-self-objects-uniq.rs index f95686cf112..0050bc7124d 100644 --- a/src/test/ui/self/explicit-self-objects-uniq.rs +++ b/src/test/ui/self/explicit-self-objects-uniq.rs @@ -17,6 +17,6 @@ impl Foo for S { pub fn main() { let x = box S { x: 3 }; - let y = x as Box<Foo>; + let y = x as Box<dyn Foo>; y.f(); } diff --git a/src/test/ui/self/object-safety-sized-self-by-value-self.rs b/src/test/ui/self/object-safety-sized-self-by-value-self.rs index ae0512666ce..43b1d8b9149 100644 --- a/src/test/ui/self/object-safety-sized-self-by-value-self.rs +++ b/src/test/ui/self/object-safety-sized-self-by-value-self.rs @@ -23,7 +23,7 @@ fn tick1<C:Counter>(mut c: C) -> u32 { c.get() } -fn tick2(c: &mut Counter) { +fn tick2(c: &mut dyn Counter) { tick3(c); } diff --git a/src/test/ui/self/object-safety-sized-self-generic-method.rs b/src/test/ui/self/object-safety-sized-self-generic-method.rs index 0b3f6633737..e0b0526a333 100644 --- a/src/test/ui/self/object-safety-sized-self-generic-method.rs +++ b/src/test/ui/self/object-safety-sized-self-generic-method.rs @@ -23,7 +23,7 @@ fn tick1<C:Counter>(c: &mut C) { c.with(|i| ()); } -fn tick2(c: &mut Counter) { +fn tick2(c: &mut dyn Counter) { tick3(c); } diff --git a/src/test/ui/self/object-safety-sized-self-return-Self.rs b/src/test/ui/self/object-safety-sized-self-return-Self.rs index e88dba0a4e8..222c7543945 100644 --- a/src/test/ui/self/object-safety-sized-self-return-Self.rs +++ b/src/test/ui/self/object-safety-sized-self-return-Self.rs @@ -23,7 +23,7 @@ fn preticked<C:Counter>() -> C { c } -fn tick(c: &mut Counter) { +fn tick(c: &mut dyn Counter) { tick_generic(c); } diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs index db48bdf4c01..6099263ccd0 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.rs @@ -2,10 +2,10 @@ // Ensure that invoking a closure counts as a unique immutable borrow -type Fn<'a> = Box<FnMut() + 'a>; +type Fn<'a> = Box<dyn FnMut() + 'a>; struct Test<'a> { - f: Box<FnMut() + 'a> + f: Box<dyn FnMut() + 'a> } fn call<F>(mut f: F) where F: FnMut(Fn) { @@ -47,9 +47,9 @@ fn test6() { } fn test7() { - fn foo<F>(_: F) where F: FnMut(Box<FnMut(isize)>, isize) {} + fn foo<F>(_: F) where F: FnMut(Box<dyn FnMut(isize)>, isize) {} let s = String::new(); // Capture to make f !Copy - let mut f = move |g: Box<FnMut(isize)>, b: isize| { + let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| { let _ = s.len(); }; f(Box::new(|a| { diff --git a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr index 847f6865624..72f979e8d3c 100644 --- a/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr +++ b/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr @@ -29,7 +29,7 @@ LL | f.f.call_mut(()) error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13 | -LL | let mut f = move |g: Box<FnMut(isize)>, b: isize| { +LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| { | ----- captured outer variable ... LL | foo(f); diff --git a/src/test/ui/span/borrowck-object-mutability.rs b/src/test/ui/span/borrowck-object-mutability.rs index e672c464535..f5adc2cc141 100644 --- a/src/test/ui/span/borrowck-object-mutability.rs +++ b/src/test/ui/span/borrowck-object-mutability.rs @@ -3,22 +3,22 @@ trait Foo { fn borrowed_mut(&mut self); } -fn borrowed_receiver(x: &Foo) { +fn borrowed_receiver(x: &dyn Foo) { x.borrowed(); x.borrowed_mut(); //~ ERROR cannot borrow } -fn borrowed_mut_receiver(x: &mut Foo) { +fn borrowed_mut_receiver(x: &mut dyn Foo) { x.borrowed(); x.borrowed_mut(); } -fn owned_receiver(x: Box<Foo>) { +fn owned_receiver(x: Box<dyn Foo>) { x.borrowed(); x.borrowed_mut(); //~ ERROR cannot borrow } -fn mut_owned_receiver(mut x: Box<Foo>) { +fn mut_owned_receiver(mut x: Box<dyn Foo>) { x.borrowed(); x.borrowed_mut(); } diff --git a/src/test/ui/span/borrowck-object-mutability.stderr b/src/test/ui/span/borrowck-object-mutability.stderr index fe6014cd5ad..fe6d05c588f 100644 --- a/src/test/ui/span/borrowck-object-mutability.stderr +++ b/src/test/ui/span/borrowck-object-mutability.stderr @@ -1,8 +1,8 @@ error[E0596]: cannot borrow `*x` as mutable, as it is behind a `&` reference --> $DIR/borrowck-object-mutability.rs:8:5 | -LL | fn borrowed_receiver(x: &Foo) { - | ---- help: consider changing this to be a mutable reference: `&mut dyn Foo` +LL | fn borrowed_receiver(x: &dyn Foo) { + | -------- help: consider changing this to be a mutable reference: `&mut dyn Foo` LL | x.borrowed(); LL | x.borrowed_mut(); | ^ `x` is a `&` reference, so the data it refers to cannot be borrowed as mutable @@ -10,7 +10,7 @@ LL | x.borrowed_mut(); error[E0596]: cannot borrow `*x` as mutable, as `x` is not declared as mutable --> $DIR/borrowck-object-mutability.rs:18:5 | -LL | fn owned_receiver(x: Box<Foo>) { +LL | fn owned_receiver(x: Box<dyn Foo>) { | - help: consider changing this to be mutable: `mut x` LL | x.borrowed(); LL | x.borrowed_mut(); diff --git a/src/test/ui/span/dropck-object-cycle.rs b/src/test/ui/span/dropck-object-cycle.rs index 8dc70ea252b..a26123d5246 100644 --- a/src/test/ui/span/dropck-object-cycle.rs +++ b/src/test/ui/span/dropck-object-cycle.rs @@ -8,7 +8,7 @@ trait Trait<'a> { fn short<'b>(&'b self) -> isize; } -fn object_invoke1<'d>(x: &'d Trait<'d>) -> (isize, isize) { loop { } } +fn object_invoke1<'d>(x: &'d dyn Trait<'d>) -> (isize, isize) { loop { } } trait MakerTrait { fn mk() -> Self; @@ -18,12 +18,12 @@ fn make_val<T:MakerTrait>() -> T { MakerTrait::mk() } -impl<'t> MakerTrait for Box<Trait<'t>+'static> { - fn mk() -> Box<Trait<'t>+'static> { loop { } } +impl<'t> MakerTrait for Box<dyn Trait<'t>+'static> { + fn mk() -> Box<dyn Trait<'t>+'static> { loop { } } } pub fn main() { - let m : Box<Trait+'static> = make_val(); + let m : Box<dyn Trait+'static> = make_val(); assert_eq!(object_invoke1(&*m), (4,5)); //~^ ERROR `*m` does not live long enough diff --git a/src/test/ui/span/issue-25199.rs b/src/test/ui/span/issue-25199.rs index ed690443d4d..dbc3b190068 100644 --- a/src/test/ui/span/issue-25199.rs +++ b/src/test/ui/span/issue-25199.rs @@ -34,7 +34,7 @@ impl Drop for VecHolder { struct Container<'a> { v: VecHolder, - d: RefCell<Vec<Box<Obj+'a>>>, + d: RefCell<Vec<Box<dyn Obj+'a>>>, } impl<'a> Container<'a> { diff --git a/src/test/ui/span/issue-26656.rs b/src/test/ui/span/issue-26656.rs index c5a70c87ed8..cde68da1897 100644 --- a/src/test/ui/span/issue-26656.rs +++ b/src/test/ui/span/issue-26656.rs @@ -10,7 +10,7 @@ impl<B: Button> Trigger<B> for () { // Still unsound Zook trait Button { fn push(&self); } -struct Zook<B> { button: B, trigger: Box<Trigger<B>+'static> } +struct Zook<B> { button: B, trigger: Box<dyn Trigger<B>+'static> } impl<B> Drop for Zook<B> { fn drop(&mut self) { diff --git a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs index 13e651fa56b..e34f84683bb 100644 --- a/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs +++ b/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.rs @@ -11,6 +11,6 @@ fn main() { { let ss: &isize = &id(1); //~^ ERROR temporary value dropped while borrowed - blah = box ss as Box<Foo>; + blah = box ss as Box<dyn Foo>; } } diff --git a/src/test/ui/span/regions-close-over-type-parameter-2.rs b/src/test/ui/span/regions-close-over-type-parameter-2.rs index 11187b74c42..29083154b89 100644 --- a/src/test/ui/span/regions-close-over-type-parameter-2.rs +++ b/src/test/ui/span/regions-close-over-type-parameter-2.rs @@ -10,8 +10,8 @@ impl<A> Foo for A { fn get(&self) { } } -fn repeater3<'a,A:'a>(v: A) -> Box<Foo+'a> { - box v as Box<Foo+'a> +fn repeater3<'a,A:'a>(v: A) -> Box<dyn Foo + 'a> { + box v as Box<dyn Foo+'a> } fn main() { diff --git a/src/test/ui/span/send-is-not-static-ensures-scoping.rs b/src/test/ui/span/send-is-not-static-ensures-scoping.rs index ac07420ee36..2aecc2a7e0d 100644 --- a/src/test/ui/span/send-is-not-static-ensures-scoping.rs +++ b/src/test/ui/span/send-is-not-static-ensures-scoping.rs @@ -1,5 +1,5 @@ struct Guard<'a> { - f: Box<Fn() + Send + 'a>, + f: Box<dyn Fn() + Send + 'a>, } fn scoped<'a, F: Fn() + Send + 'a>(f: F) -> Guard<'a> { diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs index a3cc53e69e2..78487bd7bb5 100644 --- a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs @@ -4,7 +4,7 @@ pub trait T<X, Y> { type C; } pub struct Foo { - i: Box<T<usize, usize, usize, usize, B=usize>>, + i: Box<dyn T<usize, usize, usize, usize, B=usize>>, //~^ ERROR must be specified //~| ERROR wrong number of type arguments } diff --git a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr index 5e333187e3d..d273ec3fca5 100644 --- a/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr +++ b/src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr @@ -1,10 +1,10 @@ error[E0107]: wrong number of type arguments: expected 2, found 4 - --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:28 + --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:32 | -LL | i: Box<T<usize, usize, usize, usize, B=usize>>, - | ^^^^^ ^^^^^ unexpected type argument - | | - | unexpected type argument +LL | i: Box<dyn T<usize, usize, usize, usize, B=usize>>, + | ^^^^^ ^^^^^ unexpected type argument + | | + | unexpected type argument error[E0191]: the value of the associated types `A` (from the trait `T`), `C` (from the trait `T`) must be specified --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:12 @@ -15,15 +15,15 @@ LL | type B; LL | type C; | ------- `C` defined here ... -LL | i: Box<T<usize, usize, usize, usize, B=usize>>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | i: Box<dyn T<usize, usize, usize, usize, B=usize>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | associated type `A` must be specified | associated type `C` must be specified help: if you meant to specify the associated types, write | -LL | i: Box<T<usize, usize, A = usize, C = usize, B=usize>>, - | ^^^^^^^^^ ^^^^^^^^^ +LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>, + | ^^^^^^^^^ ^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/trait-alias/trait-alias-bounds.rs b/src/test/ui/traits/trait-alias/trait-alias-bounds.rs index 428ce5102ba..b97eb38c5af 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-bounds.rs +++ b/src/test/ui/traits/trait-alias/trait-alias-bounds.rs @@ -17,7 +17,7 @@ struct Foo<T: SendSyncAlias>(PhantomData<T>); #[allow(dead_code)] struct Bar<T>(PhantomData<T>) where T: SendSyncAlias; -impl EmptyAlias {} +impl dyn EmptyAlias {} impl<T: SendSyncAlias> Empty for T {} diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs index afd8400e230..88feb89170d 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs +++ b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.rs @@ -114,13 +114,13 @@ type _T44 = dyn _4 + Send + Sync + _8; trait ObjL<'l> {} trait _9 = for<'a> ObjL<'a>; trait _10 = for<'b> ObjL<'b>; -type _T50 = _9 + _10; +type _T50 = dyn _9 + _10; //~^ ERROR only auto traits can be used as additional traits in a trait object [E0225] trait ObjT<T> {} trait _11 = ObjT<for<'a> fn(&'a u8)>; trait _12 = ObjT<for<'b> fn(&'b u8)>; -type _T60 = _11 + _12; +type _T60 = dyn _11 + _12; //~^ ERROR only auto traits can be used as additional traits in a trait object [E0225] fn main() {} diff --git a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr index eb667c9522c..6df1df86508 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-no-duplicates.stderr @@ -430,28 +430,28 @@ LL | type _T44 = dyn _4 + Send + Sync + _8; | trait alias used in trait object type (first use) error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/trait-alias-no-duplicates.rs:117:18 + --> $DIR/trait-alias-no-duplicates.rs:117:22 | LL | trait _9 = for<'a> ObjL<'a>; | ---------------- first non-auto trait LL | trait _10 = for<'b> ObjL<'b>; | ---------------- additional non-auto trait -LL | type _T50 = _9 + _10; - | -- ^^^ trait alias used in trait object type (additional use) - | | - | trait alias used in trait object type (first use) +LL | type _T50 = dyn _9 + _10; + | -- ^^^ trait alias used in trait object type (additional use) + | | + | trait alias used in trait object type (first use) error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/trait-alias-no-duplicates.rs:123:19 + --> $DIR/trait-alias-no-duplicates.rs:123:23 | LL | trait _11 = ObjT<for<'a> fn(&'a u8)>; | ------------------------ first non-auto trait LL | trait _12 = ObjT<for<'b> fn(&'b u8)>; | ------------------------ additional non-auto trait -LL | type _T60 = _11 + _12; - | --- ^^^ trait alias used in trait object type (additional use) - | | - | trait alias used in trait object type (first use) +LL | type _T60 = dyn _11 + _12; + | --- ^^^ trait alias used in trait object type (additional use) + | | + | trait alias used in trait object type (first use) error: aborting due to 27 previous errors diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs b/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs index fd3af6f3a9a..33c9f2f00cf 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.rs @@ -6,6 +6,7 @@ trait Foo { fn foo(_x: Foo + Send) { //~^ ERROR the size for values of type + //~| WARN trait objects without an explicit `dyn` are deprecated } fn main() { } diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr index 5aee1e7e982..250ea4b1c32 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr @@ -1,3 +1,11 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/trait-bounds-not-on-bare-trait.rs:7:12 + | +LL | fn foo(_x: Foo + Send) { + | ^^^^^^^^^^ help: use `dyn`: `dyn Foo + Send` + | + = note: #[warn(bare_trait_objects)] on by default + error[E0277]: the size for values of type `(dyn Foo + std::marker::Send + 'static)` cannot be known at compilation time --> $DIR/trait-bounds-not-on-bare-trait.rs:7:8 | diff --git a/src/test/ui/traits/trait-bounds-sugar.rs b/src/test/ui/traits/trait-bounds-sugar.rs index 0892153c0cf..65b6f6faa42 100644 --- a/src/test/ui/traits/trait-bounds-sugar.rs +++ b/src/test/ui/traits/trait-bounds-sugar.rs @@ -2,17 +2,17 @@ trait Foo {} -fn a(_x: Box<Foo+Send>) { +fn a(_x: Box<dyn Foo + Send>) { } -fn b(_x: &'static (Foo+'static)) { +fn b(_x: &'static (dyn Foo + 'static)) { } -fn c(x: Box<Foo+Sync>) { +fn c(x: Box<dyn Foo + Sync>) { a(x); //~ ERROR mismatched types } -fn d(x: &'static (Foo+Sync)) { +fn d(x: &'static (dyn Foo + Sync)) { b(x); } diff --git a/src/test/ui/traits/trait-coercion-generic-bad.rs b/src/test/ui/traits/trait-coercion-generic-bad.rs index 5aa21834148..2e115c732b9 100644 --- a/src/test/ui/traits/trait-coercion-generic-bad.rs +++ b/src/test/ui/traits/trait-coercion-generic-bad.rs @@ -13,7 +13,7 @@ impl Trait<&'static str> for Struct { } fn main() { - let s: Box<Trait<isize>> = Box::new(Struct { person: "Fred" }); + let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" }); //~^ ERROR `Struct: Trait<isize>` is not satisfied s.f(1); } diff --git a/src/test/ui/traits/trait-coercion-generic-bad.stderr b/src/test/ui/traits/trait-coercion-generic-bad.stderr index 7f3b46b8ae5..f2710dea095 100644 --- a/src/test/ui/traits/trait-coercion-generic-bad.stderr +++ b/src/test/ui/traits/trait-coercion-generic-bad.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `Struct: Trait<isize>` is not satisfied - --> $DIR/trait-coercion-generic-bad.rs:16:32 + --> $DIR/trait-coercion-generic-bad.rs:16:36 | -LL | let s: Box<Trait<isize>> = Box::new(Struct { person: "Fred" }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<isize>` is not implemented for `Struct` +LL | let s: Box<dyn Trait<isize>> = Box::new(Struct { person: "Fred" }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait<isize>` is not implemented for `Struct` | = help: the following implementations were found: <Struct as Trait<&'static str>> diff --git a/src/test/ui/traits/trait-coercion-generic-regions.rs b/src/test/ui/traits/trait-coercion-generic-regions.rs index 148b7dd5c43..af478df6dfa 100644 --- a/src/test/ui/traits/trait-coercion-generic-regions.rs +++ b/src/test/ui/traits/trait-coercion-generic-regions.rs @@ -15,5 +15,5 @@ impl Trait<&'static str> for Struct { fn main() { let person = "Fred".to_string(); let person: &str = &person; //~ ERROR `person` does not live long enough - let s: Box<Trait<&'static str>> = Box::new(Struct { person: person }); + let s: Box<dyn Trait<&'static str>> = Box::new(Struct { person: person }); } diff --git a/src/test/ui/traits/trait-coercion-generic-regions.stderr b/src/test/ui/traits/trait-coercion-generic-regions.stderr index 4ee3e4cacc3..d21b48e571d 100644 --- a/src/test/ui/traits/trait-coercion-generic-regions.stderr +++ b/src/test/ui/traits/trait-coercion-generic-regions.stderr @@ -6,7 +6,7 @@ LL | let person: &str = &person; | | | borrowed value does not live long enough | assignment requires that `person` is borrowed for `'static` -LL | let s: Box<Trait<&'static str>> = Box::new(Struct { person: person }); +LL | let s: Box<dyn Trait<&'static str>> = Box::new(Struct { person: person }); LL | } | - `person` dropped here while still borrowed diff --git a/src/test/ui/traits/trait-impl-1.rs b/src/test/ui/traits/trait-impl-1.rs index 29f58a6a9cb..43b82221835 100644 --- a/src/test/ui/traits/trait-impl-1.rs +++ b/src/test/ui/traits/trait-impl-1.rs @@ -4,7 +4,7 @@ trait T {} -impl<'a> T+'a { +impl<'a> dyn T + 'a { fn foo(&self) {} } diff --git a/src/test/ui/traits/trait-item-privacy.rs b/src/test/ui/traits/trait-item-privacy.rs index dfc8c8f4f6c..d58bbef38c4 100644 --- a/src/test/ui/traits/trait-item-privacy.rs +++ b/src/test/ui/traits/trait-item-privacy.rs @@ -68,7 +68,7 @@ fn check_method() { S.b(); //~ ERROR no method named `b` found for type `S` in the current scope S.c(); // OK // a, b, c are resolved as inherent items, their traits don't need to be in scope - let c = &S as &C; + let c = &S as &dyn C; c.a(); //~ ERROR method `a` is private c.b(); // OK c.c(); // OK @@ -121,10 +121,10 @@ fn check_assoc_ty<T: assoc_ty::C>() { let _: T::C; // OK // Associated types, bindings - let _: assoc_ty::B< + let _: dyn assoc_ty::B< B = u8, // OK >; - let _: C< + let _: dyn C< A = u8, //~ ERROR associated type `A` is private B = u8, // OK C = u8, // OK diff --git a/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs b/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs index 6ba5d28a6c4..85698f19489 100644 --- a/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs +++ b/src/test/ui/traits/trait-object-auto-dedup-in-impl.rs @@ -5,15 +5,15 @@ struct Struct; impl Trait for Struct {} trait Trait {} -type Send1 = Trait + Send; -type Send2 = Trait + Send + Send; +type Send1 = dyn Trait + Send; +type Send2 = dyn Trait + Send + Send; fn main () {} -impl Trait + Send { +impl dyn Trait + Send { fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name `test` } -impl Trait + Send + Send { +impl dyn Trait + Send + Send { fn test(&self) { println!("two"); } } diff --git a/src/test/ui/traits/trait-object-macro-matcher.rs b/src/test/ui/traits/trait-object-macro-matcher.rs index 0f55e2dc4f2..5ec157275a6 100644 --- a/src/test/ui/traits/trait-object-macro-matcher.rs +++ b/src/test/ui/traits/trait-object-macro-matcher.rs @@ -5,7 +5,8 @@ macro_rules! m { } fn main() { - m!(Copy + Send + 'static); //~ ERROR the trait `std::marker::Copy` cannot be made into an object - m!('static + Send); - m!('static +); //~ ERROR at least one non-builtin trait is required for an object type + m!(dyn Copy + Send + 'static); + //~^ ERROR the trait `std::marker::Copy` cannot be made into an object + m!(dyn 'static + Send); + m!(dyn 'static +); //~ ERROR at least one non-builtin trait is required for an object type } diff --git a/src/test/ui/traits/trait-object-macro-matcher.stderr b/src/test/ui/traits/trait-object-macro-matcher.stderr index 57a529ebc57..0b84c3dfcb0 100644 --- a/src/test/ui/traits/trait-object-macro-matcher.stderr +++ b/src/test/ui/traits/trait-object-macro-matcher.stderr @@ -1,14 +1,14 @@ error[E0224]: at least one non-builtin trait is required for an object type - --> $DIR/trait-object-macro-matcher.rs:10:8 + --> $DIR/trait-object-macro-matcher.rs:11:8 | -LL | m!('static +); - | ^^^^^^^^^ +LL | m!(dyn 'static +); + | ^^^^^^^^^^^^^ error[E0038]: the trait `std::marker::Copy` cannot be made into an object --> $DIR/trait-object-macro-matcher.rs:8:8 | -LL | m!(Copy + Send + 'static); - | ^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` cannot be made into an object +LL | m!(dyn Copy + Send + 'static); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` cannot be made into an object | = note: the trait cannot require that `Self : Sized` diff --git a/src/test/ui/traits/trait-object-safety.rs b/src/test/ui/traits/trait-object-safety.rs index e333bf6bfe5..f43d332d696 100644 --- a/src/test/ui/traits/trait-object-safety.rs +++ b/src/test/ui/traits/trait-object-safety.rs @@ -12,6 +12,6 @@ impl Tr for St { } fn main() { - let _: &Tr = &St; //~ ERROR E0038 + let _: &dyn Tr = &St; //~ ERROR E0038 //~^ ERROR E0038 } diff --git a/src/test/ui/traits/trait-object-safety.stderr b/src/test/ui/traits/trait-object-safety.stderr index a7fe83cb756..68edc178705 100644 --- a/src/test/ui/traits/trait-object-safety.stderr +++ b/src/test/ui/traits/trait-object-safety.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `Tr` cannot be made into an object - --> $DIR/trait-object-safety.rs:15:18 + --> $DIR/trait-object-safety.rs:15:22 | -LL | let _: &Tr = &St; - | ^^^ the trait `Tr` cannot be made into an object +LL | let _: &dyn Tr = &St; + | ^^^ the trait `Tr` cannot be made into an object | = note: method `foo` has no receiver = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<&dyn Tr>` for `&St` @@ -10,8 +10,8 @@ LL | let _: &Tr = &St; error[E0038]: the trait `Tr` cannot be made into an object --> $DIR/trait-object-safety.rs:15:12 | -LL | let _: &Tr = &St; - | ^^^ the trait `Tr` cannot be made into an object +LL | let _: &dyn Tr = &St; + | ^^^^^^^ the trait `Tr` cannot be made into an object | = note: method `foo` has no receiver diff --git a/src/test/ui/traits/trait-object-vs-lifetime-2.rs b/src/test/ui/traits/trait-object-vs-lifetime-2.rs index 2579a0056f1..4d56fcf11e3 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime-2.rs +++ b/src/test/ui/traits/trait-object-vs-lifetime-2.rs @@ -6,7 +6,7 @@ // `'static` is a lifetime, `'static +` is a type, `'a` is a type fn g() where 'static: 'static, - 'static +: 'static + Copy, + dyn 'static +: 'static + Copy, //~^ ERROR at least one non-builtin trait is required for an object type {} diff --git a/src/test/ui/traits/trait-object-vs-lifetime-2.stderr b/src/test/ui/traits/trait-object-vs-lifetime-2.stderr index 057f587a7b6..24162c920be 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime-2.stderr +++ b/src/test/ui/traits/trait-object-vs-lifetime-2.stderr @@ -1,8 +1,8 @@ error[E0224]: at least one non-builtin trait is required for an object type --> $DIR/trait-object-vs-lifetime-2.rs:9:5 | -LL | 'static +: 'static + Copy, - | ^^^^^^^^^ +LL | dyn 'static +: 'static + Copy, + | ^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/traits/trait-object-vs-lifetime.rs b/src/test/ui/traits/trait-object-vs-lifetime.rs index 36dec21be05..803b29367c8 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime.rs +++ b/src/test/ui/traits/trait-object-vs-lifetime.rs @@ -6,12 +6,12 @@ struct S<'a, T>(&'a u8, T); fn main() { // `'static` is a lifetime argument, `'static +` is a type argument let _: S<'static, u8>; - let _: S<'static, 'static +>; + let _: S<'static, dyn 'static +>; //~^ at least one non-builtin trait is required for an object type let _: S<'static, 'static>; //~^ ERROR wrong number of lifetime arguments: expected 1, found 2 //~| ERROR wrong number of type arguments: expected 1, found 0 - let _: S<'static +, 'static>; + let _: S<dyn 'static +, 'static>; //~^ ERROR lifetime arguments must be declared prior to type arguments //~| ERROR at least one non-builtin trait is required for an object type } diff --git a/src/test/ui/traits/trait-object-vs-lifetime.stderr b/src/test/ui/traits/trait-object-vs-lifetime.stderr index c13d0e3f293..be1af59ed4f 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime.stderr +++ b/src/test/ui/traits/trait-object-vs-lifetime.stderr @@ -1,14 +1,14 @@ error: lifetime arguments must be declared prior to type arguments - --> $DIR/trait-object-vs-lifetime.rs:14:25 + --> $DIR/trait-object-vs-lifetime.rs:14:29 | -LL | let _: S<'static +, 'static>; - | ^^^^^^^ +LL | let _: S<dyn 'static +, 'static>; + | ^^^^^^^ error[E0224]: at least one non-builtin trait is required for an object type --> $DIR/trait-object-vs-lifetime.rs:9:23 | -LL | let _: S<'static, 'static +>; - | ^^^^^^^^^ +LL | let _: S<'static, dyn 'static +>; + | ^^^^^^^^^^^^^ error[E0107]: wrong number of lifetime arguments: expected 1, found 2 --> $DIR/trait-object-vs-lifetime.rs:11:23 @@ -25,8 +25,8 @@ LL | let _: S<'static, 'static>; error[E0224]: at least one non-builtin trait is required for an object type --> $DIR/trait-object-vs-lifetime.rs:14:14 | -LL | let _: S<'static +, 'static>; - | ^^^^^^^^^ +LL | let _: S<dyn 'static +, 'static>; + | ^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/traits/trait-test-2.rs b/src/test/ui/traits/trait-test-2.rs index 20d979df4bf..86570f1152e 100644 --- a/src/test/ui/traits/trait-test-2.rs +++ b/src/test/ui/traits/trait-test-2.rs @@ -8,7 +8,7 @@ impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} } fn main() { 10.dup::<i32>(); //~ ERROR wrong number of type arguments: expected 0, found 1 10.blah::<i32, i32>(); //~ ERROR wrong number of type arguments: expected 1, found 2 - (box 10 as Box<bar>).dup(); + (box 10 as Box<dyn bar>).dup(); //~^ ERROR E0038 //~| ERROR E0038 } diff --git a/src/test/ui/traits/trait-test-2.stderr b/src/test/ui/traits/trait-test-2.stderr index 0e3446e0d23..5d5251925a1 100644 --- a/src/test/ui/traits/trait-test-2.stderr +++ b/src/test/ui/traits/trait-test-2.stderr @@ -13,8 +13,8 @@ LL | 10.blah::<i32, i32>(); error[E0038]: the trait `bar` cannot be made into an object --> $DIR/trait-test-2.rs:11:16 | -LL | (box 10 as Box<bar>).dup(); - | ^^^^^^^^ the trait `bar` cannot be made into an object +LL | (box 10 as Box<dyn bar>).dup(); + | ^^^^^^^^^^^^ the trait `bar` cannot be made into an object | = note: method `dup` references the `Self` type in its arguments or return type = note: method `blah` has generic type parameters @@ -22,7 +22,7 @@ LL | (box 10 as Box<bar>).dup(); error[E0038]: the trait `bar` cannot be made into an object --> $DIR/trait-test-2.rs:11:6 | -LL | (box 10 as Box<bar>).dup(); +LL | (box 10 as Box<dyn bar>).dup(); | ^^^^^^ the trait `bar` cannot be made into an object | = note: method `dup` references the `Self` type in its arguments or return type diff --git a/src/test/ui/traits/traits-repeated-supertrait-ambig.rs b/src/test/ui/traits/traits-repeated-supertrait-ambig.rs index 5fa7e87aa4b..6aaef8a305b 100644 --- a/src/test/ui/traits/traits-repeated-supertrait-ambig.rs +++ b/src/test/ui/traits/traits-repeated-supertrait-ambig.rs @@ -22,7 +22,7 @@ impl CompareTo<u64> for i64 { impl CompareToInts for i64 { } -fn with_obj(c: &CompareToInts) -> bool { +fn with_obj(c: &dyn CompareToInts) -> bool { c.same_as(22) //~ ERROR `dyn CompareToInts: CompareTo<i32>` is not satisfied } diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs index a5d5b937726..d411807673c 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.rs @@ -13,8 +13,8 @@ struct T<X: ?Sized> { struct S(str, str) where str: Sized; -fn unsized_local() where for<'a> T<A + 'a>: Sized { - let x: T<A> = *(Box::new(T { x: 1 }) as Box<T<A>>); +fn unsized_local() where for<'a> T<dyn A + 'a>: Sized { + let x: T<dyn A> = *(Box::new(T { x: 1 }) as Box<T<dyn A>>); } fn return_str() -> str where str: Sized { diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr index a9d2634c1ad..fda1d6d70ac 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr @@ -7,10 +7,10 @@ LL | struct S(str, str) where str: Sized; = note: #[warn(trivial_bounds)] on by default warning: Trait bound for<'a> T<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-sized.rs:16:45 + --> $DIR/trivial-bounds-inconsistent-sized.rs:16:49 | -LL | fn unsized_local() where for<'a> T<A + 'a>: Sized { - | ^^^^^ +LL | fn unsized_local() where for<'a> T<dyn A + 'a>: Sized { + | ^^^^^ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent-sized.rs:20:35 diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs index fdbaec9a5c7..f6538b14d17 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.rs @@ -52,8 +52,8 @@ struct Dst<X: ?Sized> { struct TwoStrs(str, str) where str: Sized; -fn unsized_local() where for<'a> Dst<A + 'a>: Sized { - let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>); +fn unsized_local() where for<'a> Dst<dyn A + 'a>: Sized { + let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>); } fn return_str() -> str where str: Sized { diff --git a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr index 744e146f830..a0d638f1714 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr @@ -64,10 +64,10 @@ LL | struct TwoStrs(str, str) where str: Sized; | ^^^^^ warning: Trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:55:47 + --> $DIR/trivial-bounds-inconsistent.rs:55:51 | -LL | fn unsized_local() where for<'a> Dst<A + 'a>: Sized { - | ^^^^^ +LL | fn unsized_local() where for<'a> Dst<dyn A + 'a>: Sized { + | ^^^^^ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters --> $DIR/trivial-bounds-inconsistent.rs:59:35 diff --git a/src/test/ui/trivial_casts.rs b/src/test/ui/trivial_casts.rs index c1f5441a36b..dd578e074fd 100644 --- a/src/test/ui/trivial_casts.rs +++ b/src/test/ui/trivial_casts.rs @@ -49,29 +49,29 @@ pub fn main() { // unsize trait let x: &Bar = &Bar; - let _ = x as &Foo; //~ERROR trivial cast: `&Bar` as `&dyn Foo` - let _ = x as *const Foo; //~ERROR trivial cast: `&Bar` as `*const dyn Foo` - let _: &Foo = x; - let _: *const Foo = x; + let _ = x as &dyn Foo; //~ERROR trivial cast: `&Bar` as `&dyn Foo` + let _ = x as *const dyn Foo; //~ERROR trivial cast: `&Bar` as `*const dyn Foo` + let _: &dyn Foo = x; + let _: *const dyn Foo = x; let x: &mut Bar = &mut Bar; - let _ = x as &mut Foo; //~ERROR trivial cast: `&mut Bar` as `&mut dyn Foo` - let _ = x as *mut Foo; //~ERROR trivial cast: `&mut Bar` as `*mut dyn Foo` - let _: &mut Foo = x; - let _: *mut Foo = x; + let _ = x as &mut dyn Foo; //~ERROR trivial cast: `&mut Bar` as `&mut dyn Foo` + let _ = x as *mut dyn Foo; //~ERROR trivial cast: `&mut Bar` as `*mut dyn Foo` + let _: &mut dyn Foo = x; + let _: *mut dyn Foo = x; let x: Box<Bar> = Box::new(Bar); - let _ = x as Box<Foo>; //~ERROR `std::boxed::Box<Bar>` as `std::boxed::Box<dyn Foo>` + let _ = x as Box<dyn Foo>; //~ERROR `std::boxed::Box<Bar>` as `std::boxed::Box<dyn Foo>` let x: Box<Bar> = Box::new(Bar); - let _: Box<Foo> = x; + let _: Box<dyn Foo> = x; // functions fn baz(_x: i32) {} - let _ = &baz as &Fn(i32); //~ERROR `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` - let _: &Fn(i32) = &baz; + let _ = &baz as &dyn Fn(i32); //~ERROR `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` + let _: &dyn Fn(i32) = &baz; let x = |_x: i32| {}; - let _ = &x as &Fn(i32); //~ERROR trivial cast - let _: &Fn(i32) = &x; + let _ = &x as &dyn Fn(i32); //~ERROR trivial cast + let _: &dyn Fn(i32) = &x; } // subtyping diff --git a/src/test/ui/trivial_casts.stderr b/src/test/ui/trivial_casts.stderr index 524eb7feaaf..8fa44372f0b 100644 --- a/src/test/ui/trivial_casts.stderr +++ b/src/test/ui/trivial_casts.stderr @@ -83,56 +83,56 @@ LL | let _ = x as Box<[u32]>; error: trivial cast: `&Bar` as `&dyn Foo` --> $DIR/trivial_casts.rs:52:13 | -LL | let _ = x as &Foo; - | ^^^^^^^^^ +LL | let _ = x as &dyn Foo; + | ^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&Bar` as `*const dyn Foo` --> $DIR/trivial_casts.rs:53:13 | -LL | let _ = x as *const Foo; - | ^^^^^^^^^^^^^^^ +LL | let _ = x as *const dyn Foo; + | ^^^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&mut Bar` as `&mut dyn Foo` --> $DIR/trivial_casts.rs:58:13 | -LL | let _ = x as &mut Foo; - | ^^^^^^^^^^^^^ +LL | let _ = x as &mut dyn Foo; + | ^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&mut Bar` as `*mut dyn Foo` --> $DIR/trivial_casts.rs:59:13 | -LL | let _ = x as *mut Foo; - | ^^^^^^^^^^^^^ +LL | let _ = x as *mut dyn Foo; + | ^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `std::boxed::Box<Bar>` as `std::boxed::Box<dyn Foo>` --> $DIR/trivial_casts.rs:64:13 | -LL | let _ = x as Box<Foo>; - | ^^^^^^^^^^^^^ +LL | let _ = x as Box<dyn Foo>; + | ^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&fn(i32) {main::baz}` as `&dyn std::ops::Fn(i32)` --> $DIR/trivial_casts.rs:70:13 | -LL | let _ = &baz as &Fn(i32); - | ^^^^^^^^^^^^^^^^ +LL | let _ = &baz as &dyn Fn(i32); + | ^^^^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable error: trivial cast: `&[closure@$DIR/trivial_casts.rs:72:13: 72:25]` as `&dyn std::ops::Fn(i32)` --> $DIR/trivial_casts.rs:73:13 | -LL | let _ = &x as &Fn(i32); - | ^^^^^^^^^^^^^^ +LL | let _ = &x as &dyn Fn(i32); + | ^^^^^^^^^^^^^^^^^^ | = help: cast can be replaced by coercion; this might require a temporary variable diff --git a/src/test/ui/type/type-arg-out-of-scope.rs b/src/test/ui/type/type-arg-out-of-scope.rs index d5b815f6a95..02aad007707 100644 --- a/src/test/ui/type/type-arg-out-of-scope.rs +++ b/src/test/ui/type/type-arg-out-of-scope.rs @@ -1,5 +1,5 @@ // error-pattern:can't use generic parameters from outer function fn foo<T>(x: T) { - fn bar(f: Box<FnMut(T) -> T>) { } + fn bar(f: Box<dyn FnMut(T) -> T>) { } } fn main() { foo(1); } diff --git a/src/test/ui/type/type-arg-out-of-scope.stderr b/src/test/ui/type/type-arg-out-of-scope.stderr index ea991069c08..0b6283fbc51 100644 --- a/src/test/ui/type/type-arg-out-of-scope.stderr +++ b/src/test/ui/type/type-arg-out-of-scope.stderr @@ -1,20 +1,20 @@ error[E0401]: can't use generic parameters from outer function - --> $DIR/type-arg-out-of-scope.rs:3:25 + --> $DIR/type-arg-out-of-scope.rs:3:29 | LL | fn foo<T>(x: T) { | - type parameter from outer function -LL | fn bar(f: Box<FnMut(T) -> T>) { } - | --- ^ use of generic parameter from outer function +LL | fn bar(f: Box<dyn FnMut(T) -> T>) { } + | --- ^ use of generic parameter from outer function | | | help: try using a local generic parameter instead: `bar<T>` error[E0401]: can't use generic parameters from outer function - --> $DIR/type-arg-out-of-scope.rs:3:31 + --> $DIR/type-arg-out-of-scope.rs:3:35 | LL | fn foo<T>(x: T) { | - type parameter from outer function -LL | fn bar(f: Box<FnMut(T) -> T>) { } - | --- ^ use of generic parameter from outer function +LL | fn bar(f: Box<dyn FnMut(T) -> T>) { } + | --- ^ use of generic parameter from outer function | | | help: try using a local generic parameter instead: `bar<T>` diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs index 3e1c876c76b..444453dc694 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs @@ -11,7 +11,7 @@ impl MyAdd for i32 { fn main() { let x: i32 = 5; - let y = x as MyAdd<i32>; + let y = x as dyn MyAdd<i32>; //~^ ERROR E0038 //~| ERROR cast to unsized type: `i32` as `dyn MyAdd<i32>` } diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr index 0beb9e9eb4b..58727ea0fef 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr @@ -1,20 +1,20 @@ error[E0620]: cast to unsized type: `i32` as `dyn MyAdd<i32>` --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13 | -LL | let y = x as MyAdd<i32>; - | ^^^^^^^^^^^^^^^ +LL | let y = x as dyn MyAdd<i32>; + | ^^^^^^^^^^^^^^^^^^^ | help: consider using a box or reference as appropriate --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13 | -LL | let y = x as MyAdd<i32>; +LL | let y = x as dyn MyAdd<i32>; | ^ error[E0038]: the trait `MyAdd` cannot be made into an object --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18 | -LL | let y = x as MyAdd<i32>; - | ^^^^^^^^^^ the trait `MyAdd` cannot be made into an object +LL | let y = x as dyn MyAdd<i32>; + | ^^^^^^^^^^^^^^ the trait `MyAdd` cannot be made into an object | = note: method `add` references the `Self` type in its arguments or return type diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self.rs b/src/test/ui/type/type-parameter-defaults-referencing-Self.rs index 721bf960a55..a4c59dced02 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self.rs +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self.rs @@ -7,7 +7,7 @@ trait Foo<T=Self> { fn method(&self); } -fn foo(x: &Foo) { } +fn foo(x: &dyn Foo) { } //~^ ERROR the type parameter `T` must be explicitly specified fn main() { } diff --git a/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr b/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr index 70093b61f25..0d6ca9d9dcd 100644 --- a/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr +++ b/src/test/ui/type/type-parameter-defaults-referencing-Self.stderr @@ -1,8 +1,8 @@ error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/type-parameter-defaults-referencing-Self.rs:10:12 + --> $DIR/type-parameter-defaults-referencing-Self.rs:10:16 | -LL | fn foo(x: &Foo) { } - | ^^^ missing reference to `T` +LL | fn foo(x: &dyn Foo) { } + | ^^^ missing reference to `T` | = note: because of the default `Self` reference, type parameters must be specified on object types diff --git a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs index 77608664362..f466c19e051 100644 --- a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs +++ b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs @@ -1,7 +1,7 @@ fn foo1<T:Copy<U>, U>(x: T) {} //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] -trait Trait: Copy<Send> {} +trait Trait: Copy<dyn Send> {} //~^ ERROR wrong number of type arguments: expected 0, found 1 [E0107] struct MyStruct1<T: Copy<T>>; diff --git a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr index 0242287a3e5..0be1c8ef3bc 100644 --- a/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr +++ b/src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr @@ -7,8 +7,8 @@ LL | fn foo1<T:Copy<U>, U>(x: T) {} error[E0107]: wrong number of type arguments: expected 0, found 1 --> $DIR/typeck-builtin-bound-type-parameters.rs:4:19 | -LL | trait Trait: Copy<Send> {} - | ^^^^ unexpected type argument +LL | trait Trait: Copy<dyn Send> {} + | ^^^^^^^^ unexpected type argument error[E0107]: wrong number of type arguments: expected 0, found 1 --> $DIR/typeck-builtin-bound-type-parameters.rs:7:26 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs index 1eb9de778e8..d8b201bf82d 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.rs @@ -10,11 +10,11 @@ trait Foo<A> { } fn main() { - let x: Box<Foo(isize)>; + let x: Box<dyn Foo(isize)>; //~^ ERROR parenthetical notation is only stable when used with `Fn`-family // No errors with these: - let x: Box<Fn(isize)>; - let x: Box<FnMut(isize)>; - let x: Box<FnOnce(isize)>; + let x: Box<dyn Fn(isize)>; + let x: Box<dyn FnMut(isize)>; + let x: Box<dyn FnOnce(isize)>; } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr index 1604aa4a0f7..c23acbcb311 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-feature-gate.stderr @@ -1,8 +1,8 @@ error[E0658]: parenthetical notation is only stable when used with `Fn`-family traits - --> $DIR/unboxed-closure-feature-gate.rs:13:16 + --> $DIR/unboxed-closure-feature-gate.rs:13:20 | -LL | let x: Box<Foo(isize)>; - | ^^^^^^^^^^ +LL | let x: Box<dyn Foo(isize)>; + | ^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add #![feature(unboxed_closures)] to the crate attributes to enable diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs index 044859de6a4..f1c83f0606f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.rs @@ -15,14 +15,14 @@ fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + eq::<dyn Foo<(isize,), Output=()>, dyn Foo(isize)>(); // In angle version, we supply something other than the default - eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); + eq::<dyn Foo<(isize,), isize, Output=()>, dyn Foo(isize)>(); //~^ ERROR E0277 // Supply default explicitly. - eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >(); + eq::<dyn Foo<(isize,), (isize,), Output=()>, dyn Foo(isize)>(); } fn main() { } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr index ce90f5b9d24..fd5ef4b9df1 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `dyn Foo<(isize,), isize, Output = ()>: Eq<dyn Foo<(isize,), Output = ()>>` is not satisfied --> $DIR/unboxed-closure-sugar-default.rs:21:5 | -LL | eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq<dyn Foo<(isize,), Output = ()>>` is not implemented for `dyn Foo<(isize,), isize, Output = ()>` +LL | eq::<dyn Foo<(isize,), isize, Output=()>, dyn Foo(isize)>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq<dyn Foo<(isize,), Output = ()>>` is not implemented for `dyn Foo<(isize,), isize, Output = ()>` | note: required by `eq` --> $DIR/unboxed-closure-sugar-default.rs:14:1 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs index 95bd391f251..0fc3e23ec73 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.rs @@ -17,31 +17,31 @@ fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } fn test<'a,'b>() { // No errors expected: - eq::< Foo<(),Output=()>, Foo() >(); - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); - eq::< Foo<(isize,usize),Output=()>, Foo(isize,usize) >(); - eq::< Foo<(isize,usize),Output=usize>, Foo(isize,usize) -> usize >(); - eq::< Foo<(&'a isize,&'b usize),Output=usize>, Foo(&'a isize,&'b usize) -> usize >(); + eq::< dyn Foo<(),Output=()>, dyn Foo() >(); + eq::< dyn Foo<(isize,),Output=()>, dyn Foo(isize) >(); + eq::< dyn Foo<(isize,usize),Output=()>, dyn Foo(isize,usize) >(); + eq::< dyn Foo<(isize,usize),Output=usize>, dyn Foo(isize,usize) -> usize >(); + eq::< dyn Foo<(&'a isize,&'b usize),Output=usize>, dyn Foo(&'a isize,&'b usize) -> usize >(); // Test that anonymous regions in `()` form are equivalent // to fresh bound regions, and that we can intermingle // named and anonymous as we choose: - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'x> Foo(&'x isize,&usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - for<'y> Foo(&isize,&'y usize) -> usize >(); - eq::< for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, - Foo(&isize,&usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn for<'x,'y> Foo(&'x isize,&'y usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn for<'x> Foo(&'x isize,&usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn for<'y> Foo(&isize,&'y usize) -> usize >(); + eq::< dyn for<'x,'y> Foo<(&'x isize,&'y usize),Output=usize>, + dyn Foo(&isize,&usize) -> usize >(); // lifetime elision - eq::< for<'x> Foo<(&'x isize,), Output=&'x isize>, - Foo(&isize) -> &isize >(); + eq::< dyn for<'x> Foo<(&'x isize,), Output=&'x isize>, + dyn Foo(&isize) -> &isize >(); // Errors expected: - eq::< Foo<(),Output=()>, - Foo(char) >(); + eq::< dyn Foo<(),Output=()>, + dyn Foo(char) >(); //~^^ ERROR E0277 } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr index 857a32ca69e..005a86bc217 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr @@ -1,9 +1,9 @@ error[E0277]: the trait bound `dyn Foo<(char,), Output = ()>: Eq<dyn Foo<(), Output = ()>>` is not satisfied --> $DIR/unboxed-closure-sugar-equiv.rs:43:5 | -LL | / eq::< Foo<(),Output=()>, -LL | | Foo(char) >(); - | |___________________________________________________________________^ the trait `Eq<dyn Foo<(), Output = ()>>` is not implemented for `dyn Foo<(char,), Output = ()>` +LL | / eq::< dyn Foo<(),Output=()>, +LL | | dyn Foo(char) >(); + | |_______________________________________________________________________^ the trait `Eq<dyn Foo<(), Output = ()>>` is not implemented for `dyn Foo<(char,), Output = ()>` | note: required by `eq` --> $DIR/unboxed-closure-sugar-equiv.rs:16:1 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs index b61d8b8c8c7..d11d663f172 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.rs @@ -18,10 +18,10 @@ impl<X: ?Sized> Eq<X> for X { } fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } fn main() { - eq::< for<'a> Foo<(&'a isize,), Output=&'a isize>, - Foo(&isize) -> &isize >(); - eq::< for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, - Foo(&isize) -> (&isize, &isize) >(); + eq::< dyn for<'a> Foo<(&'a isize,), Output=&'a isize>, + dyn Foo(&isize) -> &isize >(); + eq::< dyn for<'a> Foo<(&'a isize,), Output=(&'a isize, &'a isize)>, + dyn Foo(&isize) -> (&isize, &isize) >(); - let _: Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier + let _: dyn Foo(&isize, &usize) -> &usize; //~ ERROR missing lifetime specifier } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr index 8c3480744fe..9fb9a07166f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-lifetime-elision.stderr @@ -1,8 +1,8 @@ error[E0106]: missing lifetime specifier - --> $DIR/unboxed-closure-sugar-lifetime-elision.rs:26:35 + --> $DIR/unboxed-closure-sugar-lifetime-elision.rs:26:39 | -LL | let _: Foo(&isize, &usize) -> &usize; - | ^ expected lifetime parameter +LL | let _: dyn Foo(&isize, &usize) -> &usize; + | ^ expected lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from argument 1 or argument 2 diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs index 09927a94019..6d6ed4b568f 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.rs @@ -1,6 +1,6 @@ // Test that the `Fn` traits require `()` form without a feature gate. -fn bar1(x: &Fn<(), Output=()>) { +fn bar1(x: &dyn Fn<(), Output=()>) { //~^ ERROR of `Fn`-family traits' type parameters is subject to change } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr index 0901126a3fe..e1ed85d4f46 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-not-used-on-fn.stderr @@ -1,8 +1,8 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead - --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:3:13 + --> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:3:17 | -LL | fn bar1(x: &Fn<(), Output=()>) { - | ^^^^^^^^^^^^^^^^^ +LL | fn bar1(x: &dyn Fn<(), Output=()>) { + | ^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add #![feature(unboxed_closures)] to the crate attributes to enable diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs index 799d9f33e2e..76c928d7b6a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.rs @@ -20,14 +20,14 @@ fn same_type<A,B:Eq<A>>(a: A, b: B) { } fn test<'a,'b>() { // Parens are equivalent to omitting default in angle. - eq::< Foo<(isize,),Output=()>, Foo(isize) >(); + eq::< dyn Foo<(isize,),Output=()>, dyn Foo(isize) >(); // Here we specify 'static explicitly in angle-bracket version. // Parenthesized winds up getting inferred. - eq::< Foo<'static, (isize,),Output=()>, Foo(isize) >(); + eq::< dyn Foo<'static, (isize,),Output=()>, dyn Foo(isize) >(); } -fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { +fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) { //~^ ERROR wrong number of lifetime arguments: expected 1, found 0 // Here, the omitted lifetimes are expanded to distinct things. same_type(x, y) diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr index 8eed7d58c46..e9d51983a7a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-region.stderr @@ -1,8 +1,8 @@ error[E0107]: wrong number of lifetime arguments: expected 1, found 0 - --> $DIR/unboxed-closure-sugar-region.rs:30:43 + --> $DIR/unboxed-closure-sugar-region.rs:30:51 | -LL | fn test2(x: &Foo<(isize,),Output=()>, y: &Foo(isize)) { - | ^^^^^^^^^^ expected 1 lifetime argument +LL | fn test2(x: &dyn Foo<(isize,),Output=()>, y: &dyn Foo(isize)) { + | ^^^^^^^^^^ expected 1 lifetime argument error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs index df0c495a11c..a6c86311b37 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs @@ -2,7 +2,7 @@ trait One<A> { fn foo(&self) -> A; } -fn foo(_: &One()) //~ ERROR associated type `Output` not found for `One<()>` +fn foo(_: &dyn One()) //~ ERROR associated type `Output` not found for `One<()>` {} fn main() { } diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr index 304339c89e6..c59082932dd 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-1.stderr @@ -1,8 +1,8 @@ error[E0220]: associated type `Output` not found for `One<()>` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:15 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-1.rs:5:19 | -LL | fn foo(_: &One()) - | ^^ associated type `Output` not found +LL | fn foo(_: &dyn One()) + | ^^ associated type `Output` not found error: aborting due to previous error diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs index 5f5ad7902aa..01c76d64c6b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs @@ -2,7 +2,7 @@ trait Three<A,B,C> { fn dummy(&self) -> (A,B,C); } -fn foo(_: &Three()) +fn foo(_: &dyn Three()) //~^ ERROR wrong number of type arguments //~| ERROR associated type `Output` not found {} diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr index 62b3a254430..6c61e74584a 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr @@ -1,14 +1,14 @@ error[E0107]: wrong number of type arguments: expected 3, found 1 - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:12 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16 | -LL | fn foo(_: &Three()) - | ^^^^^^^ expected 3 type arguments +LL | fn foo(_: &dyn Three()) + | ^^^^^^^ expected 3 type arguments error[E0220]: associated type `Output` not found for `Three<(), [type error], [type error]>` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:17 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:21 | -LL | fn foo(_: &Three()) - | ^^ associated type `Output` not found +LL | fn foo(_: &dyn Three()) + | ^^ associated type `Output` not found error: aborting due to 2 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs index 2e87d91f8bd..bc9901c795b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs @@ -2,7 +2,7 @@ trait Zero { fn dummy(&self); } -fn foo(_: Zero()) +fn foo(_: dyn Zero()) //~^ ERROR wrong number of type arguments //~| ERROR associated type `Output` not found for `Zero` {} diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr index b64fc61cc85..b96e2cbc36b 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr @@ -1,14 +1,14 @@ error[E0107]: wrong number of type arguments: expected 0, found 1 - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:15 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:19 | -LL | fn foo(_: Zero()) - | ^^ unexpected type argument +LL | fn foo(_: dyn Zero()) + | ^^ unexpected type argument error[E0220]: associated type `Output` not found for `Zero` - --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:15 + --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:19 | -LL | fn foo(_: Zero()) - | ^^ associated type `Output` not found +LL | fn foo(_: dyn Zero()) + | ^^ associated type `Output` not found error: aborting due to 2 previous errors diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs index 82dc536bb56..1358ba0f953 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs @@ -9,7 +9,7 @@ fn a() { // iteration, but it still doesn't work. The weird structure with // the `Option` is to avoid giving any useful hints about the `Fn` // kind via the expected type. - let mut factorial: Option<Box<Fn(u32) -> u32>> = None; + let mut factorial: Option<Box<dyn Fn(u32) -> u32>> = None; let f = |x: u32| -> u32 { let g = factorial.as_ref().unwrap(); @@ -22,7 +22,7 @@ fn a() { } fn b() { - let mut factorial: Option<Box<Fn(u32) -> u32 + 'static>> = None; + let mut factorial: Option<Box<dyn Fn(u32) -> u32 + 'static>> = None; let f = |x: u32| -> u32 { let g = factorial.as_ref().unwrap(); diff --git a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr index 8d39fb026b3..0466887e371 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.stderr @@ -29,8 +29,8 @@ LL | factorial = Some(Box::new(f)); error[E0597]: `factorial` does not live long enough --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:28:17 | -LL | let mut factorial: Option<Box<Fn(u32) -> u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | let mut factorial: Option<Box<dyn Fn(u32) -> u32 + 'static>> = None; + | ----------------------------------------- type annotation requires that `factorial` is borrowed for `'static` LL | LL | let f = |x: u32| -> u32 { | --------------- value captured here @@ -43,8 +43,8 @@ LL | } error[E0506]: cannot assign to `factorial` because it is borrowed --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:33:5 | -LL | let mut factorial: Option<Box<Fn(u32) -> u32 + 'static>> = None; - | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | let mut factorial: Option<Box<dyn Fn(u32) -> u32 + 'static>> = None; + | ----------------------------------------- type annotation requires that `factorial` is borrowed for `'static` LL | LL | let f = |x: u32| -> u32 { | --------------- borrow of `factorial` occurs here diff --git a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs index 0beead1ad92..6a707b2096d 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs +++ b/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.rs @@ -17,14 +17,14 @@ impl<F,A,R> YCombinator<F,A,R> { } } -impl<A,R,F : FnMut(&mut FnMut(A) -> R, A) -> R> FnMut<(A,)> for YCombinator<F,A,R> { +impl<A,R,F : FnMut(&mut dyn FnMut(A) -> R, A) -> R> FnMut<(A,)> for YCombinator<F,A,R> { extern "rust-call" fn call_mut(&mut self, (arg,): (A,)) -> R { (self.func)(self, arg) //~^ ERROR cannot borrow `*self` as mutable more than once at a time } } -impl<A,R,F : FnMut(&mut FnMut(A) -> R, A) -> R> FnOnce<(A,)> for YCombinator<F,A,R> { +impl<A,R,F : FnMut(&mut dyn FnMut(A) -> R, A) -> R> FnOnce<(A,)> for YCombinator<F,A,R> { type Output = R; extern "rust-call" fn call_once(mut self, args: (A,)) -> R { self.call_mut(args) @@ -33,7 +33,7 @@ impl<A,R,F : FnMut(&mut FnMut(A) -> R, A) -> R> FnOnce<(A,)> for YCombinator<F,A fn main() { let mut counter = 0; - let factorial = |recur: &mut FnMut(u32) -> u32, arg: u32| -> u32 { + let factorial = |recur: &mut dyn FnMut(u32) -> u32, arg: u32| -> u32 { counter += 1; if arg == 0 {1} else {arg * recur(arg-1)} }; diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs index 614f7e49f87..3d049cc5639 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs @@ -7,7 +7,7 @@ fn foo<'_> //~ ERROR cannot be used here trait Meh<'a> {} impl<'a> Meh<'a> for u8 {} -fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here +fn meh() -> Box<dyn for<'_> Meh<'_>> //~ ERROR cannot be used here //~^ ERROR missing lifetime specifier { Box::new(5u8) diff --git a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr index 936e3ba55fe..654f4285f65 100644 --- a/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr +++ b/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr @@ -5,10 +5,10 @@ LL | fn foo<'_> | ^^ `'_` is a reserved lifetime name error[E0637]: `'_` cannot be used here - --> $DIR/underscore-lifetime-binders.rs:10:21 + --> $DIR/underscore-lifetime-binders.rs:10:25 | -LL | fn meh() -> Box<for<'_> Meh<'_>> - | ^^ `'_` is a reserved lifetime name +LL | fn meh() -> Box<dyn for<'_> Meh<'_>> + | ^^ `'_` is a reserved lifetime name error[E0106]: missing lifetime specifier --> $DIR/underscore-lifetime-binders.rs:2:17 @@ -17,10 +17,10 @@ LL | struct Baz<'a>(&'_ &'a u8); | ^^ expected lifetime parameter error[E0106]: missing lifetime specifier - --> $DIR/underscore-lifetime-binders.rs:10:29 + --> $DIR/underscore-lifetime-binders.rs:10:33 | -LL | fn meh() -> Box<for<'_> Meh<'_>> - | ^^ help: consider giving it a 'static lifetime: `'static` +LL | fn meh() -> Box<dyn for<'_> Meh<'_>> + | ^^ help: consider giving it a 'static lifetime: `'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from diff --git a/src/test/ui/unique-object-noncopyable.rs b/src/test/ui/unique-object-noncopyable.rs index 1c467a2421a..dd38a7190aa 100644 --- a/src/test/ui/unique-object-noncopyable.rs +++ b/src/test/ui/unique-object-noncopyable.rs @@ -20,6 +20,6 @@ impl Foo for Bar { fn main() { let x = box Bar { x: 10 }; - let y: Box<Foo> = x as Box<Foo>; + let y: Box<dyn Foo> = x as Box<dyn Foo>; let _z = y.clone(); //~ ERROR no method named `clone` found } diff --git a/src/test/ui/unsized/unsized-enum2.rs b/src/test/ui/unsized/unsized-enum2.rs index 60bfb5cb640..d589f5ae582 100644 --- a/src/test/ui/unsized/unsized-enum2.rs +++ b/src/test/ui/unsized/unsized-enum2.rs @@ -13,10 +13,10 @@ trait PathHelper2 {} trait PathHelper3 {} trait PathHelper4 {} -struct Path1(PathHelper1); -struct Path2(PathHelper2); -struct Path3(PathHelper3); -struct Path4(PathHelper4); +struct Path1(dyn PathHelper1); +struct Path2(dyn PathHelper2); +struct Path3(dyn PathHelper3); +struct Path4(dyn PathHelper4); enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> { // parameter @@ -50,13 +50,13 @@ enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> { //~^ ERROR the size for values of type // plain trait - VM(Foo), + VM(dyn Foo), //~^ ERROR the size for values of type - VN{x: Bar}, + VN{x: dyn Bar}, //~^ ERROR the size for values of type - VO(isize, FooBar), + VO(isize, dyn FooBar), //~^ ERROR the size for values of type - VP{u: isize, x: BarFoo}, + VP{u: isize, x: dyn BarFoo}, //~^ ERROR the size for values of type // projected diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr index 9109366e4fc..cdd5747d86b 100644 --- a/src/test/ui/unsized/unsized-enum2.stderr +++ b/src/test/ui/unsized/unsized-enum2.stderr @@ -85,8 +85,8 @@ LL | VH{u: isize, x: [u32]}, error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:53:8 | -LL | VM(Foo), - | ^^^ doesn't have a size known at compile-time +LL | VM(dyn Foo), + | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -95,8 +95,8 @@ LL | VM(Foo), error[E0277]: the size for values of type `(dyn Bar + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:55:8 | -LL | VN{x: Bar}, - | ^^^^^^ doesn't have a size known at compile-time +LL | VN{x: dyn Bar}, + | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Bar + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -105,8 +105,8 @@ LL | VN{x: Bar}, error[E0277]: the size for values of type `(dyn FooBar + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:57:15 | -LL | VO(isize, FooBar), - | ^^^^^^ doesn't have a size known at compile-time +LL | VO(isize, dyn FooBar), + | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn FooBar + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -115,8 +115,8 @@ LL | VO(isize, FooBar), error[E0277]: the size for values of type `(dyn BarFoo + 'static)` cannot be known at compilation time --> $DIR/unsized-enum2.rs:59:18 | -LL | VP{u: isize, x: BarFoo}, - | ^^^^^^^^^ doesn't have a size known at compile-time +LL | VP{u: isize, x: dyn BarFoo}, + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn BarFoo + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.rs b/src/test/ui/use/use-after-move-implicity-coerced-object.rs index 2e465ee8962..76487ef1c14 100644 --- a/src/test/ui/use/use-after-move-implicity-coerced-object.rs +++ b/src/test/ui/use/use-after-move-implicity-coerced-object.rs @@ -13,10 +13,10 @@ impl fmt::Display for Number { } struct List { - list: Vec<Box<ToString+'static>> } + list: Vec<Box<dyn ToString + 'static>> } impl List { - fn push(&mut self, n: Box<ToString+'static>) { + fn push(&mut self, n: Box<dyn ToString + 'static>) { self.list.push(n); } } diff --git a/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr b/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr index 8b5ecbe56ff..69818aedd15 100644 --- a/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/variance-contravariant-arg-object.rs:14:5 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here @@ -12,7 +12,7 @@ LL | v error: lifetime may not live long enough --> $DIR/variance-contravariant-arg-object.rs:22:5 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here diff --git a/src/test/ui/variance/variance-contravariant-arg-object.rs b/src/test/ui/variance/variance-contravariant-arg-object.rs index 27e5675dcde..947f4cd8b8f 100644 --- a/src/test/ui/variance/variance-contravariant-arg-object.rs +++ b/src/test/ui/variance/variance-contravariant-arg-object.rs @@ -7,15 +7,15 @@ trait Get<T> : 'static { fn get(&self, t: T); } -fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) - -> Box<Get<&'min i32>> +fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) + -> Box<dyn Get<&'min i32>> where 'max : 'min { v //~ ERROR mismatched types } -fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) - -> Box<Get<&'max i32>> +fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) + -> Box<dyn Get<&'max i32>> where 'max : 'min { // Previously OK: diff --git a/src/test/ui/variance/variance-contravariant-arg-object.stderr b/src/test/ui/variance/variance-contravariant-arg-object.stderr index beac05e04a8..263c849e199 100644 --- a/src/test/ui/variance/variance-contravariant-arg-object.stderr +++ b/src/test/ui/variance/variance-contravariant-arg-object.stderr @@ -9,12 +9,12 @@ LL | v note: the lifetime 'min as defined on the function body at 10:21... --> $DIR/variance-contravariant-arg-object.rs:10:21 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 10:27 --> $DIR/variance-contravariant-arg-object.rs:10:27 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ^^^^ error[E0308]: mismatched types @@ -28,12 +28,12 @@ LL | v note: the lifetime 'min as defined on the function body at 17:21... --> $DIR/variance-contravariant-arg-object.rs:17:21 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 17:27 --> $DIR/variance-contravariant-arg-object.rs:17:27 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-covariant-arg-object.nll.stderr b/src/test/ui/variance/variance-covariant-arg-object.nll.stderr index acf9f2e060c..63ab7fe9651 100644 --- a/src/test/ui/variance/variance-covariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-covariant-arg-object.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/variance-covariant-arg-object.rs:15:5 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here @@ -12,7 +12,7 @@ LL | v error: lifetime may not live long enough --> $DIR/variance-covariant-arg-object.rs:22:5 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here diff --git a/src/test/ui/variance/variance-covariant-arg-object.rs b/src/test/ui/variance/variance-covariant-arg-object.rs index 4b371841654..7cbf65ae3d9 100644 --- a/src/test/ui/variance/variance-covariant-arg-object.rs +++ b/src/test/ui/variance/variance-covariant-arg-object.rs @@ -7,16 +7,16 @@ trait Get<T> : 'static { fn get(&self) -> T; } -fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) - -> Box<Get<&'min i32>> +fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) + -> Box<dyn Get<&'min i32>> where 'max : 'min { // Previously OK, now an error as traits are invariant. v //~ ERROR mismatched types } -fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) - -> Box<Get<&'max i32>> +fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) + -> Box<dyn Get<&'max i32>> where 'max : 'min { v //~ ERROR mismatched types diff --git a/src/test/ui/variance/variance-covariant-arg-object.stderr b/src/test/ui/variance/variance-covariant-arg-object.stderr index cdcc7a6fd55..94f80c2b657 100644 --- a/src/test/ui/variance/variance-covariant-arg-object.stderr +++ b/src/test/ui/variance/variance-covariant-arg-object.stderr @@ -9,12 +9,12 @@ LL | v note: the lifetime 'min as defined on the function body at 10:21... --> $DIR/variance-covariant-arg-object.rs:10:21 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 10:27 --> $DIR/variance-covariant-arg-object.rs:10:27 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ^^^^ error[E0308]: mismatched types @@ -28,12 +28,12 @@ LL | v note: the lifetime 'min as defined on the function body at 18:21... --> $DIR/variance-covariant-arg-object.rs:18:21 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 18:27 --> $DIR/variance-covariant-arg-object.rs:18:27 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-invariant-arg-object.nll.stderr b/src/test/ui/variance/variance-invariant-arg-object.nll.stderr index 3c1ee7fc707..fe2f35b63b5 100644 --- a/src/test/ui/variance/variance-invariant-arg-object.nll.stderr +++ b/src/test/ui/variance/variance-invariant-arg-object.nll.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough --> $DIR/variance-invariant-arg-object.rs:11:5 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here @@ -12,7 +12,7 @@ LL | v error: lifetime may not live long enough --> $DIR/variance-invariant-arg-object.rs:18:5 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ---- ---- lifetime `'max` defined here | | | lifetime `'min` defined here diff --git a/src/test/ui/variance/variance-invariant-arg-object.rs b/src/test/ui/variance/variance-invariant-arg-object.rs index 91f5982e533..886d263c457 100644 --- a/src/test/ui/variance/variance-invariant-arg-object.rs +++ b/src/test/ui/variance/variance-invariant-arg-object.rs @@ -4,15 +4,15 @@ trait Get<T> : 'static { fn get(&self, t: T) -> T; } -fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) - -> Box<Get<&'min i32>> +fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) + -> Box<dyn Get<&'min i32>> where 'max : 'min { v //~ ERROR mismatched types } -fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) - -> Box<Get<&'max i32>> +fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) + -> Box<dyn Get<&'max i32>> where 'max : 'min { v //~ ERROR mismatched types diff --git a/src/test/ui/variance/variance-invariant-arg-object.stderr b/src/test/ui/variance/variance-invariant-arg-object.stderr index e2ee35de1a2..50a8697d439 100644 --- a/src/test/ui/variance/variance-invariant-arg-object.stderr +++ b/src/test/ui/variance/variance-invariant-arg-object.stderr @@ -9,12 +9,12 @@ LL | v note: the lifetime 'min as defined on the function body at 7:21... --> $DIR/variance-invariant-arg-object.rs:7:21 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 7:27 --> $DIR/variance-invariant-arg-object.rs:7:27 | -LL | fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>) +LL | fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>) | ^^^^ error[E0308]: mismatched types @@ -28,12 +28,12 @@ LL | v note: the lifetime 'min as defined on the function body at 14:21... --> $DIR/variance-invariant-arg-object.rs:14:21 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ^^^^ note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 14:27 --> $DIR/variance-invariant-arg-object.rs:14:27 | -LL | fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>) +LL | fn get_max_from_min<'min, 'max, G>(v: Box<dyn Get<&'min i32>>) | ^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-object-types.rs b/src/test/ui/variance/variance-object-types.rs index 12af7ae8c5b..14e11f681b1 100644 --- a/src/test/ui/variance/variance-object-types.rs +++ b/src/test/ui/variance/variance-object-types.rs @@ -9,7 +9,7 @@ use std::cell::Cell; // get an invariant result for `'a`. #[rustc_variance] struct Foo<'a> { //~ ERROR [o] - x: Box<Fn(i32) -> &'a i32 + 'static> + x: Box<dyn Fn(i32) -> &'a i32 + 'static> } fn main() { diff --git a/src/test/ui/variance/variance-object-types.stderr b/src/test/ui/variance/variance-object-types.stderr index be94a727a8d..d97d222e711 100644 --- a/src/test/ui/variance/variance-object-types.stderr +++ b/src/test/ui/variance/variance-object-types.stderr @@ -2,7 +2,7 @@ error[E0208]: [o] --> $DIR/variance-object-types.rs:11:1 | LL | / struct Foo<'a> { -LL | | x: Box<Fn(i32) -> &'a i32 + 'static> +LL | | x: Box<dyn Fn(i32) -> &'a i32 + 'static> LL | | } | |_^ diff --git a/src/test/ui/variance/variance-trait-object-bound.rs b/src/test/ui/variance/variance-trait-object-bound.rs index ada93b7f6ef..ec3c973bc76 100644 --- a/src/test/ui/variance/variance-trait-object-bound.rs +++ b/src/test/ui/variance/variance-trait-object-bound.rs @@ -12,7 +12,7 @@ trait T { fn foo(&self); } #[rustc_variance] struct TOption<'a> { //~ ERROR [-] - v: Option<Box<T + 'a>>, + v: Option<Box<dyn T + 'a>>, } fn main() { } diff --git a/src/test/ui/variance/variance-trait-object-bound.stderr b/src/test/ui/variance/variance-trait-object-bound.stderr index 503c087fb4d..fb0fab1950c 100644 --- a/src/test/ui/variance/variance-trait-object-bound.stderr +++ b/src/test/ui/variance/variance-trait-object-bound.stderr @@ -2,7 +2,7 @@ error[E0208]: [-] --> $DIR/variance-trait-object-bound.rs:14:1 | LL | / struct TOption<'a> { -LL | | v: Option<Box<T + 'a>>, +LL | | v: Option<Box<dyn T + 'a>>, LL | | } | |_^ diff --git a/src/test/ui/variance/variance-types-bounds.rs b/src/test/ui/variance/variance-types-bounds.rs index 5cbda10fbde..d1814dd97a0 100644 --- a/src/test/ui/variance/variance-types-bounds.rs +++ b/src/test/ui/variance/variance-types-bounds.rs @@ -36,8 +36,8 @@ trait Setter<A> { #[rustc_variance] struct TestObject<A, R> { //~ ERROR [o, o] - n: Box<Setter<A>+Send>, - m: Box<Getter<R>+Send>, + n: Box<dyn Setter<A>+Send>, + m: Box<dyn Getter<R>+Send>, } fn main() {} diff --git a/src/test/ui/variance/variance-types-bounds.stderr b/src/test/ui/variance/variance-types-bounds.stderr index 8e3e0515aec..5cffdffc7f2 100644 --- a/src/test/ui/variance/variance-types-bounds.stderr +++ b/src/test/ui/variance/variance-types-bounds.stderr @@ -37,8 +37,8 @@ error[E0208]: [o, o] --> $DIR/variance-types-bounds.rs:38:1 | LL | / struct TestObject<A, R> { -LL | | n: Box<Setter<A>+Send>, -LL | | m: Box<Getter<R>+Send>, +LL | | n: Box<dyn Setter<A>+Send>, +LL | | m: Box<dyn Getter<R>+Send>, LL | | } | |_^ diff --git a/src/test/ui/wf/wf-in-obj-type-static.rs b/src/test/ui/wf/wf-in-obj-type-static.rs index 858a75ab1ab..1ad2fd1edb3 100644 --- a/src/test/ui/wf/wf-in-obj-type-static.rs +++ b/src/test/ui/wf/wf-in-obj-type-static.rs @@ -11,7 +11,7 @@ struct MustBeCopy<T:Copy> { struct Foo<T> { // needs T: 'static - x: Object<&'static T> //~ ERROR E0310 + x: dyn Object<&'static T> //~ ERROR E0310 } diff --git a/src/test/ui/wf/wf-in-obj-type-static.stderr b/src/test/ui/wf/wf-in-obj-type-static.stderr index cc06b9243f7..c461da76a25 100644 --- a/src/test/ui/wf/wf-in-obj-type-static.stderr +++ b/src/test/ui/wf/wf-in-obj-type-static.stderr @@ -4,14 +4,14 @@ error[E0310]: the parameter type `T` may not live long enough LL | struct Foo<T> { | - help: consider adding an explicit lifetime bound `T: 'static`... LL | // needs T: 'static -LL | x: Object<&'static T> - | ^^^^^^^^^^^^^^^^^^^^^ +LL | x: dyn Object<&'static T> + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'static T` does not outlive the data it points at --> $DIR/wf-in-obj-type-static.rs:14:5 | -LL | x: Object<&'static T> - | ^^^^^^^^^^^^^^^^^^^^^ +LL | x: dyn Object<&'static T> + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/wf/wf-in-obj-type-trait.rs b/src/test/ui/wf/wf-in-obj-type-trait.rs index fad1da199ea..170fad55f8f 100644 --- a/src/test/ui/wf/wf-in-obj-type-trait.rs +++ b/src/test/ui/wf/wf-in-obj-type-trait.rs @@ -8,7 +8,7 @@ struct MustBeCopy<T:Copy> { struct Bar<T> { // needs T: Copy - x: Object<MustBeCopy<T>> //~ ERROR E0277 + x: dyn Object<MustBeCopy<T>> //~ ERROR E0277 } fn main() { } diff --git a/src/test/ui/wf/wf-in-obj-type-trait.stderr b/src/test/ui/wf/wf-in-obj-type-trait.stderr index 94b3de78898..2c85dd042e7 100644 --- a/src/test/ui/wf/wf-in-obj-type-trait.stderr +++ b/src/test/ui/wf/wf-in-obj-type-trait.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-obj-type-trait.rs:11:5 | -LL | x: Object<MustBeCopy<T>> - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` +LL | x: dyn Object<MustBeCopy<T>> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | = help: consider adding a `where T: std::marker::Copy` bound note: required by `MustBeCopy` diff --git a/src/test/ui/wf/wf-object-safe.rs b/src/test/ui/wf/wf-object-safe.rs index 08f68f6c004..42e6917551f 100644 --- a/src/test/ui/wf/wf-object-safe.rs +++ b/src/test/ui/wf/wf-object-safe.rs @@ -6,5 +6,5 @@ trait A { } fn main() { - let _x: &A; //~ ERROR E0038 + let _x: &dyn A; //~ ERROR E0038 } diff --git a/src/test/ui/wf/wf-object-safe.stderr b/src/test/ui/wf/wf-object-safe.stderr index 87e8105d4af..3b264ecd580 100644 --- a/src/test/ui/wf/wf-object-safe.stderr +++ b/src/test/ui/wf/wf-object-safe.stderr @@ -1,8 +1,8 @@ error[E0038]: the trait `A` cannot be made into an object --> $DIR/wf-object-safe.rs:9:13 | -LL | let _x: &A; - | ^^ the trait `A` cannot be made into an object +LL | let _x: &dyn A; + | ^^^^^^ the trait `A` cannot be made into an object | = note: method `foo` references the `Self` type in its arguments or return type diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs index ac95cbab1f7..85a332e244f 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs @@ -16,7 +16,7 @@ struct Foo<'a,T> { trait Baz<T> { } impl<'a, T> Trait<'a, T> for u32 { - type Out = &'a Baz<T>; //~ ERROR `T` may not live long enough + type Out = &'a dyn Baz<T>; //~ ERROR `T` may not live long enough } fn main() { } diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index 8649506c870..f1cf514e6b2 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -17,14 +17,14 @@ error[E0309]: the parameter type `T` may not live long enough | LL | impl<'a, T> Trait<'a, T> for u32 { | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = &'a Baz<T>; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | type Out = &'a dyn Baz<T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'a (dyn Baz<T> + 'a)` does not outlive the data it points at --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | -LL | type Out = &'a Baz<T>; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | type Out = &'a dyn Baz<T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/where-clauses/where-lifetime-resolution.rs b/src/test/ui/where-clauses/where-lifetime-resolution.rs index 4c46a77ae29..0d426386768 100644 --- a/src/test/ui/where-clauses/where-lifetime-resolution.rs +++ b/src/test/ui/where-clauses/where-lifetime-resolution.rs @@ -2,10 +2,10 @@ trait Trait1<'a> {} trait Trait2<'a, 'b> {} fn f() where - for<'a> Trait1<'a>: Trait1<'a>, // OK - (for<'a> Trait1<'a>): Trait1<'a>, + for<'a> dyn Trait1<'a>: Trait1<'a>, // OK + (dyn for<'a> Trait1<'a>): Trait1<'a>, //~^ ERROR use of undeclared lifetime name `'a` - for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, //~^ ERROR use of undeclared lifetime name `'b` //~| ERROR nested quantification of lifetimes {} diff --git a/src/test/ui/where-clauses/where-lifetime-resolution.stderr b/src/test/ui/where-clauses/where-lifetime-resolution.stderr index babf8efc23f..0081ae07163 100644 --- a/src/test/ui/where-clauses/where-lifetime-resolution.stderr +++ b/src/test/ui/where-clauses/where-lifetime-resolution.stderr @@ -1,20 +1,20 @@ error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/where-lifetime-resolution.rs:6:34 + --> $DIR/where-lifetime-resolution.rs:6:38 | -LL | (for<'a> Trait1<'a>): Trait1<'a>, - | ^^ undeclared lifetime +LL | (dyn for<'a> Trait1<'a>): Trait1<'a>, + | ^^ undeclared lifetime error[E0316]: nested quantification of lifetimes - --> $DIR/where-lifetime-resolution.rs:8:13 + --> $DIR/where-lifetime-resolution.rs:8:17 | -LL | for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/where-lifetime-resolution.rs:8:48 + --> $DIR/where-lifetime-resolution.rs:8:52 | -LL | for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, - | ^^ undeclared lifetime +LL | for<'a> dyn for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>, + | ^^ undeclared lifetime error: aborting due to 3 previous errors |
