Is there any way to pass feature flags to rust-analyzer? Right now I have two definitions for the same function that are compiled for different features:
Right now rust-analyzer is only linting the second, and not the first. And that's an issue because the first has...more than a few issues (as cargo check will attest to). So how can I get rust-analyzer to lint the first definition?
I don't know anything specific about the internals of rust-analyzer, but in general feature flags are used at compile time. So if you want to alter something that is controlled by feature flags, you'll need to compile the project yourself. Check its GitHub page for details on how to do that.
There is a rust-analyzer.cargo.features setting where you can specify a list of features.
In VS Code, open the Extensions sidebar, click the gear icon next to the rust-analyzer extension, and choose “Extension Settings.” You can choose whether to customize settings for all projects (the “User” tab) or just the current one (the “Workspace” tab). The setting is labeled “Cargo: Features.”
Other editors will have a different way to pass settings to rust-analyzer.
If @mbrubeck's suggestion of rust-analyzer.cargo.features doesn't work for you, I created an almost identical issue against the rust-analyzer repo today for cases where you are in a workspace.
As an escape hatch, rust-analyzer can scan the output from a VS Code Action running in the background and use that to detect things like compile errors and suggestions. We've just merged an update to the docs showing you how that's done (PR / rendered).