diff options
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 23 |
1 files changed, 13 insertions, 10 deletions
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)] |
36 | pub(crate) struct ExprScope { | 36 | pub(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)] |
56 | pub enum TypeNs { | 57 | pub(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)] |
71 | pub enum ResolveValueResult { | 72 | pub(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)] |
77 | pub enum ValueNs { | 78 | pub(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 | } |