mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Make cargo run
always available for binaries
Previously, items for `cargo test` and `cargo check` would appear as in the `Select Runnable` quick pick that appears when running `rust-analyzer: Run`, but `run` would only appear as a runnable if a `main`` function was selected in the editor. This change adds `cargo run` as an always available runnable command for binary packages. This makes it easier to develop cli / tui applications, as now users can run application from anywhere in their codebase.
This commit is contained in:
parent
ab10eea62e
commit
032fca9572
1 changed files with 5 additions and 2 deletions
|
@ -836,10 +836,13 @@ pub(crate) fn handle_runnables(
|
||||||
let config = snap.config.runnables();
|
let config = snap.config.runnables();
|
||||||
match cargo_spec {
|
match cargo_spec {
|
||||||
Some(spec) => {
|
Some(spec) => {
|
||||||
let all_targets = !snap.analysis.is_crate_no_std(spec.crate_id)?;
|
for cmd in ["check", "run", "test"] {
|
||||||
for cmd in ["check", "test"] {
|
if cmd == "run" && spec.target_kind != TargetKind::Bin {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let mut cargo_args =
|
let mut cargo_args =
|
||||||
vec![cmd.to_owned(), "--package".to_owned(), spec.package.clone()];
|
vec![cmd.to_owned(), "--package".to_owned(), spec.package.clone()];
|
||||||
|
let all_targets = cmd != "run" && !snap.analysis.is_crate_no_std(spec.crate_id)?;
|
||||||
if all_targets {
|
if all_targets {
|
||||||
cargo_args.push("--all-targets".to_owned());
|
cargo_args.push("--all-targets".to_owned());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue