From: Pierre-Emmanuel Patry <[email protected]>

Every wildcard should be considered different and no error should be
emitted when multiple wildcards are used within the same rib.

gcc/rust/ChangeLog:

        * resolve/rust-toplevel-name-resolver-2.0.cc(TopLevel::visit): Insert
        constant item only if now wildcard.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/c9fef4eb68d4263844bb8dd6b26020fe58a4e626

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4450

 .../resolve/rust-toplevel-name-resolver-2.0.cc     |  5 +++--
 gcc/testsuite/rust/compile/wildcard_items.rs       | 14 ++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/rust/compile/wildcard_items.rs

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 98245846d..67a8c52d1 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -367,8 +367,9 @@ TopLevel::visit (AST::Union &union_item)
 void
 TopLevel::visit (AST::ConstantItem &const_item)
 {
-  insert_or_error_out (const_item.get_identifier (), const_item,
-                      Namespace::Values);
+  if (const_item.get_identifier ().as_string () != 
Values::Keywords::UNDERSCORE)
+    insert_or_error_out (const_item.get_identifier (), const_item,
+                        Namespace::Values);
 
   DefaultResolver::visit (const_item);
 }
diff --git a/gcc/testsuite/rust/compile/wildcard_items.rs 
b/gcc/testsuite/rust/compile/wildcard_items.rs
new file mode 100644
index 000000000..8ce4733c1
--- /dev/null
+++ b/gcc/testsuite/rust/compile/wildcard_items.rs
@@ -0,0 +1,14 @@
+#![feature(lang_items)]
+#![feature(no_core)]
+#![no_core]
+
+macro_rules! assert {
+    ($cond:expr $(,)?) => {{ /* compiler built-in */ }};
+    ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};
+}
+
+#[lang = "sized"]
+trait Sized {}
+
+const _: () = assert!(true);
+const _: () = assert!(true);

base-commit: fd8acf80ceca1b2d3ca73c2ddb81f78a4aa93b24
-- 
2.53.0

Reply via email to