diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-05-16 14:23:04 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-05-17 01:01:47 -0700 |
| commit | 4e9e091e91ea2ad8a6f45a9b20ff331d4bca7a23 (patch) | |
| tree | c01cb3c61732225abd28d5eb8991537ca7ad30b5 /src/libsyntax/ext | |
| parent | 25c54226c3e7dd6f59cf2e92238a4d79d8b0128d (diff) | |
| download | rust-4e9e091e91ea2ad8a6f45a9b20ff331d4bca7a23.tar.gz rust-4e9e091e91ea2ad8a6f45a9b20ff331d4bca7a23.zip | |
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]
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs (renamed from src/libsyntax/ext/deriving/generic.rs) | 0 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/ty.rs (renamed from src/libsyntax/ext/deriving/ty.rs) | 0 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 2 |
3 files changed, 2 insertions, 0 deletions
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 6df4da89402..6df4da89402 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index 602245b4c47..602245b4c47 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 6e7e72bd2e8..6bc08741c07 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -95,6 +95,8 @@ pub fn expand_include(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) &res_rel_file(cx, sp, &Path::new(file)), + true, + None, sp); base::MacExpr::new(p.parse_expr()) } |
