diff options
author | Lukas Wirth <[email protected]> | 2021-01-19 19:01:49 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-01-19 19:06:39 +0000 |
commit | bed12833cc4ce7c6b4085ba8dc47fc167c83f8ea (patch) | |
tree | a5cf5bb4506fca6ff759980a0f44bb8cff006bcd /crates/hir_def | |
parent | bf889bcf3be44720ca1c26fccec0374dfc7f3763 (diff) |
Show const params in completions
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/resolver.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index e7e92c72d..a505bf2be 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs | |||
@@ -21,8 +21,9 @@ use crate::{ | |||
21 | per_ns::PerNs, | 21 | per_ns::PerNs, |
22 | visibility::{RawVisibility, Visibility}, | 22 | visibility::{RawVisibility, Visibility}, |
23 | AdtId, AssocContainerId, ConstId, ConstParamId, ContainerId, DefWithBodyId, EnumId, | 23 | AdtId, AssocContainerId, ConstId, ConstParamId, ContainerId, DefWithBodyId, EnumId, |
24 | EnumVariantId, FunctionId, GenericDefId, HasModule, ImplId, LocalModuleId, Lookup, ModuleDefId, | 24 | EnumVariantId, FunctionId, GenericDefId, GenericParamId, HasModule, ImplId, LifetimeParamId, |
25 | ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, VariantId, | 25 | LocalModuleId, Lookup, ModuleDefId, ModuleId, StaticId, StructId, TraitId, TypeAliasId, |
26 | TypeParamId, VariantId, | ||
26 | }; | 27 | }; |
27 | 28 | ||
28 | #[derive(Debug, Clone, Default)] | 29 | #[derive(Debug, Clone, Default)] |
@@ -484,7 +485,7 @@ pub enum ScopeDef { | |||
484 | PerNs(PerNs), | 485 | PerNs(PerNs), |
485 | ImplSelfType(ImplId), | 486 | ImplSelfType(ImplId), |
486 | AdtSelfType(AdtId), | 487 | AdtSelfType(AdtId), |
487 | GenericParam(TypeParamId), | 488 | GenericParam(GenericParamId), |
488 | Local(PatId), | 489 | Local(PatId), |
489 | } | 490 | } |
490 | 491 | ||
@@ -527,15 +528,21 @@ impl Scope { | |||
527 | Scope::LocalItemsScope(body) => body.item_scope.entries().for_each(|(name, def)| { | 528 | Scope::LocalItemsScope(body) => body.item_scope.entries().for_each(|(name, def)| { |
528 | f(name.clone(), ScopeDef::PerNs(def)); | 529 | f(name.clone(), ScopeDef::PerNs(def)); |
529 | }), | 530 | }), |
530 | Scope::GenericParams { params, def } => { | 531 | &Scope::GenericParams { ref params, def: parent } => { |
531 | for (local_id, param) in params.types.iter() { | 532 | for (local_id, param) in params.types.iter() { |
532 | if let Some(name) = ¶m.name { | 533 | if let Some(ref name) = param.name { |
533 | f( | 534 | let id = TypeParamId { local_id, parent }; |
534 | name.clone(), | 535 | f(name.clone(), ScopeDef::GenericParam(id.into())) |
535 | ScopeDef::GenericParam(TypeParamId { local_id, parent: *def }), | ||
536 | ) | ||
537 | } | 536 | } |
538 | } | 537 | } |
538 | for (local_id, param) in params.consts.iter() { | ||
539 | let id = ConstParamId { local_id, parent }; | ||
540 | f(param.name.clone(), ScopeDef::GenericParam(id.into())) | ||
541 | } | ||
542 | for (local_id, param) in params.lifetimes.iter() { | ||
543 | let id = LifetimeParamId { local_id, parent }; | ||
544 | f(param.name.clone(), ScopeDef::GenericParam(id.into())) | ||
545 | } | ||
539 | } | 546 | } |
540 | Scope::ImplDefScope(i) => { | 547 | Scope::ImplDefScope(i) => { |
541 | f(name![Self], ScopeDef::ImplSelfType(*i)); | 548 | f(name![Self], ScopeDef::ImplSelfType(*i)); |