470: Type inference for enum variants r=flodiebold a=marcusklaas

Opened a new PR instead of https://github.com/rust-analyzer/rust-analyzer/pull/461. Totally botched that one.

I think I resolved all the issues mentioned there.

Co-authored-by: Marcus Klaas de Vries <mail@marcusklaas.nl>
This commit is contained in:
bors[bot] 2019-01-10 19:12:40 +00:00
commit dc2a8d5acc
12 changed files with 205 additions and 46 deletions

View file

@ -21,14 +21,15 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) -> C
.add_to(acc)
});
}
hir::Def::Enum(e) => e
.variants(ctx.db)?
.into_iter()
.for_each(|(name, _variant)| {
CompletionItem::new(CompletionKind::Reference, name.to_string())
.kind(CompletionItemKind::EnumVariant)
.add_to(acc)
}),
hir::Def::Enum(e) => {
e.variants(ctx.db)?
.into_iter()
.for_each(|(variant_name, _variant)| {
CompletionItem::new(CompletionKind::Reference, variant_name.to_string())
.kind(CompletionItemKind::EnumVariant)
.add_to(acc)
});
}
_ => return Ok(()),
};
Ok(())

View file

@ -122,6 +122,7 @@ salsa::database_storage! {
fn type_for_field() for hir::db::TypeForFieldQuery;
fn struct_data() for hir::db::StructDataQuery;
fn enum_data() for hir::db::EnumDataQuery;
fn enum_variant_data() for hir::db::EnumVariantDataQuery;
fn impls_in_module() for hir::db::ImplsInModuleQuery;
fn body_hir() for hir::db::BodyHirQuery;
fn body_syntax_mapping() for hir::db::BodySyntaxMappingQuery;