From f4f8b8147426b0096d4b5126e487caaa13d13c27 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 7 Dec 2019 20:05:08 +0100 Subject: Get the right analyzer for impls --- crates/ra_hir/src/source_binder.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/source_binder.rs') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 8c4b635d2..2957e496c 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -37,7 +37,7 @@ use crate::{ InEnvironment, TraitEnvironment, Ty, }, Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, GenericParam, - Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, + ImplBlock, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, }; fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option { @@ -59,6 +59,10 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) - let src = node.with_value(it); Some(Enum::from_source(db, src)?.id.resolver(db)) }, + ast::ImplBlock(it) => { + let src = node.with_value(it); + Some(ImplBlock::from_source(db, src)?.id.resolver(db)) + }, _ => match node.value.kind() { FN_DEF | CONST_DEF | STATIC_DEF => { let def = def_with_body_from_child_node(db, node)?; -- cgit v1.2.3 From 88c5b1282a5770097c6c768b24bedfc3a6944e08 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 7 Dec 2019 20:09:53 +0100 Subject: Rename GenericParam -> TypeParam We don't have LifetimeParam yet, but they are planned! --- crates/ra_hir/src/source_binder.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir/src/source_binder.rs') diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 2957e496c..b80aaeb90 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs @@ -36,8 +36,8 @@ use crate::{ method_resolution::{self, implements_trait}, InEnvironment, TraitEnvironment, Ty, }, - Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, GenericParam, - ImplBlock, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, + Adt, AssocItem, Const, DefWithBody, Enum, EnumVariant, FromSource, Function, ImplBlock, Local, + MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, TypeParam, }; fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option { @@ -112,7 +112,7 @@ pub enum PathResolution { /// A local binding (only value namespace) Local(Local), /// A generic parameter - GenericParam(GenericParam), + TypeParam(TypeParam), SelfType(crate::ImplBlock), Macro(MacroDef), AssocItem(crate::AssocItem), @@ -266,7 +266,7 @@ impl SourceAnalyzer { ) -> Option { let types = self.resolver.resolve_path_in_type_ns_fully(db, &path).map(|ty| match ty { TypeNs::SelfType(it) => PathResolution::SelfType(it.into()), - TypeNs::GenericParam(id) => PathResolution::GenericParam(GenericParam { id }), + TypeNs::GenericParam(id) => PathResolution::TypeParam(TypeParam { id }), TypeNs::AdtSelfType(it) | TypeNs::AdtId(it) => { PathResolution::Def(Adt::from(it).into()) } @@ -338,7 +338,7 @@ impl SourceAnalyzer { resolver::ScopeDef::PerNs(it) => it.into(), resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()), resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()), - resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(GenericParam { id }), + resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }), resolver::ScopeDef::Local(pat_id) => { let parent = self.resolver.body_owner().unwrap().into(); ScopeDef::Local(Local { parent, pat_id }) -- cgit v1.2.3