support a way to check bitflags are exhaustive
@jdonszelmann is already working on this.
Since Dec 12, 2025.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Right now you just have to hope that whoever adds a new option to CodegenFnAttrFlags correctly updates all the places where it is relevant, e.g.
cc @jdonszelmann https://github.com/rust-lang/rust/pull/146348
This is quite fragile and I certainly wouldn't have caught this omission in review.
A way to prevent such bugs is by exhaustively matching on all options in such places, e.g.
https://github.com/rust-lang/rust/blob/c4dc70ee0ad7f811fb32e5bed9cd6c7b37beed4e/compiler/rustc_middle/src/ty/context.rs#L632-L638
Imo we should extend our bitflags macro to also emit an enum of all options to enable us to exhaustively match on them in cases where this is likely useful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.