Skip to content

Unhelpful highlighting in type inference error #68063

@Torrencem

Description

@Torrencem

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

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions