diff options
author | Aleksey Kladov <[email protected]> | 2019-09-12 22:10:16 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-09-12 22:10:16 +0100 |
commit | 45117c63884366ee82102a782a62a09fefff746b (patch) | |
tree | b66d9ca105e39b96b78bf7f3659d1858577a2c8c /crates/ra_ide_api/src/completion/complete_path.rs | |
parent | d8b621cf26b59ff5ae9379b50fc822590b6a3a4e (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.rs | 13 |
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 @@ | |||
1 | use hir::{Either, Resolution}; | 1 | use hir::{AdtDef, Either, Resolution}; |
2 | use ra_syntax::AstNode; | 2 | use ra_syntax::AstNode; |
3 | use test_utils::tested_by; | 3 | use 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 | }; |