about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-07 19:20:31 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-18 15:08:25 +0100
commit2db5d49d4791723b5335d5b66a0e2c304bf37d4c (patch)
tree8e12f62dce75abb6ed7cbcbace02e712b373206c
parent185c1d340c5b985195abf15f69b06aa6572d793c (diff)
downloadrust-2db5d49d4791723b5335d5b66a0e2c304bf37d4c.tar.gz
rust-2db5d49d4791723b5335d5b66a0e2c304bf37d4c.zip
simplify submod_path
-rw-r--r--src/librustc_parse/parser/module.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/librustc_parse/parser/module.rs b/src/librustc_parse/parser/module.rs
index c7d120e3cc6..c426b073a05 100644
--- a/src/librustc_parse/parser/module.rs
+++ b/src/librustc_parse/parser/module.rs
@@ -102,20 +102,18 @@ impl<'a> Parser<'a> {
         id_sp: Span,
     ) -> PResult<'a, ModulePathSuccess> {
         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()) {
-                    // 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,
-                },
-                path,
-            });
+            let directory_ownership = match path.file_name().and_then(|s| s.to_str()) {
+                // 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,
+            };
+            return Ok(ModulePathSuccess { directory_ownership, path });
         }
 
         let relative = match self.directory.ownership {