[COMMITTED 24/35] gccrs: Add new test to highlight namespace for self import

arthur.cohen@embecosm.com arthur.cohen@embecosm.com
Mon Mar 31 19:25:06 GMT 2025


From: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
---
 .../rust/compile/self_import_namespace.rs          | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/self_import_namespace.rs

diff --git a/gcc/testsuite/rust/compile/self_import_namespace.rs b/gcc/testsuite/rust/compile/self_import_namespace.rs
new file mode 100644
index 00000000000..2d9b2ed8e0f
--- /dev/null
+++ b/gcc/testsuite/rust/compile/self_import_namespace.rs
@@ -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" }
+}
-- 
2.49.0



More information about the Gcc-rust mailing list