-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make cargo.features
a crate-level config
#18114
Comments
@vaqxai I cannot reproduce any errors when I use |
I will try to give you a minimal example soon. Please note that I have experienced this error in VSCode and in Vim (both running rust-analyzer themselves), i haven't done a check without an IDE/Editor. |
I think this error will manifest specifically when the workspace uses |
I have compiled a reproducible repo, the full command that is being ran/error returned (by vscode?) is:
Edit: It seems that VSCode runs Edit no. 2: It seems sometime between my original issue and now there was a feature added that allows per folder Edit no. 3: My bad, that setting is just ignored and I get |
So after some thorough investigation I can finally say a few things about this. First things first : I believe #18197 has resolved resolved this issue in some ways : Your This is where things get more interesting : Comically if you use VSCode's It would be good to know the intention with setting Finally, your repro is flawed in that you don't have proper workspace, due to which cargo metadata's manifest path points to I am sorry if this is not the answer you were expecting. I would be happy to help if you can provide more context. 👋 |
Not sure if I omitted an update somewhere, AFAIK I'm using the latest nightly for everything, but it still won't work for me (i.e. nothing really changes, all cargo commands and VSC/VIM/ZED still act as if the feat was disabled)
It actually does, wow. That's very interesting. {
"lsp": {
"rust-analyzer": {
"initialization_options": {
"cargo": {
"features": ["feat1"]
}
}
}
}
} Works fine, ig zed runs RA per-folder/project
Primarily, I want syntax highlighting, diagnostics, inlay hints and all other LSP features to work correctly, considering the feature tags I have currently enabled/disabled. The error I was getting earlier (with the metadata command) "crashes" RA for a given folder and makes it not generate/show any LSP things at all.
Yeah, that's the point, actually, I was trying to be able to attach many ad-hoc random directories to a vscode window / vim window / zed window and not create any actual cargo workspaces. Perhaps my usage of the word "workspace" is what threw it off. I basically wanted for RA to only consider crate-level feature toggles, treating them all as separate things. But, with the changes you consider for RA itself (i.e. to have a crate-level P.S.Currently, a good-enough, for-the-time-being solution would be to just have RA/cargo ignore the feature for a crate if it doesn't exist. So instead of having the error "features could not be enabled because they could not be found" it could be just a soft warning "features which do not exist have been requested, ignoring" and just run the rest of the command like nothing happened. Then I could enable as many features as I want (even in my global, "User" settings), and unless I have two crates with features named the same way, of which I only intended to enable one (which is an odd case even for me), there would be no problem. Could this be something we'd need to suggest to the cargo people (as the error I think originates in cargo-metadata and not rust-analyzer?) |
Originally posted by @vaqxai in #13529 (comment)
What the title indicates is just a way to resolve this issue although making such a change is not wanted. This issue is just to discuss and shed a light on what we can do
The text was updated successfully, but these errors were encountered: