How to tell Rust Analyzer about target-features

Hello,

I'm using Rust Analyzer under VS Code. I know you can set which features to enable in RA's analysis by going under the settings and either enabling specific features or enabling all features. However, I haven't been able to find a way to do the same for -C target-features (e.g. -C target-feature=+aes for the ahash crate when compiling for x86_64). Is this a known limitation or is it available in some hidden corner I wasn't able to find?

Thanks!

You can use rust-analyzer.server.extraEnv to set RUSTFLAGS like you would when using cargo. AFAIK rust-analyzer should pick it up.

2 Likes

Awesome, that worked like a charm. For future reference to anyone reading this:

    "rust-analyzer.server.extraEnv": {
        "RUSTFLAGS": "-Ctarget-feature=+aes"
    },

That did the trick for me.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.