Skip to content

DST leads to unintuitive errors with traits like Int #16874

@huonw

Description

@huonw

The Int trait has a very similar name to the int primitive type, so if someone accidentally uses Int (e.g. forgetting that primitive types have special names/if they come from Haskell or some such) they can get confusing messages, especially now that DST allows for bare traits to be used more often, e.g.

struct Foo { x: Int }

fn main() {}

gives

<anon>:1:17: 1:20 error: explicit lifetime bound required
<anon>:1 struct Foo { x: Int }
                         ^~~

which is really confusing.

I'm not really sure how we fix this, but mentioning "trait" somewhere in the message would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-DSTsArea: Dynamically-sized types (DSTs)A-diagnosticsArea: Messages for errors, warnings, and lintsT-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