diff options
Diffstat (limited to '')
35 files changed, 134 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-4874/bar/baz.rs b/src/tools/rustfmt/tests/mod-resolver/issue-4874/bar/baz.rs new file mode 100644 index 000000000..d31b675ea --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-4874/bar/baz.rs @@ -0,0 +1,5 @@ +fn + fail_fmt_check + ( + + ) {}
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-4874/foo.rs b/src/tools/rustfmt/tests/mod-resolver/issue-4874/foo.rs new file mode 100644 index 000000000..246d84786 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-4874/foo.rs @@ -0,0 +1 @@ +mod qux;
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-4874/foo/qux.rs b/src/tools/rustfmt/tests/mod-resolver/issue-4874/foo/qux.rs new file mode 100644 index 000000000..d8bb610a6 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-4874/foo/qux.rs @@ -0,0 +1,5 @@ + fn + badly_formatted + ( + + ) {}
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-4874/main.rs b/src/tools/rustfmt/tests/mod-resolver/issue-4874/main.rs new file mode 100644 index 000000000..3609415b1 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-4874/main.rs @@ -0,0 +1,8 @@ +fn main() { + println!("Hello, world!"); +} + +mod foo; +mod bar { + mod baz; +}
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5063/foo.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5063/foo.rs new file mode 100644 index 000000000..d56974773 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5063/foo.rs @@ -0,0 +1,2 @@ +mod bar { + mod baz;}
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5063/foo/bar/baz.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5063/foo/bar/baz.rs new file mode 100644 index 000000000..3519b0ee5 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5063/foo/bar/baz.rs @@ -0,0 +1 @@ +fn baz() { }
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5063/main.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5063/main.rs new file mode 100644 index 000000000..41c81c7bb --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5063/main.rs @@ -0,0 +1,5 @@ +fn main() { + println!("Hello, world!"); +} + +mod foo;
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/a.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/a.rs new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/a.rs diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/a/mod.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/a/mod.rs new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/a/mod.rs diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/lib.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/lib.rs new file mode 100644 index 000000000..f21af614d --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5167/src/lib.rs @@ -0,0 +1 @@ +mod a; diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/a.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/a.rs new file mode 100644 index 000000000..cd686f561 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/a.rs @@ -0,0 +1 @@ +fn main( ) { println!("Hello World!") } diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib.rs new file mode 100644 index 000000000..696832913 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib.rs @@ -0,0 +1,3 @@ +mod a; +mod b; +mod c; diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/b.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/b.rs new file mode 100644 index 000000000..cd686f561 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/b.rs @@ -0,0 +1 @@ +fn main( ) { println!("Hello World!") } diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d.rs new file mode 100644 index 000000000..d1604aa23 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d.rs @@ -0,0 +1,3 @@ +mod e; +mod f; +mod g; diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/explanation.txt b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/explanation.txt new file mode 100644 index 000000000..92c9e3021 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/explanation.txt @@ -0,0 +1,16 @@ +This file is contained in the './lib/c/d/' directory. + +The directory name './lib/c/d/' conflicts with the './lib/c/d.rs' file name. + +'./lib/c/d.rs' defines 3 external modules: + + * mod e; + * mod f; + * mod g; + +Module resolution will fail if we look for './lib/c/d/e.rs' or './lib/c/d/e/mod.rs', +so we should fall back to looking for './lib/c/e.rs', which correctly finds the modlue, that +rustfmt should format. + +'./lib/c/d/f.rs' and './lib/c/d/g/mod.rs' exist at the default submodule paths so we should be able +to resolve these modules with no problems.
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/f.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/f.rs new file mode 100644 index 000000000..cd686f561 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/f.rs @@ -0,0 +1 @@ +fn main( ) { println!("Hello World!") } diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/g/mod.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/g/mod.rs new file mode 100644 index 000000000..cd686f561 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/d/g/mod.rs @@ -0,0 +1 @@ +fn main( ) { println!("Hello World!") } diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/e.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/e.rs new file mode 100644 index 000000000..cd686f561 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/e.rs @@ -0,0 +1 @@ +fn main( ) { println!("Hello World!") } diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/mod.rs b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/mod.rs new file mode 100644 index 000000000..819046196 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/c/mod.rs @@ -0,0 +1,3 @@ +mod d; + +fn main( ) { println!("Hello World!") } diff --git a/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/explanation.txt b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/explanation.txt new file mode 100644 index 000000000..d436a8076 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/issue-5198/lib/explanation.txt @@ -0,0 +1,16 @@ +This file is contained in the './lib' directory. + +The directory name './lib' conflicts with the './lib.rs' file name. + +'lib.rs' defines 3 external modules: + + * mod a; + * mod b; + * mod c; + +Module resolution will fail if we look for './lib/a.rs' or './lib/a/mod.rs', +so we should fall back to looking for './a.rs', which correctly finds the modlue that +rustfmt should format. + +'./lib/b.rs' and './lib/c/mod.rs' exist at the default submodule paths so we should be able +to resolve these modules with no problems. diff --git a/src/tools/rustfmt/tests/mod-resolver/module-not-found/bad_path_attribute/lib.rs b/src/tools/rustfmt/tests/mod-resolver/module-not-found/bad_path_attribute/lib.rs new file mode 100644 index 000000000..2a63c961b --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/module-not-found/bad_path_attribute/lib.rs @@ -0,0 +1,3 @@ +// module resolution fails because the path does not exist. +#[path = "path/to/does_not_exist.rs"] +mod a; diff --git a/src/tools/rustfmt/tests/mod-resolver/module-not-found/relative_module/a.rs b/src/tools/rustfmt/tests/mod-resolver/module-not-found/relative_module/a.rs new file mode 100644 index 000000000..4a1eac896 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/module-not-found/relative_module/a.rs @@ -0,0 +1,2 @@ +// module resolution fails because `./a/b.rs` does not exist +mod b; diff --git a/src/tools/rustfmt/tests/mod-resolver/module-not-found/relative_module/lib.rs b/src/tools/rustfmt/tests/mod-resolver/module-not-found/relative_module/lib.rs new file mode 100644 index 000000000..f21af614d --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/module-not-found/relative_module/lib.rs @@ -0,0 +1 @@ +mod a; diff --git a/src/tools/rustfmt/tests/mod-resolver/module-not-found/sibling_module/lib.rs b/src/tools/rustfmt/tests/mod-resolver/module-not-found/sibling_module/lib.rs new file mode 100644 index 000000000..d9d9e1e3c --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/module-not-found/sibling_module/lib.rs @@ -0,0 +1,2 @@ +// module resolution fails because `./a.rs` does not exist +mod a; diff --git a/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/foo.rs b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/foo.rs new file mode 100644 index 000000000..74889acf0 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/foo.rs @@ -0,0 +1,5 @@ +#![rustfmt::skip] + +mod bar { + + mod baz;}
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/foo/bar/baz.rs b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/foo/bar/baz.rs new file mode 100644 index 000000000..3519b0ee5 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/foo/bar/baz.rs @@ -0,0 +1 @@ +fn baz() { }
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/main.rs b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/main.rs new file mode 100644 index 000000000..3122e4f22 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/main.rs @@ -0,0 +1,9 @@ +#![rustfmt::skip] + +mod foo; +mod one; + +fn main() {println!("Hello, world!"); +} + +// trailing commet diff --git a/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/one.rs b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/one.rs new file mode 100644 index 000000000..e7eb2c2d6 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/skip-files-issue-5065/one.rs @@ -0,0 +1 @@ +struct One { value: String }
\ No newline at end of file diff --git a/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/Cargo.toml b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/Cargo.toml new file mode 100644 index 000000000..0993f1279 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rustfmt-test-submodule-issue" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/src/lib.rs b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/src/lib.rs new file mode 100644 index 000000000..3f7ddba8a --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/src/lib.rs @@ -0,0 +1,7 @@ +pub fn foo() -> i32 { +3 +} + +pub fn bar() -> i32 { +4 +} diff --git a/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1.rs b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1.rs new file mode 100644 index 000000000..da4e86169 --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1.rs @@ -0,0 +1,8 @@ +mod test1 { +#[cfg(unix)] +mod sub1; +#[cfg(not(unix))] +mod sub2; + +mod sub3; +} diff --git a/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub1.rs b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub1.rs new file mode 100644 index 000000000..b760ba23c --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub1.rs @@ -0,0 +1,6 @@ +use rustfmt_test_submodule_issue::foo; + +#[test] +fn test_foo() { +assert_eq!(3, foo()); +} diff --git a/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub2.rs b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub2.rs new file mode 100644 index 000000000..4fd8286ea --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub2.rs @@ -0,0 +1,6 @@ +use rustfmt_test_submodule_issue::bar; + +#[test] +fn test_bar() { +assert_eq!(4, bar()); +} diff --git a/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub3/mod.rs b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub3/mod.rs new file mode 100644 index 000000000..e029785bc --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub3/mod.rs @@ -0,0 +1 @@ +mod sub4; diff --git a/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub3/sub4.rs b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub3/sub4.rs new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/tools/rustfmt/tests/mod-resolver/test-submodule-issue-5119/tests/test1/sub3/sub4.rs |