-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coherenceArea: CoherenceArea: CoherenceA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
Disclaimer: I am not sure if this an actual bug or rather a diagnostic issue.
The following simplified code
use std::str::FromStr;
type BoolErr = <bool as FromStr>::Err;
struct Error(BoolErr);
impl From<BoolErr> for Error {
fn from(err: BoolErr) -> Self {
Self(err)
}
}
Produces the following incorrect/confusing error message on both stable and nigthly:
error[E0119]: conflicting implementations of trait `std::convert::From<Error>` for type `Error`:
--> src/lib.rs:7:1
|
7 | impl From<BoolErr> for Error {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<T> From<T> for T;
I encountered this issue when I wanted to wrap the result returned by str::parse
for a type from crate A which uses an error type from another crate B, which I did not want to depend on and import directly. I am aware that using an associated type here has implications for backwards compatibility, but in this case this is actually desirable I think, since I only want to forward the result into my custom error type, even if the concrete error type in crate A/B changes.
hniksic, im-nefilim, rodya-mirov, tvallotton, Ten0 and 7 more
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coherenceArea: CoherenceArea: CoherenceA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.