mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
make various enums "inherit" from AdtDef
This commit is contained in:
parent
d8b621cf26
commit
45117c6388
17 changed files with 156 additions and 121 deletions
|
@ -1,4 +1,4 @@
|
|||
use hir::{Either, Resolution};
|
||||
use hir::{AdtDef, Either, Resolution};
|
||||
use ra_syntax::AstNode;
|
||||
use test_utils::tested_by;
|
||||
|
||||
|
@ -37,19 +37,14 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def));
|
||||
}
|
||||
}
|
||||
hir::ModuleDef::Enum(_)
|
||||
| hir::ModuleDef::Struct(_)
|
||||
| hir::ModuleDef::Union(_)
|
||||
| hir::ModuleDef::TypeAlias(_) => {
|
||||
if let hir::ModuleDef::Enum(e) = def {
|
||||
hir::ModuleDef::AdtDef(_) | hir::ModuleDef::TypeAlias(_) => {
|
||||
if let hir::ModuleDef::AdtDef(AdtDef::Enum(e)) = def {
|
||||
for variant in e.variants(ctx.db) {
|
||||
acc.add_enum_variant(ctx, variant);
|
||||
}
|
||||
}
|
||||
let ty = match def {
|
||||
hir::ModuleDef::Enum(e) => e.ty(ctx.db),
|
||||
hir::ModuleDef::Struct(s) => s.ty(ctx.db),
|
||||
hir::ModuleDef::Union(u) => u.ty(ctx.db),
|
||||
hir::ModuleDef::AdtDef(adt) => adt.ty(ctx.db),
|
||||
hir::ModuleDef::TypeAlias(a) => a.ty(ctx.db),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue