Commit graph

16624 commits

Author SHA1 Message Date
bors
f4bafa7f91 Auto merge of #13346 - epage:error, r=weihanglo
fix(cli): Improve errors related to cargo script

### What does this PR try to resolve?

Fixes #13332

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

See tests in last commit to see how this changes error messages.

This is a lot of duplication with minor tweaking that will go away on stabilization

### Additional information
2024-01-25 22:38:35 +00:00
Ed Page
51b1200572 fix(cli): Improve bad script errors 2024-01-25 13:28:43 -06:00
Ed Page
2a7e5c05ed test(script): Show existing non-existent behavior 2024-01-25 13:28:43 -06:00
Ed Page
c377c2aae6 test(script): Avoid common subcommand name 2024-01-25 13:28:30 -06:00
Ed Page
c51ea384b0 fix(cli): Suggest fix for scripts that look like external subcommands 2024-01-25 11:28:48 -06:00
Ed Page
40331900ae refactor(cli): Use string interpolation 2024-01-25 11:05:07 -06:00
bors
29386b9c32 Auto merge of #13344 - my-contributes:master, r=weihanglo
fix list option description starting with uppercase

All options' description start with uppercase except list.
2024-01-25 12:47:19 +00:00
bestgopher
f30987fc76
Update stdout.log 2024-01-25 16:31:22 +08:00
bestgopher
ae7c08c1ff
fix list option description starting with uppercase 2024-01-25 15:55:11 +08:00
bors
b2e1d3b623 Auto merge of #13342 - Kobzol:test-fix-typo, r=epage
Fix typo in test

