]> git.proxmox.com Git - cargo.git/log
cargo.git
20 months agochore(ci): Ensure intradoc links are valid
Ed Page [Tue, 6 Sep 2022 14:19:03 +0000 (09:19 -0500)]
chore(ci): Ensure intradoc links are valid

20 months agoAuto merge of #11029 - epage:config, r=weihanglo
bors [Thu, 1 Sep 2022 06:05:27 +0000 (06:05 +0000)]
Auto merge of #11029 - epage:config, r=weihanglo

refactor(cli): Lazy load config

This is trying to clarify `-C` support when it is implemented in #10952

Cargo currently has two initialization states for Config, `Config::default` (process start) and `config.configure` (after parsing args).  The most help we provide for a developer touching this code is a giant `CAUTION` comment in one of the relevant functions.

Currently, #10952 adds another configuration state in the middle where the `current_dir` has been set.

The goal of this PR is to remove that third configuration state by
- Lazy loading `Config::default` so it can be called after parsing `-C`
- Allowing `-C` support to assert that the config isn't loaded yet to catch bugs with it

The hope is this will make the intent of the code clearer and reduce the chance for bugs.

In doing this, there are two intermediate refactorings
- Make help behave like other subcommands
  - Before, we had hacks to intercept raw arguments and to intercept clap errors and assume what their intention was to be able to implement our help system.
  - This flips it around and makes help like any other subcommand,
simplifying cargo initialization.
  - We had to upgrade clap because this exposed a bug where `Command::print_help` wasn't respecting `disable_colored_help(true)`
- Delay fix's access to config

Personally, I also find both changes make the intent of the code clearer.

To review this, I recommend looking at the individual commits.   As this is just refactors, this has no impact on testing.

20 months agorefactor(cli): Lazily do first-pass config loading
Ed Page [Mon, 29 Aug 2022 17:06:19 +0000 (12:06 -0500)]
refactor(cli): Lazily do first-pass config loading

This will be a help for cases like #10952 which I would expect would
assert that the config is not loaded before changing the current_dir.

20 months agorefactor(cli): Delay fix's access to config
Ed Page [Mon, 29 Aug 2022 16:46:54 +0000 (11:46 -0500)]
refactor(cli): Delay fix's access to config

My hope is to make it so we can lazy load the config.  This makes it so
we only load the config for the fix proxy if needed.

I also feel like this better clarifies the intention of the code that we
are running in a special mode.

20 months agorefactor(cli): Make help behave like other subcommands
Ed Page [Mon, 29 Aug 2022 16:29:11 +0000 (11:29 -0500)]
refactor(cli): Make help behave like other subcommands

Before, we had hacks to intercept raw arguments and to intercept clap
errors and assume what their intention was to be able to implement our
help system.

This flips it around and makes help like any other subcommand,
simplifying cargo initialization.

20 months agoAuto merge of #11040 - epage:confusion, r=ehuss
bors [Thu, 1 Sep 2022 00:00:35 +0000 (00:00 +0000)]
Auto merge of #11040 - epage:confusion, r=ehuss

chore: Don't show genned docs in ripgrep

