aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/ty.rs14
-rw-r--r--crates/ra_hir/src/ty/tests/data/0003_paths.txt4
2 files changed, 13 insertions, 5 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 13ee6cb27..92de9842c 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -211,7 +211,6 @@ impl fmt::Display for Ty {
211} 211}
212 212
213pub fn type_for_fn(db: &impl HirDatabase, f: Function) -> Cancelable<Ty> { 213pub fn type_for_fn(db: &impl HirDatabase, f: Function) -> Cancelable<Ty> {
214 eprintln!("type_for_fn {:?}", f.fn_id);
215 let syntax = f.syntax(db); 214 let syntax = f.syntax(db);
216 let node = syntax.borrowed(); 215 let node = syntax.borrowed();
217 // TODO we ignore type parameters for now 216 // TODO we ignore type parameters for now
@@ -397,7 +396,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
397 Ty::Unknown 396 Ty::Unknown
398 } 397 }
399 ast::Expr::CallExpr(e) => { 398 ast::Expr::CallExpr(e) => {
400 let _callee_ty = if let Some(e) = e.expr() { 399 let callee_ty = if let Some(e) = e.expr() {
401 self.infer_expr(e)? 400 self.infer_expr(e)?
402 } else { 401 } else {
403 Ty::Unknown 402 Ty::Unknown
@@ -408,7 +407,16 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
408 self.infer_expr(arg)?; 407 self.infer_expr(arg)?;
409 } 408 }
410 } 409 }
411 Ty::Unknown 410 match callee_ty {
411 Ty::FnPtr(sig) => {
412 sig.output.clone()
413 }
414 _ => {
415 // not callable
416 // TODO report an error?
417 Ty::Unknown
418 }
419 }
412 } 420 }
413 ast::Expr::MethodCallExpr(e) => { 421 ast::Expr::MethodCallExpr(e) => {
414 let _receiver_ty = if let Some(e) = e.expr() { 422 let _receiver_ty = if let Some(e) = e.expr() {
diff --git a/crates/ra_hir/src/ty/tests/data/0003_paths.txt b/crates/ra_hir/src/ty/tests/data/0003_paths.txt
index 3a53370a2..acde9b7ad 100644
--- a/crates/ra_hir/src/ty/tests/data/0003_paths.txt
+++ b/crates/ra_hir/src/ty/tests/data/0003_paths.txt
@@ -2,8 +2,8 @@
2[14; 19) '{ 1 }': [unknown] 2[14; 19) '{ 1 }': [unknown]
3[47; 52) '{ 1 }': [unknown] 3[47; 52) '{ 1 }': [unknown]
4[49; 50) '1': [unknown] 4[49; 50) '1': [unknown]
5[81; 87) 'b::c()': [unknown] 5[81; 87) 'b::c()': u32
6[66; 90) '{ ...c(); }': () 6[66; 90) '{ ...c(); }': ()
7[72; 73) 'a': fn() -> u32 7[72; 73) 'a': fn() -> u32
8[72; 75) 'a()': [unknown] 8[72; 75) 'a()': u32
9[81; 85) 'b::c': fn() -> u32 9[81; 85) 'b::c': fn() -> u32