From 215baae2238971361c5f92accfae35ba0ad6c634 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 4 May 2018 20:12:06 +0200 Subject: [PATCH] Add a test for non-mod.rs mods --- src/modules.rs | 1 - src/test/mod.rs | 17 +++++++++++++++++ tests/issue-2673-nonmodrs-mods/foo.rs | 3 +++ tests/issue-2673-nonmodrs-mods/foo/bar.rs | 1 + tests/issue-2673-nonmodrs-mods/lib.rs | 3 +++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/issue-2673-nonmodrs-mods/foo.rs create mode 100644 tests/issue-2673-nonmodrs-mods/foo/bar.rs create mode 100644 tests/issue-2673-nonmodrs-mods/lib.rs diff --git a/src/modules.rs b/src/modules.rs index 8426a751daa..80a7e85c71d 100644 --- a/src/modules.rs +++ b/src/modules.rs @@ -75,7 +75,6 @@ fn module_file( relative: Option, codemap: &codemap::CodeMap, ) -> Result<(PathBuf, Option), io::Error> { - eprintln!("module_file {:?} {:?} {:?}", id, attrs, dir_path); if let Some(path) = parser::Parser::submod_path_from_attr(attrs, dir_path) { return Ok((path, None)); } diff --git a/src/test/mod.rs b/src/test/mod.rs index 2680830f065..c5898950813 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -232,6 +232,23 @@ fn self_tests() { ); } +#[test] +fn issue_2673_non_modrs_mods() { + match idempotent_check(&PathBuf::from("tests/issue-2673-nonmodrs-mods/lib.rs")) { + Ok(ref report) if report.has_warnings() => { + print!("{}", report); + panic!("had warnings"); + } + Ok(_report) => {} + Err(err) => { + if let IdempotentCheckError::Mismatch(msg) = err { + print_mismatches_default_message(msg); + } + panic!("had errors"); + } + } +} + #[test] fn stdin_formatting_smoke_test() { let input = Input::Text("fn main () {}".to_owned()); diff --git a/tests/issue-2673-nonmodrs-mods/foo.rs b/tests/issue-2673-nonmodrs-mods/foo.rs new file mode 100644 index 00000000000..c9fb22cf1a6 --- /dev/null +++ b/tests/issue-2673-nonmodrs-mods/foo.rs @@ -0,0 +1,3 @@ +mod bar; + +mod baz {} diff --git a/tests/issue-2673-nonmodrs-mods/foo/bar.rs b/tests/issue-2673-nonmodrs-mods/foo/bar.rs new file mode 100644 index 00000000000..9ceacd59d86 --- /dev/null +++ b/tests/issue-2673-nonmodrs-mods/foo/bar.rs @@ -0,0 +1 @@ +fn dummy() {} diff --git a/tests/issue-2673-nonmodrs-mods/lib.rs b/tests/issue-2673-nonmodrs-mods/lib.rs new file mode 100644 index 00000000000..e2025a5449d --- /dev/null +++ b/tests/issue-2673-nonmodrs-mods/lib.rs @@ -0,0 +1,3 @@ +#![feature(non_modrs_mods)] + +mod foo;