Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lint: Removal of a re-export of an enum variant #291

Open
obi1kenobi opened this issue Jan 14, 2023 · 0 comments
Open

New lint: Removal of a re-export of an enum variant #291

obi1kenobi opened this issue Jan 14, 2023 · 0 comments
Labels
A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations

Comments

@obi1kenobi
Copy link
Owner

Imagine a crate with the following code:

pub enum Foo {
    First,
}

pub use Foo::First;

Removing the pub use is clearly a breaking change, since downstream users would no longer be able to use First to refer to that enum variant.

The analogous case for functions, structs, enums, etc. is treated equivalently to the case where the function/struct/enum/etc. itself was deleted ("no longer accessible at its old path").

But the lint for enum variants specifically goes through the enum, so I believe that re-exports of enum variants right now wouldn't be caught by any lint. It's not currently obvious to me how to write a lint to catch this case.

In addition to the above scenario, the following variations should be considered for inclusion as test cases for this new lint:

  • the re-export is a glob re-export
  • the re-export renames the variant (pub use X as Y)
  • the enum is private but its variants are publicly re-exported (Is this even reasonable Rust? When might it be used?)
@obi1kenobi obi1kenobi added A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations labels Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: new or existing lint C-enhancement Category: raise the bar on expectations
Projects
None yet
Development

No branches or pull requests

1 participant