18547 Commits

Author SHA1 Message Date
bors
d7bffc302e Auto merge of #14280 - Flowrey:dry-run-install, r=weihanglo
Add a `--dry-run` flag to the `install` command

### What does this PR try to resolve?

This PR add the `--dry-run` flag to the `cargo install` command (see #11123).
I've tried to do the bare minimal for this flag to work without changing anything in the output.

In my opinion, the `--dry-run` flag should mimic as close as possible the behavior of the normal command to avoid missing potential issue in the normal execution. ~~Currently we're missing information about where the binary will be installed.~~

Unlike #13598 this PR:
- Include as much of the compilation process as possible without actually compiling
- use the information provided by `BuildContext` instead of `InstallablePackage::new`
- in the same way as `unit_graph`, it add a `dry_run` to the `CompileOptions` and return a `Compilation::new` from the function `compile_ws` without actually compiling.
- keeps the output the same rather than adding  status messages indicating which very broad actions would be performed
- ~~remove some warning not relevant in the case of  a `--dry-run`~~

Like #13598, the version check and crate downloads still occur.

### How should we test and review this PR?

The first commit include a unit tests to ensure that no binary is actually installed after the dry run.
There is also a snapshot test that show the diff output of the `--help` flag.

### Additional information

Tests and documentation done in #13598, may be cherry picked into this PR if needed.
2024-09-21 00:35:19 +00:00
bors
6469a3e863 Auto merge of #14568 - epage:message, r=weihanglo
fix(resolve): Don't list transitive, incompatible dependencies as available

### What does this PR try to resolve?

We have limited capability to clearly communicate to the user the different update states without overwhelming them.
Before we showed all versions that were behind, with color distinguishing how actionable they are.
Color doesn't communicate enough though and we don't want to add footnotes to clarify everything.
For now, the least useful messages will be removed, available, transitive, incompatible versions.  These only give the user a hint of tech debt within their dependencies and can't be acted upon.

This is part of #13908

### How should we test and review this PR?

### Additional information
2024-09-21 00:05:22 +00:00
Flowrey
b0e08fcd32 feat: add --dry-run to install command 2024-09-21 01:10:19 +02:00
Ed Page
874a8a04bf refactor(compile): Extract test collection 2024-09-21 01:07:06 +02:00
Flowrey
8424b5f3f4 test: add test for install without dry-run option 2024-09-21 01:07:06 +02:00
bors
e0dfa38e0a Auto merge of #14573 - epage:complete, r=weihanglo
feat(complete): Upgrade clap_complete

Changes:
- Change completion order to subcommands, positional values, flags
- When completing `-[TAB]`, prioritize shorts over longs
- De-duplicate completions that have the same result (longs, shorts, aliases)
- Group candidates from the same `CompletionCandidate::tag`
- Sort candidates within a `CompletionCandidate::tag` by their `display_order`
2024-09-20 20:24:52 +00:00
Ed Page
86a1ff300d feat(complete): Upgrade clap_complete
Changes:
- Change completion order to subcommands, positional values, flags
- When completing `-[TAB]`, prioritize shorts over longs
- De-duplicate completions that have the same result (longs, shorts, aliases)
- Group candidates from the same `CompletionCandidate::tag`
- Sort candidates within a `CompletionCandidate::tag` by their `display_order`
2024-09-20 15:07:46 -05:00
bors
eaee77dc15 Auto merge of #14564 - epage:rustup, r=weihanglo
fix(complete): Harden `--target` completions

### What does this PR try to resolve?

I found `--target` wasn't working with rustup as I expected, so this fixes it.  We generally only reference rustup if we are running under it but I think in UX code like this, with a fallback scheme, this should be reasonable enough.

### How should we test and review this PR?

### Additional information
2024-09-19 21:10:23 +00:00
Ed Page
fd743dacdc fix(resolve): Don't list transitive, incompatible dependencies as available
This is part of #13908
2024-09-19 11:42:33 -05:00
bors
9d5c1497f6 Auto merge of #14567 - Urgau:check-cfg-cleanup-lints, r=epage
Cleanup duplicated check-cfg lint logic

### What does this PR try to resolve?

This PR clean-ups some duplication left by https://github.com/rust-lang/cargo/pull/13958, because of Cargo MSRV.

Fixes https://github.com/rust-lang/cargo/issues/13975

### How should we test and review this PR?

The tests in `tests/testsuite/check_cfg.rs` show no change in behaviours (except for the better error messages). I suggest maybe reviewing commit by commit.
2024-09-19 15:46:28 +00:00
Urgau
3058f50f71 Make check_cfg_args fn not-fallible anymore 2024-09-19 15:55:22 +02:00
Urgau
4c38aeed80 Cleanup duplicated check-cfg lints logic 2024-09-19 15:52:49 +02:00
bors
f1d350055a Auto merge of #14562 - epage:revert, r=weihanglo
Revert "remove reference to incomplete crates.io feature from docs"

This reverts commit 1735917adc11aaa14011a187baf47a320f1c5bc5.

As discussed in #13660, my stance on removing the docs was if there wasn't a path forward.
There is work progressing on the docs.rs side which will unblock the crates.io side.

If the concern for removing the docs is for new crates, then no harm in removing it for now but also little benefit.
If its to get existing crates to change, I don't think that ecosystem churn is worth it to try to get everyone to add the link and then remove it again.
2024-09-18 21:36:12 +00:00
bors
c652c56e2a Auto merge of #14557 - shannmu:_cargo_cmds, r=epage
feat: Add custom completer for `cargo help <TAB>`

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo help <TAB>`

### Additional information
The current completer function is quite slow because it executes too many functions. One idea I have is to use the file!() macro to list the filenames under the commands directory, excluding mod.rs, and return them as the completion results. Would this approach be too hacky?
2024-09-18 20:50:29 +00:00
bors
cb12afe586 Auto merge of #14563 - epage:complete, r=weihanglo
docs(unstable): Expand on completion documentation

### What does this PR try to resolve?

Wanting to improve the workflow for people testing completions

### How should we test and review this PR?

### Additional information
2024-09-18 20:16:16 +00:00
bors
a6de8c7fc0 Auto merge of #14531 - shannmu:_cargo_example_names, r=epage
feat: Add custom completer for `cargo build --example=<TAB>`

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo build --example=<TAB>`
2024-09-18 19:45:31 +00:00
shannmu
13c4c130e8 feat: Add custom completer for completing example names 2024-09-19 01:11:12 +08:00
shannmu
f64411c4cd feat: Add custom completer for cargo help <TAB> 2024-09-19 01:02:33 +08:00
Ed Page
a5c25f3dd5 fix(complete): Always check rustup for --target
clap-rs/clap#5733 removed the rustup proxy so that
`CARGO_COMPLETE=bash cargo +nightly` works
(with a side benefit of removing the proxy overhead).

As a downside, cargo no longer knows it is running within rustup, so we
aren't reading `--target` candidates from rustup.

This changes the code to always try rustup.  It is likely a good enough
source, even if the user isn't currently using it.
The candidates should be about the same, just rustup hides some by
default.
Hiding just means it isn't shown by default but if only hidden
candidates match, then we show them.
2024-09-18 09:28:05 -05:00
Ed Page
397a18076a 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)
2024-09-18 09:20:22 -05:00
Ed Page
9a658f9407 docs(unstable): Add completion feedback information 2024-09-18 09:08:33 -05:00
Ed Page
9101762dd4 docs(unstable): Make sure completion users know of +nightly 2024-09-18 09:00:19 -05:00
Ed Page
78cda34a17 Revert "remove reference to incomplete crates.io feature from docs"
This reverts commit 1735917adc11aaa14011a187baf47a320f1c5bc5.

As discussed in #13660, my stance on removing the docs was if there
wasn't a path forward.
There is work progressing on the docs.rs side which will unblock the
crates.io side.

If the concern for removing the docs is for new crates, then no harm in
removing it for now but also little benefit.
If its to get existing crates to change, I don't think that ecosystem
churn is worth it to try to get everyone to add the link and then remove
it again.
2024-09-18 08:55:47 -05:00
bors
0461165eae Auto merge of #14561 - RalfJung:crates-io-docs, r=weihanglo
remove reference to incomplete crates.io feature from docs

The cargo docs for the `documentation` field currently are written in a way that makes it sound like if I want to use docs.rs, I can just leave the field empty. However, that is not the case: leaving the field empty will never show a "Documentation" link in the search results, so there's always an unnecessary extra click to go from "type crate name into search" to reaching the docs.

This crates.io limitation is tracked at https://github.com/rust-lang/crates.io/issues/1484. It doesn't really matter whether this is a bug or a missing feature, the point is that cargo docs are misrepresenting what crates.io does in a way that leads to a suboptimal user experience (many crates without "Documentation" link in crates.io search results). Since the suggestion to document what crates.io actually does was rejected (https://github.com/rust-lang/cargo/pull/13660), I suggest we instead stop mentioning this feature at all -- that's still clearly better than mentioning it while it is not yet fully implemented / while it has some significant *undocumented* limitation.
2024-09-18 11:42:26 +00:00
Ralf Jung
1735917adc remove reference to incomplete crates.io feature from docs 2024-09-18 07:44:30 +02:00
bors
7f44292260 Auto merge of #14558 - epage:complete, r=ehuss
fix(complete): Fix problems on my machine

### What does this PR try to resolve?
This pulls in
- clap-rs/clap#5731 for `IFS` oddities I had
- clap-rs/clap#5733 with the hope that this makes `CARGO_COMPLETE_BASH cargo +nightly` just work

### How should we test and review this PR?

### Additional information

`clap` was completed next to `clap_complete` because `clap_complete` depends on unstable features from `clap`.
None should have changed in this time window but I wanted to exercise caution.
2024-09-18 00:11:22 +00:00
Ed Page
90856d9a7f fix(complete): Fix problems on my machine
This pulls in
- clap-rs/clap#5731 for `IFS` oddities I had
- clap-rs/clap#5733 with the hope that this makes `CARGO_COMPLETE_BASH cargo +nightly` just work

`clap` was completed next to `clap_complete` because `clap_complete`
depends on unstable features from `clap`.
None should have changed in this time window but I wanted to exercise
caution.
2024-09-17 16:14:35 -05:00
bors
60fbfb9421 Auto merge of #14532 - shannmu:_cargo_benchmark_names, r=epage
feat: Add custom completer for completing benchmark names

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo build --bench=<TAB>`
2024-09-17 17:49:12 +00:00
shannmu
9d08d4a494 feat: Add custom completer for completing benchmark names 2024-09-18 01:31:28 +08:00
bors
1eb49a1030 Auto merge of #14554 - Rustin170506:rustin-patch-notes, r=epage
refactor(info): Use the `shell.note` to print the note
2024-09-17 17:09:37 +00:00
bors
25456eadc5 Auto merge of #14548 - shannmu:_cargo_test_names, r=epage
feat: Add custom completer for completing test names

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo test --test <TAB>`
2024-09-17 16:32:45 +00:00
bors
32f024f788 Auto merge of #14537 - Rustin170506:rustin-patch-suggest-cargo-info, r=epage
Suggest `cargo info` command in the `cargo search` result
2024-09-17 15:55:50 +00:00
Rustin170506
0ba7540858 Use the shell.note to print the note
Signed-off-by: Rustin170506 <29879298+Rustin170506@users.noreply.github.com>
2024-09-17 23:53:39 +08:00
Rustin170506
52f8487c79 Suggest cargo info command in the cargo search result 2024-09-17 23:51:57 +08:00
bors
10eaf3400b Auto merge of #14535 - shannmu:_cargo_target_triple, r=epage
feat: Add custom completer for completing target triple

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo build --target=<TAB>`
2024-09-17 15:24:50 +00:00
shanmu
7968f54648 feat: Add custom completer for completing target triple 2024-09-17 23:10:57 +08:00
shannmu
f47e2a5b43 feat: Add custom completer for completing test names 2024-09-17 12:40:14 +08:00
bors
75ab4e5119 Auto merge of #14536 - shannmu:_cargo_unstable_flags, r=epage
feat: Add custom completer for `cargo -Z <TAB>`

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo -Z <TAB>`
2024-09-16 15:04:18 +00:00
bors
654a433361 Auto merge of #14534 - shannmu:_cargo_installed_crates, r=epage
feat: Add custom completer for completing installed binaries

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo uninstall <TAB>`
2024-09-16 14:27:32 +00:00
bors
7984efa4d6 Auto merge of #14533 - shannmu:_bin_names, r=epage
feat: Add custom completer for completing bin names

### What does this PR try to resolve?
Tracking issue https://github.com/rust-lang/cargo/issues/14520

Add custom completer for `cargo build --bin=<TAB>`
2024-09-16 13:55:18 +00:00
shannmu
8b2f08cc88 feat: Add custom completer for cargo -Z <TAB> 2024-09-16 03:22:37 +08:00
bors
a9a418d1a2 Auto merge of #14547 - weihanglo:only-update-clap, r=ehuss
chore: revert change to Cargo.lock in f25806c

Some unrelated dependencies has been updated and blocked CI.

See rust-lang/rust#130377
2024-09-15 19:13:12 +00:00
shannmu
954581bdfb feat: Add custom completer for completing installed binaries 2024-09-16 02:51:16 +08:00
Weihang Lo
4689efefa7
chore: necessary lock updates for clap_complete 2024-09-15 14:45:02 -04:00
Weihang Lo
fcaafa45f2
chore: revert change to Cargo.lock in f25806c472fd36f1ab0a8ba8a6a003f78734dd60
Some unrelated dependencies have been updated and blocked CI.
See rust-lang/rust 130377
2024-09-15 14:44:59 -04:00
shannmu
93fc5646d9 feat: Add custom completer for completing bin names 2024-09-16 02:31:14 +08:00
bors
468f1500bd Auto merge of #14546 - ehuss:disable-shell-completions, r=weihanglo
Disable the shell_completions tests

The shell_completions tests have a few issues that are causing some problems. See https://github.com/rust-lang/cargo/issues/14545 for a description. This disables the tests until those can get resolved.
2024-09-14 19:24:54 +00:00
bors
d949021e91 Auto merge of #14530 - stormshield-guillaumed:vendor, r=weihanglo
fix(vendor): trust crate version only when coming from registries

### What does this PR try to resolve?

Fixes #8181
Relates to #11897 and #14525

### How should we test and review this PR?

As mentioned in the contribution guide, I made a first commit adding a test that passes with the actual behaviour. Then, I made a second commit with a fix and modified the test with the new expected  behaviour.

### Additional information

The fix doesn't take into account switching from a git dependency to crates.io, which is not handled correctly on master either, and would probably require the vendoring to serialize the source ID to detect source changes.

I specifically limited the trust of immutable version to crates.io, but it could be extended to other registries.
2024-09-14 18:56:06 +00:00
Eric Huss
47f4cdc093 Disable the shell_completions tests 2024-09-14 11:53:00 -07:00
Ed Page
2107a43cb7 refactor(update): Clarify what each checks intention is 2024-09-13 10:56:40 -04:00