User `rust-analyzer.toml` applies workspace settings but reports them as unexpected fields
Workspace-level settings in the user config (<config dir>/rust-analyzer/rust-analyzer.toml) are applied, and also reported as invalid. The reader and the validator disagree about whether workspace settings belong in that file. Which one is intended?
Repro
User config:
check.overrideCommand = ["my-cargo-wrapper", "check", "--workspace", "--message-format=json"]The server reports:
invalid config value:
check/overrideCommand: unexpected field
;and flycheck then spawns my-cargo-wrapper. Seen on the 2026-09-15 release build (0.4.3051-standalone, fa88768e77) in VS Code and Zed, on Windows, Linux and macOS.
What the code does
All in crates/rust-analyzer/src/config.rs:
GlobalWorkspaceLocalConfigInputhas aworkspacemember, and itsfrom_tomldeserializesWorkspaceConfigInput.- The generated workspace getters fall back to
user_config.workspaceafter the project files and the client config. GlobalWorkspaceLocalConfigInput::FIELDSlists onlyGlobalConfigInput::FIELDSandLocalConfigInput::FIELDS, sovalidate_toml_tableflags every workspace key asunexpected field.
All three come from 94ed6217dd, which renamed GlobalLocalConfigInput, added the workspace level, and left this list alone.
Earlier attempts
Adding WorkspaceConfigInput::FIELDS to that list is a one-line change. @my1e5 sent it as #23381 (reported downstream in jdx/mr-boxington#471). On #23381, @ChayimFriedman2 replied:
I know, and it shouldn't be there, because it's not global. If there is a bug caused by a different treatment to
WorkspaceLocalConfigInput::FIELDS, then that's what we need to fix.
I don't see another code path with a different treatment to fix, and WorkspaceLocalConfigInput is live, so I may be misreading the suggestion. It validates a rust-analyzer.toml at the workspace root against WorkspaceLocalConfigInput::FIELDS, which includes the workspace fields. The only file with the mismatch is the user config: it is validated against global and local fields only, yet its workspace fields are read and applied. If workspace settings don't belong in the user config, the user_config.workspace fallback is what's wrong. If they do, GlobalWorkspaceLocalConfigInput::FIELDS is.
Why removing the fallback isn't a drop-in fix
reload_flycheck resolves its config with self.config.flycheck(None) (reload.rs). With no source root, the lookup skips every project rust-analyzer.toml. A check.overrideCommand beside Cargo.toml passes validation and never runs. Today the user config is the only TOML location where it works, and the only other place is the client's own settings (settings.json and the like).
Question
Which is intended?
- Workspace settings are valid in the user config. Then validation should accept them, which is the
FIELDSchange. - They aren't. Then the
user_config.workspacefallback should go, andcheck.*should be read from the project file. That meansflycheckneeds a source root, or per-workspace flycheck configs.
I'm happy to send a PR for either. Downstream, mr-boxington writes this setting to the user config and currently tells users the warning is harmless (jdx/mr-boxington#572, #573). Option 2 would need a different setup path on our side.
AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: claude-code_2-1-284_agent.
Source: rust-lang/rust-analyzer