aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/code_model.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-12-07 19:26:33 +0000
committerGitHub <[email protected]>2019-12-07 19:26:33 +0000
commit971df306ada43f6150e12a143873f680e104a866 (patch)
tree913c24e889f3db8044b4b9f11bc3969e7eb02e34 /crates/ra_hir/src/code_model.rs
parenta3eb8787452a04400784ba8fed38303232595695 (diff)
parent88c5b1282a5770097c6c768b24bedfc3a6944e08 (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/code_model.rs')
-rw-r--r--crates/ra_hir/src/code_model.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 29ace8479..4578a0ba8 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -15,9 +15,9 @@ 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, GenericParamId, 18 AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, FunctionId, HasModule, ImplId,
19 HasModule, ImplId, LocalEnumVariantId, LocalImportId, LocalModuleId, LocalStructFieldId, 19 LocalEnumVariantId, LocalImportId, LocalModuleId, LocalStructFieldId, Lookup, ModuleId,
20 Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId, UnionId, 20 StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId,
21}; 21};
22use hir_expand::{ 22use hir_expand::{
23 diagnostics::DiagnosticSink, 23 diagnostics::DiagnosticSink,
@@ -856,8 +856,19 @@ impl Local {
856} 856}
857 857
858#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 858#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
859pub struct GenericParam { 859pub struct TypeParam {
860 pub(crate) id: GenericParamId, 860 pub(crate) id: TypeParamId,
861}
862
863impl TypeParam {
864 pub fn name(self, db: &impl HirDatabase) -> Name {
865 let params = db.generic_params(self.id.parent);
866 params.types[self.id.local_id].name.clone()
867 }
868
869 pub fn module(self, db: &impl HirDatabase) -> Module {
870 self.id.parent.module(db).into()
871 }
861} 872}
862 873
863#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 874#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -1100,7 +1111,7 @@ impl HirDisplay for Type {
1100pub enum ScopeDef { 1111pub enum ScopeDef {
1101 ModuleDef(ModuleDef), 1112 ModuleDef(ModuleDef),
1102 MacroDef(MacroDef), 1113 MacroDef(MacroDef),
1103 GenericParam(GenericParam), 1114 GenericParam(TypeParam),
1104 ImplSelfType(ImplBlock), 1115 ImplSelfType(ImplBlock),
1105 AdtSelfType(Adt), 1116 AdtSelfType(Adt),
1106 Local(Local), 1117 Local(Local),