]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: resolve: Fix ICE on ambiguous glob re-exports
authorHarishankar <harishankarpp7@gmail.com>
Fri, 27 Feb 2026 01:43:10 +0000 (07:13 +0530)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 20 Mar 2026 17:10:52 +0000 (18:10 +0100)
This patch adds an ambiguity check in 'finalize_rebind_import'.
If a Definition is ambiguous, it emits a proper error diagnostic
instead of crashing, consistent with rustc's behavior(verified)

Fixes Rust-GCC/gccrs#4411

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import): Add ambiguity
check before calling get_node_id() on glob import definitions.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4411.rs: New test.

Signed-off-by: Harishankar <harishankarpp7@gmail.com>
gcc/rust/resolve/rust-early-name-resolver-2.0.cc
gcc/testsuite/rust/compile/issue-4411.rs [new file with mode: 0644]

index a0e31047a2b535eacff94091682beb68e098639e..df29a55c8fbf40bca5f084f42efae19b3f6c7ff9 100644 (file)
@@ -123,6 +123,17 @@ Early::resolve_rebind_import (NodeId use_dec_id,
   // if we've found at least one definition, then we're good
   if (definitions.empty ())
     return false;
+  for (const auto &def : definitions)
+    {
+      if (def.first.is_ambiguous ())
+       {
+         rich_location rich_locus (line_table,
+                                   rebind_import.to_resolve.get_locus ());
+         rust_error_at (rich_locus, ErrorCode::E0659, "%qs is ambiguous",
+                        rebind_import.to_resolve.as_string ().c_str ());
+         return true;
+       }
+    }
 
   auto &imports = import_mappings.new_or_access (use_dec_id);
 
diff --git a/gcc/testsuite/rust/compile/issue-4411.rs b/gcc/testsuite/rust/compile/issue-4411.rs
new file mode 100644 (file)
index 0000000..ddbe5a3
--- /dev/null
@@ -0,0 +1,16 @@
+#![feature(no_core)]
+#![no_core]
+mod framing {
+    mod public_message {
+        pub struct ConfirmedTranscriptHashInput;
+    }
+    mod public_message_in {
+        pub struct ConfirmedTranscriptHashInput;
+    }
+    pub use self::public_message::*;
+    pub use self::public_message_in::*;
+}
+
+use crate::framing::ConfirmedTranscriptHashInput; // { dg-error "is ambiguous .E0659." }
+
+fn main() {}
\ No newline at end of file