diff options
-rw-r--r-- | crates/ra_hir/src/ty.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests/data/0006_backwards.txt | 4 |
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 |