Account for arbitrary self types in E0599

This commit is contained in:
Esteban Küber 2020-02-19 15:57:21 -08:00
parent 392d853589
commit 01286408c1
4 changed files with 60 additions and 17 deletions

View file

@ -1,13 +1,11 @@
error[E0599]: no method named `foo` found for reference `&dyn Foo` in the current scope
--> $DIR/issue-5153.rs:10:27
|
LL | trait Foo {
| --------- `Foo` defines an item `foo`, perhaps you need to implement it
LL | fn foo(self: Box<Self>);
| --------- the method might not be found because of this arbitrary self type
...
LL | (&5isize as &dyn Foo).foo();
| ^^^ method not found in `&dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
error: aborting due to previous error

View file

@ -1,24 +1,20 @@
error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope
--> $DIR/object-pointer-types.rs:11:7
|
LL | trait Foo {
| --------- `Foo` defines an item `owned`, perhaps you need to implement it
LL | fn owned(self: Box<Self>);
| --------- the method might not be found because of this arbitrary self type
...
LL | x.owned();
| ^^^^^ method not found in `&dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope
--> $DIR/object-pointer-types.rs:17:7
|
LL | trait Foo {
| --------- `Foo` defines an item `owned`, perhaps you need to implement it
LL | fn owned(self: Box<Self>);
| --------- the method might not be found because of this arbitrary self type
...
LL | x.owned();
| ^^^^^ method not found in `&mut dyn Foo`
|
= help: items from traits can only be used if the trait is implemented and in scope
error[E0599]: no method named `managed` found for struct `std::boxed::Box<(dyn Foo + 'static)>` in the current scope
--> $DIR/object-pointer-types.rs:23:7

View file

@ -2,16 +2,14 @@ error[E0599]: no method named `foo` found for struct `A` in the current scope
--> $DIR/point-at-arbitrary-self-type-trait-method.rs:9:7
|
LL | trait B { fn foo(self: Box<Self>); }
| ------- --- the method is available for `std::boxed::Box<A>` here
| |
| `B` defines an item `foo`, perhaps you need to implement it
| --- --------- the method might not be found because of this arbitrary self type
| |
| the method is available for `std::boxed::Box<A>` here
LL | struct A;
| --------- method `foo` not found for this
...
LL | A.foo()
| ^^^ method not found in `A`
|
= help: items from traits can only be used if the trait is implemented and in scope
error: aborting due to previous error