3 ms·
There is currently a missing middle ground in stable Rust, which is to lint on a missing variant rather than fail compilation. There's an unstable option for it
by sunshowers 2y ago
There is currently a missing middle ground in stable Rust, which is to lint on a missing variant rather than fail compilation. There's an unstable option for it, but it would be very useful for non-exhaustive enums where consumers care about matching against every known variant.
You can practically use it today by gating on a nightly-only cfg flag. See https://github.com/guppy-rs/guppy/blob/fa61210b67bea233de52c10395045bc19c62b068/.cargo/nightly-config.toml#L11 https://github.com/guppy-rs/guppy/blob/fa61210b67bea233de52c... and https://github.com/guppy-rs/guppy/blob/fa61210b67bea233de52c10395045bc19c62b068/tools/hakari/src/cli_ops/initialize.rs#L63 https://github.com/guppy-rs/guppy/blob/fa61210b67bea233de52c...
- eru 2y agoCouldn't clippy do that for you?
- sunshowers 2y agoNot at the moment. The unstable lint is implemented in rustc directly, not in clippy, though I guess it could move to clippy in the future.