It seems to be a glitch. The Rust-analyzer LSP is able to infer what the type is supposed to be, but for whatever reason the compiler can’t.
From what I can tell, this code doesn’t compile on any version of Rust, and cannot be automatically fixed with cargo fix
.
Interestingly, the compiler does seem to work on this equivalent code:
bar(|x| x ^ true);