public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add Mappings::iterate_trait_items helper
@ 2022-06-08 12:00 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:00 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:dfb7f9c123ad930734aaa2befbbf40163f115920
commit dfb7f9c123ad930734aaa2befbbf40163f115920
Author: Philip Herron <philip.herron@embecosm.com>
Date: Fri Jan 21 20:00:20 2022 +0000
Add Mappings::iterate_trait_items helper
Diff:
---
gcc/rust/util/rust-hir-map.cc | 19 +++++++++++++++++++
gcc/rust/util/rust-hir-map.h | 3 +++
2 files changed, 22 insertions(+)
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 4b713128b0f..786fc5a627e 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -719,5 +719,24 @@ Mappings::iterate_impl_blocks (std::function<bool (HirId, HIR::ImplBlock *)> cb)
}
}
+void
+Mappings::iterate_trait_items (
+ std::function<bool (HIR::TraitItem *, HIR::Trait *)> cb)
+{
+ for (auto it = hirTraitItemMappings.begin ();
+ it != hirTraitItemMappings.end (); it++)
+ {
+ for (auto iy = it->second.begin (); iy != it->second.end (); iy++)
+ {
+ HirId trait_item_id = iy->first;
+ HIR::TraitItem *trait_item = iy->second;
+ HIR::Trait *trait = lookup_trait_item_mapping (trait_item_id);
+
+ if (!cb (trait_item, trait))
+ return;
+ }
+ }
+}
+
} // namespace Analysis
} // namespace Rust
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 3ed3d470011..ec08170af83 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -474,6 +474,9 @@ public:
void iterate_impl_blocks (std::function<bool (HirId, HIR::ImplBlock *)> cb);
+ void iterate_trait_items (
+ std::function<bool (HIR::TraitItem *item, HIR::Trait *)> cb);
+
bool is_impl_item (HirId id)
{
HirId parent_impl_block_id = UNKNOWN_HIRID;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:00 [gcc/devel/rust/master] Add Mappings::iterate_trait_items helper Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).