From: Owen Avery <[email protected]>

gcc/rust/ChangeLog:

        * resolve/rust-early-name-resolver-2.0.cc
        (Early::finalize_glob_import): Check if the globbing visitor was
        marked dirty.
        * resolve/rust-finalize-imports-2.0.cc
        (GlobbingVisitor::glob_definitions): Mark dirty if a definition
        was inserted.
        (GlobbingVisitor::glob_definition): Replace silent failure with
        assertion.
        * resolve/rust-finalize-imports-2.0.h
        (GlobbingVisitor::GlobbingVisitor): Initialize dirty member
        variable.
        (GlobbingVisitor::is_dirty): New member function.
        (GlobbingVisitor::dirty): New member variable.

Signed-off-by: Owen Avery <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/4576cf19812fc2c83ff5c80572ac730c8980b2eb

The commit has NOT been mentioned in any issue.

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4713

 gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 4 +++-
 gcc/rust/resolve/rust-finalize-imports-2.0.cc    | 9 +++------
 gcc/rust/resolve/rust-finalize-imports-2.0.h     | 5 ++++-
 3 files changed, 10 insertions(+), 8 deletions(-)

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 854102ff9..1c87804a7 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -491,7 +491,9 @@ Early::finalize_glob_import (NameResolutionContext &ctx,
       ctx.prelude = mapping.data.container ().get_node_id ();
     }
 
-  GlobbingVisitor (ctx).go (container.value ());
+  GlobbingVisitor glob_visit (ctx);
+  glob_visit.go (container.value ());
+  dirty |= glob_visit.is_dirty ();
 }
 
 void
diff --git a/gcc/rust/resolve/rust-finalize-imports-2.0.cc 
b/gcc/rust/resolve/rust-finalize-imports-2.0.cc
index 3dcaa4290..7fbbb921a 100644
--- a/gcc/rust/resolve/rust-finalize-imports-2.0.cc
+++ b/gcc/rust/resolve/rust-finalize-imports-2.0.cc
@@ -75,10 +75,10 @@ GlobbingVisitor::glob_definitions (Rib &dst, Rib &src)
          auto res = dst.insert (ent.first, globbed.value ());
          // inserting a globbed definition should (?) always succeed
          // TODO: double check
-         // TODO: mark fixed point as dirty/changed?
          rust_assert (res.has_value ()
                       || res.error ().existing
                            == globbed.value ().get_node_id ());
+         dirty |= res.has_value ();
        }
     }
 }
@@ -86,11 +86,8 @@ GlobbingVisitor::glob_definitions (Rib &dst, Rib &src)
 tl::optional<Rib::Definition>
 GlobbingVisitor::glob_definition (const Rib::Definition &def)
 {
-  if (def.is_ambiguous ())
-    {
-      // TODO: error?
-      return tl::nullopt;
-    }
+  // TODO: normal error?
+  rust_assert (!def.is_ambiguous ());
 
   return Rib::Definition::Globbed (def.get_node_id ());
 }
diff --git a/gcc/rust/resolve/rust-finalize-imports-2.0.h 
b/gcc/rust/resolve/rust-finalize-imports-2.0.h
index 281c979ba..dfbd1fe9a 100644
--- a/gcc/rust/resolve/rust-finalize-imports-2.0.h
+++ b/gcc/rust/resolve/rust-finalize-imports-2.0.h
@@ -29,7 +29,7 @@ namespace Resolver2_0 {
 class GlobbingVisitor
 {
 public:
-  GlobbingVisitor (NameResolutionContext &ctx) : ctx (ctx) {}
+  GlobbingVisitor (NameResolutionContext &ctx) : ctx (ctx), dirty (false) {}
 
   void go (AST::GlobContainer *container);
 
@@ -41,8 +41,11 @@ public:
 
   tl::optional<Rib::Definition> glob_definition (const Rib::Definition &def);
 
+  bool is_dirty () const { return dirty; }
+
 private:
   NameResolutionContext &ctx;
+  bool dirty;
 };
 
 } // namespace Resolver2_0

base-commit: bf3ef5f03c3e2b340266a5d015c45bd47e890b42
-- 
2.54.0

Reply via email to