From 338823f73aefbf7957b928ad76fc5f55cc43df9c Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 23 Feb 2021 17:56:16 +0100 Subject: is_visible_from_def_map: handle block expressions --- crates/hir_def/src/nameres.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/hir_def/src/nameres.rs') diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 34ff07f3c..f92232eb3 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs @@ -337,6 +337,12 @@ impl DefMap { None } + /// If this `DefMap` is for a block expression, returns the module containing the block (which + /// might again be a block, or a module inside a block). + pub fn parent(&self) -> Option { + Some(self.block?.parent) + } + // FIXME: this can use some more human-readable format (ideally, an IR // even), as this should be a great debugging aid. pub fn dump(&self, db: &dyn DefDatabase) -> String { -- cgit v1.2.3