Skip to content

Commit ad8797c

Browse files
committed
Add a test for non-mod.rs mods
1 parent 082542d commit ad8797c

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

src/modules.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ fn module_file(
7575
relative: Option<ast::Ident>,
7676
codemap: &codemap::CodeMap,
7777
) -> Result<(PathBuf, Option<ast::Ident>), io::Error> {
78-
eprintln!("module_file {:?} {:?} {:?}", id, attrs, dir_path);
7978
if let Some(path) = parser::Parser::submod_path_from_attr(attrs, dir_path) {
8079
return Ok((path, None));
8180
}

src/test/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,23 @@ fn self_tests() {
232232
);
233233
}
234234

235+
#[test]
236+
fn issue_2673_non_modrs_mods() {
237+
match idempotent_check(&PathBuf::from("tests/issue-2673-nonmodrs-mods/lib.rs")) {
238+
Ok(ref report) if report.has_warnings() => {
239+
print!("{}", report);
240+
panic!("had warnings");
241+
}
242+
Ok(_report) => {}
243+
Err(err) => {
244+
if let IdempotentCheckError::Mismatch(msg) = err {
245+
print_mismatches_default_message(msg);
246+
}
247+
panic!("had errors");
248+
}
249+
}
250+
}
251+
235252
#[test]
236253
fn stdin_formatting_smoke_test() {
237254
let input = Input::Text("fn main () {}".to_owned());

tests/issue-2673-nonmodrs-mods/foo.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mod bar;
2+
3+
mod baz {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn dummy() {}

tests/issue-2673-nonmodrs-mods/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#![feature(non_modrs_mods)]
2+
3+
mod foo;

0 commit comments

Comments
 (0)