cargo-semver-checks
cargo-semver-checks copied to clipboard
New lints: an enum variant changes from unit/tuple/struct to another kind.
Describe your use case
We have lints for when a struct
changes "kind":
However, currently cargo-semver-checks
does not check when an enum variant changes kind like this.
from:
pub enum Enum {
WasTuple(),
WasStruct {},
WasUnit,
TupleItem (()),
StructItem { a: (), },
Unit,
}
to:
pub enum Enum {
WasTuple {},
WasStruct,
WasUnit(),
TupleItem { a: () },
StructItem,
Unit(()),
}
the first three variants would break with:
let _ = Enum::WasTuple;
// since it's now a tuple variant, this still gives us a value,
// but it's a `fn(()) -> Enum` tuple constructor, not an `Enum` instance.
let _: Enum = Enum::WasStruct;
let _ = Enum::WasUnit;
the second three also have breakage in a similar fashion, and cargo-semver-checks
currently does not catch the
fields_missing/removed lints because these variants changed kind
Describe the solution you'd like
Thus, it would be helpful to have lint(s) that detect this change for constructible enum variants - if a tuple/struct variant is marked #[non_exhaustive]
in the baseline version, this is not a breaking change because it was not possible to construct these variants in the baseline version.
Alternatives, if applicable
No response
Additional Context
No response