mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Missing return type means unit, not unknown
This commit is contained in:
parent
cfa1de72eb
commit
b1590bdf6a
@ -381,7 +381,11 @@ pub fn type_for_fn(db: &impl HirDatabase, f: Function) -> Cancelable<Ty> {
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_else(|| Ok(Vec::new()))?;
|
||||
let output = Ty::from_ast_opt(db, &module, node.ret_type().and_then(|rt| rt.type_ref()))?;
|
||||
let output = if let Some(type_ref) = node.ret_type().and_then(|rt| rt.type_ref()) {
|
||||
Ty::from_ast(db, &module, type_ref)?
|
||||
} else {
|
||||
Ty::unit()
|
||||
};
|
||||
let sig = FnSig { input, output };
|
||||
Ok(Ty::FnPtr(Arc::new(sig)))
|
||||
}
|
||||
|
@ -11,10 +11,10 @@
|
||||
[92; 110) 'unknow...tion()': u32
|
||||
[142; 160) 'unknow...tion()': i32
|
||||
[92; 108) 'unknow...nction': [unknown]
|
||||
[116; 128) 'takes_u32(a)': [unknown]
|
||||
[116; 128) 'takes_u32(a)': ()
|
||||
[78; 231) '{ ...t &c }': &mut &f64
|
||||
[227; 229) '&c': &f64
|
||||
[88; 89) 'a': u32
|
||||
[181; 182) 'b': i32
|
||||
[116; 125) 'takes_u32': fn(u32,) -> [unknown]
|
||||
[116; 125) 'takes_u32': fn(u32,) -> ()
|
||||
[138; 139) 'b': i32
|
||||
|
Loading…
Reference in New Issue
Block a user