From: Pierre-Emmanuel Patry Date: Wed, 21 Aug 2024 15:01:29 +0000 (+0200) Subject: gccrs: Fix missing error on duplicated nodes X-Git-Tag: basepoints/gcc-16~1154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57dc3ab97393f526afcc74fa6c82347f3f77402a;p=thirdparty%2Fgcc.git gccrs: Fix missing error on duplicated nodes When we tried to insert a shadowable node and another shadowable node has been inserted before, we didn't emit any error if the node has already been inserted previously and failed silently. gcc/rust/ChangeLog: * resolve/rust-rib.cc (Rib::insert): Emit an error when trying to insert an already inserted node. Signed-off-by: Pierre-Emmanuel Patry --- diff --git a/gcc/rust/resolve/rust-rib.cc b/gcc/rust/resolve/rust-rib.cc index 0a8fce34a1a..714507219e0 100644 --- a/gcc/rust/resolve/rust-rib.cc +++ b/gcc/rust/resolve/rust-rib.cc @@ -92,9 +92,9 @@ Rib::insert (std::string name, Definition def) { if (std::find (current.ids.cbegin (), current.ids.cend (), id) == current.ids.cend ()) - { - current.ids.push_back (id); - } + current.ids.push_back (id); + else + return tl::make_unexpected (DuplicateNameError (name, id)); } } else if (it->second.shadowable)