Commit Graph

12369 Commits

Author SHA1 Message Date
bors fd9c4297cc Auto merge of #10811 - Diomendius:bugfix-zsh-completions-1.63.0, r=weihanglo
[BETA-1.63] Fix zsh completions for add and locate-project

This is a backport of #10810 to the `rust-1.63.0` branch. `src/etc/_cargo` is unchanged between this branch and `master` and only Zsh cares about the contents of this file, so there should be no issues with merging this.
2022-07-01 18:13:04 +00:00
Diomendius 9766342120 Fix zsh completions for add and locate-project
The zsh tab-completion script had missing line continuations which would
cause `command not found:` errors when trying to complete the
`cargo add` or `cargo locate-project` subcommands.
2022-07-01 21:52:03 +12:00
bors 542ba27b77 Auto merge of #10805 - ehuss:bump-cargo-util-beta-1.63, r=joshtriplett
[BETA-1.63] Bump cargo-util version.

This is a beta backport of #10804.  There is no version different between here and #10804 as there haven't been any changes since the branch was made a week ago.

cc #10803
2022-07-01 02:53:32 +00:00
Eric Huss 7ef922e7db Bump cargo-util version. 2022-06-30 14:26:48 -07:00
bors a5e08c4703 Auto merge of #10785 - ehuss:fix-dead_code-diag, r=Eh2406
Fix tests due to change in dead_code diagnostic.

https://github.com/rust-lang/rust/pull/97853 changed some diagnostics which is causing some tests to fail on the latest nightly.  This updates the tests to work on both stable and nightly.
2022-06-23 20:12:03 +00:00
Eric Huss 502a9c5407 Fix tests due to change in dead_code diagnostic. 2022-06-23 13:08:08 -07:00
bors ed549d8717 Auto merge of #10755 - jonhoo:stabilize-config-cli, r=ehuss
Stabilize config-cli

