aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-19 18:47:56 +0000
committerFlorian Diebold <[email protected]>2019-01-30 20:23:50 +0000
commit65864d85f992300bad3913438a542af1bd736a24 (patch)
treec2030da2bcd55fc1033a2c0602b7a9349c2dd702 /crates
parentc65e6cdcb3d603ce7c0943785f7140662022c54a (diff)
Rename FnScopes -> ExprScopes
The reason for this is that it describes scopes for any body expression, not just that of a function. It did not actually refer to functions at all anymore.
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/code_model_api.rs4
-rw-r--r--crates/ra_hir/src/code_model_impl/function.rs4
-rw-r--r--crates/ra_hir/src/db.rs6
-rw-r--r--crates/ra_hir/src/expr.rs4
-rw-r--r--crates/ra_hir/src/expr/scope.rs (renamed from crates/ra_hir/src/code_model_impl/function/scope.rs)18
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_hir/src/query_definitions.rs6
-rw-r--r--crates/ra_hir/src/ty.rs8
8 files changed, 26 insertions, 26 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index c59b7fbc5..9405aa8ad 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -396,7 +396,7 @@ pub struct Function {
396 pub(crate) id: FunctionId, 396 pub(crate) id: FunctionId,
397} 397}
398 398
399pub use crate::code_model_impl::function::ScopeEntryWithSyntax; 399pub use crate::expr::ScopeEntryWithSyntax;
400 400
401/// The declared signature of a function. 401/// The declared signature of a function.
402#[derive(Debug, Clone, PartialEq, Eq)] 402#[derive(Debug, Clone, PartialEq, Eq)]
@@ -447,7 +447,7 @@ impl Function {
447 } 447 }
448 448
449 pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping { 449 pub fn scopes(&self, db: &impl HirDatabase) -> ScopesWithSyntaxMapping {
450 let scopes = db.fn_scopes(*self); 450 let scopes = db.expr_scopes(*self);
451 let syntax_mapping = db.body_syntax_mapping(*self); 451 let syntax_mapping = db.body_syntax_mapping(*self);
452 ScopesWithSyntaxMapping { 452 ScopesWithSyntaxMapping {
453 scopes, 453 scopes,
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs
index e0dd4d629..422643996 100644
--- a/crates/ra_hir/src/code_model_impl/function.rs
+++ b/crates/ra_hir/src/code_model_impl/function.rs
@@ -1,5 +1,3 @@
1mod scope;
2
3use std::sync::Arc; 1use std::sync::Arc;
4 2
5use ra_syntax::ast::{self, NameOwner}; 3use ra_syntax::ast::{self, NameOwner};
@@ -11,8 +9,6 @@ use crate::{
11 impl_block::ImplBlock, 9 impl_block::ImplBlock,
12}; 10};
13 11
14pub use self::scope::{FnScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax};
15
16impl Function { 12impl Function {
17 pub(crate) fn body(&self, db: &impl HirDatabase) -> Arc<Body> { 13 pub(crate) fn body(&self, db: &impl HirDatabase) -> Arc<Body> {
18 db.body_hir(*self) 14 db.body_hir(*self)
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index 16d5a7877..ddd4b2687 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -7,7 +7,7 @@ use crate::{
7 MacroCallId, HirFileId, 7 MacroCallId, HirFileId,
8 SourceFileItems, SourceItemId, Crate, Module, HirInterner, 8 SourceFileItems, SourceItemId, Crate, Module, HirInterner,
9 query_definitions, 9 query_definitions,
10 Function, FnSignature, FnScopes, 10 Function, FnSignature, ExprScopes,
11 Struct, Enum, StructField, 11 Struct, Enum, StructField,
12 macros::MacroExpansion, 12 macros::MacroExpansion,
13 module_tree::ModuleTree, 13 module_tree::ModuleTree,
@@ -27,8 +27,8 @@ pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> {
27 #[salsa::invoke(crate::macros::expand_macro_invocation)] 27 #[salsa::invoke(crate::macros::expand_macro_invocation)]
28 fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>; 28 fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>;
29 29
30 #[salsa::invoke(query_definitions::fn_scopes)] 30 #[salsa::invoke(query_definitions::expr_scopes)]
31 fn fn_scopes(&self, func: Function) -> Arc<FnScopes>; 31 fn expr_scopes(&self, func: Function) -> Arc<ExprScopes>;
32 32
33 #[salsa::invoke(crate::adt::StructData::struct_data_query)] 33 #[salsa::invoke(crate::adt::StructData::struct_data_query)]
34 fn struct_data(&self, s: Struct) -> Arc<StructData>; 34 fn struct_data(&self, s: Struct) -> Arc<StructData>;
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 60d997bbe..83e913e4a 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -16,6 +16,10 @@ use crate::{
16}; 16};
17use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}; 17use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy};
18 18
19pub use self::scope::{ExprScopes, ScopesWithSyntaxMapping, ScopeEntryWithSyntax};
20
21mod scope;
22
19#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 23#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
20pub struct ExprId(RawId); 24pub struct ExprId(RawId);
21impl_arena_id!(ExprId); 25impl_arena_id!(ExprId);
diff --git a/crates/ra_hir/src/code_model_impl/function/scope.rs b/crates/ra_hir/src/expr/scope.rs
index c5d1de5eb..17a1efed2 100644
--- a/crates/ra_hir/src/code_model_impl/function/scope.rs
+++ b/crates/ra_hir/src/expr/scope.rs
@@ -16,7 +16,7 @@ pub struct ScopeId(RawId);
16impl_arena_id!(ScopeId); 16impl_arena_id!(ScopeId);
17 17
18#[derive(Debug, PartialEq, Eq)] 18#[derive(Debug, PartialEq, Eq)]
19pub struct FnScopes { 19pub struct ExprScopes {
20 body: Arc<Body>, 20 body: Arc<Body>,
21 scopes: Arena<ScopeId, ScopeData>, 21 scopes: Arena<ScopeId, ScopeData>,
22 scope_for: FxHashMap<ExprId, ScopeId>, 22 scope_for: FxHashMap<ExprId, ScopeId>,
@@ -34,9 +34,9 @@ pub struct ScopeData {
34 entries: Vec<ScopeEntry>, 34 entries: Vec<ScopeEntry>,
35} 35}
36 36
37impl FnScopes { 37impl ExprScopes {
38 pub(crate) fn new(body: Arc<Body>) -> FnScopes { 38 pub(crate) fn new(body: Arc<Body>) -> ExprScopes {
39 let mut scopes = FnScopes { 39 let mut scopes = ExprScopes {
40 body: body.clone(), 40 body: body.clone(),
41 scopes: Arena::default(), 41 scopes: Arena::default(),
42 scope_for: FxHashMap::default(), 42 scope_for: FxHashMap::default(),
@@ -119,7 +119,7 @@ impl FnScopes {
119#[derive(Debug, Clone, PartialEq, Eq)] 119#[derive(Debug, Clone, PartialEq, Eq)]
120pub struct ScopesWithSyntaxMapping { 120pub struct ScopesWithSyntaxMapping {
121 pub syntax_mapping: Arc<BodySyntaxMapping>, 121 pub syntax_mapping: Arc<BodySyntaxMapping>,
122 pub scopes: Arc<FnScopes>, 122 pub scopes: Arc<ExprScopes>,
123} 123}
124 124
125#[derive(Debug, Clone, PartialEq, Eq)] 125#[derive(Debug, Clone, PartialEq, Eq)]
@@ -249,7 +249,7 @@ fn compute_block_scopes(
249 statements: &[Statement], 249 statements: &[Statement],
250 tail: Option<ExprId>, 250 tail: Option<ExprId>,
251 body: &Body, 251 body: &Body,
252 scopes: &mut FnScopes, 252 scopes: &mut ExprScopes,
253 mut scope: ScopeId, 253 mut scope: ScopeId,
254) { 254) {
255 for stmt in statements { 255 for stmt in statements {
@@ -275,7 +275,7 @@ fn compute_block_scopes(
275 } 275 }
276} 276}
277 277
278fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut FnScopes, scope: ScopeId) { 278fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope: ScopeId) {
279 scopes.set_scope(expr, scope); 279 scopes.set_scope(expr, scope);
280 match &body[expr] { 280 match &body[expr] {
281 Expr::Block { statements, tail } => { 281 Expr::Block { statements, tail } => {
@@ -344,7 +344,7 @@ mod tests {
344 let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap(); 344 let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap();
345 let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); 345 let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap();
346 let body_hir = expr::collect_fn_body_syntax(fn_def); 346 let body_hir = expr::collect_fn_body_syntax(fn_def);
347 let scopes = FnScopes::new(Arc::clone(body_hir.body())); 347 let scopes = ExprScopes::new(Arc::clone(body_hir.body()));
348 let scopes = ScopesWithSyntaxMapping { 348 let scopes = ScopesWithSyntaxMapping {
349 scopes: Arc::new(scopes), 349 scopes: Arc::new(scopes),
350 syntax_mapping: Arc::new(body_hir), 350 syntax_mapping: Arc::new(body_hir),
@@ -444,7 +444,7 @@ mod tests {
444 let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); 444 let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap();
445 445
446 let body_hir = expr::collect_fn_body_syntax(fn_def); 446 let body_hir = expr::collect_fn_body_syntax(fn_def);
447 let scopes = FnScopes::new(Arc::clone(body_hir.body())); 447 let scopes = ExprScopes::new(Arc::clone(body_hir.body()));
448 let scopes = ScopesWithSyntaxMapping { 448 let scopes = ScopesWithSyntaxMapping {
449 scopes: Arc::new(scopes), 449 scopes: Arc::new(scopes),
450 syntax_mapping: Arc::new(body_hir), 450 syntax_mapping: Arc::new(body_hir),
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index eaf8565ee..0b9ee63bf 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -57,9 +57,9 @@ pub use self::{
57 nameres::{ItemMap, PerNs, Namespace, Resolution}, 57 nameres::{ItemMap, PerNs, Namespace, Resolution},
58 ty::Ty, 58 ty::Ty,
59 impl_block::{ImplBlock, ImplItem}, 59 impl_block::{ImplBlock, ImplItem},
60 code_model_impl::function::{FnScopes, ScopesWithSyntaxMapping},
61 docs::{Docs, Documentation}, 60 docs::{Docs, Documentation},
62 adt::AdtDef, 61 adt::AdtDef,
62 expr::{ExprScopes, ScopesWithSyntaxMapping},
63}; 63};
64 64
65pub use self::code_model_api::{ 65pub use self::code_model_api::{
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs
index 6724649e1..1b61d449e 100644
--- a/crates/ra_hir/src/query_definitions.rs
+++ b/crates/ra_hir/src/query_definitions.rs
@@ -4,13 +4,13 @@ use ra_syntax::{SyntaxNode, TreeArc};
4 4
5use crate::{ 5use crate::{
6 SourceFileItems, SourceItemId, HirFileId, 6 SourceFileItems, SourceItemId, HirFileId,
7 Function, FnScopes, 7 Function, ExprScopes,
8 db::HirDatabase, 8 db::HirDatabase,
9}; 9};
10 10
11pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes> { 11pub(super) fn expr_scopes(db: &impl HirDatabase, func: Function) -> Arc<ExprScopes> {
12 let body = db.body_hir(func); 12 let body = db.body_hir(func);
13 let res = FnScopes::new(body); 13 let res = ExprScopes::new(body);
14 Arc::new(res) 14 Arc::new(res)
15} 15}
16 16
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 7a5485698..0472414a6 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -34,7 +34,7 @@ use test_utils::tested_by;
34 34
35use crate::{ 35use crate::{
36 Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock, 36 Module, Function, Struct, StructField, Enum, EnumVariant, Path, Name, ImplBlock,
37 FnSignature, FnScopes, ModuleDef, AdtDef, 37 FnSignature, ExprScopes, ModuleDef, AdtDef,
38 db::HirDatabase, 38 db::HirDatabase,
39 type_ref::{TypeRef, Mutability}, 39 type_ref::{TypeRef, Mutability},
40 name::KnownName, 40 name::KnownName,
@@ -814,7 +814,7 @@ impl Index<PatId> for InferenceResult {
814struct InferenceContext<'a, D: HirDatabase> { 814struct InferenceContext<'a, D: HirDatabase> {
815 db: &'a D, 815 db: &'a D,
816 body: Arc<Body>, 816 body: Arc<Body>,
817 scopes: Arc<FnScopes>, 817 scopes: Arc<ExprScopes>,
818 module: Module, 818 module: Module,
819 impl_block: Option<ImplBlock>, 819 impl_block: Option<ImplBlock>,
820 var_unification_table: InPlaceUnificationTable<TypeVarId>, 820 var_unification_table: InPlaceUnificationTable<TypeVarId>,
@@ -908,7 +908,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
908 fn new( 908 fn new(
909 db: &'a D, 909 db: &'a D,
910 body: Arc<Body>, 910 body: Arc<Body>,
911 scopes: Arc<FnScopes>, 911 scopes: Arc<ExprScopes>,
912 module: Module, 912 module: Module,
913 impl_block: Option<ImplBlock>, 913 impl_block: Option<ImplBlock>,
914 ) -> Self { 914 ) -> Self {
@@ -1720,7 +1720,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1720pub fn infer(db: &impl HirDatabase, func: Function) -> Arc<InferenceResult> { 1720pub fn infer(db: &impl HirDatabase, func: Function) -> Arc<InferenceResult> {
1721 db.check_canceled(); 1721 db.check_canceled();
1722 let body = func.body(db); 1722 let body = func.body(db);
1723 let scopes = db.fn_scopes(func); 1723 let scopes = db.expr_scopes(func);
1724 let module = func.module(db); 1724 let module = func.module(db);
1725 let impl_block = func.impl_block(db); 1725 let impl_block = func.impl_block(db);
1726 let mut ctx = InferenceContext::new(db, body, scopes, module, impl_block); 1726 let mut ctx = InferenceContext::new(db, body, scopes, module, impl_block);