Commit graph

12597 commits

Author SHA1 Message Date
bors e5ec3a8ff9 Auto merge of #11004 - jonhoo:bump-git2, r=weihanglo
Bump git2 to 0.15 and libgit2-sys to 0.14

This will allow cargo to avoid vendored builds of git2 in up-to-date
environments going forward, and brings in the [libgit2 1.4.4 CVE fix].

[libgit2 1.4.4 CVE fix]: https://github.com/libgit2/libgit2/releases/tag/v1.4.4
2022-08-27 09:22:12 +00:00
bors bcf18e5cf5 Auto merge of #11025 - hi-rustin:rustin-patch-typo, r=Eh2406
Fix typo

Just fix a typo. bacwkards -> backwards
2022-08-27 04:27:39 +00:00
hi-rustin c1d1246eb7 Fix typo
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-27 11:20:52 +08:00
bors 716d401227 Auto merge of #11021 - 4TT1L4:patch-1, r=weihanglo
Update cargo-toml-vs-cargo-lock.md

 - Improved wording ('rev' is not a line)
2022-08-25 12:30:53 +00:00
4TT1L4 7e6c487b9c
Update cargo-toml-vs-cargo-lock.md
- Improved wording ('rev' is not a line)
2022-08-25 13:50:11 +02:00
bors 9ded34a558 Auto merge of #10807 - dtolnay-contrib:sha256, r=weihanglo
Apply GitHub fast path even for partial hashes

### What does this PR try to resolve?

As flagged in https://github.com/rust-lang/cargo/pull/10079#issuecomment-1170940132, it's not great to assume that git SHAs would always be 40-character hex strings. In the future they will be longer.

