-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing From
for associated type results in confusing error
#85576
Comments
This is a bug. When it happensWhen type is an associated type of a trait, and the trait is implemented in another crate. if the trait is implemented in the same crate, it works fine. Also if types are used directly, it works fine. playground 1 use
type BoolErr = <bool as FromStr>::Err;
assert_eq!(TypeId::of::<BoolErr>(), TypeId::of::<ParseBoolError>()); I have created a new repository that showcases another example of the same error. type OtherDuration = <other::Systick as other::Monotonic>::Duration;
type OtherInstant = <other::Systick as other::Monotonic>::Instant;
impl FromTime for OtherDuration {}
impl FromTime for OtherInstant {} |
FOr an explanation of the affected issue, see #99940 (comment) |
With the toolchain 1.82 and the following really similar code,
I am not sure how different it is from the bug reported in this issue. Using the nightly 1.84 toolchain, the compilation terminates with the same error. |
Disclaimer: I am not sure if this an actual bug or rather a diagnostic issue.
The following simplified code
Playground
Produces the following incorrect/confusing error message on both stable and nigthly:
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.The text was updated successfully, but these errors were encountered: