diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-14 14:38:01 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-14 14:38:01 +0000 |
commit | f2c64ba15d3ef87f731f17d90c873383d5f3e432 (patch) | |
tree | ff8a962228a7532a5f468862bc4b0c62535f5069 /crates/ra_hir_def/src/body | |
parent | 5c3ccc55082838524f695ffe40138fd8e805db70 (diff) | |
parent | 1583ab1558022d0fdbbc10d3a440a2d3daa4a840 (diff) |
Merge #2243
2243: Move body queries to hir_def r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/scope.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index dd8d06d11..09a39e721 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | use std::sync::Arc; | ||
2 | 3 | ||
3 | use hir_expand::name::Name; | 4 | use hir_expand::name::Name; |
4 | use ra_arena::{impl_arena_id, Arena, RawId}; | 5 | use ra_arena::{impl_arena_id, Arena, RawId}; |
@@ -6,7 +7,9 @@ use rustc_hash::FxHashMap; | |||
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
8 | body::Body, | 9 | body::Body, |
10 | db::DefDatabase2, | ||
9 | expr::{Expr, ExprId, Pat, PatId, Statement}, | 11 | expr::{Expr, ExprId, Pat, PatId, Statement}, |
12 | DefWithBodyId, | ||
10 | }; | 13 | }; |
11 | 14 | ||
12 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
@@ -42,7 +45,12 @@ pub struct ScopeData { | |||
42 | } | 45 | } |
43 | 46 | ||
44 | impl ExprScopes { | 47 | impl ExprScopes { |
45 | pub fn new(body: &Body) -> ExprScopes { | 48 | pub(crate) fn expr_scopes_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<ExprScopes> { |
49 | let body = db.body(def); | ||
50 | Arc::new(ExprScopes::new(&*body)) | ||
51 | } | ||
52 | |||
53 | fn new(body: &Body) -> ExprScopes { | ||
46 | let mut scopes = | 54 | let mut scopes = |
47 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; | 55 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; |
48 | let root = scopes.root_scope(); | 56 | let root = scopes.root_scope(); |