Skip to content

Commit 7b420cf

Browse files
committed
Treat #[path] files as mod.rs files
1 parent 8e7a609 commit 7b420cf

File tree

7 files changed

+9
-30
lines changed

7 files changed

+9
-30
lines changed

Diff for: src/libsyntax/parse/parser.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -5876,10 +5876,14 @@ impl<'a> Parser<'a> {
58765876
if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) {
58775877
return Ok(ModulePathSuccess {
58785878
directory_ownership: match path.file_name().and_then(|s| s.to_str()) {
5879-
Some("mod.rs") => DirectoryOwnership::Owned { relative: None },
5880-
Some(_) => {
5881-
DirectoryOwnership::Owned { relative: Some(id) }
5882-
}
5879+
// All `#[path]` files are treated as though they are a `mod.rs` file.
5880+
// This means that `mod foo;` declarations inside `#[path]`-included
5881+
// files are siblings,
5882+
//
5883+
// Note that this will produce weirdness when a file named `foo.rs` is
5884+
// `#[path]` included and contains a `mod foo;` declaration.
5885+
// If you encounter this, it's your own darn fault :P
5886+
Some(_) => DirectoryOwnership::Owned { relative: None },
58835887
_ => DirectoryOwnership::UnownedViaMod(true),
58845888
},
58855889
path,

Diff for: src/test/compile-fail/directory_ownership/backcompat-warnings.rs

-16
This file was deleted.

Diff for: src/test/ui/non_modrs_mods/non_modrs_mods.stderr

+1-10
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,5 @@ error: mod statements in non-mod.rs files are unstable (see issue #44660)
3434
= help: add #![feature(non_modrs_mods)] to the crate attributes to enable
3535
= help: on stable builds, rename this file to inner_foors_mod/mod.rs
3636

37-
error: mod statements in non-mod.rs files are unstable (see issue #44660)
38-
--> $DIR/some_crazy_attr_mod_dir/arbitrary_name.rs:11:9
39-
|
40-
11 | pub mod inner_modrs_mod;
41-
| ^^^^^^^^^^^^^^^
42-
|
43-
= help: add #![feature(non_modrs_mods)] to the crate attributes to enable
44-
= help: on stable builds, rename this file to attr_mod/mod.rs
45-
46-
error: aborting due to 5 previous errors
37+
error: aborting due to 4 previous errors
4738

0 commit comments

Comments
 (0)