diff options
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() { |