Unhelpful highlighting in type inference error #68063
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-inference
Area: Type inference
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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 typeT
. 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 the1
: no matter what type1
takes, the full expression is always typeT
. This is pretty confusingThe text was updated successfully, but these errors were encountered: