Commit 4e9e091
committed
syntax: Tighten search paths for inner modules
This is an implementation of RFC 16. A module can now only be loaded if the
module declaring `mod name;` "owns" the current directory. A module is
considered as owning its directory if it meets one of the following criteria:
* It is the top-level crate file
* It is a `mod.rs` file
* It was loaded via `#[path]`
* It was loaded via `include!`
* The module was declared via an inline `mod foo { ... }` statement
For example, this directory structure is now invalid
// lib.rs
mod foo;
// foo.rs
mod bar;
// bar.rs;
fn bar() {}
With this change `foo.rs` must be renamed to `foo/mod.rs`, and `bar.rs` must be
renamed to `foo/bar.rs`. This makes it clear that `bar` is a submodule of `foo`,
and can only be accessed through `foo`.
RFC: 0016-module-file-system-hierarchy
Closes #14180
[breaking-change]1 parent 25c5422 commit 4e9e091
File tree
12 files changed
+93
-8
lines changed- src
- libregex/parse
- libsyntax
- ext
- deriving/generic
- parse
- test
- compile-fail
- run-pass/mod_dir_simple
12 files changed
+93
-8
lines changedFile renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
187 | 189 | | |
188 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
189 | 194 | | |
190 | 195 | | |
191 | 196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| 316 | + | |
| 317 | + | |
316 | 318 | | |
317 | 319 | | |
318 | 320 | | |
| |||
342 | 344 | | |
343 | 345 | | |
344 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
345 | 354 | | |
346 | 355 | | |
347 | 356 | | |
| |||
4179 | 4188 | | |
4180 | 4189 | | |
4181 | 4190 | | |
| 4191 | + | |
| 4192 | + | |
4182 | 4193 | | |
4183 | 4194 | | |
4184 | 4195 | | |
| 4196 | + | |
4185 | 4197 | | |
4186 | 4198 | | |
4187 | 4199 | | |
| |||
4211 | 4223 | | |
4212 | 4224 | | |
4213 | 4225 | | |
4214 | | - | |
| 4226 | + | |
| 4227 | + | |
4215 | 4228 | | |
4216 | | - | |
| 4229 | + | |
4217 | 4230 | | |
4218 | | - | |
4219 | 4231 | | |
4220 | 4232 | | |
4221 | 4233 | | |
4222 | 4234 | | |
4223 | 4235 | | |
4224 | 4236 | | |
4225 | 4237 | | |
| 4238 | + | |
| 4239 | + | |
| 4240 | + | |
| 4241 | + | |
| 4242 | + | |
| 4243 | + | |
| 4244 | + | |
| 4245 | + | |
| 4246 | + | |
| 4247 | + | |
| 4248 | + | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
4226 | 4259 | | |
4227 | | - | |
4228 | | - | |
| 4260 | + | |
| 4261 | + | |
4229 | 4262 | | |
4230 | 4263 | | |
4231 | 4264 | | |
| |||
4238 | 4271 | | |
4239 | 4272 | | |
4240 | 4273 | | |
4241 | | - | |
| 4274 | + | |
| 4275 | + | |
4242 | 4276 | | |
4243 | 4277 | | |
4244 | 4278 | | |
4245 | 4279 | | |
| 4280 | + | |
| 4281 | + | |
4246 | 4282 | | |
4247 | 4283 | | |
4248 | 4284 | | |
| |||
4265 | 4301 | | |
4266 | 4302 | | |
4267 | 4303 | | |
| 4304 | + | |
| 4305 | + | |
4268 | 4306 | | |
4269 | 4307 | | |
4270 | 4308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments