aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/query_definitions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/query_definitions.rs')
-rw-r--r--crates/ra_hir/src/query_definitions.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs
index efaeb1525..b654af920 100644
--- a/crates/ra_hir/src/query_definitions.rs
+++ b/crates/ra_hir/src/query_definitions.rs
@@ -11,7 +11,7 @@ use ra_syntax::{
11use ra_db::{SourceRootId, FileId, Cancelable,}; 11use ra_db::{SourceRootId, FileId, Cancelable,};
12 12
13use crate::{ 13use crate::{
14 SourceFileItems, SourceItemId, DefKind, 14 SourceFileItems, SourceItemId, DefKind, Function, DefId,
15 db::HirDatabase, 15 db::HirDatabase,
16 function::{FnScopes, FnId}, 16 function::{FnScopes, FnId},
17 module::{ 17 module::{
@@ -19,6 +19,7 @@ use crate::{
19 imp::Submodule, 19 imp::Submodule,
20 nameres::{InputModuleItems, ItemMap, Resolver}, 20 nameres::{InputModuleItems, ItemMap, Resolver},
21 }, 21 },
22 ty::{self, InferenceResult, Ty}
22}; 23};
23 24
24/// Resolve `FnId` to the corresponding `SyntaxNode` 25/// Resolve `FnId` to the corresponding `SyntaxNode`
@@ -35,6 +36,15 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> {
35 Arc::new(res) 36 Arc::new(res)
36} 37}
37 38
39pub(super) fn infer(db: &impl HirDatabase, fn_id: FnId) -> Cancelable<Arc<InferenceResult>> {
40 let function = Function { fn_id };
41 ty::infer(db, function).map(Arc::new)
42}
43
44pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Ty> {
45 ty::type_for_def(db, def_id)
46}
47
38pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<SourceFileItems> { 48pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<SourceFileItems> {
39 let mut res = SourceFileItems::new(file_id); 49 let mut res = SourceFileItems::new(file_id);
40 let source_file = db.source_file(file_id); 50 let source_file = db.source_file(file_id);