Skip to content

Commit 024af0b

Browse files
committed
simplify submod_path
1 parent 6cb04d9 commit 024af0b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/librustc_parse/parser/module.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,18 @@ impl<'a> Parser<'a> {
102102
id_sp: Span,
103103
) -> PResult<'a, ModulePathSuccess> {
104104
if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) {
105-
return Ok(ModulePathSuccess {
106-
directory_ownership: match path.file_name().and_then(|s| s.to_str()) {
107-
// All `#[path]` files are treated as though they are a `mod.rs` file.
108-
// This means that `mod foo;` declarations inside `#[path]`-included
109-
// files are siblings,
110-
//
111-
// Note that this will produce weirdness when a file named `foo.rs` is
112-
// `#[path]` included and contains a `mod foo;` declaration.
113-
// If you encounter this, it's your own darn fault :P
114-
Some(_) => DirectoryOwnership::Owned { relative: None },
115-
_ => DirectoryOwnership::UnownedViaMod,
116-
},
117-
path,
118-
});
105+
let directory_ownership = match path.file_name().and_then(|s| s.to_str()) {
106+
// All `#[path]` files are treated as though they are a `mod.rs` file.
107+
// This means that `mod foo;` declarations inside `#[path]`-included
108+
// files are siblings,
109+
//
110+
// Note that this will produce weirdness when a file named `foo.rs` is
111+
// `#[path]` included and contains a `mod foo;` declaration.
112+
// If you encounter this, it's your own darn fault :P
113+
Some(_) => DirectoryOwnership::Owned { relative: None },
114+
_ => DirectoryOwnership::UnownedViaMod,
115+
};
116+
return Ok(ModulePathSuccess { directory_ownership, path });
119117
}
120118

121119
let relative = match self.directory.ownership {

0 commit comments

Comments
 (0)