Skip to content

BREAKING: Use #[non_exhaustive] on structs? #1867

@madsmtm

Description

@madsmtm

In v3.x, it might make sense to use #[non_exhaustive] on syn's structs. As long as some kind of fn new or impl Default is provided, users would still be able to construct structs manually, while still allowing the language to evolve further.

I'm not entirely sure yet which structs should have this attribute, but I think it should basically be "all, unless a good argument is given as to why not". As an example, Abi probably shouldn't be, since it's basically a small helper struct. But ItemStruct definitely should (imagine the language wanted add unsafe struct Foo {} or extern "C" struct Foo {}).

This would have avoided the issues in #1851.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions