]> git.lizzy.rs Git - rust.git/blob - src/docs/duplicate_mod.txt
Merge remote-tracking branch 'upstream/master' into rustup
[rust.git] / src / docs / duplicate_mod.txt
1 ### What it does
2 Checks for files that are included as modules multiple times.
3
4 ### Why is this bad?
5 Loading a file as a module more than once causes it to be compiled
6 multiple times, taking longer and putting duplicate content into the
7 module tree.
8
9 ### Example
10 ```
11 // lib.rs
12 mod a;
13 mod b;
14 ```
15 ```
16 // a.rs
17 #[path = "./b.rs"]
18 mod b;
19 ```
20
21 Use instead:
22
23 ```
24 // lib.rs
25 mod a;
26 mod b;
27 ```
28 ```
29 // a.rs
30 use crate::b;
31 ```