aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2018-12-29 11:08:57 +0000
committerFlorian Diebold <[email protected]>2018-12-29 11:08:57 +0000
commitb1590bdf6a88c03e2aeeedbe04f4dbc4203073db (patch)
treeea6733ad05e79e93912924cc3725ab3fe96c83b3
parentcfa1de72ebb7060a82dbf7a67432047d9ea2288a (diff)
Missing return type means unit, not unknown
-rw-r--r--crates/ra_hir/src/ty.rs6
-rw-r--r--crates/ra_hir/src/ty/tests/data/0006_backwards.txt4
2 files changed, 7 insertions, 3 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 0592e4a63..4ebd44d27 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -381,7 +381,11 @@ pub fn type_for_fn(db: &impl HirDatabase, f: Function) -> Cancelable<Ty> {
381 .collect() 381 .collect()
382 }) 382 })
383 .unwrap_or_else(|| Ok(Vec::new()))?; 383 .unwrap_or_else(|| Ok(Vec::new()))?;
384 let output = Ty::from_ast_opt(db, &module, node.ret_type().and_then(|rt| rt.type_ref()))?; 384 let output = if let Some(type_ref) = node.ret_type().and_then(|rt| rt.type_ref()) {
385 Ty::from_ast(db, &module, type_ref)?
386 } else {
387 Ty::unit()
388 };
385 let sig = FnSig { input, output }; 389 let sig = FnSig { input, output };
386 Ok(Ty::FnPtr(Arc::new(sig))) 390 Ok(Ty::FnPtr(Arc::new(sig)))
387} 391}
diff --git a/crates/ra_hir/src/ty/tests/data/0006_backwards.txt b/crates/ra_hir/src/ty/tests/data/0006_backwards.txt
index 3a12aeef4..120069401 100644
--- a/crates/ra_hir/src/ty/tests/data/0006_backwards.txt
+++ b/crates/ra_hir/src/ty/tests/data/0006_backwards.txt
@@ -11,10 +11,10 @@
11[92; 110) 'unknow...tion()': u32 11[92; 110) 'unknow...tion()': u32
12[142; 160) 'unknow...tion()': i32 12[142; 160) 'unknow...tion()': i32
13[92; 108) 'unknow...nction': [unknown] 13[92; 108) 'unknow...nction': [unknown]
14[116; 128) 'takes_u32(a)': [unknown] 14[116; 128) 'takes_u32(a)': ()
15[78; 231) '{ ...t &c }': &mut &f64 15[78; 231) '{ ...t &c }': &mut &f64
16[227; 229) '&c': &f64 16[227; 229) '&c': &f64
17[88; 89) 'a': u32 17[88; 89) 'a': u32
18[181; 182) 'b': i32 18[181; 182) 'b': i32
19[116; 125) 'takes_u32': fn(u32,) -> [unknown] 19[116; 125) 'takes_u32': fn(u32,) -> ()
20[138; 139) 'b': i32 20[138; 139) 'b': i32