The typo was introduced in https://github.com/rust-lang/cargo/pull/13257, it only produced a warning, so it didn't break the test.
Noticed [here](https://github.com/rust-lang/cargo/pull/13257#discussion_r1464506596).
2024-01-24 14:57:40 +00:00
Jakub Beránek
262e31e9fd
Fix typo in test 2024-01-24 10:07:46 +01:00
hi-rustin
aa6444734d test: add a case for running binary with same name as dependency
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-01-22 21:06:32 +08:00
Weihang Lo
3f2f4ed29b
feat(cargo-update): --precise to allow yanked versions 2024-01-21 20:14:24 -05:00
Weihang Lo
4f1e41ebe3
test(update): demonstrate not able to update --precise <yanked> 2024-01-21 14:45:35 -05:00
Weihang Lo
515f6e3f9d
refactor: rename items in OptVersionReq
* `OptVersionReq::update_precise` to `precise_to`
* `OptVersionReq::UpdatePrecise` to `Precise`
2024-01-21 14:37:00 -05:00
Weihang Lo
70e7868ddb
refactor(registry): merge called flags into one 2024-01-20 23:53:57 -05:00
bors
7bb7b53955 Auto merge of #12776 - weihanglo:jobserver, r=ehuss
feat: inherit jobserver from env for all kinds of runner
2024-01-20 00:15:32 +00:00
Weihang Lo
678f3ff487
feat: inherit jobserver from env for all kinds of runner
External subcommands are already able to inherit the jobserver from
env since #10511. However, users reported that they've expected
`cargo run` to behave the same as external subcommands.

A popular example "cargo-xtask" pattern is used as scripting to run
arbitrary tasks. Users may want to invoke `cargo run` from Make and
expect some parallelism. This PR provides such an ability to the
general `target.<...>.runner`, which affects `cargo test`,
`cargo bench`, and `cargo run`.

Note that this PR doesn't create any jobserver client if there is no
existing jobserver from the environment. Nor `-j`/`--jobs` would create
a new client. Reasons for this decision:

* There might be crates don't want the jobserver to pollute their
  file descriptors, although they might be rare
* Creating a jobsever driver with the new FIFO named pipe style is not
  yet supported as of `jobserver@0.1.26`. Once we can create a named
  pipe-based jobserver, it will be less risky and inheritance by
  default can be implemented.
2024-01-19 18:36:35 -05:00
bors
07021393fa Auto merge of #13329 - ehuss:fix-static_mut_ref, r=weihanglo
Fix static_mut_ref warning.

The nightly compiler has recently added the [`static_mut_ref`](https://doc.rust-lang.org/nightly/rustc/lints/listing/warn-by-default.html#static-mut-ref) lint, which warns about taking a reference to a `mut static`. This fixes the issue by copying the value instead of taking a reference. I don't recall what I was thinking when I wrote this, but it was probably a bad reflex against making copies.
2024-01-19 23:34:37 +00:00
Eric Huss
3c414b5cf1 Fix static_mut_ref warning. 2024-01-19 15:12:37 -08:00
bors
c22cc7bb8b Auto merge of #13210 - weihanglo:remap-rules, r=epage
fix(trim-paths): remap common prefix only
2024-01-19 21:31:41 +00:00
bors
63f4af9c51 Auto merge of #13325 - kanru:issue13303-output-generated-json, r=weihanglo
fix(cargo-rustdoc): use same path by output format logic everywhere
2024-01-19 01:54:10 +00:00
Weihang Lo
ac1dc0bb99
test: verify runner doesn't inherit jobserver 2024-01-18 20:24:25 -05:00
Kan-Ru Chen
4160441245
fix(cargo-rustdoc): use same path by output format logic everywhere 2024-01-19 08:42:48 +08:00
bors
c061bfbc08 Auto merge of #13324 - epage:msrv, r=weihanglo
chore: Make MSRV=N-2 the workspace default

### What does this PR try to resolve?

Since we update the MSRV every release, `cargo bump-check` forces the changed packages to be released (#13266).
A caveat is that `cargo bump-check` only checks the directory and doesn't do a `.crate` diff, so it misses out of changes to `workspace.package`.
Because of our current workspace default, this means every 6 weeks we ship our user-facing packages but not the internal ones.

This shifts that so we ship our internal packages every 6 weeks and our internal only when changed.

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

### Additional information

 If `rust-version = "auto"` (rust-lang/rfcs#3537) gets approved, then we will only ship packages that actually change
2024-01-19 00:23:48 +00:00
Weihang Lo
a62a3c65dc
test: extract making make exectuable to fn 2024-01-18 17:21:04 -05:00
Ed Page
c6c1df4758 chore: Make N-2 the default MSRV
We likely don't want to release these packages every 6 months just for
an MSRV bump.
By moving the MSRV out of the package, `cargo bump-check` will ignore
the MSRV bump.

Inspired by #13266
2024-01-18 15:30:41 -06:00
Ed Page
b291f42dce chore: Make N-0 MSRVs explicit
This will require a version bump every release but over-releasing these
packages is likely a lot better than over-releasing the N-3 packages,
which we won't have to do anymore after this.

My hope is the `auto` value will be approved and stabilized and then we
won't have to over-release anymore.
2024-01-18 15:28:04 -06:00
Ed Page
9438f80042 chore: Remove rust-version from private packages
I removed it from `cargo-test-support` and `cargo-test-macro`, despite
people depending on those (via git) because my long term plan is resting
on the `auto` value which won't affect git dependencies.
2024-01-18 15:24:25 -06:00
bors
a8187e5885 Auto merge of #13320 - ehuss:fix-precise-link, r=epage
Fix precise-prerelease tracking link.

Fixes a link that goes to the wrong location.
2024-01-18 20:12:36 +00:00
bors
6221d8744d Auto merge of #13322 - weihanglo:pkgid-consistency, r=epage
test(pkgid): keep package ID format in sync
2024-01-18 19:30:52 +00:00
Weihang Lo
eb9e3778dd
test(pkgid): keep package ID format in sync
* Package ID specifications
* machine-readable message via `--message-format=json`
* `cargo metadata` output
2024-01-18 14:05:57 -05:00
Eric Huss
e26bfa5752 Fix precise-prerelease tracking link. 2024-01-18 10:53:47 -08:00
bors
e01eeb053c Auto merge of #13317 - Urgau:improve-ci, r=epage
Improve GitHub Actions CI config

This pull request improves Cargo CI by:
 1. Explicitly listing the branches the main CI should be run on (to avoid running on unwanted branches, particularly in forks)
 2. By adding a [concurrency](https://docs.github.com/en/actions/using-jobs/using-concurrency) config so that only one "CI" runs for each "group" (one by PR), very inspired by rust-lang/rust [one](c485ee7147/.github/workflows/ci.yml (L35))
 3. ~~By making all the jobs run only if triggered from this repository (to avoid having forks unnecessarily run CI jobs)~~
 4. ~~By making all the checkouts take `fetch-depth: 2` like done in [rust-lang/rust](c485ee7147/.github/workflows/ci.yml (L452-L455)) (to avoid unnecessary work, saves bandwidth and maybe a bit of time)~~
 5. Included `refs/heads/try` in the `success` and `failure` bors job gates (to fix `bors try` from timing out)

The main motivation for this PR was (at first) to make the CI jobs not run on forks since it's a waste of CI resources as well as always failing (like [this](https://github.com/Urgau/cargo/actions/runs/7567435677/job/20606586124)); but after looking at the `main.yml` config I took the opportunity to improve the situation by using rust-lang/rust [ci.yml](https://github.com/rust-lang/rust/blob/master/.github/workflows/ci.yml) as reference.
2024-01-18 16:48:33 +00:00
Urgau
2739b6d3b6 Improve and fix the success and failure bors job gates 2024-01-18 16:58:27 +01:00
Urgau
f7bed34c1d Improve GitHub Actions CI config 2024-01-18 16:58:27 +01:00
bors
9574120bf0 Auto merge of #13316 - Urgau:check-cfg-zero-features-2, r=epage
Go back to passing an empty `values()` when no features are declared

This PR is basically a revert of https://github.com/rust-lang/cargo/pull/13011, which made the `--check-cfg` invocation be `cfg()` when no features are declared instead of `cfg(feature, values())` since it meant declaring that the config `feature` were to be available in this form: `#[cfg(feature)]`, which is not the case.

Thankfully after some brainstorming, I [proposed](https://github.com/rust-lang/rust/pull/119930) changing the behavior of empty `values()` in `rustc` to no longer imply the _none_ value and simply create an empty set of expected values. 😃

For Cargo, always using `cfg(feature, values(...))` means that the config `feature` is always expected, regardless of the number of features. This makes the warning better, as it will now always be `unexpected config value` (instead of `unexpected config name`). 🎉

Fixes https://github.com/rust-lang/cargo/pull/13011#issuecomment-1819427800 as well as the concern in the [tracking issue](https://github.com/rust-lang/cargo/issues/10554).

r? `@epage`
2024-01-18 13:33:11 +00:00
bors
c9d5cb37bf Auto merge of #13315 - weihanglo:pkg-selection, r=epage
fix(`--package`): accept `?` if it's a valid pkgid spec
2024-01-18 12:46:24 +00:00
Urgau
fecb8ff0c8 Go back to passing an empty values() when no features are declared
See https://github.com/rust-lang/rust/pull/119930
2024-01-18 09:45:09 +01:00
Weihang Lo
637b5d1eae
fix(--package): accept ? if it's a valid pkgid spec
Previously if a value from `--package` flag contains `?`, Cargo
considered it as a glob pattern. However, staring from 12933 the
Package Id Spec has been extended to accept `?` for git sources.
This PR adjust accordingly to accept `?` from `--package` flag
when it is a valid Package Id Spec.
2024-01-18 00:45:35 -05:00
Weihang Lo
a37d122949
test: show pkgid spec + query doesnt work with --package 2024-01-18 00:37:52 -05:00
bors
1ae631085f Auto merge of #13311 - weihanglo:pkgid-json-message, r=epage
fix(json-msg): use pkgid spec in in JSON messages
2024-01-17 17:26:41 +00:00
Weihang Lo
ad1a3b3758
docs: more links to JSON messages 2024-01-17 11:31:19 -05:00
Weihang Lo
b5457ac883
docs(json-msg): pkgid spec as package_id 2024-01-17 11:31:19 -05:00
Weihang Lo
f9fd4ff4ee
fix(json-msg): use pkgid spec in in JSON messages
In 12914 we stabilized pkgid spec as unique package identifier for
`cargo metadata`. However, we forgot to make the same change to
JSON message format[^1]. This PR does so.

Note that the `package_id` field in JSON message is not clearly stated
as "opaque", so it might be considered as a breaking change to some extent.

[^1]: https://doc.rust-lang.org/nightly/cargo/reference/external-tools.html#compiler-messages
2024-01-17 11:31:19 -05:00
bors
a383063b00 Auto merge of #13307 - epage:unstable, r=weihanglo
doc(features): Highlight the non-blocking feature gating technique

We already discussed non-blocking gates but the language makes it sound like it was limited to `config.toml`.
Since I haven't been touching that, I had always overlooked that section.

This change brings the blocking / non-blocking decision front and center.
To support this, the later sections focus more on mechanisms (the gate) rather than on what is being done (new syntax for `cargo-features`).

I also feel this makes the content more scannable.

This is adapted from what I did for `[lints]` (see #12148).
2024-01-16 23:07:24 +00:00
Ed Page
354e1989f8 doc(features): Highlight the non-blocking feature gating technique
We already discussed non-blocking gates but the language makes it sound
like it was limited to `config.toml`.
Since I haven't been touching that, I had always overlooked that
section.

This change brings the blocking / non-blocking decision front and
center.
To support this, the later sections focus more on mechanisms (the gate)
rather than on what is being done (new syntax for `cargo-features`).

I also feel this makes the content more scannable.

This is adapted from what I did for `[lints]` (see #12148).
2024-01-16 12:51:27 -06:00
bors
1cff2ee6b9 Auto merge of #13305 - linyihai:issue-13289, r=epage
doc: add a heading to highlight "How to find features enabled on dependencies"

### What does this PR try to resolve?

Maybe fixes https://github.com/rust-lang/cargo/issues/13289

Add a title to highlight "How to find features enabled on dependencies"?

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

### Additional information
2024-01-16 16:56:57 +00:00
Lin Yihai
aa9a1cfa40 doc: add a heading to highlight "How to find features enabled on dependencies" 2024-01-16 23:52:52 +08:00
bors
350098d5ef Auto merge of #13250 - weihanglo:cargo-update, r=ehuss
fix(cargo-update): `--precise` accept arbitrary git revisions
2024-01-15 17:57:47 +00:00