[gcc r17-3114] gccrs: Record dirty state of GlobbingVisitor

Arthur Cohen via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:08e1db36b05a6631f8fd93159a687d80b0e3c03d

commit r17-3114-g08e1db36b05a6631f8fd93159a687d80b0e3c03d
Author: Owen Avery <[email protected]>
Date:   Sun Jul 19 16:53:19 2026 -0400

    gccrs: Record dirty state of GlobbingVisitor
    
    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]>

Diff:
---
 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 854102ff90b3..1c87804a7330 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 3dcaa42903e9..7fbbb921a258 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 281c979ba3e4..dfbd1fe9a071 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.