diff options
author | Florian Diebold <[email protected]> | 2018-12-25 12:31:30 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2018-12-25 14:16:42 +0000 |
commit | 07a72859650254d8ba326e2c9683ae52164cb3b5 (patch) | |
tree | bc652bf0deb9f0d12380081b04585a2beaa97fce /crates/ra_hir/src/ty.rs | |
parent | 4cb7b0f2af9787abe1c73fc3922e9b426a96e0ef (diff) |
Collect field data for structs/enum variants
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 11 |
1 files changed, 10 insertions, 1 deletions
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 { | |||
156 | Ok(ty) | 156 | Ok(ty) |
157 | } | 157 | } |
158 | 158 | ||
159 | pub(crate) fn new_opt( | ||
160 | db: &impl HirDatabase, | ||
161 | module: &Module, | ||
162 | node: Option<ast::TypeRef>, | ||
163 | ) -> Cancelable<Self> { | ||
164 | node.map(|n| Ty::new(db, module, n)) | ||
165 | .unwrap_or(Ok(Ty::Unknown)) | ||
166 | } | ||
167 | |||
159 | pub(crate) fn new( | 168 | pub(crate) fn new( |
160 | db: &impl HirDatabase, | 169 | db: &impl HirDatabase, |
161 | module: &Module, | 170 | module: &Module, |
@@ -534,7 +543,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
534 | Ty::Unknown | 543 | Ty::Unknown |
535 | } | 544 | } |
536 | ast::Expr::StructLit(e) => { | 545 | ast::Expr::StructLit(e) => { |
537 | let (ty, variant_data) = self.resolve_variant(e.path())?; | 546 | let (ty, _variant_data) = self.resolve_variant(e.path())?; |
538 | if let Some(nfl) = e.named_field_list() { | 547 | if let Some(nfl) = e.named_field_list() { |
539 | for field in nfl.fields() { | 548 | for field in nfl.fields() { |
540 | if let Some(e) = field.expr() { | 549 | if let Some(e) = field.expr() { |