Rollup merge of #141439 - compiler-errors:dyn-compatible-coerce, r=oli-obk
Deduplicate dyn compatibility violations due to coercion Don't unnecessarily emit dyn compatibility violations due to coercion to a non-dyn-compatible target type. For us to even have that target type, we would have had to write `dyn Trait` somewhere in source, and that would have led to us *already* emitting a dyn compatibility violation when checking that user written type is WF. r? oli-obk
This commit is contained in:
commit
92b07de1ca
62 changed files with 73 additions and 767 deletions
|
|
@ -47,7 +47,7 @@ use rustc_infer::infer::relate::RelateResult;
|
|||
use rustc_infer::infer::{Coercion, DefineOpaqueTypes, InferOk, InferResult};
|
||||
use rustc_infer::traits::{
|
||||
IfExpressionCause, MatchExpressionArmCause, Obligation, PredicateObligation,
|
||||
PredicateObligations,
|
||||
PredicateObligations, SelectionError,
|
||||
};
|
||||
use rustc_middle::span_bug;
|
||||
use rustc_middle::ty::adjustment::{
|
||||
|
|
@ -677,7 +677,21 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
return Err(TypeError::Mismatch);
|
||||
}
|
||||
|
||||
// Dyn-compatibility violations or miscellaneous.
|
||||
Err(SelectionError::TraitDynIncompatible(_)) => {
|
||||
// Dyn compatibility errors in coercion will *always* be due to the
|
||||
// fact that the RHS of the coercion is a non-dyn compatible `dyn Trait`
|
||||
// writen in source somewhere (otherwise we will never have lowered
|
||||
// the dyn trait from HIR to middle).
|
||||
//
|
||||
// There's no reason to emit yet another dyn compatibility error,
|
||||
// especially since the span will differ slightly and thus not be
|
||||
// deduplicated at all!
|
||||
self.fcx.set_tainted_by_errors(
|
||||
self.fcx
|
||||
.dcx()
|
||||
.span_delayed_bug(self.cause.span, "dyn compatibility during coercion"),
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
let guar = self.err_ctxt().report_selection_error(
|
||||
obligation.clone(),
|
||||
|
|
|
|||
|
|
@ -24,24 +24,6 @@ LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output;
|
|||
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
|
||||
= help: consider moving `async_dispatch` to another trait
|
||||
|
||||
error[E0038]: the trait `AsyncTrait` is not dyn compatible
|
||||
--> $DIR/mut-is-pointer-like.rs:35:56
|
||||
|
|
||||
LL | let x: Pin<&mut dyn AsyncTrait<Output = ()>> = f;
|
||||
| ^ `AsyncTrait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/mut-is-pointer-like.rs:16:14
|
||||
|
|
||||
LL | trait AsyncTrait {
|
||||
| ---------- this trait is not dyn compatible...
|
||||
...
|
||||
LL | async fn async_dispatch(self: Pin<&mut Self>) -> Self::Output;
|
||||
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
|
||||
= help: consider moving `async_dispatch` to another trait
|
||||
= note: required for the cast from `Pin<&mut {async block@$DIR/mut-is-pointer-like.rs:32:32: 32:37}>` to `Pin<&mut dyn AsyncTrait<Output = ()>>`
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -7,24 +7,6 @@ LL | #![feature(async_fn_in_dyn_trait)]
|
|||
= note: see issue #133119 <https://github.com/rust-lang/rust/issues/133119> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0038]: the trait `AsyncTrait` is not dyn compatible
|
||||
--> $DIR/works.rs:27:34
|
||||
|
|
||||
LL | let x: &dyn AsyncTrait = &"hello, world!";
|
||||
| ^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/works.rs:14:14
|
||||
|
|
||||
LL | trait AsyncTrait {
|
||||
| ---------- this trait is not dyn compatible...
|
||||
LL | async fn async_dispatch(&self);
|
||||
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
|
||||
= help: consider moving `async_dispatch` to another trait
|
||||
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
|
||||
= note: required for the cast from `&&'static str` to `&dyn AsyncTrait`
|
||||
|
||||
error[E0038]: the trait `AsyncTrait` is not dyn compatible
|
||||
--> $DIR/works.rs:27:16
|
||||
|
|
||||
|
|
@ -42,6 +24,6 @@ LL | async fn async_dispatch(&self);
|
|||
= help: consider moving `async_dispatch` to another trait
|
||||
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -7,24 +7,6 @@ LL | #![feature(async_fn_in_dyn_trait)]
|
|||
= note: see issue #133119 <https://github.com/rust-lang/rust/issues/133119> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0038]: the trait `AsyncTrait` is not dyn compatible
|
||||
--> $DIR/wrong-size.rs:21:30
|
||||
|
|
||||
LL | let x: &dyn AsyncTrait = &"hello, world!";
|
||||
| ^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/wrong-size.rs:9:14
|
||||
|
|
||||
LL | trait AsyncTrait {
|
||||
| ---------- this trait is not dyn compatible...
|
||||
LL | async fn async_dispatch(&self);
|
||||
| ^^^^^^^^^^^^^^ ...because method `async_dispatch` is `async`
|
||||
= help: consider moving `async_dispatch` to another trait
|
||||
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
|
||||
= note: required for the cast from `&&'static str` to `&dyn AsyncTrait`
|
||||
|
||||
error[E0038]: the trait `AsyncTrait` is not dyn compatible
|
||||
--> $DIR/wrong-size.rs:21:12
|
||||
|
|
||||
|
|
@ -42,6 +24,6 @@ LL | async fn async_dispatch(&self);
|
|||
= help: consider moving `async_dispatch` to another trait
|
||||
= help: only type `&'static str` implements `AsyncTrait`; consider using it directly instead.
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use std::marker::PhantomData;
|
|||
fn transmute<T, U>(t: T) -> U {
|
||||
(&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
|
||||
//~^ ERROR the trait `Foo` is not dyn compatible
|
||||
//~| ERROR the trait `Foo` is not dyn compatible
|
||||
}
|
||||
|
||||
struct ActuallySuper;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/almost-supertrait-associated-type.rs:21:20
|
||||
--> $DIR/almost-supertrait-associated-type.rs:20:20
|
||||
|
|
||||
LL | impl<T, U> Dyn for dyn Foo<T, U> + '_ {
|
||||
| ^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
||||
--> $DIR/almost-supertrait-associated-type.rs:32:34
|
||||
|
|
||||
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
|
||||
| --- this trait is not dyn compatible...
|
||||
|
|
@ -23,7 +23,7 @@ LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
|
|||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
||||
--> $DIR/almost-supertrait-associated-type.rs:32:34
|
||||
|
|
||||
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
|
||||
| --- this trait is not dyn compatible...
|
||||
|
|
@ -32,24 +32,6 @@ LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
|
||||
= help: consider moving `transmute` to another trait
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/almost-supertrait-associated-type.rs:7:6
|
||||
|
|
||||
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
|
||||
| ^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/almost-supertrait-associated-type.rs:33:34
|
||||
|
|
||||
LL | trait Foo<T, U>: Super<ActuallySuper, Assoc = T>
|
||||
| --- this trait is not dyn compatible...
|
||||
...
|
||||
LL | fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `transmute` references the `Self` type in its return type
|
||||
= help: consider moving `transmute` to another trait
|
||||
= note: required for the cast from `&PhantomData<T>` to `&dyn Foo<T, U>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ trait Bar {
|
|||
fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
//~^ ERROR E0038
|
||||
t
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -14,23 +14,6 @@ LL | const X: usize;
|
|||
| ^ ...because it contains this associated `const`
|
||||
= help: consider moving `X` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/associated-consts.rs:10:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/associated-consts.rs:5:11
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | const X: usize;
|
||||
| ^ ...because it contains this associated `const`
|
||||
= help: consider moving `X` to another trait
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -15,14 +15,12 @@ trait Quux {
|
|||
fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
//~^ ERROR E0038
|
||||
t
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
|
||||
fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
|
||||
//~^ ERROR E0038
|
||||
t as &dyn Bar
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
}
|
||||
|
||||
fn make_quux<T:Quux>(t: &T) -> &dyn Quux {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ LL | fn bar<T>(&self, t: T);
|
|||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/generics.rs:21:40
|
||||
--> $DIR/generics.rs:20:40
|
||||
|
|
||||
LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar {
|
||||
| ^^^^^^^ `Bar` is not dyn compatible
|
||||
|
|
@ -31,24 +31,7 @@ LL | fn bar<T>(&self, t: T);
|
|||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/generics.rs:17:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/generics.rs:7:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn bar<T>(&self, t: T);
|
||||
| ^^^ ...because method `bar` has generic type parameters
|
||||
= help: consider moving `bar` to another trait
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/generics.rs:23:10
|
||||
--> $DIR/generics.rs:22:10
|
||||
|
|
||||
LL | t as &dyn Bar
|
||||
| ^^^^^^^^ `Bar` is not dyn compatible
|
||||
|
|
@ -63,23 +46,6 @@ LL | fn bar<T>(&self, t: T);
|
|||
| ^^^ ...because method `bar` has generic type parameters
|
||||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/generics.rs:23:5
|
||||
|
|
||||
LL | t as &dyn Bar
|
||||
| ^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/generics.rs:7:8
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn bar<T>(&self, t: T);
|
||||
| ^^^ ...because method `bar` has generic type parameters
|
||||
= help: consider moving `bar` to another trait
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -18,5 +18,4 @@ fn main() {
|
|||
let mut thing = Thing;
|
||||
let test: &mut dyn Bar = &mut thing;
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,3 @@
|
|||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:30
|
||||
|
|
||||
LL | let test: &mut dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/mention-correct-dyn-incompatible-trait.rs:4:8
|
||||
|
|
||||
LL | fn foo<T>(&self, val: T);
|
||||
| ^^^ ...because method `foo` has generic type parameters
|
||||
...
|
||||
LL | trait Bar: Foo { }
|
||||
| --- this trait is not dyn compatible...
|
||||
= help: consider moving `foo` to another trait
|
||||
= help: only type `Thing` implements `Bar`; consider using it directly instead.
|
||||
= note: required for the cast from `&mut Thing` to `&mut dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/mention-correct-dyn-incompatible-trait.rs:19:15
|
||||
|
|
||||
|
|
@ -35,6 +16,6 @@ LL | trait Bar: Foo { }
|
|||
= help: consider moving `foo` to another trait
|
||||
= help: only type `Thing` implements `Bar`; consider using it directly instead.
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -18,13 +18,11 @@ trait Quux {
|
|||
fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
//~^ ERROR E0038
|
||||
t
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
|
||||
fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
|
||||
//~^ ERROR E0038
|
||||
t
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
|
||||
fn make_quux<T:Quux>(t: &T) -> &dyn Quux {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ LL | fn bar(&self, x: &Self);
|
|||
= help: consider moving `bar` to another trait
|
||||
|
||||
error[E0038]: the trait `Baz` is not dyn compatible
|
||||
--> $DIR/mentions-Self.rs:24:31
|
||||
--> $DIR/mentions-Self.rs:23:31
|
||||
|
|
||||
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
|
||||
| ^^^^^^^ `Baz` is not dyn compatible
|
||||
|
|
@ -30,40 +30,6 @@ LL | fn baz(&self) -> Self;
|
|||
| ^^^^ ...because method `baz` references the `Self` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/mentions-Self.rs:20:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/mentions-Self.rs:7:22
|
||||
|
|
||||
LL | trait Bar {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn bar(&self, x: &Self);
|
||||
| ^^^^^ ...because method `bar` references the `Self` type in this parameter
|
||||
= help: consider moving `bar` to another trait
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Baz` is not dyn compatible
|
||||
--> $DIR/mentions-Self.rs:26:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Baz` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/mentions-Self.rs:11:22
|
||||
|
|
||||
LL | trait Baz {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn baz(&self) -> Self;
|
||||
| ^^^^ ...because method `baz` references the `Self` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
= note: required for the cast from `&T` to `&dyn Baz`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -17,5 +17,4 @@ impl Foo for Bar {}
|
|||
fn main() {
|
||||
let b: Box<dyn Foo> = Box::new(Bar);
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,31 +46,6 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
|
|||
LL | fn foo() where Self: Sized {}
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/no-static.rs:18:27
|
||||
|
|
||||
LL | let b: Box<dyn Foo> = Box::new(Bar);
|
||||
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/no-static.rs:5:8
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn foo() {}
|
||||
| ^^^ ...because associated function `foo` has no `self` parameter
|
||||
= help: only type `Bar` implements `Foo`; consider using it directly instead.
|
||||
= note: required for the cast from `Box<Bar>` to `Box<dyn Foo>`
|
||||
help: consider turning `foo` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn foo(&self) {}
|
||||
| +++++
|
||||
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn foo() where Self: Sized {}
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ trait Bar
|
|||
fn make_bar<T:Bar>(t: &T) -> &dyn Bar {
|
||||
//~^ ERROR E0038
|
||||
t
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -13,22 +13,6 @@ LL | trait Bar
|
|||
LL | where Self : Sized
|
||||
| ^^^^^ ...because it requires `Self: Sized`
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/sized-2.rs:12:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/sized-2.rs:5:18
|
||||
|
|
||||
LL | trait Bar
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | where Self : Sized
|
||||
| ^^^^^ ...because it requires `Self: Sized`
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ trait Bar: Sized {
|
|||
fn make_bar<T: Bar>(t: &T) -> &dyn Bar {
|
||||
//~^ ERROR E0038
|
||||
t
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -13,22 +13,6 @@ LL | trait Bar: Sized {
|
|||
| |
|
||||
| this trait is not dyn compatible...
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/sized.rs:10:5
|
||||
|
|
||||
LL | t
|
||||
| ^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/sized.rs:4:12
|
||||
|
|
||||
LL | trait Bar: Sized {
|
||||
| --- ^^^^^ ...because it requires `Self: Sized`
|
||||
| |
|
||||
| this trait is not dyn compatible...
|
||||
= note: required for the cast from `&T` to `&dyn Bar`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,5 @@ trait Qux {
|
|||
static FOO: &(dyn Qux + Sync) = "desc";
|
||||
//~^ ERROR the trait `Qux` is not dyn compatible
|
||||
//~| ERROR the trait `Qux` is not dyn compatible
|
||||
//~| ERROR the trait `Qux` is not dyn compatible
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -21,30 +21,6 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o
|
|||
LL | fn bar() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Qux` is not dyn compatible
|
||||
--> $DIR/taint-const-eval.rs:7:33
|
||||
|
|
||||
LL | static FOO: &(dyn Qux + Sync) = "desc";
|
||||
| ^^^^^^ `Qux` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/taint-const-eval.rs:4:8
|
||||
|
|
||||
LL | trait Qux {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn bar();
|
||||
| ^^^ ...because associated function `bar` has no `self` parameter
|
||||
= note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)`
|
||||
help: consider turning `bar` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn bar(&self);
|
||||
| +++++
|
||||
help: alternatively, consider constraining `bar` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn bar() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Qux` is not dyn compatible
|
||||
--> $DIR/taint-const-eval.rs:7:15
|
||||
|
|
||||
|
|
@ -69,6 +45,6 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o
|
|||
LL | fn bar() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -31,5 +31,4 @@ impl Trait for i32 {
|
|||
fn main() {
|
||||
Ptr(Box::new(4)) as Ptr<dyn Trait>;
|
||||
//~^ ERROR the trait `Trait` is not dyn compatible
|
||||
//~^^ ERROR the trait `Trait` is not dyn compatible
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,26 +17,6 @@ LL | fn ptr(self: Ptr<Self>);
|
|||
| ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on
|
||||
= help: only type `i32` implements `Trait`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `Trait` is not dyn compatible
|
||||
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:5
|
||||
|
|
||||
LL | fn ptr(self: Ptr<Self>);
|
||||
| --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self`
|
||||
...
|
||||
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
|
||||
| ^^^^^^^^^^^^^^^^ `Trait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:25:18
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ----- this trait is not dyn compatible...
|
||||
LL | fn ptr(self: Ptr<Self>);
|
||||
| ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on
|
||||
= help: only type `i32` implements `Trait`; consider using it directly instead.
|
||||
= note: required for the cast from `Ptr<{integer}>` to `Ptr<dyn Trait>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -26,5 +26,4 @@ fn main() {
|
|||
let foo = Fooer(5);
|
||||
f(Box::new(foo));
|
||||
//~^ ERROR the trait `Foo` is not dyn compatible
|
||||
//~| ERROR the trait `Foo` is not dyn compatible
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,23 +30,6 @@ LL | type A<'a> where Self: 'a;
|
|||
| ^ ...because it contains the generic associated type `A`
|
||||
= help: consider moving `A` to another trait
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/gat-in-trait-path.rs:27:5
|
||||
|
|
||||
LL | f(Box::new(foo));
|
||||
| ^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/gat-in-trait-path.rs:6:10
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | type A<'a> where Self: 'a;
|
||||
| ^ ...because it contains the generic associated type `A`
|
||||
= help: consider moving `A` to another trait
|
||||
= note: required for the cast from `Box<Fooer<{integer}>>` to `Box<(dyn Foo<A<'a> = &'a ()> + 'static)>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,5 @@ fn main() {
|
|||
Holder {
|
||||
inner: Box::new(()),
|
||||
//~^ ERROR: the trait `Provider` is not dyn compatible
|
||||
//~| ERROR: the trait `Provider` is not dyn compatible
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,25 +82,7 @@ LL | type A<'a>;
|
|||
= help: consider moving `A` to another trait
|
||||
= help: only type `()` implements `Provider`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `Provider` is not dyn compatible
|
||||
--> $DIR/issue-71176.rs:19:16
|
||||
|
|
||||
LL | inner: Box::new(()),
|
||||
| ^^^^^^^^^^^^ `Provider` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-71176.rs:2:10
|
||||
|
|
||||
LL | trait Provider {
|
||||
| -------- this trait is not dyn compatible...
|
||||
LL | type A<'a>;
|
||||
| ^ ...because it contains the generic associated type `A`
|
||||
= help: consider moving `A` to another trait
|
||||
= help: only type `()` implements `Provider`; consider using it directly instead.
|
||||
= note: required for the cast from `Box<()>` to `Box<(dyn Provider<A<'_> = _> + 'static), {type error}>`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0107.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -33,6 +33,5 @@ impl SuperTrait for SuperStruct {
|
|||
fn main() {
|
||||
let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
|
||||
//~^ ERROR missing generics for associated type
|
||||
//~^^ ERROR the trait
|
||||
//~| ERROR the trait
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,26 +32,7 @@ LL | type SubType<'a>: SubTrait where Self: 'a;
|
|||
= help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead.
|
||||
= note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
|
||||
|
||||
error[E0038]: the trait `SuperTrait` is not dyn compatible
|
||||
--> $DIR/issue-76535.rs:34:57
|
||||
|
|
||||
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-76535.rs:4:10
|
||||
|
|
||||
LL | pub trait SuperTrait {
|
||||
| ---------- this trait is not dyn compatible...
|
||||
LL | type SubType<'a>: SubTrait where Self: 'a;
|
||||
| ^^^^^^^ ...because it contains the generic associated type `SubType`
|
||||
= help: consider moving `SubType` to another trait
|
||||
= help: only type `SuperStruct` implements `SuperTrait` within this crate; consider using it directly instead.
|
||||
= note: `SuperTrait` may be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type
|
||||
= note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType<'_> = SubStruct<'_>>>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0107.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -15,12 +15,17 @@ impl<'a, T> RefCont<'a, T> for Box<T> {
|
|||
}
|
||||
|
||||
trait MapLike<K, V> {
|
||||
type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
|
||||
type VRefCont<'a>: RefCont<'a, V>
|
||||
where
|
||||
Self: 'a;
|
||||
fn get<'a>(&'a self, key: &K) -> Option<Self::VRefCont<'a>>;
|
||||
}
|
||||
|
||||
impl<K: Ord, V: 'static> MapLike<K, V> for std::collections::BTreeMap<K, V> {
|
||||
type VRefCont<'a> = &'a V where Self: 'a;
|
||||
type VRefCont<'a>
|
||||
= &'a V
|
||||
where
|
||||
Self: 'a;
|
||||
fn get<'a>(&'a self, key: &K) -> Option<&'a V> {
|
||||
std::collections::BTreeMap::get(self, key)
|
||||
}
|
||||
|
|
@ -37,8 +42,7 @@ impl<K, V: Default> MapLike<K, V> for Source {
|
|||
|
||||
fn main() {
|
||||
let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
|
||||
//~^ ERROR the trait
|
||||
as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
|
||||
//~^ ERROR missing generics for associated type
|
||||
//~| ERROR the trait
|
||||
//~^ ERROR the trait
|
||||
//~| ERROR missing generics for associated type
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0107]: missing generics for associated type `MapLike::VRefCont`
|
||||
--> $DIR/issue-79422.rs:41:36
|
||||
--> $DIR/issue-79422.rs:45:36
|
||||
|
|
||||
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
|
||||
| ^^^^^^^^ expected 1 lifetime argument
|
||||
|
|
@ -7,7 +7,7 @@ LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
|
|||
note: associated type defined here, with 1 lifetime parameter: `'a`
|
||||
--> $DIR/issue-79422.rs:18:10
|
||||
|
|
||||
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
|
||||
LL | type VRefCont<'a>: RefCont<'a, V>
|
||||
| ^^^^^^^^ --
|
||||
help: add missing lifetime argument
|
||||
|
|
||||
|
|
@ -15,7 +15,7 @@ LL | as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>;
|
|||
| ++++
|
||||
|
||||
error[E0038]: the trait `MapLike` is not dyn compatible
|
||||
--> $DIR/issue-79422.rs:41:12
|
||||
--> $DIR/issue-79422.rs:45:12
|
||||
|
|
||||
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
|
||||
|
|
@ -26,28 +26,11 @@ note: for a trait to be dyn compatible it needs to allow building a vtable
|
|||
|
|
||||
LL | trait MapLike<K, V> {
|
||||
| ------- this trait is not dyn compatible...
|
||||
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
|
||||
LL | type VRefCont<'a>: RefCont<'a, V>
|
||||
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
|
||||
= help: consider moving `VRefCont` to another trait
|
||||
|
||||
error[E0038]: the trait `MapLike` is not dyn compatible
|
||||
--> $DIR/issue-79422.rs:39:13
|
||||
|
|
||||
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-79422.rs:18:10
|
||||
|
|
||||
LL | trait MapLike<K, V> {
|
||||
| ------- this trait is not dyn compatible...
|
||||
LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
|
||||
| ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
|
||||
= help: consider moving `VRefCont` to another trait
|
||||
= note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont<'_> = (dyn RefCont<'_, u8> + 'static)>>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0107.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ fn needs_bar(_: *mut Type2) {}
|
|||
fn main() {
|
||||
let x: &dyn Foo = &();
|
||||
//~^ ERROR the trait `Foo` is not dyn compatible
|
||||
//~| ERROR the trait `Foo` is not dyn compatible
|
||||
|
||||
needs_bar(x);
|
||||
//~^ ERROR mismatched types
|
||||
|
|
|
|||
|
|
@ -1,19 +1,3 @@
|
|||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/span-bug-issue-121597.rs:14:23
|
||||
|
|
||||
LL | let x: &dyn Foo = &();
|
||||
| ^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/span-bug-issue-121597.rs:4:12
|
||||
|
|
||||
LL | trait Foo: for<T> Bar<T> {}
|
||||
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
|
||||
| |
|
||||
| this trait is not dyn compatible...
|
||||
= note: required for the cast from `&()` to `&dyn Foo`
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/span-bug-issue-121597.rs:14:12
|
||||
|
|
||||
|
|
@ -30,7 +14,7 @@ LL | trait Foo: for<T> Bar<T> {}
|
|||
| this trait is not dyn compatible...
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/span-bug-issue-121597.rs:18:15
|
||||
--> $DIR/span-bug-issue-121597.rs:17:15
|
||||
|
|
||||
LL | needs_bar(x);
|
||||
| --------- ^ types differ in mutability
|
||||
|
|
@ -45,7 +29,7 @@ note: function defined here
|
|||
LL | fn needs_bar(_: *mut Type2) {}
|
||||
| ^^^^^^^^^ -------------
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0308.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` is not d
|
|||
|
||||
fn cat() -> Box<dyn DynIncompatible> { //~ ERROR the trait `DynIncompatible` is not dyn compatible
|
||||
if true {
|
||||
return Box::new(A); //~ ERROR is not dyn compatible
|
||||
return Box::new(A);
|
||||
}
|
||||
Box::new(B) //~ ERROR is not dyn compatible
|
||||
Box::new(B)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -75,65 +75,7 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
|
|||
LL | fn foo() -> Self where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `DynIncompatible` is not dyn compatible
|
||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:16
|
||||
|
|
||||
LL | return Box::new(A);
|
||||
| ^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8
|
||||
|
|
||||
LL | trait DynIncompatible {
|
||||
| --------------- this trait is not dyn compatible...
|
||||
LL | fn foo() -> Self;
|
||||
| ^^^ ...because associated function `foo` has no `self` parameter
|
||||
= help: the following types implement `DynIncompatible`:
|
||||
A
|
||||
B
|
||||
consider defining an enum where each variant holds one of these types,
|
||||
implementing `DynIncompatible` for this new enum and using it instead
|
||||
= note: required for the cast from `Box<A>` to `Box<(dyn DynIncompatible + 'static)>`
|
||||
help: consider turning `foo` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn foo(&self) -> Self;
|
||||
| +++++
|
||||
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn foo() -> Self where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `DynIncompatible` is not dyn compatible
|
||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:34:5
|
||||
|
|
||||
LL | Box::new(B)
|
||||
| ^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8
|
||||
|
|
||||
LL | trait DynIncompatible {
|
||||
| --------------- this trait is not dyn compatible...
|
||||
LL | fn foo() -> Self;
|
||||
| ^^^ ...because associated function `foo` has no `self` parameter
|
||||
= help: the following types implement `DynIncompatible`:
|
||||
A
|
||||
B
|
||||
consider defining an enum where each variant holds one of these types,
|
||||
implementing `DynIncompatible` for this new enum and using it instead
|
||||
= note: required for the cast from `Box<B>` to `Box<(dyn DynIncompatible + 'static)>`
|
||||
help: consider turning `foo` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn foo(&self) -> Self;
|
||||
| +++++
|
||||
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn foo() -> Self where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0746.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -13,6 +13,5 @@ impl Foo for u32 {
|
|||
fn main() {
|
||||
let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||
//~^ ERROR the trait `Foo` is not dyn compatible
|
||||
//~| ERROR the trait `Foo` is not dyn compatible
|
||||
let s = i.baz();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,24 +15,6 @@ LL | fn baz(&self) -> impl Debug;
|
|||
= help: consider moving `baz` to another trait
|
||||
= help: only type `u32` implements `Foo`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/dyn-compatibility.rs:14:13
|
||||
|
|
||||
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||
| ^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/dyn-compatibility.rs:4:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn baz(&self) -> impl Debug;
|
||||
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
= help: only type `u32` implements `Foo`; consider using it directly instead.
|
||||
= note: required for the cast from `Box<u32>` to `Box<dyn Foo>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -17,6 +17,5 @@ fn main() {
|
|||
let mut thing = Thing;
|
||||
let test: &dyn Bar = &mut thing;
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
foo(test);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,23 +14,6 @@ LL | pub trait Bar: Foo { }
|
|||
| --- this trait is not dyn compatible...
|
||||
= help: consider moving `foo` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/issue-18959.rs:18:26
|
||||
|
|
||||
LL | let test: &dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^ `Bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-18959.rs:1:20
|
||||
|
|
||||
LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
||||
| ^^^ ...because method `foo` has generic type parameters
|
||||
LL | pub trait Bar: Foo { }
|
||||
| --- this trait is not dyn compatible...
|
||||
= help: consider moving `foo` to another trait
|
||||
= note: required for the cast from `&mut Thing` to `&dyn Bar`
|
||||
|
||||
error[E0038]: the trait `Bar` is not dyn compatible
|
||||
--> $DIR/issue-18959.rs:18:15
|
||||
|
|
||||
|
|
@ -47,6 +30,6 @@ LL | pub trait Bar: Foo { }
|
|||
| --- this trait is not dyn compatible...
|
||||
= help: consider moving `foo` to another trait
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,5 @@ struct Bar {
|
|||
const FOO : Foo = Foo;
|
||||
const BAR : Bar = Bar { foos: &[&FOO]};
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -22,31 +22,6 @@ help: alternatively, consider constraining `qiz` so it does not apply to trait o
|
|||
LL | fn qiz() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Qiz` is not dyn compatible
|
||||
--> $DIR/issue-19380.rs:16:33
|
||||
|
|
||||
LL | const BAR : Bar = Bar { foos: &[&FOO]};
|
||||
| ^^^^ `Qiz` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-19380.rs:2:6
|
||||
|
|
||||
LL | trait Qiz {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn qiz();
|
||||
| ^^^ ...because associated function `qiz` has no `self` parameter
|
||||
= help: only type `Foo` implements `Qiz`; consider using it directly instead.
|
||||
= note: required for the cast from `&Foo` to `&'static (dyn Qiz + 'static)`
|
||||
help: consider turning `qiz` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn qiz(&self);
|
||||
| +++++
|
||||
help: alternatively, consider constraining `qiz` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn qiz() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Qiz` is not dyn compatible
|
||||
--> $DIR/issue-19380.rs:16:31
|
||||
|
|
||||
|
|
@ -71,6 +46,6 @@ help: alternatively, consider constraining `qiz` so it does not apply to trait o
|
|||
LL | fn qiz() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -15,5 +15,4 @@ pub fn main() {
|
|||
// Check that this does not segfault.
|
||||
<dyn X as X>::foo(&());
|
||||
//~^ ERROR the trait `X` is not dyn compatible
|
||||
//~| ERROR the trait `X` is not dyn compatible
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,24 +15,6 @@ LL | fn foo(&self) where Self: Trait;
|
|||
= help: consider moving `foo` to another trait
|
||||
= help: only type `()` implements `X`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `X` is not dyn compatible
|
||||
--> $DIR/issue-50781.rs:16:23
|
||||
|
|
||||
LL | <dyn X as X>::foo(&());
|
||||
| ^^^ `X` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-50781.rs:4:8
|
||||
|
|
||||
LL | trait X {
|
||||
| - this trait is not dyn compatible...
|
||||
LL | fn foo(&self) where Self: Trait;
|
||||
| ^^^ ...because method `foo` references the `Self` type in its `where` clause
|
||||
= help: consider moving `foo` to another trait
|
||||
= help: only type `()` implements `X`; consider using it directly instead.
|
||||
= note: required for the cast from `&()` to `&dyn X`
|
||||
|
||||
error[E0038]: the trait `X` is not dyn compatible
|
||||
--> $DIR/issue-50781.rs:16:6
|
||||
|
|
||||
|
|
@ -50,6 +32,6 @@ LL | fn foo(&self) where Self: Trait;
|
|||
= help: consider moving `foo` to another trait
|
||||
= help: only type `()` implements `X`; consider using it directly instead.
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ fn b() {
|
|||
let y = &x;
|
||||
let z = &x as &dyn Foo;
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -34,23 +34,7 @@ LL | trait Foo : Copy {
|
|||
| |
|
||||
| this trait is not dyn compatible...
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/kindck-inherited-copy-bound.rs:23:13
|
||||
|
|
||||
LL | let z = &x as &dyn Foo;
|
||||
| ^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/kindck-inherited-copy-bound.rs:6:13
|
||||
|
|
||||
LL | trait Foo : Copy {
|
||||
| --- ^^^^ ...because it requires `Self: Sized`
|
||||
| |
|
||||
| this trait is not dyn compatible...
|
||||
= note: required for the cast from `&Box<{integer}>` to `&dyn Foo`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0277.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ impl Bar for usize {
|
|||
fn make_foo() {
|
||||
let x = Rc::new(5usize) as Rc<dyn Foo>;
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
}
|
||||
|
||||
fn make_bar() {
|
||||
|
|
|
|||
|
|
@ -17,26 +17,6 @@ LL | fn foo(self: &Rc<Self>) -> usize;
|
|||
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
|
||||
= help: only type `usize` implements `Foo`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:13
|
||||
|
|
||||
LL | fn foo(self: &Rc<Self>) -> usize;
|
||||
| --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self`
|
||||
...
|
||||
LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
|
||||
| ^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/arbitrary-self-types-dyn-incompatible.rs:4:18
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn foo(self: &Rc<Self>) -> usize;
|
||||
| ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
|
||||
= help: only type `usize` implements `Foo`; consider using it directly instead.
|
||||
= note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -12,6 +12,5 @@ pub struct Lint {
|
|||
static FOO: &Lint = &Lint { desc: "desc" };
|
||||
//~^ ERROR cannot be shared between threads safely
|
||||
//~| ERROR is not dyn compatible
|
||||
//~| ERROR is not dyn compatible
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ LL | trait Qux {
|
|||
| --- this trait is not dyn compatible...
|
||||
LL | fn bar() -> i32;
|
||||
| ^^^ ...because associated function `bar` has no `self` parameter
|
||||
= note: required for the cast from `&'static str` to `&'static (dyn Qux + 'static)`
|
||||
help: consider turning `bar` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn bar(&self) -> i32;
|
||||
|
|
@ -61,30 +60,7 @@ help: alternatively, consider constraining `bar` so it does not apply to trait o
|
|||
LL | fn bar() -> i32 where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Qux` is not dyn compatible
|
||||
--> $DIR/unsizing-wfcheck-issue-127299.rs:12:35
|
||||
|
|
||||
LL | static FOO: &Lint = &Lint { desc: "desc" };
|
||||
| ^^^^^^ `Qux` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/unsizing-wfcheck-issue-127299.rs:4:8
|
||||
|
|
||||
LL | trait Qux {
|
||||
| --- this trait is not dyn compatible...
|
||||
LL | fn bar() -> i32;
|
||||
| ^^^ ...because associated function `bar` has no `self` parameter
|
||||
help: consider turning `bar` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn bar(&self) -> i32;
|
||||
| +++++
|
||||
help: alternatively, consider constraining `bar` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn bar() -> i32 where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0277.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ trait Array: Sized + Copy {}
|
|||
|
||||
fn f<T: Array>(x: &T) {
|
||||
let _ = x
|
||||
//~^ ERROR `Array` is not dyn compatible
|
||||
as
|
||||
&dyn Array;
|
||||
//~^ ERROR `Array` is not dyn compatible
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0038]: the trait `Array` is not dyn compatible
|
||||
--> $DIR/issue-20692.rs:7:5
|
||||
--> $DIR/issue-20692.rs:6:5
|
||||
|
|
||||
LL | &dyn Array;
|
||||
| ^^^^^^^^^^ `Array` is not dyn compatible
|
||||
|
|
@ -14,23 +14,6 @@ LL | trait Array: Sized + Copy {}
|
|||
| | ...because it requires `Self: Sized`
|
||||
| this trait is not dyn compatible...
|
||||
|
||||
error[E0038]: the trait `Array` is not dyn compatible
|
||||
--> $DIR/issue-20692.rs:4:13
|
||||
|
|
||||
LL | let _ = x
|
||||
| ^ `Array` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-20692.rs:1:14
|
||||
|
|
||||
LL | trait Array: Sized + Copy {}
|
||||
| ----- ^^^^^ ^^^^ ...because it requires `Self: Sized`
|
||||
| | |
|
||||
| | ...because it requires `Self: Sized`
|
||||
| this trait is not dyn compatible...
|
||||
= note: required for the cast from `&T` to `&dyn Array`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ impl Foo for () {
|
|||
|
||||
fn main() {
|
||||
let _f: Box<dyn Foo> = //~ ERROR `Foo` is not dyn compatible
|
||||
Box::new(()); //~ ERROR `Foo` is not dyn compatible
|
||||
Box::new(());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,23 +14,6 @@ LL | trait Foo where u32: Q<Self> {
|
|||
| this trait is not dyn compatible...
|
||||
= help: only type `()` implements `Foo`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/issue-38604.rs:15:9
|
||||
|
|
||||
LL | Box::new(());
|
||||
| ^^^^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/issue-38604.rs:2:22
|
||||
|
|
||||
LL | trait Foo where u32: Q<Self> {
|
||||
| --- ^^^^^^^ ...because it uses `Self` as a type parameter
|
||||
| |
|
||||
| this trait is not dyn compatible...
|
||||
= help: only type `()` implements `Foo`; consider using it directly instead.
|
||||
= note: required for the cast from `Box<()>` to `Box<dyn Foo>`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ impl<T: ?Sized> Bar<T> for () {}
|
|||
fn main() {
|
||||
let x: &dyn Foo = &();
|
||||
//~^ ERROR the trait `Foo` is not dyn compatible
|
||||
//~| ERROR the trait `Foo` is not dyn compatible
|
||||
needs_bar(x);
|
||||
//~^ ERROR the trait `Foo` is not dyn compatible
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,23 +7,6 @@ LL | #![feature(non_lifetime_binders)]
|
|||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/supertrait-dyn-compatibility.rs:19:23
|
||||
|
|
||||
LL | let x: &dyn Foo = &();
|
||||
| ^^^ `Foo` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/supertrait-dyn-compatibility.rs:4:12
|
||||
|
|
||||
LL | trait Foo: for<T> Bar<T> {}
|
||||
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
|
||||
| |
|
||||
| this trait is not dyn compatible...
|
||||
= help: only type `()` implements `Foo`; consider using it directly instead.
|
||||
= note: required for the cast from `&()` to `&dyn Foo`
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/supertrait-dyn-compatibility.rs:19:12
|
||||
|
|
||||
|
|
@ -41,7 +24,7 @@ LL | trait Foo: for<T> Bar<T> {}
|
|||
= help: only type `()` implements `Foo`; consider using it directly instead.
|
||||
|
||||
error[E0038]: the trait `Foo` is not dyn compatible
|
||||
--> $DIR/supertrait-dyn-compatibility.rs:22:5
|
||||
--> $DIR/supertrait-dyn-compatibility.rs:21:5
|
||||
|
|
||||
LL | needs_bar(x);
|
||||
| ^^^^^^^^^ `Foo` is not dyn compatible
|
||||
|
|
@ -56,6 +39,6 @@ LL | trait Foo: for<T> Bar<T> {}
|
|||
| this trait is not dyn compatible...
|
||||
= help: only type `()` implements `Foo`; consider using it directly instead.
|
||||
|
||||
error: aborting due to 3 previous errors; 1 warning emitted
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ trait Try {
|
|||
fn w<'a, T: 'a, F: Fn(&'a T)>() {
|
||||
let b: &dyn FromResidual = &();
|
||||
//~^ ERROR: the trait `FromResidual` is not dyn compatible
|
||||
//~| ERROR: the trait `FromResidual` is not dyn compatible
|
||||
//~| ERROR the type parameter `R` must be explicitly specified
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,30 +13,6 @@ help: set the type parameter to the desired type
|
|||
LL | let b: &dyn FromResidual<R> = &();
|
||||
| +++
|
||||
|
||||
error[E0038]: the trait `FromResidual` is not dyn compatible
|
||||
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:32
|
||||
|
|
||||
LL | let b: &dyn FromResidual = &();
|
||||
| ^^^ `FromResidual` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:2:8
|
||||
|
|
||||
LL | trait FromResidual<R = <Self as Try>::Residual> {
|
||||
| ------------ this trait is not dyn compatible...
|
||||
LL | fn from_residual(residual: R) -> Self;
|
||||
| ^^^^^^^^^^^^^ ...because associated function `from_residual` has no `self` parameter
|
||||
= note: required for the cast from `&()` to `&dyn FromResidual<{type error}>`
|
||||
help: consider turning `from_residual` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn from_residual(&self, residual: R) -> Self;
|
||||
| ++++++
|
||||
help: alternatively, consider constraining `from_residual` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn from_residual(residual: R) -> Self where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `FromResidual` is not dyn compatible
|
||||
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:12
|
||||
|
|
||||
|
|
@ -60,7 +36,7 @@ help: alternatively, consider constraining `from_residual` so it does not apply
|
|||
LL | fn from_residual(residual: R) -> Self where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0393.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -13,5 +13,4 @@ impl Tr for St {
|
|||
|
||||
fn main() {
|
||||
let _: &dyn Tr = &St; //~ ERROR E0038
|
||||
//~^ ERROR E0038
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,3 @@
|
|||
error[E0038]: the trait `Tr` is not dyn compatible
|
||||
--> $DIR/safety.rs:15:22
|
||||
|
|
||||
LL | let _: &dyn Tr = &St;
|
||||
| ^^^ `Tr` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/safety.rs:4:8
|
||||
|
|
||||
LL | trait Tr {
|
||||
| -- this trait is not dyn compatible...
|
||||
LL | fn foo();
|
||||
| ^^^ ...because associated function `foo` has no `self` parameter
|
||||
= help: only type `St` implements `Tr`; consider using it directly instead.
|
||||
= note: required for the cast from `&St` to `&dyn Tr`
|
||||
help: consider turning `foo` into a method by giving it a `&self` argument
|
||||
|
|
||||
LL | fn foo(&self);
|
||||
| +++++
|
||||
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
||||
|
|
||||
LL | fn foo() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error[E0038]: the trait `Tr` is not dyn compatible
|
||||
--> $DIR/safety.rs:15:12
|
||||
|
|
||||
|
|
@ -47,6 +22,6 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o
|
|||
LL | fn foo() where Self: Sized;
|
||||
| +++++++++++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
|
|
@ -12,5 +12,4 @@ fn main() {
|
|||
//~^ ERROR method takes 1 generic argument but 2
|
||||
(Box::new(10) as Box<dyn bar>).dup();
|
||||
//~^ ERROR E0038
|
||||
//~| ERROR E0038
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,31 +49,7 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
|
|||
consider defining an enum where each variant holds one of these types,
|
||||
implementing `bar` for this new enum and using it instead
|
||||
|
||||
error[E0038]: the trait `bar` is not dyn compatible
|
||||
--> $DIR/test-2.rs:13:6
|
||||
|
|
||||
LL | (Box::new(10) as Box<dyn bar>).dup();
|
||||
| ^^^^^^^^^^^^ `bar` is not dyn compatible
|
||||
|
|
||||
note: for a trait to be dyn compatible it needs to allow building a vtable
|
||||
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
|
||||
--> $DIR/test-2.rs:4:30
|
||||
|
|
||||
LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
|
||||
| --- ^^^^ ^^^^ ...because method `blah` has generic type parameters
|
||||
| | |
|
||||
| | ...because method `dup` references the `Self` type in its return type
|
||||
| this trait is not dyn compatible...
|
||||
= help: consider moving `dup` to another trait
|
||||
= help: consider moving `blah` to another trait
|
||||
= help: the following types implement `bar`:
|
||||
i32
|
||||
u32
|
||||
consider defining an enum where each variant holds one of these types,
|
||||
implementing `bar` for this new enum and using it instead
|
||||
= note: required for the cast from `Box<{integer}>` to `Box<dyn bar>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0107.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue