Closed
Description
Code
trait FromRow {
fn prepare(self) -> impl Fn() -> T;
}
impl<T> FromRow for T {
fn prepare(self) -> impl Fn() -> T {
|| loop {}
}
}
Current output
error[E0412]: cannot find type `T` in this scope
--> src/lib.rs:2:38
|
2 | fn prepare(self) -> impl Fn() -> T;
| ^ not found in this scope
warning: impl trait in impl method signature does not match trait method signature
--> src/lib.rs:6:38
|
2 | fn prepare(self) -> impl Fn() -> T;
| -------------- return type from trait method defined here
...
6 | fn prepare(self) -> impl Fn() -> T {
| ^ this bound is stronger than that defined on the trait
|
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
= note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information
= note: `#[warn(refining_impl_trait_internal)]` on by default
help: replace the return type so that it matches the trait
|
6 | fn prepare(self) -> impl Fn() -> {type error} {
| ~~~~~~~~~~~~~~~~~~~~~~~~~
For more information about this error, try `rustc --explain E0412`.
Desired output
error[E0412]: cannot find type `T` in this scope
--> src/lib.rs:2:38
|
2 | fn prepare(self) -> impl Fn() -> T;
| ^ not found in this scope
Rationale and extra context
Not sure if this is worth fixing, but the warning message is not helpful here at all and the suggestion fn prepare(self) -> impl Fn() -> {type error}
is not usable.
Other cases
No response
Rust Version
rustc 1.80.1
Anything else?
No response