diff options
author | Aleksey Kladov <[email protected]> | 2019-12-07 10:50:36 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-07 12:05:56 +0000 |
commit | 8e9837df21942ca12a5aece0a868ea46eb405742 (patch) | |
tree | 664cfafc63c0895d76df5c85f6f10c0739f82275 /crates/ra_hir/src | |
parent | 30fefcc08cc0c670ce541476491238d258ca55c1 (diff) |
Remove idx and parent generics from generics
This makes `hir_def::GenericParams` flatter. The logic for
re-numbering the params is moved to hir instead.
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 10 |
2 files changed, 4 insertions, 11 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 7706399ae..29ace8479 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -15,7 +15,7 @@ use hir_def::{ | |||
15 | per_ns::PerNs, | 15 | per_ns::PerNs, |
16 | resolver::HasResolver, | 16 | resolver::HasResolver, |
17 | type_ref::{Mutability, TypeRef}, | 17 | type_ref::{Mutability, TypeRef}, |
18 | AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, FunctionId, GenericDefId, | 18 | AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, FunctionId, GenericParamId, |
19 | HasModule, ImplId, LocalEnumVariantId, LocalImportId, LocalModuleId, LocalStructFieldId, | 19 | HasModule, ImplId, LocalEnumVariantId, LocalImportId, LocalModuleId, LocalStructFieldId, |
20 | Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, UnionId, | 20 | Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, UnionId, |
21 | }; | 21 | }; |
@@ -857,8 +857,7 @@ impl Local { | |||
857 | 857 | ||
858 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 858 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
859 | pub struct GenericParam { | 859 | pub struct GenericParam { |
860 | pub(crate) parent: GenericDefId, | 860 | pub(crate) id: GenericParamId, |
861 | pub(crate) idx: u32, | ||
862 | } | 861 | } |
863 | 862 | ||
864 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 863 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 0e136b904..8c4b635d2 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -262,10 +262,7 @@ impl SourceAnalyzer { | |||
262 | ) -> Option<PathResolution> { | 262 | ) -> Option<PathResolution> { |
263 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { | 263 | let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { |
264 | TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), | 264 | TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), |
265 | TypeNs::GenericParam(idx) => PathResolution::GenericParam(GenericParam { | 265 | TypeNs::GenericParam(id) => PathResolution::GenericParam(GenericParam { id }), |
266 | parent: self.resolver.generic_def().unwrap(), | ||
267 | idx, | ||
268 | }), | ||
269 | TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { | 266 | TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { |
270 | PathResolution::Def(Adt::from(it).into()) | 267 | PathResolution::Def(Adt::from(it).into()) |
271 | } | 268 | } |
@@ -337,10 +334,7 @@ impl SourceAnalyzer { | |||
337 | resolver::ScopeDef::PerNs(it) => it.into(), | 334 | resolver::ScopeDef::PerNs(it) => it.into(), |
338 | resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), | 335 | resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), |
339 | resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), | 336 | resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), |
340 | resolver::ScopeDef::GenericParam(idx) => { | 337 | resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(GenericParam { id }), |
341 | let parent = self.resolver.generic_def().unwrap(); | ||
342 | ScopeDef::GenericParam(GenericParam { parent, idx }) | ||
343 | } | ||
344 | resolver::ScopeDef::Local(pat_id) => { | 338 | resolver::ScopeDef::Local(pat_id) => { |
345 | let parent = self.resolver.body_owner().unwrap().into(); | 339 | let parent = self.resolver.body_owner().unwrap().into(); |
346 | ScopeDef::Local(Local { parent, pat_id }) | 340 | ScopeDef::Local(Local { parent, pat_id }) |