-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Type inference issues with well specified trait function call #135698
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`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-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`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.
While debugging a recent build failure in diesel I noticed that type inference fails in situation where the type is fully specified. I've build the following minimal example for this:
This fails to compile with the following error:
This seems to be caused by the additional
PartialEqimplementation that breaks inferring the type of theoutvariable. For me it looks strange that rustc cannot infer that there is only a single possible impl that fulfills the given constraints, so it should be possible to infer the correct type here.(Also even if that's desired behavior the suggestion is definitively off, as the second variant (that with
i32 as FromSql<UuidST, Pg>would result in a compilation error.Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1a20f58b8678382f922f0006217bbf60
Related: uuid-rs/uuid#787
rustc --version --verbose: