Skip to content

Commit

Permalink
Add a test for non-mod.rs mods
Browse files Browse the repository at this point in the history
  • Loading branch information
flodiebold committed May 6, 2018
1 parent cf573e8 commit 215baae
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/modules.rs
Expand Up @@ -75,7 +75,6 @@ fn module_file(
relative: Option<ast::Ident>,
codemap: &codemap::CodeMap,
) -> Result<(PathBuf, Option<ast::Ident>), 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));
}
Expand Down
17 changes: 17 additions & 0 deletions src/test/mod.rs
Expand Up @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions tests/issue-2673-nonmodrs-mods/foo.rs
@@ -0,0 +1,3 @@
mod bar;

mod baz {}
1 change: 1 addition & 0 deletions tests/issue-2673-nonmodrs-mods/foo/bar.rs
@@ -0,0 +1 @@
fn dummy() {}
3 changes: 3 additions & 0 deletions tests/issue-2673-nonmodrs-mods/lib.rs
@@ -0,0 +1,3 @@
#![feature(non_modrs_mods)]

mod foo;

0 comments on commit 215baae

Please sign in to comment.