From 3ac605e6876056fa56098231cc2f96553faab8f0 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 20 Dec 2018 21:56:28 +0100 Subject: Add beginnings of type infrastructure --- crates/ra_hir/src/query_definitions.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/ra_hir/src/query_definitions.rs') diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index efaeb1525..ccbfdf028 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs @@ -19,6 +19,7 @@ use crate::{ imp::Submodule, nameres::{InputModuleItems, ItemMap, Resolver}, }, + ty::{self, InferenceResult} }; /// Resolve `FnId` to the corresponding `SyntaxNode` @@ -35,6 +36,13 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc { Arc::new(res) } +pub(super) fn infer(db: &impl HirDatabase, fn_id: FnId) -> Arc { + let syntax = db.fn_syntax(fn_id); + let scopes = db.fn_scopes(fn_id); + let res = ty::infer(db, syntax.borrowed(), scopes); + Arc::new(res) +} + pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc { let mut res = SourceFileItems::new(file_id); let source_file = db.source_file(file_id); -- cgit v1.2.3 From ef67581104eb00a0c199f0b2a3b558da8a6f90a2 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 23 Dec 2018 17:13:11 +0100 Subject: Resolve paths to defs (functions currently) during type inference --- crates/ra_hir/src/query_definitions.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'crates/ra_hir/src/query_definitions.rs') diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index ccbfdf028..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::{ use ra_db::{SourceRootId, FileId, Cancelable,}; use crate::{ - SourceFileItems, SourceItemId, DefKind, + SourceFileItems, SourceItemId, DefKind, Function, DefId, db::HirDatabase, function::{FnScopes, FnId}, module::{ @@ -19,7 +19,7 @@ use crate::{ imp::Submodule, nameres::{InputModuleItems, ItemMap, Resolver}, }, - ty::{self, InferenceResult} + ty::{self, InferenceResult, Ty} }; /// Resolve `FnId` to the corresponding `SyntaxNode` @@ -36,11 +36,13 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc { Arc::new(res) } -pub(super) fn infer(db: &impl HirDatabase, fn_id: FnId) -> Arc { - let syntax = db.fn_syntax(fn_id); - let scopes = db.fn_scopes(fn_id); - let res = ty::infer(db, syntax.borrowed(), scopes); - Arc::new(res) +pub(super) fn infer(db: &impl HirDatabase, fn_id: FnId) -> Cancelable> { + let function = Function { fn_id }; + ty::infer(db, function).map(Arc::new) +} + +pub(super) fn type_for_def(db: &impl HirDatabase, def_id: DefId) -> Cancelable { + ty::type_for_def(db, def_id) } pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc { -- cgit v1.2.3