[gccrs COMMIT] gccrs: nr1.0: Remove old Scope class

gerris.rs@gmail.com gerris.rs@gmail.com
Wed Sep 16 12:34:16 GMT 2026


From: Owen Avery <powerboat9.gamer@gmail.com>

gcc/rust/ChangeLog:

	* resolve/rust-name-resolver.cc (Scope::Scope): Remove function
	definition.
	(Scope::insert): Likewise.
	(Scope::lookup): Likewise.
	(Scope::lookup_decl_type): Likewise.
	(Scope::lookup_rib_for_decl): Likewise.
	(Scope::iterate): Likewise.
	(Scope::peek): Likewise.
	(Scope::push): Likewise.
	(Scope::pop): Likewise.
	(Scope::append_reference_for_def): Likewise.
	(Scope::decl_was_declared_here): Likewise.
	* resolve/rust-name-resolver.h (class Scope): Remove.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
---
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/d955d57e7141bfa58402bd88d5e9c845af245a41

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/4901

 gcc/rust/resolve/rust-name-resolver.cc | 137 -------------------------
 gcc/rust/resolve/rust-name-resolver.h  |  35 -------
 2 files changed, 172 deletions(-)

diff --git a/gcc/rust/resolve/rust-name-resolver.cc b/gcc/rust/resolve/rust-name-resolver.cc
index ab6fcb839..a695ab192 100644
--- a/gcc/rust/resolve/rust-name-resolver.cc
+++ b/gcc/rust/resolve/rust-name-resolver.cc
@@ -135,143 +135,6 @@ Rib::debug_str () const
   return "{" + buffer + "}";
 }
 
-Scope::Scope (CrateNum crate_num) : crate_num (crate_num) {}
-
-void
-Scope::insert (
-  const CanonicalPath &ident, NodeId id, location_t locus, bool shadow,
-  Rib::ItemType type,
-  std::function<void (const CanonicalPath &, NodeId, location_t)> dup_cb)
-{
-  peek ()->insert_name (ident, id, locus, shadow, type, dup_cb);
-}
-
-void
-Scope::insert (const CanonicalPath &ident, NodeId id, location_t locus,
-	       Rib::ItemType type)
-{
-  peek ()->insert_name (ident, id, locus, true, type,
-			[] (const CanonicalPath &, NodeId, location_t) -> void {
-			});
-}
-
-bool
-Scope::lookup (const CanonicalPath &ident, NodeId *id)
-{
-  NodeId lookup = UNKNOWN_NODEID;
-  iterate ([&] (Rib *r) mutable -> bool {
-    if (r->lookup_name (ident, &lookup))
-      return false;
-    return true;
-  });
-
-  *id = lookup;
-  return lookup != UNKNOWN_NODEID;
-}
-
-bool
-Scope::lookup_decl_type (NodeId id, Rib::ItemType *type)
-{
-  bool found = false;
-  iterate ([&] (const Rib *r) -> bool {
-    if (r->decl_was_declared_here (id))
-      {
-	bool ok = r->lookup_decl_type (id, type);
-	rust_assert (ok);
-	found = true;
-	return false;
-      }
-    return true;
-  });
-  return found;
-}
-
-bool
-Scope::lookup_rib_for_decl (NodeId id, const Rib **rib)
-{
-  bool found = false;
-  iterate ([&] (const Rib *r) -> bool {
-    if (r->decl_was_declared_here (id))
-      {
-	*rib = r;
-	found = true;
-	return false;
-      }
-    return true;
-  });
-  return found;
-}
-
-void
-Scope::iterate (std::function<bool (Rib *)> cb)
-{
-  for (auto it = stack.rbegin (); it != stack.rend (); ++it)
-    {
-      if (!cb (*it))
-	return;
-    }
-}
-
-void
-Scope::iterate (std::function<bool (const Rib *)> cb) const
-{
-  for (auto it = stack.rbegin (); it != stack.rend (); ++it)
-    {
-      if (!cb (*it))
-	return;
-    }
-}
-
-Rib *
-Scope::peek ()
-{
-  return stack.back ();
-}
-
-void
-Scope::push (NodeId id)
-{
-  stack.push_back (new Rib (get_crate_num (), id));
-}
-
-Rib *
-Scope::pop ()
-{
-  Rib *r = peek ();
-  stack.pop_back ();
-  return r;
-}
-
-void
-Scope::append_reference_for_def (NodeId refId, NodeId defId)
-{
-  bool ok = false;
-  iterate ([&] (Rib *r) mutable -> bool {
-    if (r->decl_was_declared_here (defId))
-      {
-	ok = true;
-	r->append_reference_for_def (defId, refId);
-      }
-    return true;
-  });
-  rust_assert (ok);
-}
-
-bool
-Scope::decl_was_declared_here (NodeId def) const
-{
-  bool found = false;
-  iterate ([&] (const Rib *r) -> bool {
-    if (r->decl_was_declared_here (def))
-      {
-	found = true;
-	return false;
-      }
-    return true;
-  });
-  return found;
-}
-
 Resolver::Resolver () {}
 
 Resolver *
diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h
index 6648959d6..a7cbb1483 100644
--- a/gcc/rust/resolve/rust-name-resolver.h
+++ b/gcc/rust/resolve/rust-name-resolver.h
@@ -83,41 +83,6 @@ private:
   std::map<NodeId, ItemType> decl_type_mappings;
 };
 
-class Scope
-{
-public:
-  Scope (CrateNum crate_num);
-
-  void insert (
-    const CanonicalPath &ident, NodeId id, location_t locus, bool shadow,
-    Rib::ItemType type,
-    std::function<void (const CanonicalPath &, NodeId, location_t)> dup_cb);
-
-  void insert (const CanonicalPath &ident, NodeId id, location_t locus,
-	       Rib::ItemType type = Rib::ItemType::Unknown);
-  bool lookup (const CanonicalPath &ident, NodeId *id);
-  bool lookup_decl_type (NodeId id, Rib::ItemType *type);
-  bool lookup_rib_for_decl (NodeId id, const Rib **rib);
-
-  void iterate (std::function<bool (Rib *)> cb);
-  void iterate (std::function<bool (const Rib *)> cb) const;
-
-  Rib *peek ();
-  void push (NodeId id);
-  Rib *pop ();
-
-  bool decl_was_declared_here (NodeId def) const;
-  void append_reference_for_def (NodeId refId, NodeId defId);
-
-  CrateNum get_crate_num () const { return crate_num; }
-
-  const std::vector<Rib *> &get_context () const { return stack; };
-
-private:
-  CrateNum crate_num;
-  std::vector<Rib *> stack;
-};
-
 class Resolver
 {
 public:

base-commit: 1f3e2252b144c1f9ae144a6d40511bcb35f04bcf
-- 
2.55.0



More information about the Gcc-rust mailing list