Closed
Description
Currently, for the following code where a function's signature returns an impl Trait
that isn't implemented by the actual return type:
#![feature(conservative_impl_trait)]
trait T {}
struct S;
fn foo() -> impl T {
return 1;
}
provides the following output:
error[E0277]: the trait bound `{integer}: T` is not satisfied
--> src/main.rs:7:13
|
7 | fn foo() -> impl T {
| ^^^^^^ the trait `T` is not implemented for `{integer}`
|
= note: the return type of a function must have a statically known size
An appropriate output would at the very least need to be:
error[E0277]: the trait bound `{integer}: T` is not satisfied
--> src/main.rs:7:13
|
7 | fn foo() -> impl T {
| ^^^^^^ the trait `T` is not implemented for `{integer}`
8 | return 1;
| ^^^^^^^^ `{integer}` is returned here
On cases where the returned type is local to the project, the declaration of the type should be pointed out
#![feature(conservative_impl_trait)]
trait T {}
struct S;
fn foo() -> impl T {
S
}
error[E0277]: the trait bound `S: T` is not satisfied
--> src/main.rs:7:13
|
7 | fn foo() -> impl T {
| ^^^^^^ the trait `T` is not implemented for `S`
8 | S
| ^ `S` is returned here
note: `S`'s definition:
|
5 | struct S;
| ^^^^^^^^
note: `T`'s definition:
|
3 | trait T {}
| ^^^^^^^^^^