-
Couldn't load subscription status.
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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 scopeRationale 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.1Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.