From 4e9e091e91ea2ad8a6f45a9b20ff331d4bca7a23 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 16 May 2014 14:23:04 -0700 Subject: 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] --- src/test/compile-fail/circular_modules_main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/test/compile-fail/circular_modules_main.rs') diff --git a/src/test/compile-fail/circular_modules_main.rs b/src/test/compile-fail/circular_modules_main.rs index bc9f3247db7..7296ea655c2 100644 --- a/src/test/compile-fail/circular_modules_main.rs +++ b/src/test/compile-fail/circular_modules_main.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - +#[path = "circular_modules_hello.rs"] mod circular_modules_hello; //~ERROR: circular modules pub fn hi_str() -> StrBuf { -- cgit 1.4.1-3-g733a5