From 2e3c156b0e560c4ef7075955883f30e517bdd075 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 15 Mar 2021 14:51:20 +0100 Subject: Return multiple modules in `parent_module` --- crates/hir/src/semantics.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'crates/hir/src/semantics.rs') diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 945638cc5..519339c0c 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -259,6 +259,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { } pub fn to_module_def(&self, file: FileId) -> Option { + self.imp.to_module_def(file).next() + } + + pub fn to_module_defs(&self, file: FileId) -> impl Iterator { self.imp.to_module_def(file) } @@ -537,8 +541,8 @@ impl<'db> SemanticsImpl<'db> { f(&mut ctx) } - fn to_module_def(&self, file: FileId) -> Option { - self.with_ctx(|ctx| ctx.file_to_def(file)).map(Module::from) + fn to_module_def(&self, file: FileId) -> impl Iterator { + self.with_ctx(|ctx| ctx.file_to_def(file)).into_iter().map(Module::from) } fn scope(&self, node: &SyntaxNode) -> SemanticsScope<'db> { -- cgit v1.2.3