This stabilizes the `--config` CLI argument as per [this FCP](https://github.com/rust-lang/cargo/issues/7722#issuecomment-1114369809).

It also makes the adjustment [suggested by `@ehuss](https://github.com/rust-lang/cargo/issues/7722#issuecomment-1098612205)` to allow stabilizing `--config path` without _also_ stabilizing [`config-include`](https://doc.rust-lang.org/cargo/reference/unstable.html#config-include).

I took a guess that this would land in 1.63 and put that in the tombstone entry in the unstable docs, but let me know if that's likely to be wrong.

Closes https://github.com/rust-lang/cargo/issues/7722.

Also, I think this should probably be tagged `relnotes`.
2022-06-22 20:02:24 +00:00
Jon Gjengset 7eefb4221f Include --config in cargo help output 2022-06-21 16:24:41 +00:00
Jon Gjengset 0ecdde53eb Don't refer to --config as unstable 2022-06-21 16:07:49 +00:00
bors c9d8c28cba Auto merge of #10767 - danilhendrasr:master, r=epage
Restrict duplicate deps warning only to published packages

Fixes #10752
2022-06-21 01:37:37 +00:00
Danil Hendra Suryawan 08d10184aa Restrict duplicate deps warning only to published packages 2022-06-21 00:28:25 +00:00
bors 5db8295f92 Auto merge of #10746 - shkoo:nils/custom_target_path_cache, r=weihanglo
Use fingerprint_hash when computing fingerprints for custom targets

This makes it easier to get reproducible builds for custom targets.
2022-06-20 22:56:09 +00:00
Josh Triplett da5f35d950
Merge pull request #10761 from Muscraft/reduce-parsing
Add preloading for workspace packages in `resolve_with_previous`
2022-06-20 10:46:11 -07:00
bors 056313dbfb Auto merge of #10772 - tshepang:patch-2, r=Eh2406
capitalise, for consistency
2022-06-20 16:35:32 +00:00
Nils McCarthy b424f90edb Don't use the full pathname of a custom target json in fingerprint hashes.
This makes it easier to get reproducible builds for custom targets.
2022-06-20 09:09:52 -07:00
bors 5f5c1966a8 Auto merge of #10774 - Muscraft:update-benchsuite-deps, r=Eh2406
remove unused dependency from benchsuite

In #10754 I added a new benchmark to the benchsuite. While figuring out the best way to add the new benchmark, I added `cargo-test-support` as a dependency. It appears I missed removing it before making the PR.

This PR removes `cargo-test-support` since it is not needed
2022-06-20 15:34:50 +00:00
bors 8fd9f82a5e Auto merge of #10758 - epage:docs, r=weihanglo
docs(contrib): Add documentation for ui tests

### What does this PR try to resolve?

This only adds information about snapshot testing using `snapbox` and
keeps the functional testing documentation focused on the existing
facilities.  We can updated this as our use of `snapbox` matures.

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

I did not generate and verify the HTML

In writing this, I did notice that we define
`cargo_test_support::compare::assert` but only use it for filesystem
asserts and not binary asserts.  We should probably add our own function
that wraps `snapbox::cmd::Command::cargo()` and passes in
`cargo_test_support::compare::assert`.  I've left that out of this PR to
keep things focused.
2022-06-20 14:47:36 +00:00
Scott Schafer 5b368820a7 remove unused dependency from benchsuite 2022-06-20 09:44:48 -05:00
Ed Page 619630c3ec docs(contrib): Update API item links 2022-06-20 09:35:54 -05:00
Tshepang Mbambo f5b21bfe6e
capitalise, for consistency 2022-06-19 18:37:50 +02:00
bors 2fcd302b4d Auto merge of #10769 - jonhoo:patch-1, r=Eh2406
Remove repeated word in in dep: error message
2022-06-18 19:15:32 +00:00
Jon Gjengset 372fdfee15
Remove repeated word in in dep: error message 2022-06-18 14:07:27 -04:00
bors 17d4db0f0b Auto merge of #10754 - Muscraft:benchsuite, r=epage
Add a benchmark for workspace initialization

It [was suggested](https://github.com/rust-lang/cargo/pull/10736#discussion_r894822022) that a benchmark for workspace initialization should be added. This was suggested because there were issues with the performance of [workspace inheritance](https://github.com/rust-lang/cargo/issues/10747) as well as a general way to track the workspace initialization time across cargo changes

### Changes
- Moved common functions out of `resolve.rs` to a shared `lib.rs`
- Added a new struct to be used when creating a new benchmark
  -  This was done because `env!("CARGO_TARGET_TMPDIR")` would fail to compile when put inside of the new `lib.rs`
- Added a new workspace test for workspace inheritance
  - This new workspace does not have a repo that it was built from and if one needs to be made I can change that
2022-06-18 06:53:48 +00:00
Jon Gjengset 39c3173619 Stabilize --config
FCP
https://github.com/rust-lang/cargo/issues/7722#issuecomment-1114369809

Closes #7722.
2022-06-17 22:46:04 +00:00
Jon Gjengset 103cff694b Allow --config path without config-include
As per
https://github.com/rust-lang/cargo/issues/7722#issuecomment-1098612205
2022-06-17 22:44:57 +00:00
Scott Schafer f182411a8e add a bench for workspace initialization 2022-06-17 13:16:56 -05:00
Scott Schafer 42962da0a5 refactor parts of benchsuite/resolve.rs to a library, so it can be used by other benchmarks 2022-06-17 12:20:23 -05:00
bors 8d42b0e879 Auto merge of #10764 - kornelski:clarify-http, r=Eh2406
Use specific terminology for sparse HTTP-based registry

Before the options is popularized, I'd like to take opportunity to give it a unique name used consistently. It's been called "http" registry, but that's a rather generic term, especially that existing git-based registry also uses HTTP as its transport.

New registry URLs use `sparse+https://` prefix, so calling it "sparse" registry seems more appropriate.

#9069
2022-06-17 16:46:26 +00:00
Jacob Finkelman 288856b778 HTTP-based -> sparse
Co-authored-by: Arlo Siemsen <arkixml@gmail.com>
2022-06-17 16:45:33 +00:00
Ed Page d847468768 docs(contrib): Add documentation for ui tests
This only adds information about snapshot testing using `snapbox` and
keeps the functional testing documentation focused on the existing
facilities.  We can updated this as our use of `snapbox` matures.

In writing this, I did notice that we define
`cargo_test_support::compare::assert` but only use it for filesystem
asserts and not binary asserts.  We should probably add our own function
that wraps `snapbox::cmd::Command::cargo()` and passes in
`cargo_test_support::compare::assert`.  I've left that out of this PR to
keep things focused.
2022-06-17 10:25:41 -05:00
Kornel a9faf49040 Use specific terminology for sparse HTTP-based registry
Git-based registry uses HTTP too
2022-06-17 15:09:56 +01:00
Scott Schafer cda5f82498 add preloading for workspace packages in `resolve_with_previous` so manifests aren't parsed twice 2022-06-16 15:34:22 -05:00
bors 17f8088d6e Auto merge of #10753 - epage:clap32-deprecated, r=weihanglo
chore: Upgrade to clap 3.2

I decided to use cargo as a test case for upgrading to clap 3.2 prior to release.  From the builder API's perspective, a lot has change.  While the changelog summarizes it, the release announcement is still pending.  In short, the API is now typed.  You declare what type an `Arg` is and access it by that type.  flags (both `is_present` and `occurrences_of`) are also now specified through `ArgAction` and the result gets stored like any other arg value.  I made a `ArgMatchesExt::flag` and `command_prelude::flag` functions to make working with these easier.

Now that clap exposes non-panicking variants of its functions, I switched from a "look before you leap" approach with `is_arg_valid` to a "better to ask forgiveness than permission" with checking the error variant.  I decided to just make a convenience to swallow that error type.  Not a fan of how loose things are but I think this will just be something we iterate on over time.
2022-06-14 23:11:47 +00:00
Ed Page fc0ca1e178 refactor: Resolve clap 3.2 deprecations 2022-06-13 10:02:23 -05:00
Ed Page 6f475f090e chore: Upgrade to clap 3.2 2022-06-13 10:02:23 -05:00
Ed Page 55f8a260e0 refactor(cli): Centralize reading of verbose 2022-06-13 10:01:35 -05:00
bors 6b8e192226 Auto merge of #10738 - arlosi:auth-testingonly, r=ehuss
Improve testing framework for http registries

Improve integration of the http server introduced by the http-registry feature.

The same HTTP server is used for serving downloads, the index, and the API within the test framework.

This makes it easier to write tests that deal with authentication and http registries.

Most of this change is pulled from #10592. Getting it in separately should make the other change easier to review.

r? `@Eh2406`
2022-06-11 00:06:55 +00:00
Arlo Siemsen 24dac452c5 Improve testing framework for http registries
Improve integration of the http server introduced by the http-registry feature.
Now the same HTTP server is used for serving downloads, the index, and
the API.

This makes it easier to write tests that deal with authentication and
http registries.
2022-06-10 16:51:35 -05:00
bors 1b3fce78d6 Auto merge of #10728 - jorendorff:patch-1, r=ehuss
doc: Improve example of using the links field

`"foo"` doesn't really help say what this is.
2022-06-10 01:11:04 +00:00
bors 4d92f07f34 Auto merge of #10739 - weihanglo:revert-num-cpus, r=epage
Revert #10427: switch from num_cpus

Same as #10737 but on nightly
2022-06-09 01:18:36 +00:00
Weihang Lo 8345cf5037
Revert #10427: switch from num_cpus
This reverts commit 6d11f9e7d4, reversing
changes made to c5cdd25c14.
2022-06-09 07:47:00 +08:00
bors 85e457e158 Auto merge of #10725 - arlosi:http-cratesio, r=Eh2406
Make -Z http-registry use index.crates.io when accessing crates-io

Use `sparse+https://index.crates.io/` to access crates.io when `-Z http-registry` is set.

* `Cargo.lock` files still emit the github URL `https://github.com/rust-lang/crates.io-index`.
* Allows publishing to a source-replaced `crates-io` only for `index.crates.io`. Other source-replacements of `crates-io` are still blocked.

Fixes #10722
r? `@Eh2406`
2022-06-07 21:57:52 +00:00
Arlo Siemsen 445db94bfe Make -Z http-registry use index.crates.io by default 2022-06-07 15:30:34 -05:00
bors bc3b99d0ff Auto merge of #10717 - jsitnicki:respect-git-submod-update-none, r=epage
Respect submodule update=none strategy in .gitmodules

Git lets users define the default update/checkout strategy for a submodule
by setting the `submodule.<name>.update` key in `.gitmodules` file.

If the update strategy is `none`, the submodule will be skipped during
update. It will not be fetched and checked out:

1. *foo* is a big git repo

```
/tmp $ git init foo
Initialized empty Git repository in /tmp/foo/.git/
/tmp $ dd if=/dev/zero of=foo/big bs=1000M count=1
1+0 records in
1+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 0.482087 s, 2.2 GB/s
/tmp $ git -C foo add big
/tmp $ git -C foo commit -m 'I am big'
[main (root-commit) 84fb533] I am big
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 big
```

2. *bar* is a repo with a big submodule with `update=none`

```
/tmp $ git init bar
Initialized empty Git repository in /tmp/bar/.git/
/tmp $ git -C bar submodule add file:///tmp/foo foo
Cloning into '/tmp/bar/foo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 1 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), 995.50 KiB | 338.00 KiB/s, done.
/tmp $ git -C bar config --file .gitmodules submodule.foo.update none
/tmp $ cat bar/.gitmodules
[submodule "foo"]
        path = foo
        url = file:///tmp/foo
        update = none
/tmp $ git -C bar commit --all -m 'I have a big submodule with update=none'
[main (root-commit) 6c355ea] I have a big submodule not updated by default
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 foo
```

3. *baz* is a clone of *bar*, notice *foo* submodule gets skipped

```
/tmp $ git clone --recurse-submodules file:///tmp/bar baz
Cloning into 'baz'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Submodule 'foo' (file:///tmp/foo) registered for path 'foo'
Skipping submodule 'foo'
/tmp $ git -C baz submodule update --init
Skipping submodule 'foo'
/tmp $
```

Cargo, on the other hand, ignores the submodule update strategy set in
`.gitmodules` properties when updating dependencies. Such behavior can
be considered against the wish of the crate publisher.

4. *bar* is now a lib with a big submodule with update disabled

```
/tmp $ cargo init --lib bar
     Created library package
/tmp $ git -C bar add .
/tmp $ git -C bar commit -m 'I am a lib with a big submodule but update=none'
[main eb07cf7] I am a lib with a big submodule but update=none
 3 files changed, 18 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Cargo.toml
 create mode 100644 src/lib.rs
/tmp $
```

5. *qux* depends on *bar*, notice *bar*'s submodules are fetched

```
/tmp $ cargo init qux && cd qux
     Created binary (application) package
/tmp/qux $ echo -e '[dependencies.bar]\ngit = "file:///tmp/bar"' >> Cargo.toml
/tmp/qux $ time cargo update
    Updating git repository `file:///tmp/bar`
    Updating git submodule `file:///tmp/foo`

real    0m22.182s
user    0m20.402s
sys     0m1.714s
/tmp/qux $
```

Fix it by checking if a Git repository submodule should be updated when
cargo processes dependencies.

6. With the change applied, submodules with `update=none` are skipped

```
/tmp/qux $ cargo cache -a > /dev/null
/tmp/qux $ time ~/src/cargo/target/debug/cargo update
    Updating git repository `file:///tmp/bar`
    Skipping git submodule `file:///tmp/foo`

real    0m0.029s
user    0m0.021s
sys     0m0.008s
/tmp/qux $
```

Fixes #4247.
2022-06-07 14:29:02 +00:00
Jakub Sitnicki 26031b9069 Respect submodule update=none strategy in .gitmodules
Git lets users define the default update/checkout strategy for a submodule
by setting the `submodule.<name>.update` key in `.gitmodules` file.

If the update strategy is `none`, the submodule will be skipped during
update. It will not be fetched and checked out:

1. *foo* is a big git repo

```
/tmp $ git init foo
Initialized empty Git repository in /tmp/foo/.git/
/tmp $ dd if=/dev/zero of=foo/big bs=1000M count=1
1+0 records in
1+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 0.482087 s, 2.2 GB/s
/tmp $ git -C foo add big
/tmp $ git -C foo commit -m 'I am big'
[main (root-commit) 84fb533] I am big
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 big
```

2. *bar* is a repo with a big submodule with `update=none`

```
/tmp $ git init bar
Initialized empty Git repository in /tmp/bar/.git/
/tmp $ git -C bar submodule add file:///tmp/foo foo
Cloning into '/tmp/bar/foo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 1 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), 995.50 KiB | 338.00 KiB/s, done.
/tmp $ git -C bar config --file .gitmodules submodule.foo.update none
/tmp $ cat bar/.gitmodules
[submodule "foo"]
        path = foo
        url = file:///tmp/foo
        update = none
/tmp $ git -C bar commit --all -m 'I have a big submodule with update=none'
[main (root-commit) 6c355ea] I have a big submodule not updated by default
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 foo
```

3. *baz* is a clone of *bar*, notice *foo* submodule gets skipped

```
/tmp $ git clone --recurse-submodules file:///tmp/bar baz
Cloning into 'baz'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Submodule 'foo' (file:///tmp/foo) registered for path 'foo'
Skipping submodule 'foo'
/tmp $ git -C baz submodule update --init
Skipping submodule 'foo'
/tmp $
```

Cargo, on the other hand, ignores the submodule update strategy set in
`.gitmodules` properties when updating dependencies. Such behavior can
be considered against the wish of the crate publisher.

4. *bar* is now a lib with a big submodule with update disabled

```
/tmp $ cargo init --lib bar
     Created library package
/tmp $ git -C bar add .
/tmp $ git -C bar commit -m 'I am a lib with a big submodule but update=none'
[main eb07cf7] I am a lib with a big submodule but update=none
 3 files changed, 18 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 Cargo.toml
 create mode 100644 src/lib.rs
/tmp $
```

5. *qux* depends on *bar*, notice *bar*'s submodules are fetched

```
/tmp $ cargo init qux && cd qux
     Created binary (application) package
/tmp/qux $ echo -e '[dependencies.bar]\ngit = "file:///tmp/bar"' >> Cargo.toml
/tmp/qux $ time cargo update
    Updating git repository `file:///tmp/bar`
    Updating git submodule `file:///tmp/foo`

real    0m22.182s
user    0m20.402s
sys     0m1.714s
/tmp/qux $
```

Fix it by checking if a Git repository submodule should be updated when
cargo processes dependencies.

6. With the change applied, submodules with `update=none` are skipped

```
/tmp/qux $ cargo cache -a > /dev/null
/tmp/qux $ time ~/src/cargo/target/debug/cargo update
    Updating git repository `file:///tmp/bar`
    Skipping git submodule `file:///tmp/foo`

real    0m0.029s
user    0m0.021s
sys     0m0.008s
/tmp/qux $
```

Fixes #4247.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
2022-06-07 14:52:02 +02:00
Jason Orendorff c586652fdf
Update manifest.md
Remove comment from example toml to prose.
2022-06-06 11:55:47 -05:00
bors 7d289b1711 Auto merge of #10713 - flip1995:rust-version-env, r=epage
Expose rust-version through env var

This adds another env var that is exposed by cargo. In Clippy we would like to use that in order to efficiently check if a rust-version is set for the current package: https://github.com/rust-lang/rust-clippy/pull/8774

Currently we either have to parse the `Cargo.toml` file ourselves or use the `cargo_metadata` crate which has a notable performance impact when running `clippy-driver` on single files.
2022-06-06 13:19:38 +00:00
flip1995 0852f5413e
Expose rust-version through env var 2022-06-06 12:04:20 +02:00
bors a9efb069c4 Auto merge of #10676 - djmcgill:origin/master, r=weihanglo
add validation for string "true"/"false" in lto profile

### What does this PR try to resolve?
Adds a special-cased error message for when `lto` is set to the _string_ `"true"`/`"false"` which is surprisingly (I was surprised anyway) not allowed and the error message is ambiguous. The new error message makes it clear what values are accepted.
Fixes https://github.com/rust-lang/cargo/issues/10572

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

 <!-- Demonstrate how you test this change and guide reviewers through your PR.
With a smooth review process, a pull request usually gets reviewed quicker.

If you don't know how to write and run your tests, please read the guide:
https://doc.crates.io/contrib/tests -->

Uh I've not actually tested yet that's the WIP part. But put
```
[profile.dev]
lto="false"
```
in your TOML and run `cargo build`, check that you get the new error message and that it makes sense and is helpful.

### Additional information

It's worth noting that as per https://github.com/rust-lang/rust/pull/97051 this doesn't fix the _real_ problem here IMO which is that [rust's `opt_parse_bool` cli parsing](491f619f56/compiler/rustc_session/src/options.rs (L456)) doesn't accept true/false which certainly seems an ad-hoc historical choice to me on first glance but also it's a much bigger change to change those semantics than this error message.
2022-06-05 23:03:21 +00:00
David McGillicuddy 0daf70d816 Special case the string true/false error message for LTO profile arg 2022-06-05 23:30:29 +01:00