[COMMITTED 55/77] gccrs: Record dirty state of GlobbingVisitor

[email protected]
Newsgroups gmane.comp.gcc.rust,gmane.comp.gcc.patches
Message-ID <[email protected]>
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]>
---
 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 854102ff90b..1c87804a733 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 3dcaa42903e..7fbbb921a25 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 281c979ba3e..dfbd1fe9a07 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
-- 
2.50.1
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.