aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-19 19:07:33 +0000
committerGitHub <[email protected]>2021-01-19 19:07:33 +0000
commitf647e134a785245579da3de04235887a5e958c9b (patch)
treed0e54ef23ff0714497ac251b6f2e1c7512c092e1 /crates/hir_def/src
parent02edb4b31be02fdab9c970cafb38439f472c0696 (diff)
parentbed12833cc4ce7c6b4085ba8dc47fc167c83f8ea (diff)
Merge #7351
7351: Show const params in completions r=Veykril a=Veykril bors r+ ![image](https://user-images.githubusercontent.com/3757771/105080872-bba76680-5a91-11eb-91cd-0910da4c8312.png) Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/resolver.rs25
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) = &param.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));