Hey folks, hope you are doing fine. I was working on some rust-lang code in vim with ale+rust-analyzer enabled and found out that the use of the syntax if let ... {} else let ... {} instead of if let ... {} else if let ... {}, leads to the analyzer telling me:
[rustc E0601] [E] `main` function not found in crate `client` consider adding a `main` function to `src/client.rs`
Attaching screenshot of code that triggered error message and once it was corrected. I am not sure if the issue was a result of my config, if this is in fact an issue with the analyzer, I would like to learn more about how to fix it and try contributing myself
Since else let isn't valid Rust syntax, it causes the tokio::main macro to fail and not output anything (not 100% on the details here), meaning it essentially removes the main function and so you get this error message. If you run cargo check you should get both the "missing fn main" error as well as an error for the else let. I don't use vim but it is often the case in vscode that I need to look at the output of cargo check to determine to root of some issue because rust-analyzer only shows one of multiple related errors, like here.
When there are issues in a function annotated with a macro such as #[tokio::main], the compiler will be bad at giving good error messages. It is often helpful to temporarily remove the macro and look at which errors you get then.