VSCode editor with rust analyzer and conditional compilation

The rust analyzer has a wonderful feature for the VSCode editor when using conditional compilation; it shows code that won't be included in the compilation fainter than code that will be included.

I'd like to change the features so that different blocks of code are fainter, but I can't figure out what to change. I tried changing rust-analyzer.cargo.features in my settings.json, but that resulted in no code being fainter. I assume that's because the change conflicts with another setting.

My current rust analyzer settings are

    "rust-analyzer.cargo.features": ["bar"],
    "rust.actionOnSave": "check",
    "rust-analyzer.checkOnSave.command": "cargo check",
    "rust-analyzer.checkOnSave.features": ["bar"],
    "rust-analyzer.checkOnSave.enable": true,
    "rust-analyzer.checkOnSave.allTargets": false,
    "rust-analyzer.checkOnSave.target": "foo",
    "rust-analyzer.checkOnSave.overrideCommand": [
        "cargo","check", 
        "--bin", "foo", 
        "--features", "bar",
        "--message-format=json"
    ],

I'd like the editor to show me the code when features=qux.

1 Like