diff options
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/resolver.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs index 717506358..15fdd9019 100644 --- a/crates/ra_hir_def/src/resolver.rs +++ b/crates/ra_hir_def/src/resolver.rs | |||
@@ -86,6 +86,7 @@ pub enum ResolveValueResult { | |||
86 | 86 | ||
87 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 87 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
88 | pub enum ValueNs { | 88 | pub enum ValueNs { |
89 | ImplSelf(ImplId), | ||
89 | LocalBinding(PatId), | 90 | LocalBinding(PatId), |
90 | FunctionId(FunctionId), | 91 | FunctionId(FunctionId), |
91 | ConstId(ConstId), | 92 | ConstId(ConstId), |
@@ -291,19 +292,26 @@ impl Resolver { | |||
291 | } | 292 | } |
292 | Scope::GenericParams { .. } => continue, | 293 | Scope::GenericParams { .. } => continue, |
293 | 294 | ||
294 | Scope::ImplDefScope(impl_) if n_segments > 1 => { | 295 | Scope::ImplDefScope(impl_) => { |
295 | if first_name == &name![Self] { | 296 | if first_name == &name![Self] { |
296 | let ty = TypeNs::SelfType(*impl_); | 297 | if n_segments > 1 { |
297 | return Some(ResolveValueResult::Partial(ty, 1)); | 298 | let ty = TypeNs::SelfType(*impl_); |
299 | return Some(ResolveValueResult::Partial(ty, 1)); | ||
300 | } else { | ||
301 | return Some(ResolveValueResult::ValueNs(ValueNs::ImplSelf(*impl_))); | ||
302 | } | ||
298 | } | 303 | } |
299 | } | 304 | } |
300 | Scope::AdtScope(adt) if n_segments > 1 => { | 305 | Scope::AdtScope(adt) => { |
306 | if n_segments == 1 { | ||
307 | // bare `Self` doesn't work in the value namespace in a struct/enum definition | ||
308 | continue; | ||
309 | } | ||
301 | if first_name == &name![Self] { | 310 | if first_name == &name![Self] { |
302 | let ty = TypeNs::AdtSelfType(*adt); | 311 | let ty = TypeNs::AdtSelfType(*adt); |
303 | return Some(ResolveValueResult::Partial(ty, 1)); | 312 | return Some(ResolveValueResult::Partial(ty, 1)); |
304 | } | 313 | } |
305 | } | 314 | } |
306 | Scope::ImplDefScope(_) | Scope::AdtScope(_) => continue, | ||
307 | 315 | ||
308 | Scope::ModuleScope(m) => { | 316 | Scope::ModuleScope(m) => { |
309 | let (module_def, idx) = m.crate_def_map.resolve_path( | 317 | let (module_def, idx) = m.crate_def_map.resolve_path( |