diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-11 16:21:55 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-11 16:21:55 +0000 |
commit | f742803c6a5a632af6e0aecb123920d1962e5fee (patch) | |
tree | 1b0f7c7b0f430d4174ca05e5464b3af98128bafe /crates/ra_hir/src/source_binder.rs | |
parent | a599147b4232c0d4f6b071a3a96e86f903f4cf52 (diff) | |
parent | c5a18c44e5211282c22b9ca7aae8700ee8ca1817 (diff) |
Merge #2213
2213: Hir generic param r=flodiebold a=matklad
r? @flodiebold
This should make the life of IDE easier: before, it got `GenericParam(u32)` which was of questionable utility. Now, it's a proper code_model type, so it can gain `source`, `name`, `module` and all the other hir methods, should the IDE need them. Moreover, IDE now doesn't care about internal representation of generic param, which seems like a long-term win.
The problem is, of course, that we now have to types named `GenericParam` in hir: this code_model type, and an internal type with an index which doesn't know about the parent. I think it's fine for the time being, but, after we finish cratefication of hir, this local `GenericParam` should move to `hir_def` or `hir_ty`, and *maybe* restrucured as `ParamId / PramData` pair.
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 | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index c5fdf3bab..fe4211819 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -28,8 +28,8 @@ use crate::{ | |||
28 | ids::LocationCtx, | 28 | ids::LocationCtx, |
29 | resolve::{ScopeDef, TypeNs, ValueNs}, | 29 | resolve::{ScopeDef, TypeNs, ValueNs}, |
30 | ty::method_resolution::{self, implements_trait}, | 30 | ty::method_resolution::{self, implements_trait}, |
31 | AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, HasBody, HirFileId, Local, | 31 | AssocItem, Const, DefWithBody, Either, Enum, FromSource, Function, GenericParam, HasBody, |
32 | MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty, | 32 | HirFileId, Local, MacroDef, Module, Name, Path, Resolver, Static, Struct, Ty, |
33 | }; | 33 | }; |
34 | 34 | ||
35 | fn try_get_resolver_for_node( | 35 | fn try_get_resolver_for_node( |
@@ -107,7 +107,7 @@ pub enum PathResolution { | |||
107 | /// A local binding (only value namespace) | 107 | /// A local binding (only value namespace) |
108 | Local(Local), | 108 | Local(Local), |
109 | /// A generic parameter | 109 | /// A generic parameter |
110 | GenericParam(u32), | 110 | GenericParam(GenericParam), |
111 | SelfType(crate::ImplBlock), | 111 | SelfType(crate::ImplBlock), |
112 | Macro(MacroDef), | 112 | Macro(MacroDef), |
113 | AssocItem(crate::AssocItem), | 113 | AssocItem(crate::AssocItem), |
@@ -227,7 +227,10 @@ impl SourceAnalyzer { | |||
227 | ) -> Option<PathResolution> { | 227 | ) -> Option<PathResolution> { |
228 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { | 228 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { |
229 | TypeNs::SelfType(it) => PathResolution::SelfType(it), | 229 | TypeNs::SelfType(it) => PathResolution::SelfType(it), |
230 | TypeNs::GenericParam(it) => PathResolution::GenericParam(it), | 230 | TypeNs::GenericParam(idx) => PathResolution::GenericParam(GenericParam { |
231 | parent: self.resolver.generic_def().unwrap(), | ||
232 | idx, | ||
233 | }), | ||
231 | TypeNs::AdtSelfType(it) | TypeNs::Adt(it) => PathResolution::Def(it.into()), | 234 | TypeNs::AdtSelfType(it) | TypeNs::Adt(it) => PathResolution::Def(it.into()), |
232 | TypeNs::EnumVariant(it) => PathResolution::Def(it.into()), | 235 | TypeNs::EnumVariant(it) => PathResolution::Def(it.into()), |
233 | TypeNs::TypeAlias(it) => PathResolution::Def(it.into()), | 236 | TypeNs::TypeAlias(it) => PathResolution::Def(it.into()), |