Peternator7 / strum

A small rust library for adding custom derives to enums
https://crates.io/crates/strum
MIT License
1.8k stars 151 forks source link

Regression: Generating private enum with `EnumDiscriminants` is no longer possible when the parent enum is public #390

Open yescallop opened 1 week ago

yescallop commented 1 week ago

The following user code is broken by #377:

#[derive(EnumDiscriminants)]
#[strum_discriminants(name(PrivateDiscriminants), vis(pub(self)))]
pub enum PublicEnum {
    Variant0(bool),
    Variant1 { a: bool },
}

With an error message:

error[E0446]: private type `PrivateDiscriminants` in public interface

This is because the IntoDiscriminant impl of PublicEnum leaks the private PrivateDiscriminants type. Should we maybe exclude the IntoDiscriminant impl when the parent enum is public and the generated enum is private?