-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Rust-analyzer does not function with non-root Cargo.toml #1798
Comments
One of the ways that I can think of how to resolve this is to use |
Is there a way to point rust analyzer to the Cargo.toml file(s) of interest? I've got a C++/CMake project with some Rust parts which are built with Cargo (invoked by CMake). Currently rust analyzer doesn't work when I load the entire source tree. It seems to assume the entire project is written in Rust. |
I am unlikely to have time to look into this in the nearest future, but I can leave a couple of pointers to the code where this should be handled:
I think we need some kind of |
@matklad Thanks for pointing out the code of interest. If I can find a bit of time I may attempt to implement your |
Might it be worth considering what In my case, I have a workspace with multiple rust projects, and although I get the correct code completions in each project, I don't get any warnings/errors being raised. |
I'd just like to note that, with the RFC up now to transition RA to be the official Rust LSP, this issue is the single blocking issue for me and all of my coworkers looking to make the switch. It unfortunately makes RA completely unusable in all of our projects so we can't even begin to consider the transition to help with reporting issues until this is fixed. |
cc #2649 |
This is now possible by using an explicit config. Doing dynamic auto-discovery is on the TODO list, and should be implemented soon: |
Any news about the dynamic auto-discovery? |
static config seem to work great so far, so there are no longer immediate plans for doing auto-discovery. As usual, PRs are welcome, but this is a challenging task. A nice intermediate goal would be to show a warning if a project is not configured propelly, with an auto-fix which sets up workspace config. |
Most of the code in the vscode extension seems to assume that the cargo.toml is located in the workspace root. And that there is one cargo.toml (or project) available.
Currently, when you try to use rust-analyzer with a cargo.toml not in the root the following error message get's shown
[ra_lsp_server::main_loop] loading workspace failed: can't find Cargo.toml
The text was updated successfully, but these errors were encountered: