]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add new test to highlight namespace for self import
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 25 Mar 2025 18:03:00 +0000 (19:03 +0100)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Thu, 27 Mar 2025 17:29:15 +0000 (17:29 +0000)
gcc/testsuite/ChangeLog:

* rust/compile/self_import_namespace.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/rust/compile/self_import_namespace.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/self_import_namespace.rs b/gcc/testsuite/rust/compile/self_import_namespace.rs
new file mode 100644 (file)
index 0000000..2d9b2ed
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-additional-options "-frust-name-resolution-2.0" }
+
+mod bar {
+    pub mod foo {}
+    pub fn foo() {}
+}
+
+// This only imports the module `foo`. The function `foo` lives in
+// the value namespace and is not imported.
+use bar::foo::{self};
+
+fn main() {
+    foo(); // { dg-error "expected value" }
+}