aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/ty.rs25
1 files changed, 19 insertions, 6 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 1d5473d17..eb5fea153 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -479,17 +479,30 @@ impl InferenceContext {
479pub fn infer(_db: &impl HirDatabase, node: ast::FnDef, scopes: Arc<FnScopes>) -> InferenceResult { 479pub fn infer(_db: &impl HirDatabase, node: ast::FnDef, scopes: Arc<FnScopes>) -> InferenceResult {
480 let mut ctx = InferenceContext::new(scopes); 480 let mut ctx = InferenceContext::new(scopes);
481 481
482 for param in node.param_list().unwrap().params() { 482 if let Some(param_list) = node.param_list() {
483 let pat = param.pat().unwrap(); 483 for param in param_list.params() {
484 let type_ref = param.type_ref().unwrap(); 484 let pat = if let Some(pat) = param.pat() {
485 let ty = Ty::new(type_ref); 485 pat
486 ctx.type_for.insert(LocalSyntaxPtr::new(pat.syntax()), ty); 486 } else {
487 continue;
488 };
489 if let Some(type_ref) = param.type_ref() {
490 let ty = Ty::new(type_ref);
491 ctx.type_for.insert(LocalSyntaxPtr::new(pat.syntax()), ty);
492 } else {
493 // TODO self param
494 ctx.type_for
495 .insert(LocalSyntaxPtr::new(pat.syntax()), Ty::Unknown);
496 };
497 }
487 } 498 }
488 499
489 // TODO get Ty for node.ret_type() and pass that to infer_block as expectation 500 // TODO get Ty for node.ret_type() and pass that to infer_block as expectation
490 // (see Expectation in rustc_typeck) 501 // (see Expectation in rustc_typeck)
491 502
492 ctx.infer_block(node.body().unwrap()); 503 if let Some(block) = node.body() {
504 ctx.infer_block(block);
505 }
493 506
494 // TODO 'resolve' the types: replace inference variables by their inferred results 507 // TODO 'resolve' the types: replace inference variables by their inferred results
495 508