-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-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
struct MyError;
impl<T> From<T> for MyError {
fn from(error: T) -> Self {
MyError::from(error)
}
}
async fn test() -> Result<(), MyError> {
block().await?;
Ok(())
}
async fn block() -> Result<(), MyError> {
Ok(())
}
This produces a rather confusing error:
error[E0283]: type annotations needed
--> src/lib.rs:10:18
|
10 | block().await?;
| ^ cannot infer type for struct `MyError`
|
= note: cannot resolve `MyError: std::convert::From<MyError>`
= note: required by `std::convert::From::from`
If you make functions non-async and remove the await then you get a proper error about overlapping From
impls:
error[E0119]: conflicting implementations of trait `std::convert::From<MyError>` for type `MyError`:
--> src/lib.rs:3:1
|
3 | impl<T> From<T> for MyError {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> std::convert::From<T> for T;
Meta
Rust version 1.41.1 (current version on playground)
Same problem appears on beta and nightly.
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-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.