https://gcc.gnu.org/g:64e0fd8f9c657b6f07569d7ff49b57ad76578dba
commit r17-5138-g64e0fd8f9c657b6f07569d7ff49b57ad76578dba Author: Owen Avery <[email protected]> Date: Tue Sep 15 20:25:46 2026 -0400 gccrs: nr1.0: Remove old Scope class 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 <[email protected]> Diff: --- 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 ab6fcb839ef9..a695ab1922cf 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 6648959d62f3..a7cbb14836f3 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:
