diff options
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 2f3e12eb8..b922fe20f 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 | } |
@@ -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 | } |