about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorTaylor Cramer <cramertj@google.com>2018-01-09 10:54:13 -0800
committerTaylor Cramer <cramertj@google.com>2018-01-09 10:54:13 -0800
commit7b420cf3da1e5ff7675923cc25a2d39715d300b6 (patch)
treed2ac94840c3bceac43bf3425bc7e5ddc068dd249 /src/libsyntax/parse
parent8e7a609e635b728eba65d471c985ab462dc4cfc7 (diff)
downloadrust-7b420cf3da1e5ff7675923cc25a2d39715d300b6.tar.gz
rust-7b420cf3da1e5ff7675923cc25a2d39715d300b6.zip
Treat #[path] files as mod.rs files
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 812e3c4967a..0d517a221da 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -5876,10 +5876,14 @@ impl<'a> Parser<'a> {
         if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) {
             return Ok(ModulePathSuccess {
                 directory_ownership: match path.file_name().and_then(|s| s.to_str()) {
-                    Some("mod.rs") => DirectoryOwnership::Owned { relative: None },
-                    Some(_) => {
-                        DirectoryOwnership::Owned { relative: Some(id) }
-                    }
+                    // All `#[path]` files are treated as though they are a `mod.rs` file.
+                    // This means that `mod foo;` declarations inside `#[path]`-included
+                    // files are siblings,
+                    //
+                    // Note that this will produce weirdness when a file named `foo.rs` is
+                    // `#[path]` included and contains a `mod foo;` declaration.
+                    // If you encounter this, it's your own darn fault :P
+                    Some(_) => DirectoryOwnership::Owned { relative: None },
                     _ => DirectoryOwnership::UnownedViaMod(true),
                 },
                 path,