Rollup merge of #128527 - estebank:ambiguity-suggestion, r=Nadrieril
More information for fully-qualified suggestion when there are multiple impls ``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/E0283.rs:30:21 | LL | fn create() -> u32; | ------------------- `Coroutine::create` defined here ... LL | let cont: u32 = Coroutine::create(); | ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | LL | let cont: u32 = <Impl as Coroutine>::create(); | ++++++++ + LL | let cont: u32 = <AnotherImpl as Coroutine>::create(); | +++++++++++++++ + ```
This commit is contained in:
commit
493233ce29
3 changed files with 59 additions and 27 deletions
|
|
@ -7,10 +7,12 @@ LL | fn create() -> u32;
|
|||
LL | let cont: u32 = Coroutine::create();
|
||||
| ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
||||
|
|
||||
help: use a fully-qualified path to a specific available implementation
|
||||
help: use a fully-qualified path to one of the available implementations
|
||||
|
|
||||
LL | let cont: u32 = </* self type */ as Coroutine>::create();
|
||||
| +++++++++++++++++++ +
|
||||
LL | let cont: u32 = <Impl as Coroutine>::create();
|
||||
| ++++++++ +
|
||||
LL | let cont: u32 = <AnotherImpl as Coroutine>::create();
|
||||
| +++++++++++++++ +
|
||||
|
||||
error[E0283]: type annotations needed
|
||||
--> $DIR/E0283.rs:35:24
|
||||
|
|
|
|||
|
|
@ -63,10 +63,12 @@ LL | fn my_fn();
|
|||
LL | MyTrait2::my_fn();
|
||||
| ^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
||||
|
|
||||
help: use a fully-qualified path to a specific available implementation
|
||||
help: use a fully-qualified path to one of the available implementations
|
||||
|
|
||||
LL | </* self type */ as MyTrait2>::my_fn();
|
||||
| +++++++++++++++++++ +
|
||||
LL | <Impl1 as MyTrait2>::my_fn();
|
||||
| +++++++++ +
|
||||
LL | <Impl2 as MyTrait2>::my_fn();
|
||||
| +++++++++ +
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue