aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-07 12:33:08 +0000
committerGitHub <[email protected]>2019-12-07 12:33:08 +0000
commit7aac5f2b427247120025f63c4864a1b937ed20c7 (patch)
tree51a841eaac9c7416e379b23887ee97ddc541ab5c /crates/ra_hir
parent35fc983dd9e904ad4961b9c10be3397bad33da0c (diff)
parent29b5e1ec2a4bc25daddfe5137503b156b3cd283f (diff)
Merge #2492
2492: Refactor generic parameteres lowering r=flodiebold a=matklad indices and parent params seem to be concerns, specific to `hir_ty`, so move them there. Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs5
-rw-r--r--crates/ra_hir/src/source_binder.rs10
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)]
859pub struct GenericParam { 859pub 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 })