]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/module_inception.txt
Auto merge of #102529 - colinba:master, r=joshtriplett
[rust.git] / src / tools / clippy / src / docs / module_inception.txt
1 ### What it does
2 Checks for modules that have the same name as their
3 parent module
4
5 ### Why is this bad?
6 A typical beginner mistake is to have `mod foo;` and
7 again `mod foo { ..
8 }` in `foo.rs`.
9 The expectation is that items inside the inner `mod foo { .. }` are then
10 available
11 through `foo::x`, but they are only available through
12 `foo::foo::x`.
13 If this is done on purpose, it would be better to choose a more
14 representative module name.
15
16 ### Example
17 ```
18 // lib.rs
19 mod foo;
20 // foo.rs
21 mod foo {
22     ...
23 }
24 ```