aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-15 09:24:59 +0000
committerGitHub <[email protected]>2019-11-15 09:24:59 +0000
commite05fc9455dd64c240ddc5896f739ea3842838210 (patch)
treebcb1d19f4e5e6f2b822b49278ef7e5fb3b4c8e5c /crates/ra_hir/src
parent31d01efb069065449e53cfd7d0935c4b9fecf1e3 (diff)
parent487fc448c3fae2f494f0e5a9e208aa012cfb6309 (diff)
Merge #2253
2253: Reduce visibility r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/expr.rs2
-rw-r--r--crates/ra_hir/src/resolve.rs23
-rw-r--r--crates/ra_hir/src/source_binder.rs8
3 files changed, 14 insertions, 19 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 9262325f2..899e0fa04 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -38,7 +38,7 @@ pub(crate) fn resolver_for_scope(
38 let scopes = owner.expr_scopes(db); 38 let scopes = owner.expr_scopes(db);
39 let scope_chain = scopes.scope_chain(scope_id).collect::<Vec<_>>(); 39 let scope_chain = scopes.scope_chain(scope_id).collect::<Vec<_>>();
40 for scope in scope_chain.into_iter().rev() { 40 for scope in scope_chain.into_iter().rev() {
41 r = r.push_expr_scope(Arc::clone(&scopes), scope); 41 r = r.push_expr_scope(owner, Arc::clone(&scopes), scope);
42 } 42 }
43 r 43 r
44} 44}
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index 2f3e12eb8..2fb913108 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -16,8 +16,8 @@ use crate::{
16 expr::{ExprScopes, PatId, ScopeId}, 16 expr::{ExprScopes, PatId, ScopeId},
17 generics::GenericParams, 17 generics::GenericParams,
18 impl_block::ImplBlock, 18 impl_block::ImplBlock,
19 Adt, Const, Enum, EnumVariant, Function, MacroDef, ModuleDef, PerNs, Static, Struct, Trait, 19 Adt, Const, DefWithBody, Enum, EnumVariant, Function, Local, MacroDef, ModuleDef, PerNs,
20 TypeAlias, 20 Static, Struct, Trait, TypeAlias,
21}; 21};
22 22
23#[derive(Debug, Clone, Default)] 23#[derive(Debug, Clone, Default)]
@@ -34,6 +34,7 @@ pub(crate) struct ModuleItemMap {
34 34
35#[derive(Debug, Clone)] 35#[derive(Debug, Clone)]
36pub(crate) struct ExprScope { 36pub(crate) struct ExprScope {
37 owner: DefWithBody,
37 expr_scopes: Arc<ExprScopes>, 38 expr_scopes: Arc<ExprScopes>,
38 scope_id: ScopeId, 39 scope_id: ScopeId,
39} 40}
@@ -53,7 +54,7 @@ pub(crate) enum Scope {
53} 54}
54 55
55#[derive(Debug, Clone, PartialEq, Eq, Hash)] 56#[derive(Debug, Clone, PartialEq, Eq, Hash)]
56pub enum TypeNs { 57pub(crate) enum TypeNs {
57 SelfType(ImplBlock), 58 SelfType(ImplBlock),
58 GenericParam(u32), 59 GenericParam(u32),
59 Adt(Adt), 60 Adt(Adt),
@@ -68,13 +69,13 @@ pub enum TypeNs {
68} 69}
69 70
70#[derive(Debug, Clone, PartialEq, Eq, Hash)] 71#[derive(Debug, Clone, PartialEq, Eq, Hash)]
71pub enum ResolveValueResult { 72pub(crate) enum ResolveValueResult {
72 ValueNs(ValueNs), 73 ValueNs(ValueNs),
73 Partial(TypeNs, usize), 74 Partial(TypeNs, usize),
74} 75}
75 76
76#[derive(Debug, Clone, PartialEq, Eq, Hash)] 77#[derive(Debug, Clone, PartialEq, Eq, Hash)]
77pub enum ValueNs { 78pub(crate) enum ValueNs {
78 LocalBinding(PatId), 79 LocalBinding(PatId),
79 Function(Function), 80 Function(Function),
80 Const(Const), 81 Const(Const),
@@ -399,10 +400,11 @@ impl Resolver {
399 400
400 pub(crate) fn push_expr_scope( 401 pub(crate) fn push_expr_scope(
401 self, 402 self,
403 owner: DefWithBody,
402 expr_scopes: Arc<ExprScopes>, 404 expr_scopes: Arc<ExprScopes>,
403 scope_id: ScopeId, 405 scope_id: ScopeId,
404 ) -> Resolver { 406 ) -> Resolver {
405 self.push_scope(Scope::ExprScope(ExprScope { expr_scopes, scope_id })) 407 self.push_scope(Scope::ExprScope(ExprScope { owner, expr_scopes, scope_id }))
406 } 408 }
407} 409}
408 410
@@ -413,7 +415,7 @@ pub enum ScopeDef {
413 GenericParam(u32), 415 GenericParam(u32),
414 ImplSelfType(ImplBlock), 416 ImplSelfType(ImplBlock),
415 AdtSelfType(Adt), 417 AdtSelfType(Adt),
416 LocalBinding(PatId), 418 Local(Local),
417 Unknown, 419 Unknown,
418} 420}
419 421
@@ -467,9 +469,10 @@ impl Scope {
467 Scope::AdtScope(i) => { 469 Scope::AdtScope(i) => {
468 f(name::SELF_TYPE, ScopeDef::AdtSelfType(*i)); 470 f(name::SELF_TYPE, ScopeDef::AdtSelfType(*i));
469 } 471 }
470 Scope::ExprScope(e) => { 472 Scope::ExprScope(scope) => {
471 e.expr_scopes.entries(e.scope_id).iter().for_each(|e| { 473 scope.expr_scopes.entries(scope.scope_id).iter().for_each(|e| {
472 f(e.name().clone(), ScopeDef::LocalBinding(e.pat())); 474 let local = Local { parent: scope.owner, pat_id: e.pat() };
475 f(e.name().clone(), ScopeDef::Local(local));
473 }); 476 });
474 } 477 }
475 } 478 }
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index ca40e3b54..59046edcc 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -195,14 +195,6 @@ impl SourceAnalyzer {
195 Some(self.infer.as_ref()?[pat_id].clone()) 195 Some(self.infer.as_ref()?[pat_id].clone())
196 } 196 }
197 197
198 pub fn type_of_pat_by_id(
199 &self,
200 _db: &impl HirDatabase,
201 pat_id: expr::PatId,
202 ) -> Option<crate::Ty> {
203 Some(self.infer.as_ref()?[pat_id].clone())
204 }
205
206 pub fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<Function> { 198 pub fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<Function> {
207 let expr_id = self.expr_id(&call.clone().into())?; 199 let expr_id = self.expr_id(&call.clone().into())?;
208 self.infer.as_ref()?.method_resolution(expr_id) 200 self.infer.as_ref()?.method_resolution(expr_id)