> Git is on a long-term trajectory to move to SHA256 hashes ([current status](https://lwn.net/SubscriberLink/898522/f267d0e9b4fe9983/)). I suppose when that becomes available/the default it's possible for a 40-digit hex-encoded hash not to be the full hash. Will this fail for that case?

The implementation from #10079 fails in that situation because it turns dependencies of the form `{ git = "…", rev = "[…40 hex…]" }` into fetches with a refspec `+[…40 hex…]:refs/commit/[…40 hex…]`. That only works if the 40 hex digits are the *full* long hash of your commit. If it's really a prefix ("short hash") of a 64-hex-digit SHA-256 commit hash, you'd get a failure that resembles:

```console
error: failed to get `dependency` as a dependency of package `repro v0.0.0`

Caused by:
  failed to load source for dependency `dependency`

Caused by:
  Unable to update https://github.com/rust-lang/dependency?rev=b30694b4d9b29141298870b7993e9aee10940524

Caused by:
  revspec 'b30694b4d9b29141298870b7993e9aee10940524' not found; class=Reference (4); code=NotFound (-3)
```

This PR updates the implementation so that Cargo will curl GitHub to get a resolved long commit hash *even if* the `rev` specified for the git dependency in Cargo.toml already looks like a SHA-1 long hash.

### Performance considerations

 This reverses a (questionable, negligible) benefit of #10079 of skipping the curl when `rev` is a long hash and is not already present in the local clone. These curls take 200-250ms on my machine.

🟰 We retain the much larger benefit of #10079 which comes from being able to precisely fetch a single `rev`, instead of fetching all branches and tags in the upstream repo and hoping to find the rev somewhere in there. This accounts for the entire performance difference explained in the summary of that PR.

🟰 We still skip the curl when `rev` is a **long hash** of a commit that is already previously fetched.

🥳 After this PR, we also curl and hit fast path when `rev` is a **short hash** of some upstream commit. For example `{ git = "https://github.com/rust-lang/cargo", rev = "b30694b4d9" }` would previously have done the download-all-branches-and-tags codepath because `b30694b4d9` is not a long hash. After this PR, the curl to GitHub informs us that `b30694b4d9` resolves to the long hash `b30694b4d9b29141298870b7993e9aee10940524`, and we download just that commit instead of all-branches-and-tags.

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

I tested with the following dependency specs, using `/path/to/target/release/cargo generate-lockfile`.

```toml
# Before: slow path (fetch all branches and tags; 70K git objects)
# After: fast path (20K git objects)
cargo = { git = "https://github.com/rust-lang/cargo", rev = "b30694b4d9b2914129" }
```

```toml
# Before and after: fast path
cargo = { git = "https://github.com/rust-lang/cargo", rev = "b30694b4d9b29141298870b7993e9aee10940524" }
```

```toml
# Before and after: fast path
cargo = { git = "https://github.com/rust-lang/cargo", rev = "refs/heads/rust-1.14.0" }
```

```toml
# Before and after: same error "revspec 'rust-1.14.0' not found"
# You are supposed to use `branch = "rust-1.14.0"`, this is not considered a `rev`
cargo = { git = "https://github.com/rust-lang/cargo", rev = "rust-1.14.0" }
```

I made sure these all work both with and without `rm -rf ~/.cargo/git/db/cargo-* ~/.cargo/git/checkouts/cargo-*` in between each cargo invocation.

FYI `@djc`
2022-08-24 07:05:49 +00:00
bors 6da726708a Auto merge of #11017 - BlackHoleFox:non-ascii-names, r=weihanglo
Update non-ASCII crate name warning message

This PR fixes an outdated warning when initializing crates sometimes.

### What does this PR try to resolve?
Per [a Zulip convo](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Non-ASCII.20crate.20name.20status/near/294876491) on the topic, non-ASCII crate names are no longer allowed on any toolchain since https://github.com/rust-lang/rust/pull/73305, during the `non_ascii_idents` feature's development. Cargo however tells the user that they are accepted on Nightly. Rust and Cargo should agree on this point to avoid future confusion.

### How should we test and review this PR?
This should be covered by the existing test that was changed but if desired its easy to test with a checkout:

```
Running `/Users/fox/x/Forks/cargo/target/release/cargo init 'ああああ'`
warning: the name `ああああ` contains non-ASCII characters
Non-ASCII crate names are not supported by Rust.
```
2022-08-23 21:39:56 +00:00
BlackHoleFox b676088572 Update non-ASCII crate name warning message 2022-08-23 14:23:59 -05:00
bors fee1c7f285 Auto merge of #11011 - hi-rustin:rustin-patch-tests, r=epage
Add more tests for aggressive or precise update

### What does this PR try to resolve?

When I was working on https://github.com/rust-lang/cargo/pull/10988, I found there is no test for the aggressive update. So I added it.

Also, I added a test for precise update to make sure it won't force update the deps of SPEC.
### How should we test and review this PR?

Unit tests.
2022-08-22 16:51:27 +00:00
hi-rustin 64e3991907 Remove useless log deps and add more test for precise update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-21 17:16:01 +08:00
hi-rustin f0b5bdad65 Add test for aggressive update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-21 17:14:07 +08:00
bors 1ac83ba696 Auto merge of #11008 - weihanglo:issue-10917, r=epage
Ignore broken but excluded file during traversing
2022-08-21 01:45:41 +00:00
Weihang Lo c0110c6382
Ignore broken but excluded file during traversing
Walkdir's [`filter_entry()`][1] won't call the predicate if the entry
is essentially an `Err` from its underyling `IntoIter`. That means
Cargo hasn't had a chance to call `filter` on an entry that should be
excluded but eventually return an `Err` and cause the loop to stop.
For instance, a broken symlink which should bee excluded by `filter`
will generate an error since `filter` closure is not called with it.

The solution is calling `filter` if an error occurs with a path
(because it has yet been called with that path).
If it's exactly excluded, ignore the error.

[1]: abf3a15887/src/lib.rs (L1042-L1058)
2022-08-20 00:56:43 +01:00
Weihang Lo 52a418c516
test: ignore broken but excluded file during traversing 2022-08-20 00:56:43 +01:00
Weihang Lo 09ff1944ca
Remove unnecessary mutability 2022-08-20 00:56:39 +01:00
bors 6066463e27 Auto merge of #10999 - hi-rustin:rustin-patch-wrong-names, r=epage
Improve error message for wrong target names

### What does this PR try to resolve?

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

We can print all available targets for users.

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

- [x] unit test
2022-08-19 14:35:26 +00:00
hi-rustin 99b3564d0d Update old tests
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-19 10:56:29 +08:00
hi-rustin abb463a7aa Improve error message for wrong target names 2022-08-19 10:53:09 +08:00
bors 0c57749ca3 Auto merge of #11005 - jonhoo:bump-snapbox, r=epage
Bump snapbox to 0.3

0.3 has a small number of [breaking changes], but makes diffs much
easier to visually parse by eliding large sections of unchanged content.

[breaking changes]: https://github.com/assert-rs/trycmd/blob/main/crates/snapbox/CHANGELOG.md#030---2022-08-01

r? `@epage`
2022-08-18 01:16:09 +00:00
Jon Gjengset 222e0e51ff Disable owner validation for Cargo-as-a-binary 2022-08-17 23:46:27 +00:00
Jon Gjengset ed78e6b747 Bump snapbox to 0.3
0.3 has a small number of [breaking changes], but makes diffs much
easier to visually parse by eliding large sections of unchanged content.

[breaking changes]: https://github.com/assert-rs/trycmd/blob/main/crates/snapbox/CHANGELOG.md#030---2022-08-01
2022-08-17 22:07:20 +00:00
Jon Gjengset 30fe22b260 Bump git2 to 0.15 and libgit2-sys to 0.14
This will allow cargo to avoid vendored builds of git2 in up-to-date
environments going forward, and brings in the [libgit2 1.4.4 CVE fix].

[libgit2 1.4.4 CVE fix]: https://github.com/libgit2/libgit2/releases/tag/v1.4.4
2022-08-17 22:02:28 +00:00
bors 3b4df5a54a Auto merge of #11001 - Muscraft:fix-unstable-docs, r=weihanglo
remove missed reference to workspace inheritance in unstable.md

Currently on the nightly docs, workspace inheritance is [under the  stable table](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#workspace-inheritance-1)  and the [unstable table](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#workspace-inheritance). It looks like I forgot to remove it from the unstable table when working on stabilization.

I am not sure if it is worth a beta backport but I will happily open a PR for it if needed.
2022-08-17 20:18:30 +00:00
Scott Schafer a5a98f6c7c remove missed reference to workspace inheritance in unstable.md 2022-08-17 14:15:50 -05:00
bors 9e1b4577ce Auto merge of #10988 - hi-rustin:rustin-patch-warn, r=epage
Warning when precise or aggressive without -p flag

### What does this PR try to resolve?

ref https://github.com/rust-lang/cargo/issues/10919.

Warning when precise or aggressive without -p flag. It will be a hard error in future.

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

- Unit test.
2022-08-17 14:36:56 +00:00
hi-rustin a58489dfbb Add test for aggressive update
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-17 21:53:12 +08:00
hi-rustin f95deaafeb Warning when precise or aggressive without -p flag
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-17 21:53:07 +08:00
bors 9809f8ff33 Auto merge of #10944 - kcrimson-ar:master, r=epage
Improve error message for an array value in the manifest

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

The error message will be:

```
error: failed to parse manifest at `/Users/..`

Caused by:
  invalid type: string "Ky", expected an array for key `package.authors`
```
2022-08-16 22:10:06 +00:00
bors 5a7ba9cdfb Auto merge of #10975 - theCapypara:flock-enosys-android, r=weihanglo
Fix file locking being not supported on Android raising an error

This PR fixes #10972 by not failing Cargo operations when the `target_os` is Android and file locking is being reported as not being implemented by the kernel.

I am sadly unable to actually test this at the moment, since despite my best efforts I am not able to get Cargo actually cross-compiled for Android (aarch64-linux-android).

I however don't see any reason why this wouldn't work. `target_os` is "android" on Android and not "linux".
2022-08-16 12:29:32 +00:00
Marco Köpcke b0c9586f4c No longer gate unsupported file locking behind Linux as OS 2022-08-16 12:46:47 +02:00
bors 84941490fd Auto merge of #10983 - ehuss:version-bump, r=weihanglo
Bump to 0.66.0, update changelog
2022-08-12 21:14:11 +00:00
Eric Huss aae4c84a09 Also mention build.target being an array. 2022-08-12 14:12:22 -07:00
Eric Huss b1f49c9737 Update changelog for 1.64 2022-08-12 13:22:37 -07:00
Eric Huss 34632c5925 Bump to 0.66.0 2022-08-12 12:22:05 -07:00
bors efd4ca3dc0 Auto merge of #10977 - weihanglo:std-thread-scope, r=epage
Use `std:🧵:scope` to replace crossbeam

Drop one dependency as `std:🧵:Scope` got stabilized in 1.63.

Haven't done any benchmark. (Should we?)
2022-08-12 01:28:28 +00:00
bors 4fe9b13276 Auto merge of #10978 - andrewpollack:docs-removing-excess-in, r=weihanglo
[docs] Remove extra "in" from `cargo-test.md`

Removes an extra "in" from doc src/doc/src/commands/cargo-test.md

Successor to #10971 without bungled merge
2022-08-11 23:57:19 +00:00
andrewpollack 195b1e0e50 Removing excess in 2022-08-11 16:47:52 -07:00
Weihang Lo 33497512a8
Use std:🧵:scope to replace crossbeam 2022-08-12 00:09:54 +01:00
bors 34cba461f2 Auto merge of #10930 - ehuss:enable-windows-tests, r=weihanglo
Enable two windows tests

These two tests were disabled on Windows a long time ago. AFAICT, the reasons are no longer relevant, and it should be safe to enable these tests. See each commit for a more detailed exposition.
2022-08-11 22:30:26 +00:00
Marco Capypara Köpcke 585cf31990 Fix flock being not supported on Android raising an error 2022-08-11 15:47:09 +02:00
bors 1ac43cf649 Auto merge of #10968 - hi-rustin:rustin-patch-msg, r=ehuss
Improve error msg for get target runner

Actually, we'll get this config from three places. So this msg may be confusing when you set it up in `.cargo/config.toml` or pass it by `--config`.
We already printed the location of the config, so I think it's OK to change it to `configurations`.
2022-08-11 03:23:09 +00:00
bors a120cfe08e Auto merge of #10962 - Nemo157:override-target-dir, r=ehuss
Ensure rustc-echo-wrapper works with an overridden build.target-dir

Without this when running with an overridden target-dir there are about a dozen test failures like

```console
> mkdir .cargo
> echo '[build]\ntarget-dir = "not-target"' > .cargo/config
> cargo test -- fix::does_not_crash
---- fix::does_not_crash_with_rustc_wrapper stdout ----
running `/home/nemo157/sources/cargo/not-target/debug/cargo build`
running `/home/nemo157/sources/cargo/not-target/debug/cargo fix --allow-no-vcs`
thread 'fix::does_not_crash_with_rustc_wrapper' panicked at '
test failed running `/home/nemo157/sources/cargo/not-target/debug/cargo fix --allow-no-vcs`
error: process exited with code 101 (expected 0)
--- stdout

--- stderr
error: failed to run `rustc` to learn about target-specific information

Caused by:
  could not execute process `/home/nemo157/sources/cargo/not-target/tmp/cit/rustc-echo-wrapper/target/debug/rustc-echo-wrapper rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (never executed)

Caused by:
  No such file or directory (os error 2)
', tests/testsuite/fix.rs:1228:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

Because the `rustc-echo-wrapper` is compiled to `not-target/debug/rustc-echo-wrapper`.

This is resolved by forcing the target-dir to be a manifest-relative one for this specific build.
2022-08-10 21:55:46 +00:00
bors 3a17953664 Auto merge of #10969 - joshtriplett:available-parallelism, r=epage
Switch back to `available_parallelism`

This reverts commit 8345cf5037 now that https://github.com/rust-lang/rust/pull/97925 is merged.

Since that
time, there are now multiple calls to get the number of CPUs, to handle
the `-j -NUM` case, so factor out a helper function.
2022-08-10 17:52:21 +00:00
Josh Triplett 86163845a5 Switch back to available_parallelism
This reverts commit 8345cf5037. Since that
time, there are now multiple calls to get the number of CPUs, to handle
the `-j -NUM` case, so factor out a helper function.
2022-08-10 17:49:24 +02:00
Wim Looman 61c4b11eae
Ensure rustc-echo-wrapper works with an overridden build.target-dir 2022-08-10 17:37:40 +02:00
hi-rustin 6bb4050552 Fix test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-10 23:19:35 +08:00
hi-rustin f11d9a1852 Improve error msg for get target runner
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-10 22:43:00 +08:00
bors 1fcbca84ee Auto merge of #10961 - Nemo157:skip-implicit-override, r=epage
Only override published resolver when the workspace is different

### What does this PR try to resolve?

Ensures when publishing a package that uses an implicit `resolver = "1"` to maintain an MSRV before the `resolver` key was stabilized the implicitness is retained rather than being turned into an explicit setting.

fixes #10954 (assuming that the workspace and its packages are configured with a consistent resolver)
2022-08-10 14:30:11 +00:00
bors fcf3281ec7 Auto merge of #10967 - hi-rustin:rustin-patch-docs, r=epage
Add `CARGO_LOG` to "Environment variables Cargo reads"

### What does this PR try to resolve?
close https://github.com/rust-lang/cargo/issues/10947
2022-08-10 13:47:46 +00:00
hi-rustin ccf81aee3a Add CARGO_LOG to Environment variables Cargo reads
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-08-10 20:51:28 +08:00