Closed
Description
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.