Description
Problem: when opening a project with unusual struture (Cargo.toml buried deep in the source tree) rust-analyzer doesn't work, without a clear error message.
At the moment, when opening the project, we to detect rust project structure we either use likedProjects
config, or, if that is absent, look for Cargo.tomls in level one subdirs. So, we fail to discover deeply nested projects.
Soln1: travers all folders, and not only the top level. This is a bad idea, as this is an unbounded amount of work.
Soln2: lazily load Cargo.projects. That is, when a user opens an .rs file which does not belong to any known project, traverse the directory upwards looking for Cargo.toml. This seems like a best solution UX wise on the first glance. There's a big problem though -- non-determinism. If there are two projects, A and B, and A uses B, then opening B first and invoking find useages won't find usages in A, because we don't know about A yet!
Soln3, what we should do: start like soln2, but, instead of magically loading the file, show a popup "add this file to a list of linked projects?". That way, discovery results are persistent, and user always gets the same workspace.