Skip to content

Commit 397a180

Browse files
committed
fix(complete): Fallback to rustc if rustup fails for --target completions
If there is any problem with rustup, we should fallback to rustc. (this also removes some extra allocations)
1 parent 9d5c149 commit 397a180

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cargo/util/command_prelude.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,13 @@ fn get_target_triples() -> Vec<clap_complete::CompletionCandidate> {
11231123

11241124
if is_rustup() {
11251125
if let Ok(targets) = get_target_triples_from_rustup() {
1126-
candidates.extend(targets);
1126+
candidates = targets;
11271127
}
1128-
} else {
1128+
}
1129+
1130+
if candidates.is_empty() {
11291131
if let Ok(targets) = get_target_triples_from_rustc() {
1130-
candidates.extend(targets);
1132+
candidates = targets;
11311133
}
11321134
}
11331135

0 commit comments

Comments
 (0)