rust-lang / rust-lang/rust-clippy
New lint: reexport_crate_in_api
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
If a library crate contains a type or trait in public API that was defined in a dependency, including alloc and std, then clippy should suggest to reexport the dependency using pub extern crate foo or pub use foo as bar.
Lint Name
reexport_crate_in_api
Category
style
Advantage
- The downstream crates don't need to bother with adding it to Cargo.toml
- Less version conflicts
- No need to look up which version is compatible
- No need for ugly tricks or high MSRV when the downstream dependency wants to depend optionally
- Including
stdandallochelps crates that want to beno_std-aware with optionalstd/allocfeatures
Drawbacks
A few more trivial items in crates. Changing rustdoc to put these at the bottom of docs would mitigate the noise.
Example
#[derive(Serialize, Deserialize)]
pub struct Foo(u32);
pub fn bar() -> String {
"hello".to_owned()
}
Could be written as:
pub extern crate serde;
pub extern crate alloc;
#[derive(Serialize, Deserialize)]
pub struct Foo(u32);
pub fn bar() -> String {
"hello".to_owned()
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no implementation files, tests, or entry points. Start by surveying existing Clippy lint implementations and their UI tests, then define detection and suggestion coverage for dependency, alloc, and std reexports before validating the proposed examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100