diff options
author | Florian Diebold <[email protected]> | 2021-06-20 15:37:50 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-06-20 18:12:06 +0100 |
commit | 04fbdce426ac8e618ac8b5d136c58cf3427bdd6c (patch) | |
tree | da6096bc68eb33c405c56ac7a9f4f60c235891e6 /crates/hir_ty/src/test_db.rs | |
parent | 679bb21633d6bbbf04b4cba5cb70f73cc5f5de19 (diff) |
Unify check_mismatches and check_types
Diffstat (limited to 'crates/hir_ty/src/test_db.rs')
-rw-r--r-- | crates/hir_ty/src/test_db.rs | 10 |
1 files changed, 7 insertions, 3 deletions
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 { | |||
86 | } | 86 | } |
87 | 87 | ||
88 | impl TestDB { | 88 | impl TestDB { |
89 | pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId { | 89 | pub(crate) fn module_for_file_opt(&self, file_id: FileId) -> Option<ModuleId> { |
90 | for &krate in self.relevant_crates(file_id).iter() { | 90 | for &krate in self.relevant_crates(file_id).iter() { |
91 | let crate_def_map = self.crate_def_map(krate); | 91 | let crate_def_map = self.crate_def_map(krate); |
92 | for (local_id, data) in crate_def_map.modules() { | 92 | for (local_id, data) in crate_def_map.modules() { |
93 | if data.origin.file_id() == Some(file_id) { | 93 | if data.origin.file_id() == Some(file_id) { |
94 | return crate_def_map.module_id(local_id); | 94 | return Some(crate_def_map.module_id(local_id)); |
95 | } | 95 | } |
96 | } | 96 | } |
97 | } | 97 | } |
98 | panic!("Can't find module for file") | 98 | None |
99 | } | ||
100 | |||
101 | pub(crate) fn module_for_file(&self, file_id: FileId) -> ModuleId { | ||
102 | self.module_for_file_opt(file_id).unwrap() | ||
99 | } | 103 | } |
100 | 104 | ||
101 | pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> { | 105 | pub(crate) fn extract_annotations(&self) -> FxHashMap<FileId, Vec<(TextRange, String)>> { |