diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index a814c88ee7821..69843a1351656 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1869,7 +1869,6 @@ mod tests { missing_fragment_specifiers: Lock::new(FxHashSet::default()), raw_identifier_spans: Lock::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), - non_modrs_mods: Lock::new(vec![]), buffered_lints: Lock::new(vec![]), } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 5c6d5816a472b..6e9f434d32306 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -52,9 +52,6 @@ pub struct ParseSess { pub raw_identifier_spans: Lock>, /// The registered diagnostics codes crate registered_diagnostics: Lock, - // Spans where a `mod foo;` statement was included in a non-mod.rs file. - // These are used to issue errors if the non_modrs_mods feature is not enabled. - pub non_modrs_mods: Lock>, /// Used to determine and report recursive mod inclusions included_mod_stack: Lock>, code_map: Lrc, @@ -81,7 +78,6 @@ impl ParseSess { registered_diagnostics: Lock::new(ErrorMap::new()), included_mod_stack: Lock::new(vec![]), code_map, - non_modrs_mods: Lock::new(vec![]), buffered_lints: Lock::new(vec![]), } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c7089a295fc3d..98541f3cdd23e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6426,6 +6426,10 @@ impl<'a> Parser<'a> { self.directory.path.to_mut().push(&path.as_str()); self.directory.ownership = DirectoryOwnership::Owned { relative: None }; } else { + if let DirectoryOwnership::Owned{ relative: Some(id) } = self.directory.ownership { + self.directory.path.to_mut().push(id.as_str()); + self.directory.ownership = DirectoryOwnership::Owned { relative: None }; + } self.directory.path.to_mut().push(&id.as_str()); } } @@ -6533,16 +6537,7 @@ impl<'a> Parser<'a> { } let relative = match self.directory.ownership { - DirectoryOwnership::Owned { relative } => { - // Push the usage onto the list of non-mod.rs mod uses. - // This is used later for feature-gate error reporting. - if let Some(cur_file_ident) = relative { - self.sess - .non_modrs_mods.borrow_mut() - .push((cur_file_ident, id_sp)); - } - relative - }, + DirectoryOwnership::Owned { relative } => relative, DirectoryOwnership::UnownedViaBlock | DirectoryOwnership::UnownedViaMod(_) => None, }; diff --git a/src/test/run-pass/non_modrs_mods/foors_mod.rs b/src/test/run-pass/non_modrs_mods/foors_mod.rs index 7d37c6d939954..40577f1122ef3 100644 --- a/src/test/run-pass/non_modrs_mods/foors_mod.rs +++ b/src/test/run-pass/non_modrs_mods/foors_mod.rs @@ -12,3 +12,8 @@ pub mod inner_modrs_mod; pub mod inner_foors_mod; +pub mod block { + pub mod block_inner { + pub mod block_inner_inner; + } +} diff --git a/src/test/run-pass/non_modrs_mods/foors_mod/block/block_inner/block_inner_inner.rs b/src/test/run-pass/non_modrs_mods/foors_mod/block/block_inner/block_inner_inner.rs new file mode 100644 index 0000000000000..b76b4321d62aa --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/foors_mod/block/block_inner/block_inner_inner.rs @@ -0,0 +1 @@ +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs b/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs new file mode 100644 index 0000000000000..a1f7ba2fed201 --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs @@ -0,0 +1,15 @@ +// run-pass +// +// ignore-pretty issue #37195 +pub mod modrs_mod; +pub mod foors_mod; +#[path = "some_crazy_attr_mod_dir/arbitrary_name.rs"] +pub mod attr_mod; +pub fn main() { + modrs_mod::inner_modrs_mod::innest::foo(); + modrs_mod::inner_foors_mod::innest::foo(); + foors_mod::inner_modrs_mod::innest::foo(); + foors_mod::inner_foors_mod::innest::foo(); + foors_mod::block::block_inner::block_inner_inner::foo(); + attr_mod::inner_modrs_mod::innest::foo(); +} diff --git a/src/test/ui/missing_non_modrs_mod/foo_inline.rs b/src/test/ui/missing_non_modrs_mod/foo_inline.rs new file mode 100644 index 0000000000000..df60629eca161 --- /dev/null +++ b/src/test/ui/missing_non_modrs_mod/foo_inline.rs @@ -0,0 +1,5 @@ +// ignore-test this is just a helper for the real test in this dir + +mod inline { + mod missing; +} diff --git a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs index 9c95f45939367..84fa1f032d78e 100644 --- a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs +++ b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs @@ -8,7 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-windows - mod foo; fn main() {} diff --git a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.rs b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.rs new file mode 100644 index 0000000000000..9ebb4f1bdbdb3 --- /dev/null +++ b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.rs @@ -0,0 +1,2 @@ +mod foo_inline; +fn main() {} diff --git a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr new file mode 100644 index 0000000000000..457e8fcccbfb3 --- /dev/null +++ b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `missing` + --> $DIR/foo_inline.rs:4:9 + | +LL | mod missing; + | ^^^^^^^ + | + = help: name the file either missing.rs or missing/mod.rs inside the directory "$DIR/foo_inline/inline" + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0583`. diff --git a/src/test/ui/non_modrs_mods/foors_mod.rs b/src/test/ui/non_modrs_mods/foors_mod.rs deleted file mode 100644 index 7d37c6d939954..0000000000000 --- a/src/test/ui/non_modrs_mods/foors_mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// ignore-test: not a test, used by non_modrs_mods.rs - -pub mod inner_modrs_mod; -pub mod inner_foors_mod; diff --git a/src/test/ui/non_modrs_mods/foors_mod/compiletest-ignore-dir b/src/test/ui/non_modrs_mods/foors_mod/compiletest-ignore-dir deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs deleted file mode 100644 index 77cab972352bd..0000000000000 --- a/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs deleted file mode 100644 index b61667cfd882c..0000000000000 --- a/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs deleted file mode 100644 index b61667cfd882c..0000000000000 --- a/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs deleted file mode 100644 index 77cab972352bd..0000000000000 --- a/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff --git a/src/test/ui/non_modrs_mods/modrs_mod/compiletest-ignore-dir b/src/test/ui/non_modrs_mods/modrs_mod/compiletest-ignore-dir deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs deleted file mode 100644 index 77cab972352bd..0000000000000 --- a/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs deleted file mode 100644 index b61667cfd882c..0000000000000 --- a/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs deleted file mode 100644 index b61667cfd882c..0000000000000 --- a/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs deleted file mode 100644 index 77cab972352bd..0000000000000 --- a/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff --git a/src/test/ui/non_modrs_mods/modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/modrs_mod/mod.rs deleted file mode 100644 index 9e3f10f12ed63..0000000000000 --- a/src/test/ui/non_modrs_mods/modrs_mod/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod inner_modrs_mod; -pub mod inner_foors_mod; diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs deleted file mode 100644 index 226e6fda0a41f..0000000000000 --- a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod inner_modrs_mod; diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs deleted file mode 100644 index b61667cfd882c..0000000000000 --- a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs deleted file mode 100644 index 77cab972352bd..0000000000000 --- a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest;