Use clap dynamic parsing to fix toolchain completion - #5033
Open
Cloud0310 wants to merge 1 commit into
Open
Conversation
rami3l
reviewed
Aug 24, 2026
rami3l
reviewed
Aug 24, 2026
Cloud0310
force-pushed
the
clap-completion
branch
from
August 24, 2026 15:25
90d4fe8 to
30aaa6f
Compare
rami3l
reviewed
Aug 24, 2026
| } | ||
| } | ||
|
|
||
| pub fn completion_command(process: Process) -> clap::Command { |
Member
There was a problem hiding this comment.
Question: What is the expected ownership model here? I have the feeling that repeatedly cloning Process is definitely not the best solution here. Also, move this below the new caller in https://github.com/rust-lang/rustup/pull/5033/changes#r3844899779.
rami3l
reviewed
Aug 24, 2026
Cloud0310
force-pushed
the
clap-completion
branch
from
August 24, 2026 15:30
30aaa6f to
d5093d4
Compare
rami3l
reviewed
Aug 24, 2026
| let Some(toolchains) = process | ||
| .current_dir() | ||
| .ok() | ||
| .and_then(|current_dir| Cfg::from_env(current_dir, true, false, &process).ok()) |
Member
There was a problem hiding this comment.
It looks like this callback should rely on an existing Cfg and use its .process, instead of creating a new Cfg from an existing process.
rami3l
reviewed
Aug 24, 2026
Comment on lines
+1970
to
+1975
| for expected in ["list", "add", "remove"] { | ||
| assert!(candidates.iter().any(|candidate| candidate == expected)); | ||
| } | ||
| for root_only in ["install", "toolchain", "show"] { | ||
| assert!(!candidates.iter().any(|candidate| candidate == root_only)); | ||
| } |
Member
There was a problem hiding this comment.
Use HashSet<> operations with appropriate error messages for better readability.
Cloud0310
force-pushed
the
clap-completion
branch
from
August 25, 2026 06:04
d5093d4 to
ff1b38d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2268.
Verified manually (see #5033 (comment)).