The goal is to help new (and existing) users more quickly find the
appropriate files to edit (like in #11033).  The main downside is for
someone trying to find output to verify what it looks like, a simple
search won't turn up results but there are other ways around that
(`--no-ignore`, `git status` after doing a man generation, etc).

20 months agoAuto merge of #11019 - weihanglo:doc-private-items-cargo-itself, r=epage
bors [Wed, 31 Aug 2022 21:57:00 +0000 (21:57 +0000)]
Auto merge of #11019 - weihanglo:doc-private-items-cargo-itself, r=epage

Document private items for Cargo and publish under contributor guide

20 months agoAuto merge of #11039 - ehuss:ci-names, r=epage
bors [Wed, 31 Aug 2022 21:14:13 +0000 (21:14 +0000)]
Auto merge of #11039 - ehuss:ci-names, r=epage

Add names to CI jobs

This adds names to the CI jobs. I've often found the existing auto-generated names to be confusing, and I think it would help to make them a little more succinct and clearer.

Before:
<img width="314" alt="image" src="https://user-images.githubusercontent.com/43198/187777515-6237f765-d747-4d74-8e06-baa86fbe8b2f.png">

After:
<img width="295" alt="image" src="https://user-images.githubusercontent.com/43198/187777559-6e21f08a-cf4c-4aaf-86ba-201bdd90c84f.png">

20 months agochore: Don't show genned docs in ripgrep
Ed Page [Wed, 31 Aug 2022 21:11:36 +0000 (16:11 -0500)]
chore: Don't show genned docs in ripgrep

The goal is to help new (and existing) users more quickly find the
appropriate files to edit (like in #11033).  The main downside is for
someone trying to find output to verify what it looks like, a simple
search won't turn up results but there are other ways around that
(`--no-ignore`, `git status` after doing a man generation, etc).

20 months agoAdd names to CI jobs
Eric Huss [Wed, 31 Aug 2022 20:36:42 +0000 (13:36 -0700)]
Add names to CI jobs

20 months agoAuto merge of #11028 - ehuss:test-errors, r=weihanglo
bors [Tue, 30 Aug 2022 22:59:43 +0000 (22:59 +0000)]
Auto merge of #11028 - ehuss:test-errors, r=weihanglo

Rework test error handling

This reworks how errors are handled when running tests and benchmarks. There were some cases where Cargo was eating the actual error and not displaying it. For example, if a test process fails to launch, it only displayed the `could not execute process` message, but didn't explain why it failed to execute. This fixes it to ensure that the full error chain is displayed.

This also tries to simplify how the errors are handled, and makes them more uniform across `test` and `bench`, and with doctests.

This also changes the `--no-fail-fast` behavior to report errors as they happen instead of grouped at the end (and prints a summary at the end). This helps to make it clearer when a nonstandard error happens. For example, before:

```
     Running tests/t1.rs (target/debug/deps/t1-bb449dfa37379ba1)

running 1 test
     Running tests/t2.rs (target/debug/deps/t2-1770ae8367bc97ce)

running 1 test
test bar ... FAILED

failures:

---- bar stdout ----
thread 'bar' panicked at 'y', tests/t2.rs:3:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    bar

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed.

Caused by:
  process didn't exit successfully: `/Users/eric/Temp/z12/target/debug/deps/t1-bb449dfa37379ba1` (signal: 11, SIGSEGV: invalid memory reference)
  process didn't exit successfully: `/Users/eric/Temp/z12/target/debug/deps/t2-1770ae8367bc97ce` (exit status: 101)
```

and the changes to that are:

```diff
`@@` -1,6 +1,10 `@@`
      Running tests/t1.rs (target/debug/deps/t1-bb449dfa37379ba1)

 running 1 test
+error: test failed, to rerun pass `--test t1`
+
+Caused by:
+  process didn't exit successfully: `/Users/eric/Temp/z12/target/debug/deps/t1-bb449dfa37379ba1` (signal: 11, SIGSEGV: invalid memory reference)
      Running tests/t2.rs (target/debug/deps/t2-1770ae8367bc97ce)

 running 1 test
`@@` -18,8 +22,7 `@@`

 test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

-error: test failed.
-
-Caused by:
-  process didn't exit successfully: `/Users/eric/Temp/z12/target/debug/deps/t1-bb449dfa37379ba1` (signal: 11, SIGSEGV: invalid memory reference)
-  process didn't exit successfully: `/Users/eric/Temp/z12/target/debug/deps/t2-1770ae8367bc97ce` (exit status: 101)
+error: test failed, to rerun pass `--test t2`
+error: 2 targets failed:
+    `--test t1`
+    `--test t2`
```

In the first example, when it says `Running tests/t1.rs`, there is no error message displayed until after all the tests finish, and that error message is not associated with the original test. This also includes the "to rerun" hint with `--no-fail-fast`.

20 months agoAuto merge of #11033 - buggymcbugfix:buggymcbugfix/cargo-add-docs, r=epage
bors [Tue, 30 Aug 2022 21:50:14 +0000 (21:50 +0000)]
Auto merge of #11033 - buggymcbugfix:buggymcbugfix/cargo-add-docs, r=epage

Very slight `cargo add` documentation improvements

As discussed in https://github.com/rust-lang/book/pull/3331, a quick explanation of the `Features` part of the message that gets printed to stdout when adding some dependency.

Consider the following example:

```
cargo add my-crate
    Updating crates.io index
      Adding my-crate v0.1.0 to dependencies.
             Features:
             + foo
             - bar
```

It was not clear to me what `+foo` and `-bar` meant until `@carols10cents'` kindly explained it to me. Hopefully the documentation now clarifies this.

TODO:

- [x] Run `./build-man.sh`

20 months agoDocument cargo-add's feature message
Vilem Liepelt [Tue, 30 Aug 2022 20:58:34 +0000 (22:58 +0200)]
Document cargo-add's feature message

This refers to the `Features` part of the message that gets printed to
stderr after successfully adding some dependency, e.g.:

```
cargo add my-crate
    Updating crates.io index
      Adding my-crate v0.1.0 to dependencies.
             Features:
             + foo
             - bar
```

This tells us that the `foo` feature is enabled and `bar` is disabled.

20 months agoAuto merge of #11030 - ehuss:update-installation-requirements, r=epage
bors [Tue, 30 Aug 2022 00:26:35 +0000 (00:26 +0000)]
Auto merge of #11030 - ehuss:update-installation-requirements, r=epage

Update compiling requirements.

This updates the requirements for building cargo itself. It adds a little more clarification on exactly what is needed, and what some of the options are.

This may be a little bit too much detail, as usually I suspect most users will just run `cargo build` and follow the error message instructions on what to install next.

20 months agoUpdate compiling requirements.
Eric Huss [Mon, 29 Aug 2022 23:07:17 +0000 (16:07 -0700)]
Update compiling requirements.

20 months agoRework test error handling
Eric Huss [Sun, 28 Aug 2022 00:45:11 +0000 (17:45 -0700)]
Rework test error handling

20 months agoAuto merge of #11027 - tshepang:patch-1, r=ehuss
bors [Sat, 27 Aug 2022 18:41:39 +0000 (18:41 +0000)]
Auto merge of #11027 - tshepang:patch-1, r=ehuss

doc: pause, for readability

20 months agopause, for readability
Tshepang Mbambo [Sat, 27 Aug 2022 17:57:40 +0000 (19:57 +0200)]
pause, for readability

20 months agoAuto merge of #11004 - jonhoo:bump-git2, r=weihanglo
bors [Sat, 27 Aug 2022 09:22:12 +0000 (09:22 +0000)]
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

20 months agoAuto merge of #11025 - hi-rustin:rustin-patch-typo, r=Eh2406
bors [Sat, 27 Aug 2022 04:27:39 +0000 (04:27 +0000)]
Auto merge of #11025 - hi-rustin:rustin-patch-typo, r=Eh2406

Fix typo

Just fix a typo. bacwkards -> backwards

20 months agoFix typo
hi-rustin [Sat, 27 Aug 2022 03:20:52 +0000 (11:20 +0800)]
Fix typo

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
20 months agoAuto merge of #11021 - 4TT1L4:patch-1, r=weihanglo
bors [Thu, 25 Aug 2022 12:30:53 +0000 (12:30 +0000)]
Auto merge of #11021 - 4TT1L4:patch-1, r=weihanglo

Update cargo-toml-vs-cargo-lock.md

 - Improved wording ('rev' is not a line)

20 months agoUpdate cargo-toml-vs-cargo-lock.md
4TT1L4 [Thu, 25 Aug 2022 11:50:11 +0000 (13:50 +0200)]
Update cargo-toml-vs-cargo-lock.md

 - Improved wording ('rev' is not a line)

20 months agoMake CI build API doc
Weihang Lo [Thu, 25 Aug 2022 10:47:33 +0000 (11:47 +0100)]
Make CI build API doc

20 months agoAdd rustdoc for lib.rs
Weihang Lo [Wed, 24 Aug 2022 21:11:42 +0000 (22:11 +0100)]
Add rustdoc for lib.rs

20 months agoFix rustdoc warnings when documenting private items
Weihang Lo [Wed, 24 Aug 2022 21:12:12 +0000 (22:12 +0100)]
Fix rustdoc warnings when documenting private items

20 months agoAuto merge of #10807 - dtolnay-contrib:sha256, r=weihanglo
bors [Wed, 24 Aug 2022 07:05:49 +0000 (07:05 +0000)]
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`

20 months agoAuto merge of #11017 - BlackHoleFox:non-ascii-names, r=weihanglo
bors [Tue, 23 Aug 2022 21:39:56 +0000 (21:39 +0000)]
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.
```

20 months agoUpdate non-ASCII crate name warning message
BlackHoleFox [Tue, 23 Aug 2022 19:11:50 +0000 (14:11 -0500)]
Update non-ASCII crate name warning message

21 months agoAuto merge of #11011 - hi-rustin:rustin-patch-tests, r=epage
bors [Mon, 22 Aug 2022 16:51:27 +0000 (16:51 +0000)]
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.

21 months agoRemove useless log deps and add more test for precise update
hi-rustin [Sun, 21 Aug 2022 09:16:01 +0000 (17:16 +0800)]
Remove useless log deps and add more test for precise update

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoAdd test for aggressive update
hi-rustin [Sun, 21 Aug 2022 09:02:04 +0000 (17:02 +0800)]
Add test for aggressive update

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoAuto merge of #11008 - weihanglo:issue-10917, r=epage
bors [Sun, 21 Aug 2022 01:45:41 +0000 (01:45 +0000)]
Auto merge of #11008 - weihanglo:issue-10917, r=epage

Ignore broken but excluded file during traversing

21 months agoIgnore broken but excluded file during traversing
Weihang Lo [Fri, 19 Aug 2022 22:30:01 +0000 (23:30 +0100)]
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]: https://github.com/BurntSushi/walkdir/blob/abf3a15887758e0af54ebca827c7b6f8b311cb45/src/lib.rs#L1042-L1058

21 months agotest: ignore broken but excluded file during traversing
Weihang Lo [Fri, 19 Aug 2022 23:32:05 +0000 (00:32 +0100)]
test: ignore broken but excluded file during traversing

21 months agoRemove unnecessary mutability
Weihang Lo [Fri, 19 Aug 2022 22:29:36 +0000 (23:29 +0100)]
Remove unnecessary mutability

21 months agoAuto merge of #10999 - hi-rustin:rustin-patch-wrong-names, r=epage
bors [Fri, 19 Aug 2022 14:35:26 +0000 (14:35 +0000)]
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

21 months agoUpdate old tests
hi-rustin [Wed, 17 Aug 2022 14:28:36 +0000 (22:28 +0800)]
Update old tests

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoImprove error message for wrong target names
hi-rustin [Wed, 17 Aug 2022 13:43:27 +0000 (21:43 +0800)]
Improve error message for wrong target names

21 months agoAuto merge of #11005 - jonhoo:bump-snapbox, r=epage
bors [Thu, 18 Aug 2022 01:16:09 +0000 (01:16 +0000)]
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`

21 months agoDisable owner validation for Cargo-as-a-binary
Jon Gjengset [Wed, 17 Aug 2022 23:46:27 +0000 (23:46 +0000)]
Disable owner validation for Cargo-as-a-binary

21 months agoBump snapbox to 0.3
Jon Gjengset [Wed, 17 Aug 2022 22:04:15 +0000 (22:04 +0000)]
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

21 months agoBump git2 to 0.15 and libgit2-sys to 0.14
Jon Gjengset [Wed, 17 Aug 2022 21:55:13 +0000 (21:55 +0000)]
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

21 months agoAuto merge of #11001 - Muscraft:fix-unstable-docs, r=weihanglo
bors [Wed, 17 Aug 2022 20:18:30 +0000 (20:18 +0000)]
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.

21 months agoremove missed reference to workspace inheritance in unstable.md
Scott Schafer [Wed, 17 Aug 2022 19:15:50 +0000 (14:15 -0500)]
remove missed reference to workspace inheritance in unstable.md

21 months agoAuto merge of #10988 - hi-rustin:rustin-patch-warn, r=epage
bors [Wed, 17 Aug 2022 14:36:56 +0000 (14:36 +0000)]
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.

21 months agoAdd test for aggressive update
hi-rustin [Tue, 16 Aug 2022 12:57:42 +0000 (20:57 +0800)]
Add test for aggressive update

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoWarning when precise or aggressive without -p flag
hi-rustin [Mon, 15 Aug 2022 13:33:23 +0000 (21:33 +0800)]
Warning when precise or aggressive  without -p flag

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoAuto merge of #10944 - kcrimson-ar:master, r=epage
bors [Tue, 16 Aug 2022 22:10:06 +0000 (22:10 +0000)]
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`
```

21 months agoAuto merge of #10975 - theCapypara:flock-enosys-android, r=weihanglo
bors [Tue, 16 Aug 2022 12:29:32 +0000 (12:29 +0000)]
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".

21 months agoNo longer gate unsupported file locking behind Linux as OS
Marco Köpcke [Tue, 16 Aug 2022 10:46:47 +0000 (12:46 +0200)]
No longer gate unsupported file locking behind Linux as OS

21 months agoAuto merge of #10983 - ehuss:version-bump, r=weihanglo
bors [Fri, 12 Aug 2022 21:14:11 +0000 (21:14 +0000)]
Auto merge of #10983 - ehuss:version-bump, r=weihanglo

Bump to 0.66.0, update changelog

21 months agoAlso mention `build.target` being an array.
Eric Huss [Fri, 12 Aug 2022 21:12:22 +0000 (14:12 -0700)]
Also mention `build.target` being an array.

21 months agoUpdate changelog for 1.64
Eric Huss [Fri, 12 Aug 2022 20:22:37 +0000 (13:22 -0700)]
Update changelog for 1.64

21 months agoBump to 0.66.0
Eric Huss [Fri, 12 Aug 2022 19:22:05 +0000 (12:22 -0700)]
Bump to 0.66.0

21 months agoAuto merge of #10977 - weihanglo:std-thread-scope, r=epage
bors [Fri, 12 Aug 2022 01:28:28 +0000 (01:28 +0000)]
Auto merge of #10977 - weihanglo:std-thread-scope, r=epage

Use `std::thread::scope` to replace crossbeam

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

Haven't done any benchmark. (Should we?)

21 months agoAuto merge of #10978 - andrewpollack:docs-removing-excess-in, r=weihanglo
bors [Thu, 11 Aug 2022 23:57:19 +0000 (23:57 +0000)]
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

21 months agoRemoving excess in
andrewpollack [Thu, 11 Aug 2022 23:47:52 +0000 (16:47 -0700)]
Removing excess in

21 months agoUse std::thread::scope to replace crossbeam
Weihang Lo [Thu, 11 Aug 2022 22:11:37 +0000 (23:11 +0100)]
Use std::thread::scope to replace crossbeam

21 months agoAuto merge of #10930 - ehuss:enable-windows-tests, r=weihanglo
bors [Thu, 11 Aug 2022 22:30:26 +0000 (22:30 +0000)]
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.

21 months agoFix flock being not supported on Android raising an error
Marco Capypara Köpcke [Thu, 11 Aug 2022 13:47:09 +0000 (15:47 +0200)]
Fix flock being not supported on Android raising an error

21 months agoAuto merge of #10968 - hi-rustin:rustin-patch-msg, r=ehuss
bors [Thu, 11 Aug 2022 03:23:09 +0000 (03:23 +0000)]
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`.

21 months agoAuto merge of #10962 - Nemo157:override-target-dir, r=ehuss
bors [Wed, 10 Aug 2022 21:55:46 +0000 (21:55 +0000)]
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.

21 months agoAuto merge of #10969 - joshtriplett:available-parallelism, r=epage
bors [Wed, 10 Aug 2022 17:52:21 +0000 (17:52 +0000)]
Auto merge of #10969 - joshtriplett:available-parallelism, r=epage

Switch back to `available_parallelism`

This reverts commit 8345cf5037506b38457483429fb113322c58f668 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.

21 months agoSwitch back to `available_parallelism`
Josh Triplett [Wed, 10 Aug 2022 15:49:24 +0000 (17:49 +0200)]
Switch back to `available_parallelism`

This reverts commit 8345cf5037506b38457483429fb113322c58f668. 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.

21 months agoEnsure rustc-echo-wrapper works with an overridden build.target-dir
Wim Looman [Fri, 29 Jul 2022 13:56:30 +0000 (15:56 +0200)]
Ensure rustc-echo-wrapper works with an overridden build.target-dir

21 months agoFix test
hi-rustin [Wed, 10 Aug 2022 15:19:35 +0000 (23:19 +0800)]
Fix test

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoImprove error msg for get target runner
hi-rustin [Wed, 10 Aug 2022 14:43:00 +0000 (22:43 +0800)]
Improve error msg for get target runner

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoAuto merge of #10961 - Nemo157:skip-implicit-override, r=epage
bors [Wed, 10 Aug 2022 14:30:11 +0000 (14:30 +0000)]
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)

