Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make #[non_exhaustive] in the api crate optional #25

Closed
xFrednet opened this issue Jun 28, 2022 · 3 comments · Fixed by #166
Closed

Make #[non_exhaustive] in the api crate optional #25

xFrednet opened this issue Jun 28, 2022 · 3 comments · Fixed by #166
Assignees
Labels
A-api Area: Stable API C-enhancement Category: New feature or request E-good-first-issue Participation: Good for newcomers

Comments

@xFrednet
Copy link
Member

xFrednet commented Jun 28, 2022

Almost every enum and struct in the API has the #[non_exhaustive] marker to ensure that it can easily be expanded. This is nice for stability, but not ideal for driver implementations. There could also be users who would prefer a failing compilation, rather than adding wildcards to every match statement.

For this reason, I would like to have a feature (which is enabled by default) that can enable the #[non_exhaustive] marker.

The implementation will probably be as simple as using:

#[cfg_attr(feature = "add-non-exhaustive", non_exhaustive)]

The feature name is just an example, another name might be better

The feature should also include some documentation, that disabling it (not using default features) might cause compilation failures when the API is updated.

@xFrednet xFrednet added C-enhancement Category: New feature or request E-good-first-issue Participation: Good for newcomers A-api Area: Stable API labels Jun 28, 2022
@DevinR528
Copy link
Contributor

Would this cause problems if some lints have this feature on and some off and I try to use lints from both? Or is each lint compiled with its own deps and so this would be perfectly fine?

@xFrednet
Copy link
Member Author

xFrednet commented Jul 9, 2022

Ohh, that's a good question. I would hope not, since we only add an attribute, but this could be the case... We should test this before we implement/merge this.

@xFrednet
Copy link
Member Author

rust-lang/rust#89554 suggests a new rustc lint that warns if a match doesn't cover all variants of a non_exhaustive enum. That lint covers exactly the reason why I suggested making the #[non_exhaustive] attributes optional.

It's sadly limited to nightly for now, but that'll work for the driver and adapter for now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-api Area: Stable API C-enhancement Category: New feature or request E-good-first-issue Participation: Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants