Commit graph

16458 commits

Author SHA1 Message Date
bors 6c9f33a909 Auto merge of #13298 - weihanglo:pkgid, r=epage
docs: add more links to pkgid spec chapter
2024-01-15 16:15:54 +00:00
bors 77f2da7b92 Auto merge of #12914 - epage:metadata, r=weihanglo
fix(metadata): Stabilize id format as PackageIDSpec

### What does this PR try to resolve?

For tools integrating with cargo, `cargo metadata` is the primary interface.  Limitations include:
-  There isn't an unambiguous way to map a package entry from `cargo metadata`  to a parameter to pass to other `cargo` commands.  An `id` field exists but it is documented as an opaque string, useful only for comparisons with other `id`s within the document.
- There isn't an unambiguous way of taking user parameters (`--package`) and mapping them to `cargo metadata` entries.  `cargo pkgid` could help but it returns a `PackageIdSpec` which doesn't exist within the `cargo metadata` output.

This attempts to solve these problems by switching the `id` field from `PackageId` to `PackageIdSpec` which is a [publicly documented format](https://doc.rust-lang.org/cargo/reference/pkgid-spec.html), can be generated by `cargo pkgid`, and is accepted by most commands via the `--package` flag.

As the `"id"` field is documented as opaque, this technically isn't a breaking change though people could be parsing it.

For `cargo_metadata` they do [use a new type that documents it as opaque but publicly expose the inner `String`](https://docs.rs/cargo_metadata/latest/cargo_metadata/struct.PackageId.html).  The `String` wasn't publicly exposed due to a request by users but instead their `PackageId` type replaced using `String`s in the API in oli-obk/cargo_metadata#59 with no indication given as to why the `String` was still exposed.  However, you'll note that before that PR, they had `WorkspaceMember` that parsed `PackageId`.  This was introduced in oli-obk/cargo_metadata#26 without a motivation given.

**Note that `PackageIdSpec` has multiple representation that might uniquely identify a package and we can return any one of them.**

Fixes #7267

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

### Additional information

cc `@oli-obk`
2024-01-15 15:45:36 +00:00
bors 19eb0f0b27 Auto merge of #13296 - eopb:precise-pre-release-flag, r=epage
Introduce `-Zprecise-pre-release` unstable flag

Tracking Issue: [#13290](https://github.com/rust-lang/cargo/issues/13290)

This change introduces the feature but does not yet attempt an implementation. The actual implementation will happen in future PRs.

r? `@epage`
2024-01-15 15:15:56 +00:00
Weihang Lo 7b8acb15c5
docs: add more links to pkgid spec chapter 2024-01-14 19:28:43 -05:00
Ethan Brierley c8ec94c765 Introduce -Zprecise-pre-release unstable flag
This change introduces the feature but does not yet attempt an implementation.
The actual implementation will happen in future PRs

r? @epage
2024-01-14 18:52:33 +00:00
bors 9d3473c727 Auto merge of #13292 - dtolnay-contrib:parentheses, r=weihanglo
Delete sentence about parentheses being unsupported in license

Parentheses have been supported by crates.io since 2 years ago.

- https://github.com/rust-lang/crates.io/pull/4257

Their functionality is tested by this test: 3acd63c1f3/tests/utils/license-test.js (L68-L79).

I think a separate test in Cargo is most likely not valuable because Cargo does not parse these license strings, they are just treated as `Option<String>`.

Here is an example of an extremely widely used package (147 million downloads) with parentheses in its license: https://crates.io/crates/unicode-ident.
2024-01-14 18:39:10 +00:00
bors d530b46da2 Auto merge of #13293 - dtolnay-contrib:homepage, r=weihanglo
Add guidance on setting homepage in manifest

Carried over from the Rust API Guidelines: https://rust-lang.github.io/api-guidelines/documentation.html#cargotoml-includes-all-common-metadata-c-metadata

This guidance has been in place since 6.5 years ago (350619f84e).
2024-01-14 17:47:22 +00:00
David Tolnay 7ccb4d3a79
Add guidance on setting homepage in manifest 2024-01-13 18:56:30 -08:00
David Tolnay c78b2ca1dd
Delete sentence about parentheses being unsupported in license 2024-01-13 18:48:28 -08:00
bors 92395d9010 Auto merge of #13236 - heisen-li:test, r=epage
Clarify the function of the test options

### What does this PR try to resolve?

Make the description of test options clearer.

from #10936
2024-01-12 22:20:03 +00:00
bors 84976cd699 Auto merge of #13287 - weihanglo:sort-summaries, r=Eh2406
fix(resolver): do not panic when sorting empty summaries
2024-01-12 15:55:43 +00:00
bors bf27f90f12 Auto merge of #13252 - connorworley:shallow_libgit2_fetches, r=weihanglo
Implementation of shallow libgit2 fetches behind an unstable flag

This is my first contribution, so guidance is appreciated.

Fixes #1171 by moving the `shallow-index` and `shallow-deps` aspects of `-Zgitoxide` to a new `-Zgit` unstable flag.

The only change in interaction with libgit2 happens in `src/cargo/sources/git/utils.rs`, where we set the depth fetch option if applicable.

Shallow fetch tests for gitoxide continue to pass, but libgit2 is harder to test as it silently ignores the depth option for local fetches. I would love any ideas on how to test it in a lightweight way or whether it's OK to wait for an upstream fix.
2024-01-12 15:18:17 +00:00
Connor Worley 426b9e3085 Update docs with tracking issue and note about consecutive fetches 2024-01-12 14:40:48 +09:00
Weihang Lo 6cee9bf72f
fix(resolver): do not panic when sorting empty summaries 2024-01-12 00:34:42 -05:00
Weihang Lo c677f73353
test(resolver): empty summaries passed in sort_summaries 2024-01-12 00:29:13 -05:00
bors 54fd66a51e Auto merge of #13284 - charmitro:output-format-doc-entry, r=weihanglo
Add documentation entry for unstable `--output-format` flag

This is a follow-up to #12252 adding a documentation entry for the newly supported unstable flag `--output-format`.
2024-01-11 21:51:16 +00:00
bors 269783715b Auto merge of #13272 - linyihai:cargo-add-public-manpage, r=epage
doc: add `public` info in `cargo-add` man page.

### What does this PR try to resolve?
follow up https://github.com/rust-lang/cargo/pull/13046
add `public/private` explanation for `cargo-add` in man page.

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

### Additional information

The help info would be like this

- `cargo help add`
```
        --public
           Mark the dependency as public.

           The dependency can be referenced in your library’s public API.

           Unstable (nightly-only) <https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency>

       --no-public
           Mark the dependency as private.

           While you can use the crate in your implementation, it cannot be referenced in your public API.

           Unstable (nightly-only) <https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency>
```
- `cargo add -h`
```
      --public               Mark the dependency as public (unstable)
      --no-public            Mark the dependency as private (unstable)
```

- `cargo add --help`
```
      --public
          Mark the dependency as public (unstable)

          The dependency can be referenced in your library's public API.

      --no-public
          Mark the dependency as private (unstable)

          While you can use the crate in your implementation, it cannot be referenced in your public API.
```
2024-01-11 21:13:02 +00:00
Charalampos Mitrodimas 40aa8b14b7 Add documentation entry for unstable --output-format flag
This is a follow-up to #12252.

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
2024-01-11 22:46:06 +02:00
bors 55f6aeb020 Auto merge of #13286 - Manishearth:prereleases, r=epage
More docs on prerelease compat

We had some questions about semver compat of prereleases when discussing https://github.com/unicode-org/icu4x/issues/4445, figured I'd document our findings.
2024-01-11 20:12:57 +00:00
Manish Goregaokar 200e9f6e7f More docs on prerelease compat 2024-01-11 15:05:21 -05:00
bors f4e2eac630 Auto merge of #12252 - charmitro:master, r=weihanglo
Add unstable `--output-format` option to  `cargo rustdoc`

Add unstable `--output-format` option to "rustdoc"

We achieved this by:
* Handle `--output-format` argument, accepting `html` or `json`
* A new field `json` in `CompileMode::Doc`.
* If `json` is passed, we append the following in
   `prepare_rustdoc`:
  1. `-Zunstable-options`
  2. `--output-format=json`

Fixes #12103
2024-01-11 18:32:07 +00:00
Charalampos Mitrodimas 9276399342 Add unstable --output-format option to "rustdoc"
We achieved this by:
   * Handle `--output-format` argument, accepting `html` or `json`
   * If `json` is passed, we append the following in
   `prepare_rustdoc`:
     	1. `-Zunstable-options`
	2. `--output-format`

Fixes #12103

Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
2024-01-11 17:37:56 +02:00
Connor Worley 5eb2899415 Fix z_help test case 2024-01-11 17:10:51 +09:00
Connor Worley 0088121d21 Update error message about removed -Zgitoxide aspects 2024-01-11 17:08:21 +09:00
Connor Worley 64716fee99 Add dummy link to appease CI 2024-01-11 17:08:21 +09:00
Connor Worley a1559be493 Implementation of shallow libgit2 fetches behind an unstable flag 2024-01-11 17:08:21 +09:00
Lin Yihai f141c10bda doc: add public info in cargo-add man page. 2024-01-11 15:11:08 +08:00
bors 4eef543a4d Auto merge of #13172 - Muscraft:diagnostic-system, r=epage
feat: Add `rustc` style errors for manifest parsing

#12235 is tracking user control over warnings. One part of that is making `cargo`'s diagnostic system output messages in the style of `rustc`. To make it so that `cargo` doesn't have to manage a formatter and renderer, I decided to use [`annotate-snippets`](https://crates.io/crates/annotate-snippets), which matches `rustc`'s style well (at one time it was meant to be the formatted for `rustc`).

To get this work kicked off, it was suggested to me that we should start with styling manifest parsing errors, and that is what his PR does.

What manifest parsing errors look like after this change:
![image](https://github.com/rust-lang/cargo/assets/23045215/0eb388b9-8d72-48ad-84a9-585160995078)

---

Note: `cargo` does not currently match `rustc` in color (#12740), `rustc`  specifies their colors [here](740cea81d6/compiler/rustc_errors/src/lib.rs (L1755-L1768)) and [here](740cea81d6/compiler/rustc_errors/src/emitter.rs (L2689-L2723)). I used `annotate-snippets` default colors which match what `rustc` currently uses for colors. I did this as a stopgap while I work to unify the colors used between `rustc` and `cargo`.

---

Note: the error messages come directly from `toml` and can be quite long. It would be nice if we could put some of the message below the highlight but this would require changes to `toml`.
Example:
```
error: invalid type: integer `3`
 --> Cargo.toml:7:7
  |
7 | bar = 3
  |       ^ expected a version string like "0.9.8" or a detailed dependency like { version = "0.9.8" }
  |
```
2024-01-11 01:07:36 +00:00
bors 187d4cf35e Auto merge of #13273 - BD103:master, r=weihanglo
Document why `du` function uses mutex

### What does this PR try to resolve?

After closing #13253, it [was suggested](https://github.com/rust-lang/cargo/pull/13253#issuecomment-1883286035) to document why the `du` function uses a `Mutex` instead of an `AtomicU64`. This will prevent others from making the same mistake I did. :)

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

N/A

### Additional information

N/A
2024-01-10 14:19:06 +00:00
BD103 0a6fe230d6 fix: update lockfile 2024-01-10 08:09:55 -05:00
BD103 c832cdf068
bump: cargo-util to 0.2.10 2024-01-10 08:01:47 -05:00
bors 3e428a38a3 Auto merge of #13275 - weihanglo:iter-join, r=epage
refactor: replace `iter_join` with `itertools::join`
2024-01-09 20:46:36 +00:00
Weihang Lo cfc6e4b1d2
refactor: replace iter_join with itertools::join 2024-01-09 15:38:22 -05:00
bors 87b4cb2182 Auto merge of #13274 - weihanglo:unstable-features-doc, r=epage
docs(unstable): doc comments for items and fields
2024-01-09 18:05:02 +00:00
BD103 529130fe54
fix: missing word in comment
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
2024-01-09 12:50:49 -05:00
Weihang Lo 4105a153d4
docs(unstable): doc comments for Features and Feature 2024-01-09 12:47:38 -05:00
Weihang Lo d0390c22b1
docs(unstable): doc comments for CliUnstable 2024-01-09 12:47:38 -05:00
bors 616bae2c86 Auto merge of #13264 - Turbo87:ct-header, r=weihanglo
crates-io: Set `Content-Type: application/json` only for requests with a body payload

### What does this PR try to resolve?

The `Content-Type` **request** header is only supposed to be used if the request comes with a body payload. `cargo` is currently sending it unconditionally, even for `GET` requests that typically don't have a payload attached to them.

This PR changes the implementation to only attach the header if the request has a body payload.
2024-01-09 17:26:05 +00:00
Tobias Bieniek 6218d08504
crates-io: Bump version to v0.40.0 2024-01-09 18:03:21 +01:00
BD103 4da5444bb7
chore: document why du function uses mutex 2024-01-09 12:01:03 -05:00
Tobias Bieniek 2d1728088f
crates-io: Set Content-Type: application/json only for requests with a body payload 2024-01-09 17:57:56 +01:00
bors b90f770d3a Auto merge of #13261 - hi-rustin:rustin-patch-not_inherit_workspace_package_table_if_not_members, r=epage
fix: only inherit workspace package table if the new package is a member
2024-01-09 16:46:09 +00:00
hi-rustin db4ed038c1 refactor: separate get_display_path_and_check_membership
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-01-09 22:10:19 +08:00
hi-rustin 874645e394 test: add lints
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-01-09 21:49:33 +08:00
hi-rustin 47f4b75847 fix: only inherit workspace package table if the new package is a member
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2024-01-09 21:24:32 +08:00
bors 88599985e9 Auto merge of #13269 - weihanglo:zhelp, r=epage
feat(cli): add colors to `-Zhelp` console output
2024-01-09 02:57:19 +00:00
Weihang Lo dbfe4277d3
test: loop over aliases to asser -Zhelp output 2024-01-08 21:34:07 -05:00
Weihang Lo 59cfee16f3
refactor(cli): remove allocation and use format arg capture 2024-01-08 21:34:06 -05:00
Weihang Lo 8fee74d47b
refactor(cli): tweak to align existing style 2024-01-08 21:33:12 -05:00
Weihang Lo f50b7740bf
feat(cli): add colors to -Zhelp console output 2024-01-08 21:33:12 -05:00