I've look around for solutions all over the internet and I can't seem to find a resolve. I have rust-analyzer (v0.3.1533) running in VSCode and it works for files only imported by the main.rs file, everything else is ignored. So this means my /tests directory is completely ignored too. My setup is normal as far as I can tell.
Example of test file where analyzer isn't working:
Try moving tests/unit/hash_sort_tests.rs to tests/hash_sort_tests.rs. It looks like cargo doesn't recurse into subdirectories when discovering integration tests.
it's not rust-analyzer, it is due to the way how cargo automatically discovers targets. rust-analyzer relies on cargo to give the necessary metadata to compile the code correctly. if you run cargo test, you'll find your code is not recognized as part of any integration test.
see integration tests and target auto discovery for details, but the short answer is, you need to manually add [[test]] target in your Cargo.toml manifest file if you stick with non-default directory structures than what is used by cargo auto target discovery.