summaryrefslogtreecommitdiffstats
path: root/tests/ui/directory_ownership
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/directory_ownership
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/directory_ownership')
-rw-r--r--tests/ui/directory_ownership/foo/compiletest-ignore-dir0
-rw-r--r--tests/ui/directory_ownership/foo/mod_file_not_owning/aux2.rs1
-rw-r--r--tests/ui/directory_ownership/foo/mod_file_not_owning_aux2.rs1
-rw-r--r--tests/ui/directory_ownership/macro-expanded-mod.rs15
-rw-r--r--tests/ui/directory_ownership/macro-expanded-mod.stderr13
-rw-r--r--tests/ui/directory_ownership/macro_expanded_mod_helper/foo/bar.rs1
-rw-r--r--tests/ui/directory_ownership/macro_expanded_mod_helper/foo/mod.rs3
-rw-r--r--tests/ui/directory_ownership/mod_file_not_owning_aux1.rs6
-rw-r--r--tests/ui/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir0
-rw-r--r--tests/ui/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs1
-rw-r--r--tests/ui/directory_ownership/mod_file_not_owning_aux2.rs1
-rw-r--r--tests/ui/directory_ownership/mod_file_not_owning_aux3.rs3
-rw-r--r--tests/ui/directory_ownership/non-inline-mod-restriction.rs5
-rw-r--r--tests/ui/directory_ownership/non-inline-mod-restriction.stderr8
14 files changed, 58 insertions, 0 deletions
diff --git a/tests/ui/directory_ownership/foo/compiletest-ignore-dir b/tests/ui/directory_ownership/foo/compiletest-ignore-dir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/ui/directory_ownership/foo/compiletest-ignore-dir
diff --git a/tests/ui/directory_ownership/foo/mod_file_not_owning/aux2.rs b/tests/ui/directory_ownership/foo/mod_file_not_owning/aux2.rs
new file mode 100644
index 000000000..d11c69f81
--- /dev/null
+++ b/tests/ui/directory_ownership/foo/mod_file_not_owning/aux2.rs
@@ -0,0 +1 @@
+// intentionally empty
diff --git a/tests/ui/directory_ownership/foo/mod_file_not_owning_aux2.rs b/tests/ui/directory_ownership/foo/mod_file_not_owning_aux2.rs
new file mode 100644
index 000000000..d11c69f81
--- /dev/null
+++ b/tests/ui/directory_ownership/foo/mod_file_not_owning_aux2.rs
@@ -0,0 +1 @@
+// intentionally empty
diff --git a/tests/ui/directory_ownership/macro-expanded-mod.rs b/tests/ui/directory_ownership/macro-expanded-mod.rs
new file mode 100644
index 000000000..fa81769e5
--- /dev/null
+++ b/tests/ui/directory_ownership/macro-expanded-mod.rs
@@ -0,0 +1,15 @@
+// Test that macro-expanded non-inline modules behave correctly
+
+macro_rules! mod_decl {
+ ($i:ident) => {
+ mod $i; //~ ERROR cannot declare a non-inline module inside a block
+ };
+}
+
+mod macro_expanded_mod_helper {
+ mod_decl!(foo); // This should search in the folder `macro_expanded_mod_helper`
+}
+
+fn main() {
+ mod_decl!(foo);
+}
diff --git a/tests/ui/directory_ownership/macro-expanded-mod.stderr b/tests/ui/directory_ownership/macro-expanded-mod.stderr
new file mode 100644
index 000000000..8976341b1
--- /dev/null
+++ b/tests/ui/directory_ownership/macro-expanded-mod.stderr
@@ -0,0 +1,13 @@
+error: cannot declare a non-inline module inside a block unless it has a path attribute
+ --> $DIR/macro-expanded-mod.rs:5:9
+ |
+LL | mod $i;
+ | ^^^^^^^
+...
+LL | mod_decl!(foo);
+ | -------------- in this macro invocation
+ |
+ = note: this error originates in the macro `mod_decl` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/tests/ui/directory_ownership/macro_expanded_mod_helper/foo/bar.rs b/tests/ui/directory_ownership/macro_expanded_mod_helper/foo/bar.rs
new file mode 100644
index 000000000..01c087dbc
--- /dev/null
+++ b/tests/ui/directory_ownership/macro_expanded_mod_helper/foo/bar.rs
@@ -0,0 +1 @@
+// ignore-test not a test, auxiliary
diff --git a/tests/ui/directory_ownership/macro_expanded_mod_helper/foo/mod.rs b/tests/ui/directory_ownership/macro_expanded_mod_helper/foo/mod.rs
new file mode 100644
index 000000000..2ec1c8bcc
--- /dev/null
+++ b/tests/ui/directory_ownership/macro_expanded_mod_helper/foo/mod.rs
@@ -0,0 +1,3 @@
+// ignore-test not a test, auxiliary
+
+mod_decl!(bar);
diff --git a/tests/ui/directory_ownership/mod_file_not_owning_aux1.rs b/tests/ui/directory_ownership/mod_file_not_owning_aux1.rs
new file mode 100644
index 000000000..eb5e8e3e1
--- /dev/null
+++ b/tests/ui/directory_ownership/mod_file_not_owning_aux1.rs
@@ -0,0 +1,6 @@
+// ignore-test this is not a test
+
+macro_rules! m {
+ () => { mod mod_file_not_owning_aux2; }
+}
+m!();
diff --git a/tests/ui/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir b/tests/ui/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/ui/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir
diff --git a/tests/ui/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs b/tests/ui/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs
new file mode 100644
index 000000000..d11c69f81
--- /dev/null
+++ b/tests/ui/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs
@@ -0,0 +1 @@
+// intentionally empty
diff --git a/tests/ui/directory_ownership/mod_file_not_owning_aux2.rs b/tests/ui/directory_ownership/mod_file_not_owning_aux2.rs
new file mode 100644
index 000000000..920938c4a
--- /dev/null
+++ b/tests/ui/directory_ownership/mod_file_not_owning_aux2.rs
@@ -0,0 +1 @@
+// ignore-test this is not a test
diff --git a/tests/ui/directory_ownership/mod_file_not_owning_aux3.rs b/tests/ui/directory_ownership/mod_file_not_owning_aux3.rs
new file mode 100644
index 000000000..6e4a39289
--- /dev/null
+++ b/tests/ui/directory_ownership/mod_file_not_owning_aux3.rs
@@ -0,0 +1,3 @@
+// ignore-test this is not a test
+
+mod mod_file_not_owning_aux2;
diff --git a/tests/ui/directory_ownership/non-inline-mod-restriction.rs b/tests/ui/directory_ownership/non-inline-mod-restriction.rs
new file mode 100644
index 000000000..de4f81665
--- /dev/null
+++ b/tests/ui/directory_ownership/non-inline-mod-restriction.rs
@@ -0,0 +1,5 @@
+// Test that non-inline modules are not allowed inside blocks.
+
+fn main() {
+ mod foo; //~ ERROR cannot declare a non-inline module inside a block
+}
diff --git a/tests/ui/directory_ownership/non-inline-mod-restriction.stderr b/tests/ui/directory_ownership/non-inline-mod-restriction.stderr
new file mode 100644
index 000000000..64189bee4
--- /dev/null
+++ b/tests/ui/directory_ownership/non-inline-mod-restriction.stderr
@@ -0,0 +1,8 @@
+error: cannot declare a non-inline module inside a block unless it has a path attribute
+ --> $DIR/non-inline-mod-restriction.rs:4:5
+ |
+LL | mod foo;
+ | ^^^^^^^^
+
+error: aborting due to previous error
+