diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index 6afcc2c51f8a..b61a968af14a 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -855,10 +855,14 @@ pub(crate) fn handle_runnables( let config = snap.config.runnables(); match cargo_spec { Some(spec) => { - let all_targets = !snap.analysis.is_crate_no_std(spec.crate_id)?; - for cmd in ["check", "test"] { + let is_crate_no_std = snap.analysis.is_crate_no_std(spec.crate_id)?; + for cmd in ["check", "run", "test"] { + if cmd == "run" && spec.target_kind != TargetKind::Bin { + continue; + } let mut cargo_args = vec![cmd.to_owned(), "--package".to_owned(), spec.package.clone()]; + let all_targets = cmd != "run" && !is_crate_no_std; if all_targets { cargo_args.push("--all-targets".to_owned()); }