Skip to content

Commit ed48f5f

Browse files
committed
feat: Remove test-enabled and make the reviewed changes
1 parent 051cf6b commit ed48f5f

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,50 +1111,53 @@ pub fn get_registry_candidates() -> CargoResult<Vec<clap_complete::CompletionCan
11111111
}
11121112

11131113
fn get_profile_candidates() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {
1114+
match get_workspace_profile_candidates() {
1115+
Ok(candidates) if !candidates.is_empty() => Ok(candidates),
1116+
// fallback to default profile candidates
1117+
_ => Ok(default_profile_candidates()),
1118+
}
1119+
}
1120+
1121+
fn get_workspace_profile_candidates() -> CargoResult<Vec<clap_complete::CompletionCandidate>> {
11141122
let gctx = new_gctx_for_completions()?;
1115-
if let Ok(ws) = Workspace::new(&find_root_manifest_for_wd(gctx.cwd())?, &gctx) {
1116-
if let Ok(profiles) = Profiles::new(&ws, InternedString::new("dev")) {
1117-
let mut candidates = Vec::new();
1118-
1119-
for name in profiles.profile_names() {
1120-
if let Ok(profile_instance) = Profiles::new(&ws, name) {
1121-
let base_profile = profile_instance.base_profile();
1122-
1123-
let mut description = String::from(if base_profile.opt_level.as_str() == "0" {
1124-
"unoptimized"
1125-
} else {
1126-
"optimized"
1127-
});
1128-
1129-
if base_profile.debuginfo.is_turned_on() {
1130-
description.push_str(" + debuginfo");
1131-
}
1123+
let ws = Workspace::new(&find_root_manifest_for_wd(gctx.cwd())?, &gctx)?;
1124+
let profiles = Profiles::new(&ws, InternedString::new("dev"))?;
11321125

1133-
if matches!(name.as_str(), "test" | "bench") {
1134-
description.push_str(" with tests enabled");
1135-
}
1126+
let mut candidates = Vec::new();
1127+
for name in profiles.profile_names() {
1128+
if let Ok(profile_instance) = Profiles::new(&ws, name) {
1129+
let base_profile = profile_instance.base_profile();
11361130

1137-
candidates.push(
1138-
clap_complete::CompletionCandidate::new(name.to_string())
1139-
.help(Some(description.into())),
1140-
);
1141-
}
1131+
let mut description = String::from(if base_profile.opt_level.as_str() == "0" {
1132+
"unoptimized"
1133+
} else {
1134+
"optimized"
1135+
});
1136+
1137+
if base_profile.debuginfo.is_turned_on() {
1138+
description.push_str(" + debuginfo");
11421139
}
11431140

1144-
return Ok(candidates);
1141+
candidates.push(
1142+
clap_complete::CompletionCandidate::new(name.to_string())
1143+
.help(Some(description.into())),
1144+
);
11451145
}
11461146
}
11471147

1148-
Ok(vec![
1148+
Ok(candidates)
1149+
}
1150+
1151+
fn default_profile_candidates() -> Vec<clap_complete::CompletionCandidate> {
1152+
vec![
11491153
clap_complete::CompletionCandidate::new("dev".to_string())
11501154
.help(Some("unoptimized + debuginfo".into())),
11511155
clap_complete::CompletionCandidate::new("release".to_string())
11521156
.help(Some("optimized".into())),
11531157
clap_complete::CompletionCandidate::new("test".to_string())
1154-
.help(Some("unoptimized + debuginfo with tests enabled".into())),
1155-
clap_complete::CompletionCandidate::new("bench".to_string())
1156-
.help(Some("optimized with tests enabled".into())),
1157-
])
1158+
.help(Some("unoptimized + debuginfo".into())),
1159+
clap_complete::CompletionCandidate::new("bench".to_string()).help(Some("optimized".into())),
1160+
]
11581161
}
11591162

11601163
fn get_example_candidates() -> Vec<clap_complete::CompletionCandidate> {

0 commit comments

Comments
 (0)