From 04fbdce426ac8e618ac8b5d136c58cf3427bdd6c Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 20 Jun 2021 16:37:50 +0200 Subject: Unify check_mismatches and check_types --- crates/hir_ty/src/test_db.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'crates/hir_ty/src/test_db.rs') diff --git a/crates/hir_ty/src/test_db.rs b/crates/hir_ty/src/test_db.rs index 4640ea821..b99a03492 100644 --- a/crates/hir_ty/src/test_db.rs +++ b/crates/hir_ty/src/test_db.rs @@ -86,16 +86,20 @@ impl FileLoader for TestDB { } impl TestDB { - pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId { + pub(crate) fn module_for_file_opt(&self, file_id: FileId) -> Option { for &krate in self.relevant_crates(file_id).iter() { let crate_def_map = self.crate_def_map(krate); for (local_id, data) in crate_def_map.modules() { if data.origin.file_id() == Some(file_id) { - return crate_def_map.module_id(local_id); + return Some(crate_def_map.module_id(local_id)); } } } - panic!("Can't find module for file") + None + } + + pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId { + self.module_for_file_opt(file_id).unwrap() } pub(crate) fn extract_annotations(&self) -> FxHashMap> { -- cgit v1.2.3