From 07a72859650254d8ba326e2c9683ae52164cb3b5 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 25 Dec 2018 13:31:30 +0100 Subject: Collect field data for structs/enum variants --- crates/ra_hir/src/ty.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/ty.rs') diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 386af8120..e2428a37f 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs @@ -156,6 +156,15 @@ impl Ty { Ok(ty) } + pub(crate) fn new_opt( + db: &impl HirDatabase, + module: &Module, + node: Option, + ) -> Cancelable { + node.map(|n| Ty::new(db, module, n)) + .unwrap_or(Ok(Ty::Unknown)) + } + pub(crate) fn new( db: &impl HirDatabase, module: &Module, @@ -534,7 +543,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { Ty::Unknown } ast::Expr::StructLit(e) => { - let (ty, variant_data) = self.resolve_variant(e.path())?; + let (ty, _variant_data) = self.resolve_variant(e.path())?; if let Some(nfl) = e.named_field_list() { for field in nfl.fields() { if let Some(e) = field.expr() { -- cgit v1.2.3