From 7f4bc2247a5fbfd8010ae1a799c3a6b2d173ec82 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 15 Oct 2018 18:43:57 -0700 Subject: [PATCH] Clean up some non-mod-rs stuff. --- src/libsyntax/parse/lexer/mod.rs | 1 - src/libsyntax/parse/mod.rs | 4 ---- src/libsyntax/parse/parser.rs | 11 +---------- src/test/run-pass/non_modrs_mods/foors_mod.rs | 4 ++++ .../non_modrs_mods/foors_mod/inline/somename.rs | 1 + .../non_modrs_mods/modrs_mod/inline/somename.rs | 1 + .../run-pass/non_modrs_mods/modrs_mod/mod.rs | 4 ++++ .../run-pass/non_modrs_mods/non_modrs_mods.rs | 16 ++++++++++++++++ .../invalid-module-declaration.rs | 1 - src/test/ui/missing_non_modrs_mod/foo_inline.rs | 5 +++++ .../missing_non_modrs_mod.rs | 2 -- .../missing_non_modrs_mod_inline.rs | 2 ++ .../missing_non_modrs_mod_inline.stderr | 11 +++++++++++ src/test/ui/non_modrs_mods/foors_mod.rs | 14 -------------- .../foors_mod/compiletest-ignore-dir | 0 .../non_modrs_mods/foors_mod/inner_foors_mod.rs | 11 ----------- .../foors_mod/inner_foors_mod/innest.rs | 11 ----------- .../foors_mod/inner_modrs_mod/innest.rs | 11 ----------- .../foors_mod/inner_modrs_mod/mod.rs | 11 ----------- .../modrs_mod/compiletest-ignore-dir | 0 .../non_modrs_mods/modrs_mod/inner_foors_mod.rs | 11 ----------- .../modrs_mod/inner_foors_mod/innest.rs | 11 ----------- .../modrs_mod/inner_modrs_mod/innest.rs | 11 ----------- .../modrs_mod/inner_modrs_mod/mod.rs | 11 ----------- src/test/ui/non_modrs_mods/modrs_mod/mod.rs | 12 ------------ .../some_crazy_attr_mod_dir/arbitrary_name.rs | 11 ----------- .../compiletest-ignore-dir | 0 .../inner_modrs_mod/innest.rs | 11 ----------- .../inner_modrs_mod/mod.rs | 11 ----------- 29 files changed, 45 insertions(+), 165 deletions(-) create mode 100644 src/test/run-pass/non_modrs_mods/foors_mod/inline/somename.rs create mode 100644 src/test/run-pass/non_modrs_mods/modrs_mod/inline/somename.rs create mode 100644 src/test/run-pass/non_modrs_mods/non_modrs_mods.rs create mode 100644 src/test/ui/missing_non_modrs_mod/foo_inline.rs create mode 100644 src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.rs create mode 100644 src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod_inline.stderr delete mode 100644 src/test/ui/non_modrs_mods/foors_mod.rs delete mode 100644 src/test/ui/non_modrs_mods/foors_mod/compiletest-ignore-dir delete mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs delete mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs delete mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs delete mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs delete mode 100644 src/test/ui/non_modrs_mods/modrs_mod/compiletest-ignore-dir delete mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs delete mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs delete mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs delete mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs delete mode 100644 src/test/ui/non_modrs_mods/modrs_mod/mod.rs delete mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs delete mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir delete mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs delete mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 590506566dd..0584cd5a3df 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1890,7 +1890,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 fd66bf55a74..ac972f20f94 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>, source_map: Lrc, @@ -81,7 +78,6 @@ impl ParseSess { registered_diagnostics: Lock::new(ErrorMap::new()), included_mod_stack: Lock::new(vec![]), source_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 d90ec4ea081..b4fc9c2c6fc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6591,16 +6591,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 7d37c6d9399..b2fea9b5e53 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,7 @@ pub mod inner_modrs_mod; pub mod inner_foors_mod; +pub mod inline { + #[path="somename.rs"] + pub mod innie; +} diff --git a/src/test/run-pass/non_modrs_mods/foors_mod/inline/somename.rs b/src/test/run-pass/non_modrs_mods/foors_mod/inline/somename.rs new file mode 100644 index 00000000000..b76b4321d62 --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/foors_mod/inline/somename.rs @@ -0,0 +1 @@ +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/inline/somename.rs b/src/test/run-pass/non_modrs_mods/modrs_mod/inline/somename.rs new file mode 100644 index 00000000000..b76b4321d62 --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/modrs_mod/inline/somename.rs @@ -0,0 +1 @@ +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs b/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs index 9e3f10f12ed..99684c86d2e 100644 --- a/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs +++ b/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs @@ -10,3 +10,7 @@ pub mod inner_modrs_mod; pub mod inner_foors_mod; +pub mod inline { + #[path="somename.rs"] + pub mod innie; +} 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 00000000000..f664b0166d8 --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs @@ -0,0 +1,16 @@ +// 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(); + modrs_mod::inline::innie::foo(); + foors_mod::inner_modrs_mod::innest::foo(); + foors_mod::inner_foors_mod::innest::foo(); + foors_mod::inline::innie::foo(); + attr_mod::inner_modrs_mod::innest::foo(); +} diff --git a/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs b/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs index c0a10fe3e60..229b005ec7d 100644 --- a/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs +++ b/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs @@ -9,7 +9,6 @@ // except according to those terms. // ignore-tidy-linelength -// ignore-windows mod auxiliary { mod 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 00000000000..df60629eca1 --- /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 9c95f459393..84fa1f032d7 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 00000000000..9ebb4f1bdbd --- /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 00000000000..457e8fcccbf --- /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 7d37c6d9399..00000000000 --- 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 e69de29bb2d..00000000000 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 77cab972352..00000000000 --- 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 b61667cfd88..00000000000 --- 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 b61667cfd88..00000000000 --- 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 77cab972352..00000000000 --- 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 e69de29bb2d..00000000000 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 77cab972352..00000000000 --- 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 b61667cfd88..00000000000 --- 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 b61667cfd88..00000000000 --- 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 77cab972352..00000000000 --- 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 9e3f10f12ed..00000000000 --- 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 226e6fda0a4..00000000000 --- 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 e69de29bb2d..00000000000 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 b61667cfd88..00000000000 --- 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 77cab972352..00000000000 --- 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;