-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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
MWE of a type inference error that came up in a real project:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cd3198d1a30439a01ca2cfa3a78b1124
The user should fix this error by adding an explicit type for the {integer} literal 1
(i.e. 1u32 or 1u64), since these could do completely different things for the generic type T
. The compiler catches this, but the highlighting seems to imply that it can't infer the type of the entire expression !(number >> 1)
, when in reality the problem is with the 1
: no matter what type 1
takes, the full expression is always type T
. This is pretty confusing
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.