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

Detect pub use statements #8545

Closed
i509VCB opened this issue Mar 15, 2022 · 3 comments · Fixed by #8670
Closed

Detect pub use statements #8545

i509VCB opened this issue Mar 15, 2022 · 3 comments · Fixed by #8670
Assignees
Labels
A-lint Area: New lints

Comments

@i509VCB
Copy link
Contributor

i509VCB commented Mar 15, 2022

What it does

Detects usage of pub use. This statement effectively exports a type or module as if it is a member of the current module.

Lint Name

detect_pub_use

Category

pedantic

Advantage

  • sometimes when reexporting multiple types, it isn't clear you have exported all the types, resulting in some types which should be public but may not be explicitly named in code.
  • a pub use statement for crate types may be better exposed by placing the type in a public module instead of explicitly exporting it and making private details crate private or module private.

Drawbacks

  • sometimes this is intended, especially for opaque retuen types or reexporting a crate for library usage, hence the pedantic categorization. This might be better done via an impl Trait return type if the type needs to be private details of a library.
  • the issue being solved might make more sense as an specialized lint working off public visibility.

Example

mod priv_mod {...}

pub use self::priv_mod::PublicType;

Could be placed in a public module, or the module the type inhabits made public.

@i509VCB i509VCB added the A-lint Area: New lints label Mar 15, 2022
@i509VCB
Copy link
Contributor Author

i509VCB commented Mar 16, 2022

I guess I'll include an example of the issue I am trying to have warnings for:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f2cccd05143720f55ffa44c8c63ee5da

@yoav-lavi
Copy link
Contributor

I don't mind taking this, I think it makes the most sense to put this in restrictions though, I'll prepare a PR and worst case we can change it

@yoav-lavi
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants