bors [Thu, 24 Mar 2022 22:28:19 +0000 (22:28 +0000)]
Auto merge of #10470 - arlosi:http, r=Eh2406
HTTP registry implementation
Implement HTTP registry support described in [RFC 2789](https://github.com/rust-lang/rfcs/pull/2789).
Adds a new unstable flag `-Z http-registry` which allows cargo to interact with remote registries served over http rather than git. These registries can be identified by urls starting with `sparse+http://` or `sparse+https://`.
When fetching index metadata over http, cargo only downloads the metadata for needed crates, which can save significant time and bandwidth over git.
The format of the http index is identical to a checkout of a git-based index.
This change is based on `@jonhoo's` PR #8890.
cc `@Eh2406`
Remaining items:
- [x] Performance measurements
- [x] Make unstable only
- [x] Investigate unification of download system. Probably best done in separate change.
- [x] Unify registry tests (code duplication in `http_registry.rs`)
- [x] Use existing on-disk cache, rather than adding a new one.
bors [Wed, 23 Mar 2022 21:08:35 +0000 (21:08 +0000)]
Auto merge of #10047 - jonhoo:ignore-symlink-dir, r=ehuss
Add tests for ignoring symlinks
This adds tests for the expected behavior in https://github.com/rust-lang/cargo/issues/10032. Interestingly, these tests pass (🎉). Will update that issue with more details shortly, but figured these tests were worthwhile to add to the testsuite anyway now that I've written them.
bors [Mon, 21 Mar 2022 21:19:23 +0000 (21:19 +0000)]
Auto merge of #10494 - ehuss:deps-of-doc, r=Eh2406
Update doc string for deps_of/compute_deps.
I noticed the `compute_deps` doc string was outdated due to some recent refactorings. This updates the doc comments to try to clarify them and make them more accurate.
bors [Mon, 21 Mar 2022 18:48:36 +0000 (18:48 +0000)]
Auto merge of #10394 - dtolnay-contrib:displayerror, r=ehuss
Consistently use crate::display_error on errors during drain
As suggested in https://github.com/rust-lang/cargo/pull/10383#discussion_r808178038 and https://github.com/rust-lang/cargo/pull/10383#discussion_r808182199.
bors [Thu, 17 Mar 2022 21:43:09 +0000 (21:43 +0000)]
Auto merge of #10482 - arlosi:refactor_load, r=Eh2406
Refactor RegistryData::load to handle management of the index cache
Enables registry implementations to signal if the cache is valid on a per-request basis.
Fixes a bug introduced by #10064 that caused Cargo not to update for several cases in a release build because it believed the index cache to be valid when it was not. The issue only occurred in release builds because debug builds verify that the cache contents is correct (by refreshing it).
Previously `current_version` was called by the index to determine whether the cache was valid. In the new model, `RegistryData::load` is passed the current version of the cache and returns an enum to indicate the status of the cached data.
Arlo Siemsen [Wed, 16 Mar 2022 20:23:48 +0000 (13:23 -0700)]
Refactor RegistryData::load to handle management of the index cache itself.
This enables registry implementations to signal if the cache is valid
on a per-request basis.
Fixes a bug introduced by #10064 that caused Cargo not to update for
several cases in a release build because it believed the index cache to
be valid when it was not.
bors [Thu, 17 Mar 2022 17:17:11 +0000 (17:17 +0000)]
Auto merge of #10483 - cuviper:vcs--, r=Eh2406
Separate VCS command paths with "--"
When building a VCS command, there may be ambiguity if a relative path
looks like an option, like "-path" or "--path". All of the VCS commands
that we use support a bare "--" separator for non-option arguments,
which is good practice to apply here.
This does not affect the cargo CLI, as it already makes sure to use
absolute paths for these calls via `value_of_path()`.
Josh Stone [Thu, 17 Mar 2022 16:31:59 +0000 (09:31 -0700)]
Separate VCS command paths with "--"
When building a VCS command, there may be ambiguity if a relative path
looks like an option, like "-path" or "--path". All of the VCS commands
that we use support a bare "--" separator for non-option arguments,
which is good practice to apply here.
This does not affect the cargo CLI, as it already makes sure to use
absolute paths for these calls via `value_of_path()`.
…it panics with `thread 'main' panicked at 'activated_features for invalid package: features did not find PackageId <dbg-info>`, but we would expect this to work normally.
### Tasks
- [x] reproduce issue in new test
- [x] figure out why the test is fixed but the real-world example isn't
- [x] find a fix
Weihang Lo [Mon, 14 Mar 2022 23:22:00 +0000 (07:22 +0800)]
Bump git2@0.14.2 and libgit2-sys@0.13.2
The previous libgit2-sys release forgot to include the fix of libgit2 1.4.2.
https://github.com/rust-lang/git2-rs/pull/820#issuecomment-1064284814
That might cause problems when people don't have "Git for Windows"
installed on their machines.
Caused by:
No such file or directory (os error 2)
````
Per discussion on #10441, this behavior is undesirable and hopefully used infrequently enough that we can change the UI for it. This patch will now only allow one value per --sync argument.
I didn't regenerate other doc files as it's not clear to me how/when that should be done.
bors [Fri, 11 Mar 2022 15:50:15 +0000 (15:50 +0000)]
Auto merge of #10471 - Eh2406:credential_process, r=weihanglo
Use types to make clere (credential process || token)
`RegistryConfig` represents what credentials we have read from disk. It was a
```
token: Option<String>,
credential_process: Option<(PathBuf, Vec<String>)>,
```
with runtime checks that they were not both `Some`.
This changes it to be an Enum `None|Token|Process`.
There is somewhat more code, but I think this is clearer.
This also changed some `Option<String>` arguments to `Option<&str>`.
bors [Tue, 1 Mar 2022 20:38:55 +0000 (20:38 +0000)]
Auto merge of #10443 - alexcrichton:disable-dependabot, r=ehuss
Disable dependabot
I don't think this has ever actually sent a meaningful version bump PR
we weren't already aware of, so unless someone else wants to be in
charge of these I'm going to go ahead and disable dependabot.
bors [Tue, 1 Mar 2022 18:12:20 +0000 (18:12 +0000)]
Auto merge of #10442 - Urgau:git2-update, r=alexcrichton
Update git2 dependencies
This pull-request update git2 to 0.14.1 and git2-curl to 0.15.0 and libgit2-sys to 0.13.1.
This fix a memory corruption that I have locally when running the testsuite:
```
==2338650== Uninitialised value was created by a stack allocation
==2338650== at 0x11FE3A0: git2::remote::Remote::fetch (remote.rs:276)
```
Alex Crichton [Tue, 1 Mar 2022 17:53:20 +0000 (09:53 -0800)]
Disable dependabot
I don't think this has ever actually sent a meaningful version bump PR
we weren't already aware of, so unless someone else wants to be in
charge of these I'm going to go ahead and disable dependabot.
Sebastian Thiel [Tue, 1 Mar 2022 07:18:14 +0000 (15:18 +0800)]
A cry for help with a fix for the issue that looks like a hack.
In order not to give up and create a basis for discussion while ending
my 3h oddisey on finding a fix for today, I present something that
seems to work even though I hope there are better ways to solve this.
Sebastian Thiel [Tue, 1 Mar 2022 02:19:10 +0000 (10:19 +0800)]
further simplify the reproduction code
This is a hacky way of making changes while leaving everything else,
despite it being deactivated for now, in the hopes to not forget
to put additional difficulties back in once this particular issue
is fixed.
Arlo Siemsen [Wed, 23 Feb 2022 22:51:31 +0000 (14:51 -0800)]
Remove the update method on registry functions. Instead of explicitly
updating, registries now update as needed. To force a registry to
ensure the latest copy of crate metadata is available, a new method
called `invalidate_cache` is added. This method will cause the registry
to update the next time `block_until_ready` is called.
bors [Mon, 28 Feb 2022 19:29:07 +0000 (19:29 +0000)]
Auto merge of #10395 - jonhoo:fix-10206, r=alexcrichton
Enable propagating host rustflags to build scripts
### What does this PR try to resolve?
This PR primarily fixes #10206, but in doing so it also slightly modifies the interface for the unstable `target-applies-to-host` feature (#9453), and adds the unstable `target-applies-to-host-kind` flag to mirror `target-applies-to-host` for build scripts and other host artifacts.
The commit messages have more in-depth discussion.
### How should we test and review this PR?
The test case from #10206 now works rather than producing an error. It has also been added a regression test case. A few additional test cases have also been added to handle the expected behavior around rustflags for build scripts with and without `target-applies-to-host-kind` enabled.
### Additional information
1. This changes the interface for `target-applies-to-host` so that it does not need to be specified twice to be used. And it can still be set through configuration files using the `[unstable]` table. However, we may(?) want to pick a stable format for in-file configuration of this setting unless we intend for it to only ever be a command-line flag.
2. It may be that `target-applies-to-host-kind` is never behavior we want users to turn on, and that it should therefore simply be removed and hard-coded as being `false`.
3. It's not entirely clear how `target-applies-to-host-kind` should interact with `-Zmultitarget`. If, for example, `requested_kinds = [HostTarget, SomeOtherTarget]` and `kind.is_host()`, should `RUSTFLAGS` take effect or not? For the time being I've just hard-coded the behavior for single targets, and the answer would be "no".
bors [Mon, 28 Feb 2022 17:15:55 +0000 (17:15 +0000)]
Auto merge of #10425 - epage:search, r=alexcrichton
feat(search): Highlight search term
This supersedes #10116. For the requested colored-output tests, this followed the pattern of the `fix` tests which just detects whether colored output is used or not. The `cache_messages` actually verify the output is colored but that is because it can just compare to a rustc call's output. Getting the colored output correct by hand in a test (with all of the resets) is a bit messy and would be brittle.
This was done in an exercise in exploring ways to generalize colored output support in preparation for `cargo-add` doing some colored output as well.
I converted all output calls to use this approach, even if coloring wasn't used, for consistency. I considered coloring the overflow message but decided to hold off on that for now (either a warning-yellow or a hint-gray).
bors [Sun, 27 Feb 2022 19:20:56 +0000 (19:20 +0000)]
Auto merge of #10428 - Urgau:check-cfg-features-rustdoc, r=ehuss
Add -Z check-cfg-features support for rustdoc
This PR is a follow to https://github.com/rust-lang/cargo/pull/10408 where support for compile-time checking of features was implemented for `rustc`.
At the time `rustdoc` support wasn't yet merged, but now that it has been [merged](https://github.com/rust-lang/rust/pull/94154), this pull-request add support for it in the `doc` and `test --doc` (doctest) mode.
Weihang Lo [Sun, 13 Feb 2022 09:51:10 +0000 (17:51 +0800)]
Override target crate-type for `cargo rustc --crate-type`
Instead of writing override rules all over the compilation logic, this
commit simply override the unit created by `generate_targets`.
As a result, `cargo rustc --crate-type` behaves exactly as expected.