From d8bf9bef800969304440fd2a2a324606a342eaa2 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 4 Apr 2021 03:03:18 +0200 Subject: Access a body's block def maps via a method --- crates/hir_ty/src/diagnostics/decl_check.rs | 3 +-- crates/hir_ty/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs index 207c7cb82..1c9f9ede7 100644 --- a/crates/hir_ty/src/diagnostics/decl_check.rs +++ b/crates/hir_ty/src/diagnostics/decl_check.rs @@ -99,8 +99,7 @@ impl<'a, 'b> DeclValidator<'a, 'b> { let body = self.db.body(func.into()); // Recursively validate inner scope items, such as static variables and constants. - let db = self.db; - for block_def_map in body.block_scopes.iter().filter_map(|block| db.block_def_map(*block)) { + for (_, block_def_map) in body.blocks(self.db.upcast()) { for (_, module) in block_def_map.modules() { for def_id in module.scope.declarations() { let mut validator = DeclValidator::new(self.db, self.krate, self.sink); diff --git a/crates/hir_ty/src/tests.rs b/crates/hir_ty/src/tests.rs index ad283c1e0..ccfb88c52 100644 --- a/crates/hir_ty/src/tests.rs +++ b/crates/hir_ty/src/tests.rs @@ -288,7 +288,7 @@ fn visit_module( } fn visit_body(db: &TestDB, body: &Body, cb: &mut dyn FnMut(DefWithBodyId)) { - for def_map in body.block_scopes.iter().filter_map(|block| db.block_def_map(*block)) { + for (_, def_map) in body.blocks(db) { for (mod_id, _) in def_map.modules() { visit_module(db, &def_map, mod_id, cb); } -- cgit v1.2.3