Point at reason in object unsafe trait with Self in supertraits or where-clause
This commit is contained in:
parent
16d935e725
commit
865216b3ad
8 changed files with 78 additions and 30 deletions
|
|
@ -1,10 +1,13 @@
|
|||
error[E0038]: the trait `Map` cannot be made into an object
|
||||
--> $DIR/issue-26056.rs:20:13
|
||||
|
|
||||
LL | trait Map: MapLookup<<Self as Map>::Key> {
|
||||
| --- ----------------------------- ...because it uses `Self` as a type parameter in this
|
||||
| |
|
||||
| this trait cannot be made into an object...
|
||||
...
|
||||
LL | as &dyn Map<Key=u32,MapValue=u32>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Map` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-28576.rs:7:12
|
||||
|
|
||||
LL | pub trait Bar: Foo<Assoc=()> {
|
||||
| --- -------------
|
||||
| | | |
|
||||
| | | ...because it uses `Self` as a type parameter in this
|
||||
| | ...because it uses `Self` as a type parameter in this
|
||||
| this trait cannot be made into an object...
|
||||
LL | fn new(&self, b: &
|
||||
LL | / dyn Bar
|
||||
LL | | <Assoc=()>
|
||||
| |________________________^ the trait `Bar` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
error[E0038]: the trait `B` cannot be made into an object
|
||||
--> $DIR/issue-38404.rs:3:15
|
||||
|
|
||||
LL | trait A<T>: std::ops::Add<Self> + Sized {}
|
||||
| ------------------- ...because it uses `Self` as a type parameter in this
|
||||
LL | trait B<T>: A<T> {}
|
||||
| - this trait cannot be made into an object...
|
||||
LL | trait C<T>: A<dyn B<T, Output=usize>> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `B` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,25 @@
|
|||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/issue-38604.rs:14:13
|
||||
|
|
||||
LL | trait Foo where u32: Q<Self> {
|
||||
| --- ------- ...because it uses `Self` as a type parameter in this
|
||||
| |
|
||||
| this trait cannot be made into an object...
|
||||
...
|
||||
LL | let _f: Box<dyn Foo> =
|
||||
| ^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/issue-38604.rs:15:9
|
||||
|
|
||||
LL | trait Foo where u32: Q<Self> {
|
||||
| --- ------- ...because it uses `Self` as a type parameter in this
|
||||
| |
|
||||
| this trait cannot be made into an object...
|
||||
...
|
||||
LL | Box::new(());
|
||||
| ^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
= note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::boxed::Box<dyn Foo>>` for `std::boxed::Box<()>`
|
||||
= note: required by cast to type `std::boxed::Box<dyn Foo>`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
error[E0038]: the trait `Expr` cannot be made into an object
|
||||
--> $DIR/object-safety-issue-22040.rs:12:23
|
||||
|
|
||||
LL | trait Expr: Debug + PartialEq {
|
||||
| ---- --------- ...because it uses `Self` as a type parameter in this
|
||||
| |
|
||||
| this trait cannot be made into an object...
|
||||
...
|
||||
LL | elements: Vec<Box<dyn Expr + 'x>>,
|
||||
| ^^^^^^^^^^^^^ the trait `Expr` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
error[E0038]: the trait `Baz` cannot be made into an object
|
||||
--> $DIR/object-safety-supertrait-mentions-Self.rs:15:31
|
||||
|
|
||||
LL | trait Baz : Bar<Self> {
|
||||
| --- --------- ...because it uses `Self` as a type parameter in this
|
||||
| |
|
||||
| this trait cannot be made into an object...
|
||||
...
|
||||
LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz {
|
||||
| ^^^^^^^ the trait `Baz` cannot be made into an object
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@ error[E0038]: the trait `std::cmp::Eq` cannot be made into an object
|
|||
|
|
||||
LL | let _: &dyn EqAlias = &123;
|
||||
| ^^^^^^^^^^^ the trait `std::cmp::Eq` cannot be made into an object
|
||||
|
|
||||
::: $SRC_DIR/libcore/cmp.rs:LL:COL
|
||||
|
|
||||
= note: the trait cannot be made into an object because it cannot use `Self` as a type parameter in the supertraits or `where`-clauses
|
||||
LL | pub trait Eq: PartialEq<Self> {
|
||||
| --------------- the trait cannot be made into an object because it uses `Self` as a type parameter in this
|
||||
|
||||
error[E0191]: the value of the associated type `Item` (from trait `std::iter::Iterator`) must be specified
|
||||
--> $DIR/trait-alias-object-fail.rs:9:17
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue