Change VSCode save on build command

I'm having a problem with the "build on save" feature in VSCode. (At least I think that's the feature.) When I save a source file, the OUTPUT window says

Running "cargo rustc -- -Zno-trans"

That command fails with

error: the option `Z` is only accepted on the nightly compiler

I have been unable to find where that command is set so that I can change it.

Actually, I would prefer to do "check on save," but I can't get that to work even with

"rust.checkOnSave": true

in my settings.json.

are you using rust analyzer? check out the rust-analyzer.CheckOnSave.Command

I am using the rust-analyzer. Searching Settings for rust-analyzer.checkOnSave gives

Rust-analyzer › Check On Save: All Features
Check with all features (will be passed as --all-features). Defaults to rust-analyzer.cargo.allFeatures.

Rust-analyzer › Check On Save: All Targets
Check all targets and tests (will be passed as --all-targets)

Rust-analyzer › Check On Save: Command
Cargo command to use for cargo check
check

Rust-analyzer › Check On Save: Enable
Run specified cargo check command for diagnostics on save

Rust-analyzer › Check On Save: Extra Args
Extra arguments for cargo check

Rust-analyzer › Check On Save: Features
List of features to activate. Defaults to `rust-analyzer.cargo.features`.
Rust-analyzer › Check On Save: No Default Features
Do not activate the default feature

Rust-analyzer › Check On Save: Override Command
Advanced option, fully override the command rust-analyzer uses for checking. The command should include --message-format=json or similar option.

The box under All Targets is not checked. The items in my settings.json that refer to the rust-analyzer are

    "rust-analyzer.cargo.allFeatures": true,
    "rust-analyzer.checkOnSave.allTargets": false,

Well I'm not sure. I have a CheckOnSave.Command which I set to clippy, which means it runs cargo clippy on save. Maybe try with the Settings Screen without fiddling with the json?

No luck. Is there any way I can search for the "-Zno-trans" string?

well if it's not showing up when searching the json file I'm not sure where it's coming from.
Have you checked your workspace settings?

as for rust analyzer
do you not see these options?

My Settings show the exact entries you have in the figure.

That's very strange, seems like something is running alongside the regular check on save.

Well, at least I don't feel like an idiot who couldn't see something obvious.

Do you have the old cargo-check custom command installed, from before check became a built-in command? Try running this command to uninstall it:

cargo uninstall cargo-check

Or maybe you have some other Rust-related editor plug-in that similarly pre-dates cargo check.

A good try, but no ceegar.

cargo uninstall cargo-check
error: package ID specification `cargo-check` matched no packages

I've been using Rust for a long time, so it's possible that I have some old stuff lying around. I just don't know how to find it. If it helps, here's what's in my ~/.cargo/bin.

ls ~/.cargo/bin
cargo			clippy-driver		rustc
cargo-audit		evcxr			rustdoc
cargo-clippy		grcov			rustfmt
cargo-fmt		parse_describe		rustfmt-old
cargo-fmt-old		racer			rustsym
cargo-instruments	rls			rustup
cargo-miri		rust-gdb
cargo-profiler		rust-lldb

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.