Idea: cargo flag to make it cancellable

Quite often I run manually cargo run etc. only to see it wait on some existing cargo invocation, either from rust-analyzer or cargo watch, etc. Makes me wonder: could we have a flag to make cargo preemptible? E.g. before starting any new crate build it would would check if any other instance is waiting for it and quit with an appropriate error code and message to yield for a more urgent invocation? The tooling that runs cargo "in the background" could just use that flag and retry.

1 Like

I have vim-ale, rust-analyzer (via vim-ale), tarpaulin, etc. each use their own target directory. In addition to avoiding lock contention, it also avoids ping-ponging the build across different configurations (e.g., nightly for clippy, but stable for building).

1 Like

This is an interesting idea. How would one go about that? Do cargo subcommands have a --target DIR option or something like that?

1 Like