Use `#[non_exhaustive]` attribute instead of `__Nonexhaustive` enum variant hack
#[non_exhaustive] was added at Rust 1.40. Since MSRV of this project is 1.41.1, the attribute is available. This PR replaces __Nonexhaustive enum variant hack with the attribute.
The benefits to use the attribute are:
- The attribute is dedicated for this use case. So compiler's error message is better than an error around
__Nonexhausitvevariant. #[non_exhaustive]allows the exhaustive pattern check atmatchin the crate where the enum/struct is implemented. This can catch bugs like 31d78a6.
Hmmm, so I just recently closed a similar PR: https://github.com/rust-lang/regex/pull/781
My reasoning was that I wasn't sure if this was a breaking change or not.
But thinking about it, I cannot think of a way that this would break folks. Obviously, they might be using __Nonexhaustive, but that wasn't part of the public API. Otherwise, I think this change is actually okay?
I considered this change may introduce some breaking change just before creating this PR, but I could come up with nothing too. Possibly it may change a data layout of enum or how a compiler optimizes it. But they are not an API change and usually don't break user code.