aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/complete_path.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-12 22:10:16 +0100
committerAleksey Kladov <[email protected]>2019-09-12 22:10:16 +0100
commit45117c63884366ee82102a782a62a09fefff746b (patch)
treeb66d9ca105e39b96b78bf7f3659d1858577a2c8c /crates/ra_ide_api/src/completion/complete_path.rs
parentd8b621cf26b59ff5ae9379b50fc822590b6a3a4e (diff)
make various enums "inherit" from AdtDef
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_path.rs')
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 457a3d10c..df14f465a 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -1,4 +1,4 @@
1use hir::{Either, Resolution}; 1use hir::{AdtDef, Either, Resolution};
2use ra_syntax::AstNode; 2use ra_syntax::AstNode;
3use test_utils::tested_by; 3use test_utils::tested_by;
4 4
@@ -37,19 +37,14 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
37 acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def)); 37 acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def));
38 } 38 }
39 } 39 }
40 hir::ModuleDef::Enum(_) 40 hir::ModuleDef::AdtDef(_) | hir::ModuleDef::TypeAlias(_) => {
41 | hir::ModuleDef::Struct(_) 41 if let hir::ModuleDef::AdtDef(AdtDef::Enum(e)) = def {
42 | hir::ModuleDef::Union(_)
43 | hir::ModuleDef::TypeAlias(_) => {
44 if let hir::ModuleDef::Enum(e) = def {
45 for variant in e.variants(ctx.db) { 42 for variant in e.variants(ctx.db) {
46 acc.add_enum_variant(ctx, variant); 43 acc.add_enum_variant(ctx, variant);
47 } 44 }
48 } 45 }
49 let ty = match def { 46 let ty = match def {
50 hir::ModuleDef::Enum(e) => e.ty(ctx.db), 47 hir::ModuleDef::AdtDef(adt) => adt.ty(ctx.db),
51 hir::ModuleDef::Struct(s) => s.ty(ctx.db),
52 hir::ModuleDef::Union(u) => u.ty(ctx.db),
53 hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db), 48 hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db),
54 _ => unreachable!(), 49 _ => unreachable!(),
55 }; 50 };