Commit graph

15273 commits

Author SHA1 Message Date
renovate[bot] b22d31672c
chore(deps): update rust crate toml_edit to 0.20.2 2023-10-13 17:48:42 +00:00
bors a9d71d291f Auto merge of #12817 - alexcrichton:workspace-public-dep, r=epage
Support `public` dependency configuration with workspace deps

This commit updates the processing of `workspace = true` dependencies in the `[dependencies]` section to process the `public` field. Previously this field was ignored and didn't get plumbed through as configured.

Also 👋 it's been awhile!
2023-10-13 14:06:12 +00:00
Alex Crichton 756fc4084e Support public dependency configuration with workspace deps
This commit updates the processing of `workspace = true` dependencies in
the `[dependencies]` section to process the `public` field. Previously
this field was ignored and didn't get plumbed through as configured.
2023-10-13 00:32:05 -07:00
bors eb2b3f9ccb Auto merge of #12815 - chenx97:rustix-0.38.18, r=epage
Update rustix to 0.38.18
2023-10-12 15:38:45 +00:00
bors 890b664ccb Auto merge of #12812 - tshepang:patch-1, r=epage
contrib docs: add some conveniences

- AND search terms, instead of OR
- allow quick-edit, by adding a button that allows one to submit a change directly via github
2023-10-12 14:50:56 +00:00
bors 0d3f77f225 Auto merge of #12811 - hi-rustin:rustin-patch-path, r=epage
Better suggestion for unsupported `--path` flag
2023-10-12 13:49:14 +00:00
bors e6b24be83f Auto merge of #12814 - tshepang:patch-3, r=epage
contrib docs: update rfc and roadmap links
2023-10-12 12:53:40 +00:00
bors 3bf258ecbb Auto merge of #12813 - tshepang:patch-2, r=weihanglo
contrib doc: remove extraneous word
2023-10-12 11:26:45 +00:00
hi-rustin ded92b17ca Call arg_quiet_without_unknown_silent_arg_tip in arg_quiet
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-12 19:25:45 +08:00
hi-rustin 497e1ee307 Better suggestion for unsupported -path flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-12 19:24:42 +08:00
Tshepang Mbambo 7d0cf18ee5
contrib docs: update rfc and roadmap links 2023-10-12 12:04:42 +02:00
Henry Chen fbb2fddba1 Update rustix to 0.38.18 2023-10-12 18:02:25 +08:00
Tshepang Mbambo 4e73422e19
contrib doc: remove extraneous word 2023-10-12 11:50:29 +02:00
Tshepang Mbambo 475136cc8c
contrib docs: add some conveniences
- AND search terms, instead of OR
- allow quick-edit, by adding a button that allows one to submit a change directly via github
2023-10-12 11:35:32 +02:00
hi-rustin 95d79094e0 Add test for unsupported --path flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-12 09:01:34 +08:00
bors 50d9f9cbfd Auto merge of #12808 - ehuss:update-curl, r=weihanglo
Update curl-sys to pull in curl 8.4.0

This updates curl-sys from 0.4.66 to 0.4.68 to pull in curl 8.4.0. This fixes two CVEs:

* CVE-2023-38546 — https://curl.se/docs/CVE-2023-38546.html
* CVE-2023-38545 — https://curl.se/docs/CVE-2023-38545.html

This also pulls in a change to fix compiling on macOS Sonoma.
2023-10-12 00:57:30 +00:00
Eric Huss 51b5c4f38f Update curl-sys to pull in curl 8.4.0
This updates curl-sys from 0.4.66 to 0.4.68 to pull in curl 8.4.0.
This fixes two CVEs:

* CVE-2023-38546 — https://curl.se/docs/CVE-2023-38546.html
* CVE-2023-38545 — https://curl.se/docs/CVE-2023-38545.html

This also pulls in a change to fix compiling on macOS Sonoma.
2023-10-11 16:59:48 -07:00
bors 71de58d5cf Auto merge of #12799 - marchiore:warn_add_package_name, r=epage
feat: add package name and version to warning messages

### What does this PR try to resolve?

Hi, this PR Fixes #8018, where i add the package name and version on warning messages.
As this is my first contribution to the project, if anything is not in compliance in the PR let me know and I will be happy to correct it.
2023-10-11 19:59:57 +00:00
Matheus Z Marchiore 380719da35 feat: add package name and version to warning messages 2023-10-11 16:52:30 -03:00
bors 90fb62fc65 Auto merge of #12796 - dtolnay-contrib:switching, r=epage
Do not call it "Downgrading" when difference is only build metadata

### What does this PR try to resolve?

When a `cargo update --precise` changes a dependency between 2 versions which differ only in build metadata, Cargo prints a log referring to it as "Updating" or "Downgrading" the dependency, depending on a comparison between the build metadatas.

This is usually not meaningful, given that build metadata is often stuff like git commit hashes, which are not meaningfully ordered.

```console
    Updating crates.io index
 Downgrading foo v0.0.1+43ef4fe -> v0.0.1+2c65d16
    Updating bar v0.0.2+bc17664 -> v0.0.2+c144a98
```

~~This PR changes to the word "Switching" when the version major, minor, patch, and pre-release value are not being changed.~~
This PR uses the word "Updating" when the version major, minor, patch, and pre-release value are unchanged, regardless of whether the build metadata is going up or down.

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

- `cargo test`
- `cargo build --release`
- `/path/to/cargo/target/release/cargo add tonic_datastore_v1`
- `/path/to/cargo/target/release/cargo update -p tonic_datastore_v1 --precise 0.1.0+3562b6cb3`
- `/path/to/cargo/target/release/cargo update -p tonic_datastore_v1 --precise 0.1.0+ee9e8e4e6`

Before:
<img src="https://github.com/rust-lang/cargo/assets/1940490/93e377e7-928e-4cec-aff6-451166ef7c81" width="500">

~~After:~~
<img src="https://github.com/rust-lang/cargo/assets/1940490/bb71459e-469a-4e09-bb8a-4083f34bce79" width="500">

After:
<img src="https://github.com/rust-lang/cargo/assets/1940490/8804e2fe-d0de-4c9e-b463-a5742daf9446" width="500">
2023-10-11 14:21:44 +00:00
David Tolnay f1d2237b72
Call cmp_precedence where applicable 2023-10-10 20:58:55 -07:00
bors 4ae21bd58f Auto merge of #12805 - hi-rustin:rustin-patch-target, r=epage
Add unsupported short flag suggestion for `--target` and `--exclude` flags
2023-10-11 02:08:04 +00:00
hi-rustin b514ca5e24 Add unsupported short flag suggestion for --exclude flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:41:05 +08:00
hi-rustin 718b69ce19 Add test for unsupported short exclude flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:39:13 +08:00
hi-rustin 819a836e9a Add unsupported short flag suggestion for --target flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:16:26 +08:00
hi-rustin 2f90430110 Add test for unsupported short target triple flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-11 09:13:55 +08:00
bors 6fa6fdc760 Auto merge of #12804 - weihanglo:generalize-test-assertion, r=Muscraft
test(build): generalize test assertion for non-rustup env
2023-10-10 23:06:08 +00:00
Weihang Lo a263a7dc31
test(build): generalize test assertion for non-rustup env 2023-10-10 17:52:46 -04:00
bors 95089bebda Auto merge of #12803 - epage:sort, r=weihanglo
chore: Sort dependency tables

This will make `cargo add` put things in the right place.

Verified by doing `cargo add arcstr && git diff && git reset --hard`
2023-10-10 21:47:39 +00:00
bors 8ba1c316ee Auto merge of #12798 - epage:msrv-install, r=ehuss
fix(install): Suggest an alternative version on MSRV failure

### What does this PR try to resolve?

Moves users from a bad error message, suggesting `--locked` which won't do anything, to suggesting a version of a package to use instead.

The side benefit is errors get reported sooner
- Before downloading the `.crate`
- When installing multiple packages, before building the first

This comes at the cost of an extra `rustc` invocation.

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

Per-commit this builds it up, from tests to the final design.

### Additional information

This is also written in a way to align fairly well with how we'd likely implement #10903.
This improved error message will still be useful after that issue is resolved when the MSRV compatible version is outside of the version req.
2023-10-10 20:03:41 +00:00
Ed Page 7846fe8cb4 chore: Sort dependency tables
This will make `cargo add` put things in the right place.

Verified by doing `cargo add arcstr && git diff && git reset --hard`
2023-10-10 15:03:22 -05:00
bors e4fe8f04e7 Auto merge of #12800 - notriddle:notriddle/version-tests, r=ehuss
rustdoc: remove the word "Version" from test cases

Needed for https://github.com/rust-lang/rust/pull/115948 to merge.

That PR gets rid of the word "Version" in rustdoc's HTML output, and it splits spaced versions on their first space, to fit in the tight horizontal spacing. This causes Cargo's test suite to fail, because it look for the word "Version", even though things are working as they should.

These tests work on both current nightly and on that pull request.
2023-10-10 18:26:44 +00:00
Michael Howell f0d3cdf191 rustdoc: remove the word "Version" from test cases
Needed for https://github.com/rust-lang/rust/pull/115948 to merge.
2023-10-10 11:19:57 -07:00
bors c97c906b79 Auto merge of #12788 - hi-rustin:rustin-patch-short-Z, r=epage
Add unsupported lowercase `-z` flag suggestion for `-Z` flag
2023-10-10 01:33:31 +00:00
Ed Page 9b32be7f89 fix(install): Suggest an alternative version on MSRV failure
The next step would be to also automatically install an MSRV compatible
version if compatible with the version req (#10903).
This improved error message will still be useful if the MSRV compatible
version is outside of the version req.

I did this as the first step
- Helps people now, not needing to wait on `-Zmsrv-policy` to be stabilized
- Has fewer questions on how it should be done (or if it should be)
2023-10-09 20:22:54 -05:00
hi-rustin d1540ccd7e Move arg_config and arg_unstable_feature out of command prelude
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2023-10-10 08:59:14 +08:00
David Tolnay c0ed70ef5e
Use semver::Version's cmp_precedence for deciding what is downgrade 2023-10-09 16:08:27 -07:00
Ed Page 2976e2ac66 fix(install): Don't suggest --locked for MSRV when its root package
This will also report the error without having to download the `.crate`
first.

If installing multiple packages, this will also report it immediately,
rather than waiting for the other packages to be installed first.

This also offers us more flexibility in the error we report,
like suggesting more appropriate fixes.
2023-10-09 16:31:30 -05:00
David Tolnay 985e1eeef5
Do not call it "Downgrading" when difference is only build metadata 2023-10-09 13:53:47 -07:00
Ed Page 699b30a5f4 test(install): Verify existing top-level MSRV behavior 2023-10-09 15:48:53 -05:00
bors b27f203e7f Auto merge of #12785 - epage:version-refactor, r=weihanglo
refactor(core): Clean up deserialization of PackageId

This came as part of another change that I'm abandoning but I felt this made things cleaner, so I decided to keep it.
2023-10-09 19:31:18 +00:00
David Tolnay 4d1bf29a2c
Add test of update with version that differ only in build metadata 2023-10-09 10:36:46 -07:00
bors b48c41aedb Auto merge of #12706 - ehuss:cache-lock-mode, r=epage
Add new package cache lock modes

The way locking worked before this PR is that only one cargo could write to the package cache at once (otherwise it could cause corruption). However, it allowed cargo's to read from the package cache while running a build under the assumption that writers are append-only and won't affect reading. This allows multiple builds to run concurrently, only blocking on the part where it is not possible to run concurrently (downloading to the cache).

This introduces a new package cache locking strategy to support the ability to safely modify existing cache entries while other cargos are potentially reading from the cache. It has different locking modes:

- `MutateExclusive` (new) — Held when cargo wants to modify existing cache entries (such as being introduced for garbage collection in #12634), and ensures only one cargo has access to the cache during that time.
- `DownloadExclusive`  (renamed) — This is a more specialized name for the lock that was before this PR.   A caller should acquire this when downloading into the cache and doing resolution.  It ensures that only one cargo can append to the cache, but allows other cargos to concurrently read from the cache.
- `Shared` (new) — This is to preserve the old concurrent build behavior by allowing multiple concurrent cargos to hold this while a build is running when it is reading from the cache

**Reviewing suggestions:**
There are a few commits needed to help with testing which are first. The main commit has the following:
- `src/cargo/util/cache_lock.rs` is an abstraction around package cache locks, and is the heart of the change. It should have comments and notes which should guide what it is doing. The `CacheLocker` is stored in `Config` along with all our other global stuff.
- Every call to `config.acquire_package_cache_lock()` has been changed to explicitly state which lock mode it wants to lock the package cache in.
- `Context::compile` is the key point where the `Shared` lock is acquired, ensuring that no mutation is done while the cache is being read.
- `MutateExclusive` is not used in this PR, but is being added in preparation for #12634.
- The non-blocking `try_acquire_package_cache_lock` API is not used in this PR, but is being added in preparation for #12634 to allow automatic gc to skip running if another cargo is already running (to avoid unnecessary blocking).
- `src/cargo/util/flock.rs` has been updated with some code cleanup (removing unused stuff), adds support for non-blocking locks, and renames some functions to make their operation clearer.
- `tests/testsuite/cache_lock.rs` contains tests for all the different permutations of ways of acquiring locks.
2023-10-09 15:56:42 +00:00
Eric Huss 78bb7c5cb5 Rearrange impl blocks to be near their types. 2023-10-08 18:18:45 -07:00
Eric Huss 889558f76b Extend cache_lock documentation. 2023-10-08 18:18:42 -07:00
Eric Huss df2e2a3ae6 Rename some Filesystem methods for clarity and consistency.
This tries to align the `Filesystem` method names so they have the same
form, and also so they spell out exactly what they do. (An alternative
would be to have a builder, similar to `OpenOptions`, but that seems a
bit overkill here.)

This also extends the docs to try to make it clearer how this works.
2023-10-08 17:46:39 -07:00
Eric Huss fd6185193a Rewrite the cache locker to use functions instead of macros. 2023-10-08 14:16:51 -07:00
Eric Huss 1f0e483c66 Inline lock method. 2023-10-08 14:16:51 -07:00
Eric Huss 907bc0f777 Rearrange CacheLockMode order. 2023-10-08 14:16:51 -07:00
Eric Huss b4982adfd9 Add a new package cache locking system.
This introduces a new `CacheLocker` which manages locks on the package
cache. Instead of either being "locked" or "not locked", the new locker
supports multiple modes:

- Shared lock: Cargo can read from the package sources, along with any
  other cargos reading at the same time.
- Download exclusive lock: Only one cargo can perform downloads.
  Download locks do not interfere with Shared locks, since it is
  expected that downloading does not modify existing files (only adds
  new ones).
- Mutate exclusive lock: Only one cargo can have this lock, and it also
  prevents shared locks. This is so that the cargo can modify the
  package cache (such as deleting files) without breaking concurrent
  processes.
2023-10-08 14:16:51 -07:00