From: Harishankar Date: Fri, 27 Feb 2026 01:43:10 +0000 (+0530) Subject: gccrs: resolve: Fix ICE on ambiguous glob re-exports X-Git-Tag: basepoints/gcc-17~576 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5706c607e2bebeb71f693e5e77984fed8b44bc9a;p=thirdparty%2Fgcc.git gccrs: resolve: Fix ICE on ambiguous glob re-exports 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 --- diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc index a0e31047a2b..df29a55c8fb 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc @@ -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 index 00000000000..ddbe5a32b6b --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-4411.rs @@ -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