`exported_private_dependencies` lint only take effect in innermost dependency
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Problem
The exported_private_dependencies lint only take affect in the innermost dependency in a recursively dependent environment.
This inspired by https://github.com/rust-lang/rust/issues/44663#issuecomment-1851227083.
Steps
In order to prove this problem, I purposely contructed a code repository, here
in the repository, the crates folder has three crates,
- grandparent_dep, the init crate provied the pub struct
- parent_dep, the middle crate, add
grandparent_depas public and reexport pub struct from grandparent_dep - pub_dep, the outmost crate, add
parent_depas public and reexport pub struct from parent_dep
(the crates in crates can be treated as download from respority(like github, crates.io))
in src/lib.rs, add pub_dep as dependency but private.
After downloading the resposity,
1、 run cargo build, no lint warning message
2、 change the public = false in crates/pub_dep/Cargo.toml, then run cargo build, no lint warning message
3、 change the public = false in crates/parent_dep/Cargo.toml, run cargo build and a lint warning message comes up.
cargo build
Compiling parent_dep v0.1.0 (/root/workspace/recursive_pub_reexport/crates/parent_dep)
Compiling pub_dep v0.1.0 (/root/workspace/recursive_pub_reexport/crates/pub_dep)
Compiling simple v0.1.0 (/root/workspace/recursive_pub_reexport)
warning: type `FromPriv` from private dependency 'grandparent_dep' in public interface
--> src/lib.rs:3:1
|
3 | pub fn use_pub(_: pub_dep::FromPriv) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(exported_private_dependencies)]` on by default
Possible Solution(s)
The focus of this issue is to verify whether there is a problem with the current situation, so the solution will not be considered for the time being.
Notes
No response
Version
cargo 1.76.0-nightly (623b78849 2023-12-02)
release: 1.76.0-nightly
commit-hash: 623b788496b3e51dc2f9282373cf0f6971a229b5
commit-date: 2023-12-02
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u 30 May 2023
os: Ubuntu 22.04 (jammy) [64-bit]
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
Start with the linked recursive_pub_reexport repository, reviewing crates/grandparent_dep, crates/parent_dep, crates/pub_dep, and the root src/lib.rs. Run cargo build while changing public in each dependency's Cargo.toml and compare the lint output. Done means confirming and characterizing the recursive exported_private_dependencies behavior; the issue does not specify an implementation or test location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100