Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab completion for --target uses rustup but fallsback to rustc #12606

Merged
merged 2 commits into from
Aug 31, 2023
Merged

Tab completion for --target uses rustup but fallsback to rustc #12606

merged 2 commits into from
Aug 31, 2023

Conversation

Angelin01
Copy link
Contributor

What does this PR try to resolve?

Fixes #12585

Currently, not only is the tab completion for --target inconsistent between bash and zsh, it depends on rustup and rustc respectively.
As discussed in the issue at hand, we'll use rustup if it is available and fallback to rustc if it is not, even if it is unfriendly.

How should we test and review this PR?

Source the respective completion functions and test it out with cargo build --target [TAB].

I would appreciate if someone that regularly uses zsh would test this. I did basic testing, but since I don't use zsh commonly I am unsure if everything is as it should be.

Additional information

I switched to using rustup target list --installed instead of grabbing lines that contain "default" or "installed". I believe that any "default" target should be installed too, right?

@rustbot
Copy link
Collaborator

rustbot commented Aug 31, 2023

r? @weihanglo

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-completions Area: shell completions S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 31, 2023
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me!


To whom wants to test the change, simply run:

zsh

fpath+=$PWD/src/etc
autoload -Uz compinit
compinit

cargo b --target <tab>

bash

. ./src/etc/cargo.bashcomp.sh

cargo b --target <tab>

fi
done <<< "$targets"
echo "${result[@]}"
if command -v rustup >/dev/null; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit better? Though I don't thinkg command -v would output anything to stderr.

Suggested change
if command -v rustup >/dev/null; then
if command -v rustup 2>&1 /dev/null; then

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried really hard to make it output anything:

> command -v
> command -v blablabla
> command -v /dev/zero
> command -v ..
> command -v ../../../..
> command -v 0
> command -v x
> command -v \`
> command -v \\
> command -v 😊
> 

It really seems like it never outputs to stdout. BUT, I don't trust that bash may not decide to add some output, so I redirected it as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command -v 😊

Nice try 😆.

@weihanglo
Copy link
Member

Tested both with and without rustup in bash and zsh. Everything goes well on my side.

Thank you for the contribution :)

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 31, 2023

📌 Commit b5c97d4 has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 31, 2023
@bors
Copy link
Collaborator

bors commented Aug 31, 2023

⌛ Testing commit b5c97d4 with merge 11966a4...

@bors
Copy link
Collaborator

bors commented Aug 31, 2023

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 11966a4 to master...

@bors bors merged commit 11966a4 into rust-lang:master Aug 31, 2023
19 checks passed
@Angelin01 Angelin01 deleted the tab-completion-rustup-fallback-rustc branch August 31, 2023 13:59
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 6, 2023
Update cargo

21 commits in 96fe1c9e1aecd8f57063e3753969bb6418fd2fd5..d14c85f4e6e7671673b1a1bc87231ff7164761e1
2023-08-29 20:10:34 +0000 to 2023-09-05 22:28:10 +0000
- fix(resolver): Make resolver behavior independent of package order (rust-lang/cargo#12602)
- cargo-credential: change serialization of cache expiration (rust-lang/cargo#12622)
- Update registry-web-api.md yank/unyank comments (rust-lang/cargo#12619)
- test: new options of debuginfo are no longer unstable (rust-lang/cargo#12618)
- use split_once for cleaner code (rust-lang/cargo#12615)
- stop using lazy_static (rust-lang/cargo#12616)
- doc: adjust all doc headings one level up (rust-lang/cargo#12595)
- chore(deps): update compatible (rust-lang/cargo#12609)
- chore(deps): update rust crate cargo_metadata to 0.17.0 (rust-lang/cargo#12610)
- Prepare for partial-version package specs (rust-lang/cargo#12591)
- refactor: Use more serde_untagged (rust-lang/cargo#12581)
- fix(cli): Help users know possible `--target` values (rust-lang/cargo#12607)
- Tab completion for --target uses rustup but fallsback to rustc (rust-lang/cargo#12606)
- Fewer temporary needless strings (rust-lang/cargo#12604)
- fix(help): Provide better commands heading for styling (rust-lang/cargo#12593)
- fix(update): Clarify meaning of --aggressive as --recursive (rust-lang/cargo#12544)
- docs(changelog): Clarify language for Cargo.lock policy (rust-lang/cargo#12601)
- fix typo: "default branch branch" -&gt; "default branch" (rust-lang/cargo#12598)
- fix: add error for unsupported credential provider version (rust-lang/cargo#12590)
- fix(help): Explain --explain (rust-lang/cargo#12592)
- fix(help): Remove redundant information from new/init (rust-lang/cargo#12594)

r? ghost
@ehuss ehuss added this to the 1.74.0 milestone Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completions Area: shell completions S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Target tab completion invokes rustup
5 participants