simplify submod_path

This commit is contained in:
Mazdak Farrokhzad 2020-03-07 19:20:31 +01:00
parent 185c1d340c
commit 2db5d49d47

View File

@ -102,8 +102,7 @@ impl<'a> Parser<'a> {
id_sp: Span, id_sp: Span,
) -> PResult<'a, ModulePathSuccess> { ) -> PResult<'a, ModulePathSuccess> {
if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) { if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) {
return Ok(ModulePathSuccess { let directory_ownership = match path.file_name().and_then(|s| s.to_str()) {
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. // All `#[path]` files are treated as though they are a `mod.rs` file.
// This means that `mod foo;` declarations inside `#[path]`-included // This means that `mod foo;` declarations inside `#[path]`-included
// files are siblings, // files are siblings,
@ -113,9 +112,8 @@ impl<'a> Parser<'a> {
// If you encounter this, it's your own darn fault :P // If you encounter this, it's your own darn fault :P
Some(_) => DirectoryOwnership::Owned { relative: None }, Some(_) => DirectoryOwnership::Owned { relative: None },
_ => DirectoryOwnership::UnownedViaMod, _ => DirectoryOwnership::UnownedViaMod,
}, };
path, return Ok(ModulePathSuccess { directory_ownership, path });
});
} }
let relative = match self.directory.ownership { let relative = match self.directory.ownership {