summaryrefslogtreecommitdiffstats
path: root/src/test/ui/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/modules')
-rw-r--r--src/test/ui/modules/auxiliary/two_macros_2.rs3
-rw-r--r--src/test/ui/modules/issue-56411-aux.rs5
-rw-r--r--src/test/ui/modules/issue-56411.rs18
-rw-r--r--src/test/ui/modules/issue-56411.stderr33
-rw-r--r--src/test/ui/modules/mod-inside-fn.rs13
-rw-r--r--src/test/ui/modules/mod-view-items.rs14
-rw-r--r--src/test/ui/modules/mod_dir_implicit.rs8
-rw-r--r--src/test/ui/modules/mod_dir_implicit_aux/compiletest-ignore-dir0
-rw-r--r--src/test/ui/modules/mod_dir_implicit_aux/mod.rs2
-rw-r--r--src/test/ui/modules/mod_dir_path.rs23
-rw-r--r--src/test/ui/modules/mod_dir_path2.rs12
-rw-r--r--src/test/ui/modules/mod_dir_path3.rs11
-rw-r--r--src/test/ui/modules/mod_dir_path_multi.rs17
-rw-r--r--src/test/ui/modules/mod_dir_recursive.rs14
-rw-r--r--src/test/ui/modules/mod_dir_simple.rs10
-rw-r--r--src/test/ui/modules/mod_dir_simple/compiletest-ignore-dir0
-rw-r--r--src/test/ui/modules/mod_dir_simple/load_another_mod.rs3
-rw-r--r--src/test/ui/modules/mod_dir_simple/test.rs2
-rw-r--r--src/test/ui/modules/mod_file.rs10
-rw-r--r--src/test/ui/modules/mod_file_aux.rs4
-rw-r--r--src/test/ui/modules/mod_file_with_path_attr.rs11
-rw-r--r--src/test/ui/modules/module-polymorphism3-files/compiletest-ignore-dir0
-rw-r--r--src/test/ui/modules/module-polymorphism3-files/float-template/inst_f32.rs3
-rw-r--r--src/test/ui/modules/module-polymorphism3-files/float-template/inst_f64.rs3
-rw-r--r--src/test/ui/modules/module-polymorphism3-files/float-template/inst_float.rs3
-rw-r--r--src/test/ui/modules/path-invalid-form.rs4
-rw-r--r--src/test/ui/modules/path-invalid-form.stderr8
-rw-r--r--src/test/ui/modules/path-macro.rs8
-rw-r--r--src/test/ui/modules/path-macro.stderr8
-rw-r--r--src/test/ui/modules/path-no-file-name.rs7
-rw-r--r--src/test/ui/modules/path-no-file-name.stderr8
31 files changed, 265 insertions, 0 deletions
diff --git a/src/test/ui/modules/auxiliary/two_macros_2.rs b/src/test/ui/modules/auxiliary/two_macros_2.rs
new file mode 100644
index 000000000..8ad2c0f12
--- /dev/null
+++ b/src/test/ui/modules/auxiliary/two_macros_2.rs
@@ -0,0 +1,3 @@
+macro_rules! macro_one { ($($t:tt)*) => ($($t)*) }
+
+macro_rules! macro_two { ($($t:tt)*) => ($($t)*) }
diff --git a/src/test/ui/modules/issue-56411-aux.rs b/src/test/ui/modules/issue-56411-aux.rs
new file mode 100644
index 000000000..c8e5a0598
--- /dev/null
+++ b/src/test/ui/modules/issue-56411-aux.rs
@@ -0,0 +1,5 @@
+// check-pass
+
+struct T {}
+
+fn main() {}
diff --git a/src/test/ui/modules/issue-56411.rs b/src/test/ui/modules/issue-56411.rs
new file mode 100644
index 000000000..0a20f5fe9
--- /dev/null
+++ b/src/test/ui/modules/issue-56411.rs
@@ -0,0 +1,18 @@
+macro_rules! import {
+ ( $(($path:expr, $name:ident)),* ) => {
+ $(
+ #[path = $path]
+ mod $name;
+ pub use self::$name;
+ //~^ ERROR the name `issue_56411_aux` is defined multiple times
+ //~| ERROR `issue_56411_aux` is only public within the crate, and cannot be re-exported outside
+
+ )*
+ }
+}
+
+import!(("issue-56411-aux.rs", issue_56411_aux));
+
+fn main() {
+ println!("Hello, world!");
+}
diff --git a/src/test/ui/modules/issue-56411.stderr b/src/test/ui/modules/issue-56411.stderr
new file mode 100644
index 000000000..6732a8a3d
--- /dev/null
+++ b/src/test/ui/modules/issue-56411.stderr
@@ -0,0 +1,33 @@
+error[E0255]: the name `issue_56411_aux` is defined multiple times
+ --> $DIR/issue-56411.rs:6:21
+ |
+LL | mod $name;
+ | ---------- previous definition of the module `issue_56411_aux` here
+LL | pub use self::$name;
+ | ^^^^^^^^^^^
+ | |
+ | `issue_56411_aux` reimported here
+ | you can use `as` to change the binding name of the import
+...
+LL | import!(("issue-56411-aux.rs", issue_56411_aux));
+ | ------------------------------------------------ in this macro invocation
+ |
+ = note: `issue_56411_aux` must be defined only once in the type namespace of this module
+ = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0365]: `issue_56411_aux` is only public within the crate, and cannot be re-exported outside
+ --> $DIR/issue-56411.rs:6:21
+ |
+LL | pub use self::$name;
+ | ^^^^^^^^^^^ re-export of crate public `issue_56411_aux`
+...
+LL | import!(("issue-56411-aux.rs", issue_56411_aux));
+ | ------------------------------------------------ in this macro invocation
+ |
+ = note: consider declaring type or module `issue_56411_aux` with `pub`
+ = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0255, E0365.
+For more information about an error, try `rustc --explain E0255`.
diff --git a/src/test/ui/modules/mod-inside-fn.rs b/src/test/ui/modules/mod-inside-fn.rs
new file mode 100644
index 000000000..93050c891
--- /dev/null
+++ b/src/test/ui/modules/mod-inside-fn.rs
@@ -0,0 +1,13 @@
+// run-pass
+
+fn f() -> isize {
+ mod m {
+ pub fn g() -> isize { 720 }
+ }
+
+ m::g()
+}
+
+pub fn main() {
+ assert_eq!(f(), 720);
+}
diff --git a/src/test/ui/modules/mod-view-items.rs b/src/test/ui/modules/mod-view-items.rs
new file mode 100644
index 000000000..db2b30366
--- /dev/null
+++ b/src/test/ui/modules/mod-view-items.rs
@@ -0,0 +1,14 @@
+// run-pass
+// Test view items inside non-file-level mods
+
+// This is a regression test for an issue where we were failing to
+// pretty-print such view items. If that happens again, this should
+// begin failing.
+
+// pretty-expanded FIXME #23616
+
+mod m {
+ pub fn f() -> Vec<isize> { Vec::new() }
+}
+
+pub fn main() { let _x = m::f(); }
diff --git a/src/test/ui/modules/mod_dir_implicit.rs b/src/test/ui/modules/mod_dir_implicit.rs
new file mode 100644
index 000000000..d6ea6a98b
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_implicit.rs
@@ -0,0 +1,8 @@
+// run-pass
+// ignore-pretty issue #37195
+
+mod mod_dir_implicit_aux;
+
+pub fn main() {
+ assert_eq!(mod_dir_implicit_aux::foo(), 10);
+}
diff --git a/src/test/ui/modules/mod_dir_implicit_aux/compiletest-ignore-dir b/src/test/ui/modules/mod_dir_implicit_aux/compiletest-ignore-dir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_implicit_aux/compiletest-ignore-dir
diff --git a/src/test/ui/modules/mod_dir_implicit_aux/mod.rs b/src/test/ui/modules/mod_dir_implicit_aux/mod.rs
new file mode 100644
index 000000000..4f1eb85e4
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_implicit_aux/mod.rs
@@ -0,0 +1,2 @@
+// run-pass
+pub fn foo() -> isize { 10 }
diff --git a/src/test/ui/modules/mod_dir_path.rs b/src/test/ui/modules/mod_dir_path.rs
new file mode 100644
index 000000000..70f592d0c
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_path.rs
@@ -0,0 +1,23 @@
+// run-pass
+#![allow(unused_macros)]
+// ignore-pretty issue #37195
+
+mod mod_dir_simple {
+ #[path = "test.rs"]
+ pub mod syrup;
+}
+
+pub fn main() {
+ assert_eq!(mod_dir_simple::syrup::foo(), 10);
+
+ #[path = "auxiliary"]
+ mod foo {
+ mod two_macros_2;
+ }
+
+ #[path = "auxiliary"]
+ mod bar {
+ macro_rules! m { () => { mod two_macros_2; } }
+ m!();
+ }
+}
diff --git a/src/test/ui/modules/mod_dir_path2.rs b/src/test/ui/modules/mod_dir_path2.rs
new file mode 100644
index 000000000..c3e3e1d63
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_path2.rs
@@ -0,0 +1,12 @@
+// run-pass
+// ignore-pretty issue #37195
+
+#[path = "mod_dir_simple"]
+mod pancakes {
+ #[path = "test.rs"]
+ pub mod syrup;
+}
+
+pub fn main() {
+ assert_eq!(pancakes::syrup::foo(), 10);
+}
diff --git a/src/test/ui/modules/mod_dir_path3.rs b/src/test/ui/modules/mod_dir_path3.rs
new file mode 100644
index 000000000..fed70c1bc
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_path3.rs
@@ -0,0 +1,11 @@
+// run-pass
+// ignore-pretty issue #37195
+
+#[path = "mod_dir_simple"]
+mod pancakes {
+ pub mod test;
+}
+
+pub fn main() {
+ assert_eq!(pancakes::test::foo(), 10);
+}
diff --git a/src/test/ui/modules/mod_dir_path_multi.rs b/src/test/ui/modules/mod_dir_path_multi.rs
new file mode 100644
index 000000000..2b805141a
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_path_multi.rs
@@ -0,0 +1,17 @@
+// run-pass
+// ignore-pretty issue #37195
+
+#[path = "mod_dir_simple"]
+mod biscuits {
+ pub mod test;
+}
+
+#[path = "mod_dir_simple"]
+mod gravy {
+ pub mod test;
+}
+
+pub fn main() {
+ assert_eq!(biscuits::test::foo(), 10);
+ assert_eq!(gravy::test::foo(), 10);
+}
diff --git a/src/test/ui/modules/mod_dir_recursive.rs b/src/test/ui/modules/mod_dir_recursive.rs
new file mode 100644
index 000000000..b109d13d1
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_recursive.rs
@@ -0,0 +1,14 @@
+// run-pass
+// ignore-pretty issue #37195
+
+// Testing that the parser for each file tracks its modules
+// and paths independently. The load_another_mod module should
+// not try to reuse the 'mod_dir_simple' path.
+
+mod mod_dir_simple {
+ pub mod load_another_mod;
+}
+
+pub fn main() {
+ assert_eq!(mod_dir_simple::load_another_mod::test::foo(), 10);
+}
diff --git a/src/test/ui/modules/mod_dir_simple.rs b/src/test/ui/modules/mod_dir_simple.rs
new file mode 100644
index 000000000..1d92c968a
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_simple.rs
@@ -0,0 +1,10 @@
+// run-pass
+// ignore-pretty issue #37195
+
+mod mod_dir_simple {
+ pub mod test;
+}
+
+pub fn main() {
+ assert_eq!(mod_dir_simple::test::foo(), 10);
+}
diff --git a/src/test/ui/modules/mod_dir_simple/compiletest-ignore-dir b/src/test/ui/modules/mod_dir_simple/compiletest-ignore-dir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_simple/compiletest-ignore-dir
diff --git a/src/test/ui/modules/mod_dir_simple/load_another_mod.rs b/src/test/ui/modules/mod_dir_simple/load_another_mod.rs
new file mode 100644
index 000000000..f96b546aa
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_simple/load_another_mod.rs
@@ -0,0 +1,3 @@
+// run-pass
+#[path = "test.rs"]
+pub mod test;
diff --git a/src/test/ui/modules/mod_dir_simple/test.rs b/src/test/ui/modules/mod_dir_simple/test.rs
new file mode 100644
index 000000000..4f1eb85e4
--- /dev/null
+++ b/src/test/ui/modules/mod_dir_simple/test.rs
@@ -0,0 +1,2 @@
+// run-pass
+pub fn foo() -> isize { 10 }
diff --git a/src/test/ui/modules/mod_file.rs b/src/test/ui/modules/mod_file.rs
new file mode 100644
index 000000000..0ca52889e
--- /dev/null
+++ b/src/test/ui/modules/mod_file.rs
@@ -0,0 +1,10 @@
+// run-pass
+// ignore-pretty issue #37195
+
+// Testing that a plain .rs file can load modules from other source files
+
+mod mod_file_aux;
+
+pub fn main() {
+ assert_eq!(mod_file_aux::foo(), 10);
+}
diff --git a/src/test/ui/modules/mod_file_aux.rs b/src/test/ui/modules/mod_file_aux.rs
new file mode 100644
index 000000000..6d052272e
--- /dev/null
+++ b/src/test/ui/modules/mod_file_aux.rs
@@ -0,0 +1,4 @@
+// run-pass
+// ignore-test Not a test. Used by other tests
+
+pub fn foo() -> isize { 10 }
diff --git a/src/test/ui/modules/mod_file_with_path_attr.rs b/src/test/ui/modules/mod_file_with_path_attr.rs
new file mode 100644
index 000000000..48e253ead
--- /dev/null
+++ b/src/test/ui/modules/mod_file_with_path_attr.rs
@@ -0,0 +1,11 @@
+// run-pass
+// ignore-pretty issue #37195
+
+// Testing that a plain .rs file can load modules from other source files
+
+#[path = "mod_file_aux.rs"]
+mod m;
+
+pub fn main() {
+ assert_eq!(m::foo(), 10);
+}
diff --git a/src/test/ui/modules/module-polymorphism3-files/compiletest-ignore-dir b/src/test/ui/modules/module-polymorphism3-files/compiletest-ignore-dir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/test/ui/modules/module-polymorphism3-files/compiletest-ignore-dir
diff --git a/src/test/ui/modules/module-polymorphism3-files/float-template/inst_f32.rs b/src/test/ui/modules/module-polymorphism3-files/float-template/inst_f32.rs
new file mode 100644
index 000000000..49d2b3d4b
--- /dev/null
+++ b/src/test/ui/modules/module-polymorphism3-files/float-template/inst_f32.rs
@@ -0,0 +1,3 @@
+// run-pass
+
+pub type T = f32;
diff --git a/src/test/ui/modules/module-polymorphism3-files/float-template/inst_f64.rs b/src/test/ui/modules/module-polymorphism3-files/float-template/inst_f64.rs
new file mode 100644
index 000000000..e2aad480e
--- /dev/null
+++ b/src/test/ui/modules/module-polymorphism3-files/float-template/inst_f64.rs
@@ -0,0 +1,3 @@
+// run-pass
+
+pub type T = f64;
diff --git a/src/test/ui/modules/module-polymorphism3-files/float-template/inst_float.rs b/src/test/ui/modules/module-polymorphism3-files/float-template/inst_float.rs
new file mode 100644
index 000000000..5828718cd
--- /dev/null
+++ b/src/test/ui/modules/module-polymorphism3-files/float-template/inst_float.rs
@@ -0,0 +1,3 @@
+// run-pass
+
+pub type T = float;
diff --git a/src/test/ui/modules/path-invalid-form.rs b/src/test/ui/modules/path-invalid-form.rs
new file mode 100644
index 000000000..713ef4a79
--- /dev/null
+++ b/src/test/ui/modules/path-invalid-form.rs
@@ -0,0 +1,4 @@
+#[path = 123] //~ ERROR malformed `path` attribute
+mod foo;
+
+fn main() {}
diff --git a/src/test/ui/modules/path-invalid-form.stderr b/src/test/ui/modules/path-invalid-form.stderr
new file mode 100644
index 000000000..7e8aa44ef
--- /dev/null
+++ b/src/test/ui/modules/path-invalid-form.stderr
@@ -0,0 +1,8 @@
+error: malformed `path` attribute input
+ --> $DIR/path-invalid-form.rs:1:1
+ |
+LL | #[path = 123]
+ | ^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/modules/path-macro.rs b/src/test/ui/modules/path-macro.rs
new file mode 100644
index 000000000..ce2d1e2da
--- /dev/null
+++ b/src/test/ui/modules/path-macro.rs
@@ -0,0 +1,8 @@
+macro_rules! foo {
+ () => {"bar.rs"};
+}
+
+#[path = foo!()] //~ ERROR malformed `path` attribute
+mod abc;
+
+fn main() {}
diff --git a/src/test/ui/modules/path-macro.stderr b/src/test/ui/modules/path-macro.stderr
new file mode 100644
index 000000000..9a2e01ea2
--- /dev/null
+++ b/src/test/ui/modules/path-macro.stderr
@@ -0,0 +1,8 @@
+error: malformed `path` attribute input
+ --> $DIR/path-macro.rs:5:1
+ |
+LL | #[path = foo!()]
+ | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/modules/path-no-file-name.rs b/src/test/ui/modules/path-no-file-name.rs
new file mode 100644
index 000000000..f62cd2a9e
--- /dev/null
+++ b/src/test/ui/modules/path-no-file-name.rs
@@ -0,0 +1,7 @@
+// normalize-stderr-test: "\.:.*\(" -> ".: $$ACCESS_DENIED_MSG ("
+// normalize-stderr-test: "os error \d+" -> "os error $$ACCESS_DENIED_CODE"
+
+#[path = "."]
+mod m; //~ ERROR couldn't read
+
+fn main() {}
diff --git a/src/test/ui/modules/path-no-file-name.stderr b/src/test/ui/modules/path-no-file-name.stderr
new file mode 100644
index 000000000..32a213c68
--- /dev/null
+++ b/src/test/ui/modules/path-no-file-name.stderr
@@ -0,0 +1,8 @@
+error: couldn't read $DIR/.: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE)
+ --> $DIR/path-no-file-name.rs:5:1
+ |
+LL | mod m;
+ | ^^^^^^
+
+error: aborting due to previous error
+