diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index ddd4b2687cd..189649841a7 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -27,7 +27,7 @@ pub trait HirDatabase: SourceDatabase + AsRef { #[salsa::invoke(crate::macros::expand_macro_invocation)] fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option>; - #[salsa::invoke(query_definitions::expr_scopes)] + #[salsa::invoke(ExprScopes::expr_scopes_query)] fn expr_scopes(&self, func: Function) -> Arc; #[salsa::invoke(crate::adt::StructData::struct_data_query)] diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 17a1efed2a7..f8b5ba581c4 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs @@ -9,7 +9,11 @@ }; use ra_arena::{Arena, RawId, impl_arena_id}; -use crate::{Name, AsName, expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}}; +use crate::{ + Name, AsName, Function, + expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}, + db::HirDatabase, +}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ScopeId(RawId); @@ -35,7 +39,14 @@ pub struct ScopeData { } impl ExprScopes { - pub(crate) fn new(body: Arc) -> ExprScopes { + // TODO: This should take something more general than Function + pub(crate) fn expr_scopes_query(db: &impl HirDatabase, function: Function) -> Arc { + let body = db.body_hir(function); + let res = ExprScopes::new(body); + Arc::new(res) + } + + fn new(body: Arc) -> ExprScopes { let mut scopes = ExprScopes { body: body.clone(), scopes: Arena::default(), diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index 1b61d449e80..734a982820a 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs @@ -1,19 +1,14 @@ use std::sync::Arc; -use ra_syntax::{SyntaxNode, TreeArc}; +use ra_syntax::{ + SyntaxNode, TreeArc, +}; use crate::{ SourceFileItems, SourceItemId, HirFileId, - Function, ExprScopes, db::HirDatabase, }; -pub(super) fn expr_scopes(db: &impl HirDatabase, func: Function) -> Arc { - let body = db.body_hir(func); - let res = ExprScopes::new(body); - Arc::new(res) -} - pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc { let source_file = db.hir_parse(file_id); let res = SourceFileItems::new(file_id, &source_file);