diff options
Diffstat (limited to 'crates/ra_hir/src/resolve.rs')
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index bb6915901..a23c8792a 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -15,7 +15,6 @@ use crate::{ | |||
15 | name::{Name, SELF_PARAM, SELF_TYPE}, | 15 | name::{Name, SELF_PARAM, SELF_TYPE}, |
16 | nameres::{CrateDefMap, CrateModuleId, PerNs}, | 16 | nameres::{CrateDefMap, CrateModuleId, PerNs}, |
17 | path::{Path, PathKind}, | 17 | path::{Path, PathKind}, |
18 | type_ref::TypeRef, | ||
19 | Adt, BuiltinType, Const, Enum, EnumVariant, Function, MacroDef, ModuleDef, Static, Struct, | 18 | Adt, BuiltinType, Const, Enum, EnumVariant, Function, MacroDef, ModuleDef, Static, Struct, |
20 | Trait, TypeAlias, | 19 | Trait, TypeAlias, |
21 | }; | 20 | }; |
@@ -50,7 +49,7 @@ pub(crate) enum Scope { | |||
50 | ExprScope(ExprScope), | 49 | ExprScope(ExprScope), |
51 | } | 50 | } |
52 | 51 | ||
53 | #[derive(Debug, Clone, PartialEq, Eq)] | 52 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
54 | pub enum TypeNs { | 53 | pub enum TypeNs { |
55 | SelfType(ImplBlock), | 54 | SelfType(ImplBlock), |
56 | GenericParam(u32), | 55 | GenericParam(u32), |
@@ -59,19 +58,18 @@ pub enum TypeNs { | |||
59 | TypeAlias(TypeAlias), | 58 | TypeAlias(TypeAlias), |
60 | BuiltinType(BuiltinType), | 59 | BuiltinType(BuiltinType), |
61 | Trait(Trait), | 60 | Trait(Trait), |
62 | // Module belong to type ns, but the resovler is used when all module paths | 61 | // Module belong to type ns, but the resolver is used when all module paths |
63 | // are fully resolved. | 62 | // are fully resolved. |
64 | // Module(Module) | 63 | // Module(Module) |
65 | } | 64 | } |
66 | 65 | ||
67 | #[derive(Debug)] | 66 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
68 | pub enum ResolveValueResult<'a> { | 67 | pub enum ResolveValueResult { |
69 | ValueNs(ValueNs), | 68 | ValueNs(ValueNs), |
70 | Partial(TypeNs, usize), | 69 | Partial(TypeNs, usize), |
71 | TypeRef(&'a TypeRef), | ||
72 | } | 70 | } |
73 | 71 | ||
74 | #[derive(Debug)] | 72 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
75 | pub enum ValueNs { | 73 | pub enum ValueNs { |
76 | LocalBinding(PatId), | 74 | LocalBinding(PatId), |
77 | Function(Function), | 75 | Function(Function), |
@@ -131,6 +129,9 @@ impl Resolver { | |||
131 | db: &impl HirDatabase, | 129 | db: &impl HirDatabase, |
132 | path: &Path, | 130 | path: &Path, |
133 | ) -> Option<(TypeNs, Option<usize>)> { | 131 | ) -> Option<(TypeNs, Option<usize>)> { |
132 | if path.is_type_relative() { | ||
133 | return None; | ||
134 | } | ||
134 | let first_name = &path.segments.first()?.name; | 135 | let first_name = &path.segments.first()?.name; |
135 | let skip_to_mod = path.kind != PathKind::Plain; | 136 | let skip_to_mod = path.kind != PathKind::Plain; |
136 | for scope in self.scopes.iter().rev() { | 137 | for scope in self.scopes.iter().rev() { |
@@ -189,11 +190,10 @@ impl Resolver { | |||
189 | &self, | 190 | &self, |
190 | db: &impl HirDatabase, | 191 | db: &impl HirDatabase, |
191 | path: &'p Path, | 192 | path: &'p Path, |
192 | ) -> Option<ResolveValueResult<'p>> { | 193 | ) -> Option<ResolveValueResult> { |
193 | if let PathKind::Type(type_ref) = &path.kind { | 194 | if path.is_type_relative() { |
194 | return Some(ResolveValueResult::TypeRef(type_ref)); | 195 | return None; |
195 | } | 196 | } |
196 | |||
197 | let n_segments = path.segments.len(); | 197 | let n_segments = path.segments.len(); |
198 | let tmp = SELF_PARAM; | 198 | let tmp = SELF_PARAM; |
199 | let first_name = if path.is_self() { &tmp } else { &path.segments.first()?.name }; | 199 | let first_name = if path.is_self() { &tmp } else { &path.segments.first()?.name }; |
@@ -284,7 +284,7 @@ impl Resolver { | |||
284 | ) -> Option<ValueNs> { | 284 | ) -> Option<ValueNs> { |
285 | match self.resolve_path_in_value_ns(db, path)? { | 285 | match self.resolve_path_in_value_ns(db, path)? { |
286 | ResolveValueResult::ValueNs(it) => Some(it), | 286 | ResolveValueResult::ValueNs(it) => Some(it), |
287 | ResolveValueResult::Partial(..) | ResolveValueResult::TypeRef(_) => None, | 287 | ResolveValueResult::Partial(..) => None, |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||