This seems to be a bug in the compiler. You can make the compiler happy by using an explicit return
statement:
use std::io::{stdin, BufRead};
fn foo() -> usize {
let stdin = stdin();
let stdinlock = stdin.lock();
return stdinlock
.lines()
.count();
}
fn main() {}
As mentioned in the comments, there are multiple Rust issues related to this: