-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[nightly regression] E0639 + adding #[non_exhaustive] to io::ErrorKind is a breaking change #53549
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I noticed this due to Travis tests of this code here. This is obviously(?) not a serious crate, but illustrates that this restriction is problematic for macros. That line expands to Err(_) => Err(io::Error::new(io::ErrorKind::Other{}, "invalid UTF-8")) |
This is a bug. Adding |
Minimal example. Defining crate: #[non_exhaustive]
pub enum NeEnum {
Variant
} Using crate: fn make_ne_enum() -> NeEnum {
// works
NeEnum::Variant
}
fn make_ne_enum_2() -> NeEnum {
// fails
NeEnum::Variant{}
} |
I have a fix |
Structs and enums can both be non-exhaustive, with a very different meaning. This PR splits `is_non_exhaustive` to 2 separate functions - 1 for structs, and another for enums, and fixes the places that got the usage confused. Fixes rust-lang#53549.
visiting for triage. P-high. (Fixed by #53721 in any case) |
fix `is_non_exhaustive` confusion between structs and enums Structs and enums can both be non-exhaustive, with a very different meaning. This PR splits `is_non_exhaustive` to 2 separate functions - 1 for structs, and another for enums, and fixes the places that got the usage confused. Fixes #53549. r? @eddyb
In stable and beta, you can write
ErrorKind::Other {}
, but in nightly this triggers E0639: cannot create non-exhaustive variant using struct expression. (As an aside, that error message should be rephrased and examples added to--explain
.)This is either a bug with
#[non_exhaustive]
, or it means that the attribute can't be applied to public enums without creating a breaking change.The text was updated successfully, but these errors were encountered: