Update ui test suite to use dyn
This commit is contained in:
parent
a1d1d7a2c6
commit
eb4580a570
529 changed files with 1620 additions and 1605 deletions
|
@ -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(&(), &())) {}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -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`
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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`
|
||||
}
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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(|_| ()));
|
||||
}
|
||||
|
|
|
@ -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!()
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn with_int(f: &mut FnMut(&isize)) {
|
||||
fn with_int(f: &mut dyn FnMut(&isize)) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn foo() -> Box<Fn()> {
|
||||
fn foo() -> Box<dyn Fn()> {
|
||||
let num = 5;
|
||||
|
||||
let closure = || { //~ ERROR expected a closure that
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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() { }
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
trait Foo { }
|
||||
|
||||
type Bar = Foo;
|
||||
type Bar = dyn Foo;
|
||||
|
|
|
@ -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) -> _>>;
|
||||
}
|
||||
|
|
|
@ -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) -> _>`
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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() { }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
struct Example {
|
||||
example: Box<Fn(i32) -> i32>
|
||||
example: Box<dyn Fn(i32) -> i32>
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// compile-pass
|
||||
|
||||
pub const STATIC_TRAIT: &Test = &();
|
||||
pub const STATIC_TRAIT: &dyn Test = &();
|
||||
|
||||
fn main() {}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()) {}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>`
|
||||
}
|
||||
|
|
|
@ -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>`
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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<_>`
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(bare_trait_objects)]
|
||||
|
||||
trait Foo {}
|
||||
|
||||
struct Bar<'a> {
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(bare_trait_objects)]
|
||||
|
||||
fn main() {
|
||||
let _: &Copy + 'static; //~ ERROR expected a path
|
||||
//~^ ERROR cannot be made into an object
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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`
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,)`
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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`
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue