rust-lang / rust-lang/rust-clippy
`module_inception` false positive for private sub-module
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
When splitting a public module up into sub-modules for code-organization purposes, you can commonly have a sub-module with the same name as the public module. This is fine for a private module since the repetition isn't exposed to the outside world.
Lint Name
module_inception
Reproducer
I tried this code:
pub mod foo {
mod foo {
pub struct Foo;
}
// other private modules
pub use self::foo::Foo;
// other re-exports
}
I saw this happen:
warning: module has the same name as its containing module
--> src/lib.rs:2:5
|
2 | / mod foo {
3 | | pub struct Foo;
4 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#module_inception
= note: `#[warn(clippy::module_inception)]` on by default
I expected to see this happen: no warning
Version
No response
Additional Labels
No response
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 module_inception lint implementation and reproduce the report's example in src/lib.rs. Check the lint's handling of a private sub-module with the same name as its public containing module; done means the example emits no warning while other module_inception cases remain covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100