21 months agoAuto merge of #10967 - hi-rustin:rustin-patch-docs, r=epage
bors [Wed, 10 Aug 2022 13:47:46 +0000 (13:47 +0000)]
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

21 months agoAdd `CARGO_LOG` to `Environment variables Cargo reads`
hi-rustin [Wed, 10 Aug 2022 12:51:28 +0000 (20:51 +0800)]
Add `CARGO_LOG` to `Environment variables Cargo reads`

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoOnly override published resolver when the workspace is different
Wim Looman [Fri, 29 Jul 2022 10:07:27 +0000 (12:07 +0200)]
Only override published resolver when the workspace is different

21 months agoAuto merge of #10891 - joshtriplett:rust-version-recommend-precise, r=ehuss
bors [Tue, 9 Aug 2022 22:32:17 +0000 (22:32 +0000)]
Auto merge of #10891 - joshtriplett:rust-version-recommend-precise, r=ehuss

Make the `rust-version` error recommend `cargo update --precise -p crate@ver`

People encountering a dependency with a newer `rust-version` requirement
may not know about `cargo update --precise`, or may consider alternate
approaches that may be harmful (such as pinning with a `=` dependency).

Provide specific guidance in the error message.

21 months agoHave `Edition` know what its default resolver behaviour is
Wim Looman [Fri, 29 Jul 2022 10:07:27 +0000 (12:07 +0200)]
Have `Edition` know what its default resolver behaviour is

21 months agoOnly show advice to use `cargo update --precise` for non-local packages
Josh Triplett [Tue, 2 Aug 2022 17:50:46 +0000 (10:50 -0700)]
Only show advice to use `cargo update --precise` for non-local packages

Packages in the local workspace can't get updated this way; the user
just needs to point to a different source, or otherwise update the
package themselves.

21 months agoMake the `rust-version` error recommend `cargo update -p crate@ver --precise ...`
Josh Triplett [Sat, 23 Jul 2022 06:52:49 +0000 (23:52 -0700)]
Make the `rust-version` error recommend `cargo update -p crate@ver --precise ...`

People encountering a dependency with a newer `rust-version` requirement
may not know about `cargo update --precise`, or may consider alternate
approaches that may be harmful (such as pinning with a `=` dependency).

Provide specific guidance in the error message.

If the user is using `cargo install`, suggest `cargo install --locked` instead.

21 months agoAdd unit test for invalid authors, refactor name
Ky Phan [Mon, 8 Aug 2022 15:05:43 +0000 (22:05 +0700)]
Add unit test for invalid authors, refactor name

21 months agoAuto merge of #10946 - RalfJung:docs, r=epage
bors [Sat, 6 Aug 2022 22:45:31 +0000 (22:45 +0000)]
Auto merge of #10946 - RalfJung:docs, r=epage

resolver docs: link to version requirements syntax full explanation

Staring at https://doc.rust-lang.org/cargo/reference/resolver.html#semver-compatibility, I was confused was this is a "refresher" for. Let's add a link to the main documentation this summarizes.

21 months agoresolver docs: link to version requirements syntax full explanation
Ralf Jung [Sat, 6 Aug 2022 21:01:59 +0000 (17:01 -0400)]
resolver docs: link to version requirements syntax full explanation

21 months agoAuto merge of #10943 - hi-rustin:rustin-patch-bump, r=epage
bors [Sat, 6 Aug 2022 15:14:30 +0000 (15:14 +0000)]
Auto merge of #10943 - hi-rustin:rustin-patch-bump, r=epage

Bump os_info to 3.5.0

close https://github.com/rust-lang/cargo/issues/10940

21 months agoImprove error message for an array
Ky Phan [Sat, 6 Aug 2022 06:52:39 +0000 (13:52 +0700)]
Improve error message for an array

21 months agoBump os_info to 3.5.0
hi-rustin [Sat, 6 Aug 2022 05:12:20 +0000 (13:12 +0800)]
Bump os_info to 3.5.0

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoAuto merge of #10941 - hi-rustin:rustin-patch-docs, r=weihanglo
bors [Fri, 5 Aug 2022 23:46:48 +0000 (23:46 +0000)]
Auto merge of #10941 - hi-rustin:rustin-patch-docs, r=weihanglo

Mark --timings=html unstable in the document

### What does this PR try to resolve?

Mark -timings=html unstable in the document. The document was confusing because if you try `--timings=html` it still requires the unstable flag.

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

Check out the document.

### Additional information

Other information you want to mention in this PR, such as prior arts,
future extensions, an unresolved problem, or a TODO list.

21 months agoMark -timings=html unstable in the document
hi-rustin [Fri, 5 Aug 2022 11:39:13 +0000 (19:39 +0800)]
Mark -timings=html unstable in the document

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
21 months agoAuto merge of #10935 - har7an:patch-1, r=epage
bors [Thu, 4 Aug 2022 13:59:45 +0000 (13:59 +0000)]
Auto merge of #10935 - har7an:patch-1, r=epage

Mention that aliases are recursive

Instead of duplicating portions of commands that are used identically across many aliases, the user can instead reuse any previously defined aliases.

### What does this PR try to resolve?

Today I started working with [`xtask`](https://github.com/matklad/cargo-xtask/), which is a build system based on a simple cargo alias:

```toml
[alias]
xtask = "run --package xtask --"
```

Since the word "xtask" is rather difficult to type in my opinion (at least my left hand struggles quite a bit) I wanted to add another alias, `x` as a shorthand (similar to what `build`, `run`, etc. have by default). Thereby I discovered that I needn't replicate the whole alias, because aliases are recursive. I consulted the docs and couldn't find a mention of this, hence I'm adding it as part of this PR so other users can discover it.

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

I don't think this requires a separate test, it's a minor change to the documentation only.

### Additional information

21 months agoMention that aliases are recursive
har7an [Wed, 3 Aug 2022 14:56:01 +0000 (14:56 +0000)]
Mention that aliases are recursive

Instead of duplicating portions of commands that are used identically
across many aliases, the user can instead reuse any previously defined
aliases.

21 months agoAuto merge of #10322 - eholk:reserved-windows-name, r=ehuss
bors [Thu, 4 Aug 2022 00:32:49 +0000 (00:32 +0000)]
Auto merge of #10322 - eholk:reserved-windows-name, r=ehuss

Test if reserved filenames are allowed in Windows

Recent versions of Windows have removed the limitation on filenames like `aux` or `con`. This change allows the `package::reserved_windows_name` to still pass by first trying to create a file with a reserved name to see if Windows supports it. If so, it skips the rest of the test. Otherwise, we keep the same behavior as before.

21 months agoUse old Windows path handling on CI
Eric Holk [Wed, 3 Aug 2022 23:09:06 +0000 (16:09 -0700)]
Use old Windows path handling on CI

21 months agoMove Windows path test function to test code
Eric Holk [Mon, 7 Mar 2022 22:08:29 +0000 (14:08 -0800)]
Move Windows path test function to test code

21 months agoUpdate comment
Eric Holk [Thu, 27 Jan 2022 18:08:40 +0000 (10:08 -0800)]
Update comment

21 months agoUse GetFullPathNameW to test restricted names
Eric Holk [Mon, 24 Jan 2022 19:09:07 +0000 (11:09 -0800)]
Use GetFullPathNameW to test restricted names

The previous commit tests whether the current machine supports Windows
restricted names by creating a file and checking whether that succeeds.
This commit reworks this testto use GetFullPathNameW, which can be done
without having to create and remove new files.

21 months agoTest if reserved filenames are allowed in Windows
Eric Holk [Wed, 19 Jan 2022 19:53:06 +0000 (11:53 -0800)]
Test if reserved filenames are allowed in Windows

Recent versions of Windows have removed the limitation on filenames like
`aux` or `con`. This change allows the `package::reserved_windows_name`
to still pass by first trying to create a file with a reserved name to
see if Windows supports it. If so, it skips the rest of the test.
Otherwise, we keep the same behavior as before.

21 months agoAuto merge of #10924 - akabinds:better-no-such-subcommand, r=epage
bors [Wed, 3 Aug 2022 19:17:49 +0000 (19:17 +0000)]
Auto merge of #10924 - akabinds:better-no-such-subcommand, r=epage

improve error message for `no such subcommand`

Closes #10900

21 months agotest checking full stderr output, with new message, resulting from a "did you mean"
akabinds [Wed, 3 Aug 2022 16:38:41 +0000 (11:38 -0500)]
test checking full stderr output, with new message, resulting from a "did you mean"

21 months agoimplement test checking if stderr, after using `+toolchain`, contains message stating...
akabinds [Wed, 3 Aug 2022 16:07:17 +0000 (11:07 -0500)]
implement test checking if stderr, after using `+toolchain`, contains message stating that the directive is not handled by Cargo

21 months agoMerge branch 'master' of https://github.com/rust-lang/cargo into better-no-such-subco...
akabinds [Wed, 3 Aug 2022 15:53:47 +0000 (10:53 -0500)]
Merge branch 'master' of https://github.com/rust-lang/cargo into better-no-such-subcommand

21 months agoMerge branch 'master' of https://github.com/rust-lang/cargo into better-no-such-subco...
akabinds [Wed, 3 Aug 2022 15:17:56 +0000 (10:17 -0500)]
Merge branch 'master' of https://github.com/rust-lang/cargo into better-no-such-subcommand

21 months agoAuto merge of #10934 - ehuss:revert-jobserver, r=epage
bors [Wed, 3 Aug 2022 15:03:52 +0000 (15:03 +0000)]
Auto merge of #10934 - ehuss:revert-jobserver, r=epage

Revert "Drop check for mingw32-make."

This reverts 8e35e2f044a8a042f9f2eedc35cb6db4649533c9 which seems to be causing a problem on rust-lang/rust Windows CI. I don't have time to investigate why it is failing right now. The Windows CI runs underneath make itself, so there is some recursive make action going on.  However, I can't tell why that would cause failures. Cargo is behaving as-if it is not running underneath make.

I'll try to do some investigation at a later time, for now I'd like to get the update unblocked.

21 months agoRevert "Drop check for mingw32-make."
Eric Huss [Wed, 3 Aug 2022 13:59:35 +0000 (06:59 -0700)]
Revert "Drop check for mingw32-make."

This reverts commit 8e35e2f044a8a042f9f2eedc35cb6db4649533c9.

21 months agoAuto merge of #10929 - ehuss:ignore-reason, r=weihanglo
bors [Wed, 3 Aug 2022 03:54:05 +0000 (03:54 +0000)]
Auto merge of #10929 - ehuss:ignore-reason, r=weihanglo

Add reasons to all ignored tests.

This adds a reason string to all `#[ignore]` attributes. This will be displayed when running the test (since 1.61), which can help quickly see and identify why tests are being ignored. It looks roughly like:

```
test basic ... ignored, requires nightly, CARGO_RUN_BUILD_STD_TESTS must be set
test build::simple_terminal_width ... ignored, --diagnostic-width is stabilized in 1.64
test check_cfg::features_with_cargo_check ... ignored, --check-cfg is unstable
test plugins::panic_abort_plugins ... ignored, requires rustc_private
```