]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix duplicate detection
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 14 Sep 2023 15:39:37 +0000 (17:39 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 1 Aug 2024 14:52:25 +0000 (16:52 +0200)
The resolver did report duplicate symbols when being run multiple times
even if the node id was the same. This commit adds an additional
condition, the error will only be reported if the existing node id is
different from the current node id.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::insert_or_error_out):
Add new constraint to duplicate errors.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc

index 446a1c6a41b12c35c8f46bba42a92007d7dc574d..407892bb7bbd846b943c6ca3f940b4239e433ed7 100644 (file)
@@ -47,11 +47,8 @@ TopLevel::insert_or_error_out (const Identifier &identifier,
 
   auto result = ctx.insert (identifier, node_id, ns);
 
-  if (!result)
+  if (!result && result.error ().existing != node_id)
     {
-      // can we do something like check if the node id is the same? if it is the
-      // same, it's not an error, just the resolver running multiple times?
-
       rich_location rich_loc (line_table, locus);
       rich_loc.add_range (node_locations[result.error ().existing]);