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>
// 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);
--- /dev/null
+#![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