Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/item_scope.rs')
-rw-r--r--crates/hir-def/src/item_scope.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/crates/hir-def/src/item_scope.rs b/crates/hir-def/src/item_scope.rs
index 2c3eb5c8e5..0fec767410 100644
--- a/crates/hir-def/src/item_scope.rs
+++ b/crates/hir-def/src/item_scope.rs
@@ -162,6 +162,20 @@ impl ItemScope {
.map(move |name| (name, self.get(name)))
}
+ pub fn values(&self) -> impl Iterator<Item = (&Name, Item<ModuleDefId, ImportId>)> + '_ {
+ self.values.iter().map(|(n, &i)| (n, i))
+ }
+
+ pub fn types(
+ &self,
+ ) -> impl Iterator<Item = (&Name, Item<ModuleDefId, ImportOrExternCrate>)> + '_ {
+ self.types.iter().map(|(n, &i)| (n, i))
+ }
+
+ pub fn macros(&self) -> impl Iterator<Item = (&Name, Item<MacroId, ImportId>)> + '_ {
+ self.macros.iter().map(|(n, &i)| (n, i))
+ }
+
pub fn imports(&self) -> impl Iterator<Item = ImportId> + '_ {
self.use_imports_types
.keys()
@@ -263,11 +277,6 @@ impl ItemScope {
self.unnamed_consts.iter().copied()
}
- /// Iterate over all module scoped macros
- pub(crate) fn macros(&self) -> impl Iterator<Item = (&Name, MacroId)> + '_ {
- self.entries().filter_map(|(name, def)| def.take_macros().map(|macro_| (name, macro_)))
- }
-
/// Iterate over all legacy textual scoped macros visible at the end of the module
pub fn legacy_macros(&self) -> impl Iterator<Item = (&Name, &[MacroId])> + '_ {
self.legacy_macros.iter().map(|(name, def)| (name, &**def))