diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-07 19:26:33 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-07 19:26:33 +0000 |
commit | 971df306ada43f6150e12a143873f680e104a866 (patch) | |
tree | 913c24e889f3db8044b4b9f11bc3969e7eb02e34 /crates/ra_hir/src/source_binder.rs | |
parent | a3eb8787452a04400784ba8fed38303232595695 (diff) | |
parent | 88c5b1282a5770097c6c768b24bedfc3a6944e08 (diff) |
Merge #2494
2494: Get the right analyzer for impls r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 8c4b635d2..b80aaeb90 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -36,8 +36,8 @@ use crate::{ | |||
36 | method_resolution::{self, implements_trait}, | 36 | method_resolution::{self, implements_trait}, |
37 | InEnvironment, TraitEnvironment, Ty, | 37 | InEnvironment, TraitEnvironment, Ty, |
38 | }, | 38 | }, |
39 | Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, GenericParam, | 39 | Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, ImplBlock, Local, |
40 | Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, | 40 | MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, |
41 | }; | 41 | }; |
42 | 42 | ||
43 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option<Resolver> { | 43 | fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option<Resolver> { |
@@ -59,6 +59,10 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) - | |||
59 | let src = node.with_value(it); | 59 | let src = node.with_value(it); |
60 | Some(Enum::from_source(db, src)?.id.resolver(db)) | 60 | Some(Enum::from_source(db, src)?.id.resolver(db)) |
61 | }, | 61 | }, |
62 | ast::ImplBlock(it) => { | ||
63 | let src = node.with_value(it); | ||
64 | Some(ImplBlock::from_source(db, src)?.id.resolver(db)) | ||
65 | }, | ||
62 | _ => match node.value.kind() { | 66 | _ => match node.value.kind() { |
63 | FN_DEF | CONST_DEF | STATIC_DEF => { | 67 | FN_DEF | CONST_DEF | STATIC_DEF => { |
64 | let def = def_with_body_from_child_node(db, node)?; | 68 | let def = def_with_body_from_child_node(db, node)?; |
@@ -108,7 +112,7 @@ pub enum PathResolution { | |||
108 | /// A local binding (only value namespace) | 112 | /// A local binding (only value namespace) |
109 | Local(Local), | 113 | Local(Local), |
110 | /// A generic parameter | 114 | /// A generic parameter |
111 | GenericParam(GenericParam), | 115 | TypeParam(TypeParam), |
112 | SelfType(crate::ImplBlock), | 116 | SelfType(crate::ImplBlock), |
113 | Macro(MacroDef), | 117 | Macro(MacroDef), |
114 | AssocItem(crate::AssocItem), | 118 | AssocItem(crate::AssocItem), |
@@ -262,7 +266,7 @@ impl SourceAnalyzer { | |||
262 | ) -> Option<PathResolution> { | 266 | ) -> Option<PathResolution> { |
263 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { | 267 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { |
264 | TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), | 268 | TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), |
265 | TypeNs::GenericParam(id) => PathResolution::GenericParam(GenericParam { id }), | 269 | TypeNs::GenericParam(id) => PathResolution::TypeParam(TypeParam { id }), |
266 | TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { | 270 | TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { |
267 | PathResolution::Def(Adt::from(it).into()) | 271 | PathResolution::Def(Adt::from(it).into()) |
268 | } | 272 | } |
@@ -334,7 +338,7 @@ impl SourceAnalyzer { | |||
334 | resolver::ScopeDef::PerNs(it) => it.into(), | 338 | resolver::ScopeDef::PerNs(it) => it.into(), |
335 | resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), | 339 | resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), |
336 | resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), | 340 | resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), |
337 | resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(GenericParam { id }), | 341 | resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }), |
338 | resolver::ScopeDef::Local(pat_id) => { | 342 | resolver::ScopeDef::Local(pat_id) => { |
339 | let parent = self.resolver.body_owner().unwrap().into(); | 343 | let parent = self.resolver.body_owner().unwrap().into(); |
340 | ScopeDef::Local(Local { parent, pat_id }) | 344 | ScopeDef::Local(Local { parent, pat_id }) |