This error occurs when an if expression without an else block is used in a context where a type other than () is expected, for example a let expression:
fn main() { let x = 5; let a = if x == 5 { 1 }; }
An if expression without an else block has the type (), so this is a type error. To resolve it, add an else block having the same type as the if block.