-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Improve compiler error on associated types #71035
Copy link
Copy link
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
If you have a variable with type
impl TryStream<Ok=T, Error=E>and want to use it as aimpl Stream<Item=Result<T,E>>, the compiler complains.The compiler does not take you by the hand and helps you with helpful hints.
I tried (roughly) this code: (EDIT: find a self-contained example here)
I expected to see this happen:
I would like the compiler to tell me that that that while there exists an implementation of
TryStream<Ok=T, Error=E>asStream<Result<T,E>>, there might exist other implementations and therefore this code is not accepted. UsingStream<Result<T,E>>instead ofTryStream<Ok=T, Error=E>would solve the error.Instead, this happened:
There are no hints by the compiler.
Meta
rustc --version --verbose: