]> git.proxmox.com Git - cargo.git/log
cargo.git
3 years agoAuto merge of #9164 - ehuss:config-search-stop, r=Eh2406
bors [Thu, 11 Feb 2021 14:48:46 +0000 (14:48 +0000)]
Auto merge of #9164 - ehuss:config-search-stop, r=Eh2406

Prevent testsuite from loading config out of sandbox.

This adds a limit to prevent config loading from walking outside of the test sandbox root. There was an environment variable for this, but that doesn't work too well for tests that were loading the config directly.

Fixes #9107

3 years agoPrevent testsuite from loading config out of sandbox.
Eric Huss [Thu, 11 Feb 2021 01:39:38 +0000 (17:39 -0800)]
Prevent testsuite from loading config out of sandbox.

3 years agoAuto merge of #9153 - calavera:strip_options, r=ehuss
bors [Wed, 10 Feb 2021 00:19:10 +0000 (00:19 +0000)]
Auto merge of #9153 - calavera:strip_options, r=ehuss

Allow `true` and `false` as options for `strip` option

This follows the convention of `lto` and `debug` that allow `true` for
the highest level, and `false` for disabled.

Signed-off-by: David Calavera <david.calavera@gmail.com>
3 years agoAllow `true` and `false` as options for `strip` option
bors [Wed, 10 Feb 2021 00:19:10 +0000 (00:19 +0000)]
Allow `true` and `false` as options for `strip` option

This follows the convention of `lto` and `debug` that allow `true` for
the highest level, and `false` for disabled.

Signed-off-by: David Calavera <david.calavera@gmail.com>
3 years agoAuto merge of #9133 - alexcrichton:git-default-branch, r=ehuss
bors [Tue, 9 Feb 2021 23:42:27 +0000 (23:42 +0000)]
Auto merge of #9133 - alexcrichton:git-default-branch, r=ehuss

Change git dependencies to use `HEAD` by default

This commit follows through with work started in #8522 to change the
default behavior of `git` dependencies where if not branch/tag/etc is
listed then `HEAD` is used instead of the `master` branch. This involves
also changing the default lock file format, now including a `version`
marker at the top of the file notably as well as changing the encoding
of `branch=master` directives in `Cargo.toml`.

If we did all our work correctly then this will be a seamless change.
First released on stable in 1.47.0 (2020-10-08) Cargo has been emitting
warnings about situations which may break in the future. This means that
if you don't specify `branch = 'master'` but your HEAD branch isn't
`master`, you've been getting a warning. Similarly if your dependency
graph used both `branch = 'master'` as well as specifying nothing, you
were receiving warnings as well. These two situations are broken by this
commit, but it's hoped that by giving enough times with warnings we
don't actually break anyone in practice.

3 years agoSquash warnings on the nightly channel
Alex Crichton [Tue, 9 Feb 2021 15:30:08 +0000 (07:30 -0800)]
Squash warnings on the nightly channel

3 years agoAdd back in deleted tests
Alex Crichton [Tue, 9 Feb 2021 15:29:01 +0000 (07:29 -0800)]
Add back in deleted tests

3 years agoAuto merge of #9152 - dzmitry-lahoda:patch-1, r=Eh2406
bors [Mon, 8 Feb 2021 16:20:08 +0000 (16:20 +0000)]
Auto merge of #9152 - dzmitry-lahoda:patch-1, r=Eh2406

appendix auth gcm link to new repo (which is xplat)

3 years agogcm link to new repo (which is xplat)
Dzmitry Lahoda [Mon, 8 Feb 2021 16:13:07 +0000 (19:13 +0300)]
gcm link to new repo (which is xplat)

3 years agoAuto merge of #9148 - bjorn3:fix_ci, r=ehuss
bors [Sat, 6 Feb 2021 19:12:01 +0000 (19:12 +0000)]
Auto merge of #9148 - bjorn3:fix_ci, r=ehuss

Fix warnings of the new non_fmt_panic lint

This fixes the CI failure since the latest nightly. See https://github.com/rust-lang/rust/pull/81645

3 years agoFix warnings of the new non_fmt_panic lint
bjorn3 [Sat, 6 Feb 2021 17:40:42 +0000 (18:40 +0100)]
Fix warnings of the new non_fmt_panic lint

3 years agoAuto merge of #9142 - ehuss:fix-doc-orphan, r=Eh2406
bors [Fri, 5 Feb 2021 18:11:29 +0000 (18:11 +0000)]
Auto merge of #9142 - ehuss:fix-doc-orphan, r=Eh2406

Fix panic with doc collision orphan.

As I feared, the collision removal added in #9077 caused problems due to orphans left in the unit graph. Ironically, it was the collision warning detection code which failed, as it iterates over all the keys of the graph.

The solution is to remove all orphans from the graph after collisions have been removed.

Fixes #9136

3 years agoFix panic with doc collision orphan.
Eric Huss [Fri, 5 Feb 2021 18:02:34 +0000 (10:02 -0800)]
Fix panic with doc collision orphan.

3 years agoFix a bug loading v2 lockfiles
Alex Crichton [Thu, 4 Feb 2021 18:37:26 +0000 (10:37 -0800)]
Fix a bug loading v2 lockfiles

This commit fixes a bug in Cargo where after `DefaultBranch` and
`Branch("master")` are considered distinct no v2 lockfile would by
default match a dependency specification with the `branch = 'master'`
annotation. A feature of the v2 lockfile, however, is that no mention of
a branch is equivalent to the `master` branch.

The bug here is fixed by updating the code which registers a previous
lock file with our `PackageRegistry`. This code registers nodes, only
with v2 lock files, for both default and `master` branch git
dependencies. This way requests for either one will get matched now that
they're considered distinct.

3 years agoChange git dependencies to use `HEAD` by default
Alex Crichton [Thu, 4 Feb 2021 16:33:33 +0000 (08:33 -0800)]
Change git dependencies to use `HEAD` by default

This commit follows through with work started in #8522 to change the
default behavior of `git` dependencies where if not branch/tag/etc is
listed then `HEAD` is used instead of the `master` branch. This involves
also changing the default lock file format, now including a `version`
marker at the top of the file notably as well as changing the encoding
of `branch=master` directives in `Cargo.toml`.

If we did all our work correctly then this will be a seamless change.
First released on stable in 1.47.0 (2020-10-08) Cargo has been emitting
warnings about situations which may break in the future. This means that
if you don't specify `branch = 'master'` but your HEAD branch isn't
`master`, you've been getting a warning. Similarly if your dependency
graph used both `branch = 'master'` as well as specifying nothing, you
were receiving warnings as well. These two situations are broken by this
commit, but it's hoped that by giving enough times with warnings we
don't actually break anyone in practice.

3 years agoAuto merge of #9131 - ehuss:fix-vendor-permissions, r=alexcrichton
bors [Thu, 4 Feb 2021 15:52:52 +0000 (15:52 +0000)]
Auto merge of #9131 - ehuss:fix-vendor-permissions, r=alexcrichton

Fix permission issue with `cargo vendor`.

I think there was an unintended regression in #8937 where the vendored output does not retain the original permissions.

Fixes #9127.

3 years agoFix permission issue with `cargo vendor`.
Eric Huss [Thu, 4 Feb 2021 00:55:05 +0000 (16:55 -0800)]
Fix permission issue with `cargo vendor`.

3 years agoAuto merge of #9112 - alexcrichton:split-debuginfo, r=ehuss
bors [Wed, 3 Feb 2021 22:50:15 +0000 (22:50 +0000)]
Auto merge of #9112 - alexcrichton:split-debuginfo, r=ehuss

Add split-debuginfo profile option

This commit adds a new `split-debuginfo` option to Cargo compilation
profiles which gets forwarded to the `-Csplit-debuginfo` codegen option
in rustc. This commit also sets the default, only on macOS, to be
`-Csplit-debuginfo=unpacked`. The purpose of this change is to leverage
rust-lang/rust#79570 to avoid running `dsymutil` on incremental builds
while also preserving a pleasant debugging experience by default. This
should lead to much faster incremental build times on macOS since
`dsymutil` isn't exactly the speediest tool in the world.

This is technically a breaking change in Cargo because we're no longer
by-default producing the `*.dSYM` folders on macOS. If those are still
desired, however, authors can always run `dsymutil` themselves or
otherwise configure `split-debuginfo = 'packed'` in their
manifest/profile configuration.

3 years agoDon't change the macOS default just yet
Alex Crichton [Tue, 2 Feb 2021 21:38:12 +0000 (13:38 -0800)]
Don't change the macOS default just yet

3 years agoAuto merge of #9126 - ehuss:registry-builder, r=alexcrichton
bors [Wed, 3 Feb 2021 15:56:05 +0000 (15:56 +0000)]
Auto merge of #9126 - ehuss:registry-builder, r=alexcrichton

Add RegistryBuilder for tests, and update crates-io error handling.

This adds `RegistryBuilder` to the test suite to make it more flexible to create different registry setups, and to reuse code a little more easily.

This also makes a small adjustment to the registry API to add a `ResponseError` type to make it easier to work with API errors.  As part of this, some tests were added to validate the API behavior for response errors.  There are only a few very small changes here:
* Extra newlines are removed from the headers printed in the error message.
* The UTF-8 error now also includes the text "invalid response from server".
* The "file too large" crates.io publish error now displays the tarball size.  (There is no test for this because it is only issued for talking to `crates.io`.)

Split from #9111.

3 years agoAuto merge of #9125 - ehuss:index-docs, r=alexcrichton
bors [Wed, 3 Feb 2021 15:21:05 +0000 (15:21 +0000)]
Auto merge of #9125 - ehuss:index-docs, r=alexcrichton

Add some documentation for index and registry stuff.

This adds some internal docs for index and registry things.

Split out of #9111.

3 years agoAuto merge of #9122 - ehuss:fix-multiple-run-custom-build, r=alexcrichton
bors [Wed, 3 Feb 2021 02:09:41 +0000 (02:09 +0000)]
Auto merge of #9122 - ehuss:fix-multiple-run-custom-build, r=alexcrichton

Fix env/cfg set for `cargo test` and `cargo run`.

There are some situations where a build script may need to run multiple times for the same package during the same `cargo` session.  There was a bug in that some of the values in the `Compilation` struct didn't handle this case.  The solution here is to be more careful about how this extra data is associated with `Unit`s, instead of assuming a package's build script only runs once.

The things that were not being handled properly:

* `Compilation::extra_env`, which is the output of `cargo:rustc-env` in build scripts.  The solution here is to use the `Metadata` hash which is used elsewhere for distinguishing build script outputs.
* `Compilation::cfgs`, which is the output of `cargo:rustc-cfg` in build scripts and the features to be set, and this is only used for doctests.  The solution here is to just add those `--cfg` flags directly in the `Doctest` struct.

The situations that cause a build script to be run multiple times:

* A package needed for both the host and target.  In the test here, this was accomplished with a proc-macro (which has to be `host`) and a cyclical dev dependency, but there are many other ways to trigger this.
* Something built with different features (with the new feature resolver), usually due to host/target differences.
* Something built with different profile settings, usually due to host/target differences.

Fixes #9100

3 years agoAdd note about `cargo:rustc-env` variables set at runtime.
Eric Huss [Wed, 3 Feb 2021 02:07:12 +0000 (18:07 -0800)]
Add note about `cargo:rustc-env` variables set at runtime.

3 years agoAdd a ResponseError for registry API interaction.
Eric Huss [Thu, 28 Jan 2021 20:39:51 +0000 (12:39 -0800)]
Add a ResponseError for registry API interaction.

The intent here is to make it easier to work with API errors.

This also includes some new tests for checking network errors.

3 years agoAdd RegistryBuilder to help initializing test registries.
Eric Huss [Thu, 28 Jan 2021 19:54:27 +0000 (11:54 -0800)]
Add RegistryBuilder to help initializing test registries.

The intent here is to make it more flexible to create different registry
setups, and to reuse code a little more easily.

3 years agoAdd some documentation for index and registry stuff.
Eric Huss [Thu, 28 Jan 2021 19:13:47 +0000 (11:13 -0800)]
Add some documentation for index and registry stuff.

3 years agoFix env/cfg set for `cargo test` and `cargo run`.
Eric Huss [Tue, 2 Feb 2021 00:28:23 +0000 (16:28 -0800)]
Fix env/cfg set for `cargo test` and `cargo run`.

3 years agoCache failures in the rustc info cache
Alex Crichton [Mon, 1 Feb 2021 18:39:36 +0000 (10:39 -0800)]
Cache failures in the rustc info cache

This commit updates the rustc info cache to cache failures to execute
rustc as well as successes. This fixes a weird issue where if you're
probing for flags the `rustc_info_cache` test fails on channels which
don't have the flag since previously a failure to execute rustc resulted
in never caching the result.

3 years agoAdd split-debuginfo profile option
Alex Crichton [Fri, 29 Jan 2021 21:24:56 +0000 (13:24 -0800)]
Add split-debuginfo profile option

This commit adds a new `split-debuginfo` option to Cargo compilation
profiles which gets forwarded to the `-Csplit-debuginfo` codegen option
in rustc. This commit also sets the default, only on macOS, to be
`-Csplit-debuginfo=unpacked`. The purpose of this change is to leverage
rust-lang/rust#79570 to avoid running `dsymutil` on incremental builds
while also preserving a pleasant debugging experience by default. This
should lead to much faster incremental build times on macOS since
`dsymutil` isn't exactly the speediest tool in the world.

This is technically a breaking change in Cargo because we're no longer
by-default producing the `*.dSYM` folders on macOS. If those are still
desired, however, authors can always run `dsymutil` themselves or
otherwise configure `split-debuginfo = 'packed'` in their
manifest/profile configuration.

3 years agoAuto merge of #9108 - CPerezz:locked_warn, r=alexcrichton
bors [Mon, 1 Feb 2021 16:24:34 +0000 (16:24 +0000)]
Auto merge of #9108 - CPerezz:locked_warn, r=alexcrichton

Impl warn for locked install without Cargo.lock

If we're installing in --locked mode and there's no `Cargo.lock` published
ie. the bin was published before https://github.com/rust-lang/cargo/pull/7026
the cargo install errors were not stating that it was due to the lack of
the `Cargo.lock` file. Instead, the error seemed completely unrelated.

Therefore, this tries to address this by adding a warn in the stderr
output.

Closes #9106

I will need some help on the testing side (assuming the code I added for the warning is correct).
It looks to me that the publish function implemented for testing purposes does not publish `Cargo.lock` which is the actual convention. Should this be updated too? See  #7026

3 years agoAuto merge of #9121 - vext01:extra-link-arg-doc, r=alexcrichton
bors [Mon, 1 Feb 2021 15:39:10 +0000 (15:39 +0000)]
Auto merge of #9121 - vext01:extra-link-arg-doc, r=alexcrichton

Document -Z extra-link-arg.

Whilst reading the cargo source code, I encountered `-Z extra-link-arg`. I'd missed this flag before because it is not documented in `-Z help`.

This commit adds the one-liner documentation.

([This argument **is** mentioned in the unstable cargo book](https://doc.rust-lang.org/beta/cargo/reference/unstable.html#extra-link-arg))

3 years agoAuto merge of #9120 - dimo414:patch-1, r=alexcrichton
bors [Mon, 1 Feb 2021 15:06:07 +0000 (15:06 +0000)]
Auto merge of #9120 - dimo414:patch-1, r=alexcrichton

Flip 'foo' and 'bar' to be consistent

The "Renaming dependencies" section initially uses 'foo' as the crate name and 'bar' as a rename, but then swaps them and uses 'bar' as the example crate name in the context of optional dependencies. Now both examples in this section treat 'foo' as the original crate name.

3 years agoDocument -Z extra-link-arg.
Edd Barrett [Mon, 1 Feb 2021 14:51:50 +0000 (14:51 +0000)]
Document -Z extra-link-arg.

3 years agoFlip 'foo' and 'bar' to be consistent
Michael Diamond [Mon, 1 Feb 2021 07:27:56 +0000 (23:27 -0800)]
Flip 'foo' and 'bar' to be consistent

The "Renaming dependencies" section initially uses 'foo' as the crate name and 'bar' as a rename, but then swaps them and uses 'bar' as the example crate name in the context of optional dependencies. Now both examples in this section treat 'foo' as the original crate name.

3 years agoAuto merge of #9115 - djc:fix-msrv-handling, r=ehuss
bors [Sat, 30 Jan 2021 22:50:11 +0000 (22:50 +0000)]
Auto merge of #9115 - djc:fix-msrv-handling, r=ehuss

Don't try to parse MSRV if feature is not enabled

`@ehuss` is something like this what you had in mind? Should we add tests to make sure this works correctly?

3 years agoDon't try to parse MSRV if feature is not enabled
Dirkjan Ochtman [Sat, 30 Jan 2021 15:33:54 +0000 (16:33 +0100)]
Don't try to parse MSRV if feature is not enabled

3 years agoImpl warn for locked install withoud Cargo.lock
CPerezz [Thu, 28 Jan 2021 01:44:12 +0000 (02:44 +0100)]
Impl warn for locked install withoud Cargo.lock

If we're installing in --locked mode and there's no `Cargo.lock` published
ie. the bin was published before https://github.com/rust-lang/cargo/pull/7026
the cargo install errors were not stating that it was due to the lack of
the `Cargo.lock` file. Instead, the error seemed completely unrelated.

Therefore, this tries to address this by adding a warn in the stderr
output.

Closes #9106

3 years agoAuto merge of #9110 - klensy:simple-fix, r=alexcrichton
bors [Fri, 29 Jan 2021 15:04:09 +0000 (15:04 +0000)]
Auto merge of #9110 - klensy:simple-fix, r=alexcrichton

simplify char range check

Instead manually checking ranges for char, use std method.

3 years agotrivial char range check
klensy [Thu, 28 Jan 2021 22:27:16 +0000 (01:27 +0300)]
trivial char range check

3 years agoAuto merge of #9097 - ehuss:tracking-issue-template-update, r=alexcrichton
bors [Mon, 25 Jan 2021 16:16:43 +0000 (16:16 +0000)]
Auto merge of #9097 - ehuss:tracking-issue-template-update, r=alexcrichton

Minor update to tracking issue template.

Just some minor tweaks, move the "about" to the bottom since it isn't that important (I think the summary should be first). Also add a link to an RFC if it is an RFC.

3 years agoAuto merge of #9098 - ehuss:extra-new-name-help, r=alexcrichton
bors [Mon, 25 Jan 2021 15:46:16 +0000 (15:46 +0000)]
Auto merge of #9098 - ehuss:extra-new-name-help, r=alexcrichton

Add some extra help to `cargo new` and invalid package names.

Binaries are not as restricted as package names, so provide some help in case the user really wants a binary with that name.

Closes #8829

3 years agoAuto merge of #9102 - alexcrichton:fix-serede, r=ehuss
bors [Mon, 25 Jan 2021 15:16:52 +0000 (15:16 +0000)]
Auto merge of #9102 - alexcrichton:fix-serede, r=ehuss

Fix compilation with serde 1.0.122

This may or may not be a bug in serde, but let's commit a fix here first
in any case.

Closes #9101

3 years agoFix compilation with serde 1.0.122
Alex Crichton [Mon, 25 Jan 2021 15:12:04 +0000 (07:12 -0800)]
Fix compilation with serde 1.0.122

This may or may not be a bug in serde, but let's commit a fix here first
in any case.

Closes #9101

3 years agoAdd some extra help to `cargo new` and invalid package names.
Eric Huss [Sun, 24 Jan 2021 19:05:11 +0000 (11:05 -0800)]
Add some extra help to `cargo new` and invalid package names.

3 years agoMinor update to tracking issue template.
Eric Huss [Sat, 23 Jan 2021 15:44:46 +0000 (07:44 -0800)]
Minor update to tracking issue template.

3 years agoAuto merge of #9095 - ehuss:spec-suggestion, r=alexcrichton
bors [Fri, 22 Jan 2021 23:18:00 +0000 (23:18 +0000)]
Auto merge of #9095 - ehuss:spec-suggestion, r=alexcrichton

Add suggestion for bad package id.

This adds some suggestions to the error message if a pkgid spec does not match any packages.

3 years agoAdd suggestion for bad package id.
Eric Huss [Fri, 22 Jan 2021 21:37:52 +0000 (13:37 -0800)]
Add suggestion for bad package id.

3 years agoAuto merge of #9093 - ehuss:remove-registry-new, r=alexcrichton
bors [Fri, 22 Jan 2021 19:24:40 +0000 (19:24 +0000)]
Auto merge of #9093 - ehuss:remove-registry-new, r=alexcrichton

Remove Registry::new.

`Registry::new` doesn't work in most circumstances because crates.io requires a user-agent, and it does not set one.

This also bumps the version over 0.32 due to #8914.

Closes #8914.
Closes #9040.

3 years agoRemove Registry::new.
Eric Huss [Fri, 22 Jan 2021 19:06:51 +0000 (11:06 -0800)]
Remove Registry::new.

3 years agoAuto merge of #9035 - weihanglo:fix/git-init-search-path, r=alexcrichton
bors [Fri, 22 Jan 2021 15:29:39 +0000 (15:29 +0000)]
Auto merge of #9035 - weihanglo:fix/git-init-search-path, r=alexcrichton

Fix: set default git config search path for tests

Fixes https://github.com/rust-lang/cargo/issues/8863 by setting the default config search path.

Just wait https://github.com/rust-lang/git2-rs/pull/656 being merged and update Cargo.toml the new release of git2-rs 😄

3 years agochore: bump versions of git2 and libgit2-sys
Weihang Lo [Fri, 22 Jan 2021 15:27:44 +0000 (23:27 +0800)]
chore: bump versions of git2 and libgit2-sys

3 years agoAuto merge of #9092 - ehuss:unstable-updates, r=alexcrichton
bors [Thu, 21 Jan 2021 21:04:12 +0000 (21:04 +0000)]
Auto merge of #9092 - ehuss:unstable-updates, r=alexcrichton

Unstable updates

This is a collection of updates for unstable/nightly feature support, intended to provide better messages for users and better internal and external documentation.  Separated by commit, in summary:

* Added comments and new docstrings for improved internal documentation.
* Added new documentation to the reference guide on how unstable things work.
  * Also added redirects for stabilized features so any external links won't be broken.
* Add a targeted error message if you put `cargo-features` in the wrong place in `Cargo.toml`.
* Remove `publish-lockfile`.  The feature was stabilized without the key in #7026 about 1.5 years ago.  Also added "removed" support for features, which prints out a more helpful error message.
* Add help messages about stabilized `-Z` flags (instead of spitting out an unhelpful error message).
* Add help messages about stabilized `cargo-features` features.
* Add more context to the error when using `cargo-features` on stable.
* Unhide nightly CLI flags. I changed my mind on how these should work. I think it is useful to "advertise" the existence of these options on stable. The error message if you try to use it should help guide on what to do.

Closes #9074.

3 years agoAdd redirects on the unstable docs.
Eric Huss [Thu, 21 Jan 2021 04:14:25 +0000 (20:14 -0800)]
Add redirects on the unstable docs.

This adds some redirects so if there are any links to old documentation,
they will get redirect to new documentation.

3 years agoUpdate the user documentation on unstable features.
Eric Huss [Thu, 21 Jan 2021 04:13:06 +0000 (20:13 -0800)]
Update the user documentation on unstable features.

This attempts to make it clearer on the different ways
unstable features can be activated.

3 years agoUpdate the internal documentation on unstable features.
Eric Huss [Thu, 21 Jan 2021 04:11:08 +0000 (20:11 -0800)]
Update the internal documentation on unstable features.

Attempts to make it clearer on how the different kinds of unstable
support works, and clarify the steps for adding new features
and stabilizing.

3 years agoRework cargo-features a little.
Eric Huss [Thu, 21 Jan 2021 04:08:52 +0000 (20:08 -0800)]
Rework cargo-features a little.

* Add `removed` support.
* Include the version where it is stabilized.
* Include a links to the documentation in the error/warning messages.

3 years agotest: remove odd semicolon
Weihang Lo [Fri, 1 Jan 2021 15:36:23 +0000 (23:36 +0800)]
test: remove odd semicolon

3 years agofix: set search path before init repos
Weihang Lo [Fri, 1 Jan 2021 14:07:34 +0000 (22:07 +0800)]
fix: set search path before init repos

3 years agoAdd more helpful message with stabilized -Z flags.
Eric Huss [Thu, 21 Jan 2021 03:46:50 +0000 (19:46 -0800)]
Add more helpful message with stabilized -Z flags.

Previously, when something was stabilized, Cargo would spit out a very
unhelpful error message about an unknown -Z flag. This changes it so
that it displays a helpful warning (or error).

3 years agoRemove publish-lockfile key from manifest.
Eric Huss [Thu, 21 Jan 2021 03:31:57 +0000 (19:31 -0800)]
Remove publish-lockfile key from manifest.

The feature was stabilized without the key in #7026 about 1.5 years ago.
(Will follow up with an error message in a subsequent commit.)

3 years agoAdd error message for wrong cargo-features placement.
Eric Huss [Thu, 21 Jan 2021 03:22:51 +0000 (19:22 -0800)]
Add error message for wrong cargo-features placement.

This is intended to help if the user puts cargo-features in the
wrong place in Cargo.toml.

3 years agoAdd some comments why some options are hidden.
Eric Huss [Thu, 21 Jan 2021 03:18:59 +0000 (19:18 -0800)]
Add some comments why some options are hidden.

3 years agoUnhide nightly-only flags.
Eric Huss [Thu, 21 Jan 2021 03:16:54 +0000 (19:16 -0800)]
Unhide nightly-only flags.

I changed my mind on how these should work. I think it is useful to
"advertise" the existence of these options on stable. The error message
if you try to use it should help guide on what to do.

3 years agoAuto merge of #9077 - ehuss:fix-doc-resolver2-proc-macro, r=alexcrichton
bors [Wed, 20 Jan 2021 19:02:26 +0000 (19:02 +0000)]
Auto merge of #9077 - ehuss:fix-doc-resolver2-proc-macro, r=alexcrichton

Fix some issues with `cargo doc` and the new feature resolver.

This contains two related commits fixing some issues with `cargo doc` and the new feature resolver.

The first commit fixes a panic. The old code was using `UnitFor::new_normal` when computing doc units, but this was wrong. That essentially circumvents the new feature resolver, and breaks determining the correct features to use. I don't remember exactly what I was thinking when I wrote that, other than "rustdoc shouldn't care", but it does matter.

Unfortunately changing that makes collisions worse because it aggravates #6313, so the second commit adds some logic for removing some collisions automatically. Specifically:

- Prefers dependencies for the target over dependencies for the host (such as proc-macros).
- Prefers the "newest" version if it comes from the same source.

There are still plenty of situations where there can be collisions, but I'm uncertain on the best way to handle those.

Fixes #9064

3 years agoOptimize removing unit_deps.
Eric Huss [Wed, 20 Jan 2021 16:27:36 +0000 (08:27 -0800)]
Optimize removing unit_deps.

3 years agoAuto merge of #8037 - djc:rfc-2495, r=ehuss
bors [Wed, 20 Jan 2021 16:12:56 +0000 (16:12 +0000)]
Auto merge of #8037 - djc:rfc-2495, r=ehuss

Implement support for rust-version field in project metadata

Needs a bunch more work, but I'd like some early feedback! Remaining work:

- [x] Bikeshedding name (picked `rust-version` here over `msrv` or `min-rust-version`)
- [x] Failing test for local dependency with unsatisfied MSRV
- [x] Requirement cannot be smaller than 1.27
- [x] Requirement cannot be smaller than initial release of edition used
- [x] Check for `run`, `verify` and `publish` subcommands
- [x] More tests (would love feedback on this)
- [x] Handle pre-release identifiers
- [x] Disallow semver range operators
- [x] Feature gate it
- [x] Add documentation for unstable feature

Minimal version of `@moxian's` earlier take in #7801.

cc rust-lang/rust#65262

3 years agoImplement support for rust-version field in project metadata
Dirkjan Ochtman [Tue, 24 Mar 2020 21:31:28 +0000 (22:31 +0100)]
Implement support for rust-version field in project metadata

3 years agoAuto merge of #9075 - alexcrichton:fix-cycles, r=ehuss
bors [Mon, 18 Jan 2021 19:51:07 +0000 (19:51 +0000)]
Auto merge of #9075 - alexcrichton:fix-cycles, r=ehuss

Fix a bug in Cargo's cyclic dep graph detection

Cargo's cyclic dependency graph detection turns out to have had a bug
for quite a long time as surfaced by #9073. The bug in Cargo has to do
with how dev-dependencies are handled. Cycles are "allowed" through
dev-dependencies because the dev-dependency can depend on the original
crate. Our cyclic graph detection, however, was too eagerly flagging a
package as known to not have a cycle before we had processed everything
about it.

The fix here was basically to just simplify the graph traversal. Instead
of traversing the raw `Resolve` this instead creates an alternate
in-memory graph which has the actual edges we care about for cycle
detection (e.g. every edge that wasn't induced via a dev-dependency).
With this simplified graph we then apply the exact same algorithm, but
this time it should be less buggy because we're not trying to do funky
things about switching sets about what's visited halfway through a
traversal.

Closes #9073

3 years agoAuto merge of #9081 - ximon18:typo-correction, r=ehuss
bors [Fri, 15 Jan 2021 15:02:30 +0000 (15:02 +0000)]
Auto merge of #9081 - ximon18:typo-correction, r=ehuss

Typo correction: artifcats -> artifacts

3 years agoTypo correction: artifcats -> artifacts
Ximon Eighteen [Fri, 15 Jan 2021 14:24:44 +0000 (15:24 +0100)]
Typo correction: artifcats -> artifacts

3 years agoAuto merge of #9079 - lzutao:stray-backtick, r=ehuss
bors [Fri, 15 Jan 2021 02:14:36 +0000 (02:14 +0000)]
Auto merge of #9079 - lzutao:stray-backtick, r=ehuss

Remove stray backtick from doc

Just a minor typo.

3 years agoRemove stray backtick from doc
Lzu Tao [Fri, 15 Jan 2021 01:24:37 +0000 (08:24 +0700)]
Remove stray backtick from doc

3 years agoRemove some doc collisions.
Eric Huss [Thu, 14 Jan 2021 21:12:24 +0000 (13:12 -0800)]
Remove some doc collisions.

There are some cases where `cargo doc` will try to document two things
with the same crate_name. This attempts to automatically remove some of
those duplicates based on some rules:

- Prefers dependencies for the target over dependencies for the host
  (such as proc-macros).
- Prefers the "newest" version if it comes from the same source.

There are still plenty of situations where there can be collisions, but
I'm uncertain on the best way to handle those.

3 years agoFix a bug in Cargo's cyclic dep graph detection
Alex Crichton [Thu, 14 Jan 2021 16:40:12 +0000 (08:40 -0800)]
Fix a bug in Cargo's cyclic dep graph detection

Cargo's cyclic dependency graph detection turns out to have had a bug
for quite a long time as surfaced by #9073. The bug in Cargo has to do
with how dev-dependencies are handled. Cycles are "allowed" through
dev-dependencies because the dev-dependency can depend on the original
crate. Our cyclic graph detection, however, was too eagerly flagging a
package as known to not have a cycle before we had processed everything
about it.

The fix here was basically to just simplify the graph traversal. Instead
of traversing the raw `Resolve` this instead creates an alternate
in-memory graph which has the actual edges we care about for cycle
detection (e.g. every edge that wasn't induced via a dev-dependency).
With this simplified graph we then apply the exact same algorithm, but
this time it should be less buggy because we're not trying to do funky
things about switching sets about what's visited halfway through a
traversal.

Closes #9073

3 years agoFix typo in method name
Dirkjan Ochtman [Sat, 4 Apr 2020 18:39:14 +0000 (20:39 +0200)]
Fix typo in method name

3 years agoAuto merge of #9066 - rubenrua:hotfix_sort_bins, r=ehuss
bors [Tue, 12 Jan 2021 23:45:39 +0000 (23:45 +0000)]
Auto merge of #9066 - rubenrua:hotfix_sort_bins, r=ehuss

Sort available binaries when multiple

From:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-13, basic-tutorial-6, basic-tutorial-1, basic-tutorial-4, basic-tutorial-9, basic-tutorial-2, basic-tutorial-3, basic-tutorial-5, basic-tutorial-12, playback-tutorial-4, basic-tutorial-8, basic-tutorial-7
```

To:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-1, basic-tutorial-12, basic-tutorial-13, basic-tutorial-2, basic-tutorial-3, basic-tutorial-4, basic-tutorial-5, basic-tutorial-6, basic-tutorial-7, basic-tutorial-8, basic-tutorial-9, playback-tutorial-4
```

3 years agoAuto merge of #9067 - AnthonyMikh:patch-1, r=ehuss
bors [Tue, 12 Jan 2021 23:16:21 +0000 (23:16 +0000)]
Auto merge of #9067 - AnthonyMikh:patch-1, r=ehuss

Fix misspelling of environment variable

3 years agoFix misspelling of environment variable
AnthonyMikh [Tue, 12 Jan 2021 17:45:36 +0000 (20:45 +0300)]
Fix misspelling of environment variable

3 years agoTest for sort available binaries when multiple
rubenrua [Tue, 12 Jan 2021 22:10:51 +0000 (23:10 +0100)]
Test for sort available binaries when multiple

3 years agoAuto merge of #9070 - joshtriplett:opt-level-vs-debug, r=Eh2406
bors [Tue, 12 Jan 2021 20:43:56 +0000 (20:43 +0000)]
Auto merge of #9070 - joshtriplett:opt-level-vs-debug, r=Eh2406

Remove statement that opt-level 0 turns on debug

See https://github.com/rust-lang/cargo/pull/9020#issuecomment-751513035

3 years agoRemove statement that opt-level 0 turns on debug
Josh Triplett [Tue, 12 Jan 2021 20:31:49 +0000 (12:31 -0800)]
Remove statement that opt-level 0 turns on debug

See https://github.com/rust-lang/cargo/pull/9020#issuecomment-751513035

3 years agoFix panic with `cargo doc` and new resolver and proc-macros.
Eric Huss [Tue, 12 Jan 2021 17:17:49 +0000 (09:17 -0800)]
Fix panic with `cargo doc` and new resolver and proc-macros.

3 years agoAuto merge of #9065 - alexcrichton:fix-build-bug-again, r=ehuss
bors [Tue, 12 Jan 2021 17:14:29 +0000 (17:14 +0000)]
Auto merge of #9065 - alexcrichton:fix-build-bug-again, r=ehuss

Fix `links` vars showing up for testing packages

If a package is tested and the library for the package wasn't built
(e.g. only tested or it wasn't present) then the `links` env vars from
dependencies weren't showing up to the build script by accident. This
was an accidental regression from #8969.

The intention of #8969 was to exclude connections to build scripts
connected via dev-dependencies, but it only applied a heuristic because
the unit graph doesn't retain information about dev-dependencies. The
fix here is to instead actually retain information about
dev-dependencies which is only used for constructing the unit graph and
connecting build script executions to one another.

Closes #9063

3 years agoFix `links` vars showing up for testing packages
Alex Crichton [Mon, 11 Jan 2021 18:42:38 +0000 (10:42 -0800)]
Fix `links` vars showing up for testing packages

If a package is tested and the library for the package wasn't built
(e.g. only tested or it wasn't present) then the `links` env vars from
dependencies weren't showing up to the build script by accident. This
was an accidental regression from #8969.

The intention of #8969 was to exclude connections to build scripts
connected via dev-dependencies, but it only applied a heuristic because
the unit graph doesn't retain information about dev-dependencies. The
fix here is to instead actually retain information about
dev-dependencies which is only used for constructing the unit graph and
connecting build script executions to one another.

Closes #9063

3 years agoSort available binaries when multiple
rubenrua [Tue, 12 Jan 2021 07:46:25 +0000 (08:46 +0100)]
Sort available binaries when multiple

From:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-13, basic-tutorial-6, basic-tutorial-1, basic-tutorial-4, basic-tutorial-9, basic-tutorial-2, basic-tutorial-3, basic-tutorial-5, basic-tutorial-12, playback-tutorial-4, basic-tutorial-8, basic-tutorial-7
```

To:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-1, basic-tutorial-12, basic-tutorial-13, basic-tutorial-2, basic-tutorial-3, basic-tutorial-4, basic-tutorial-5, basic-tutorial-6, basic-tutorial-7, basic-tutorial-8, basic-tutorial-9, playback-tutorial-4
```

3 years agoAuto merge of #9059 - ehuss:fix-unit-for-host, r=alexcrichton
bors [Mon, 11 Jan 2021 15:12:09 +0000 (15:12 +0000)]
Auto merge of #9059 - ehuss:fix-unit-for-host, r=alexcrichton

Fix unit_for computation on proc-macros in shared workspace.

There was a bug where the UnitFor was not being computed properly for proc-macros in a workspace with shared dependencies, integration tests, and a mixture of various flags (`--workspace --all-targets --all-features`). The issue is that [this line](https://github.com/rust-lang/cargo/blob/faf05ac316cd71100a691799cd8da02fce6dd85d/src/cargo/core/compiler/unit_dependencies.rs#L474), which is used when attaching the implicit dependency from an integration test to its library, was using the wrong unit_for value (it was not checking if the implicit lib is a proc-macro). The consequence is that the graph could be built inconsistently, causing features to be randomly selected incorrectly if the integration test happened to be the first unit processed.

The solution here is to use a common function for transitioning the unit_for value. The with_for_host/with_host_features split was mostly a consequence of how things evolved over time, and keeping them separate wasn't really necessary.

3 years agoAuto merge of #9000 - JohnTitor:owner-add-docs, r=ehuss
bors [Sun, 10 Jan 2021 20:25:54 +0000 (20:25 +0000)]
Auto merge of #9000 - JohnTitor:owner-add-docs, r=ehuss

Document `could not find the github team` error on `cargo owner --add`

When running `cargo owner --add`, the `could not find the github team` error often occurs due to lack of the permissions.
Example cases: https://github.com/rust-lang/cargo/issues/5297#issuecomment-653709183, https://github.com/rust-lang/crates.io/issues/2928

I think it's worth documenting that error and the possible solution.

3 years agoAddress the review comments
Yuki Okushi [Sun, 10 Jan 2021 08:12:18 +0000 (17:12 +0900)]
Address the review comments

3 years agoFix unit_for computation on proc-macros in shared workspace.
Eric Huss [Sat, 9 Jan 2021 23:18:28 +0000 (15:18 -0800)]
Fix unit_for computation on proc-macros in shared workspace.

3 years agoAuto merge of #9057 - roblabla:patch-2, r=ehuss
bors [Fri, 8 Jan 2021 17:50:56 +0000 (17:50 +0000)]
Auto merge of #9057 - roblabla:patch-2, r=ehuss

Unstable section of cargo/config.toml takes bools

At least according to a quick local test, those should not be strings, but booleans! With the following cargo config:

```toml
[unstable]
mtime-on-use = 'yes'
```

I get the following cargo output:

```
error: error in /root/builds/hlab/isengard/agent-rust/.cargo_cache/config: `unstable.mtime-on-use` expected true/false, but found a string
```

3 years agoTimings takes an array of strings.
Robin Lambertz [Fri, 8 Jan 2021 17:30:56 +0000 (18:30 +0100)]
Timings takes an array of strings.

Co-authored-by: Eric Huss <eric@huss.org>
3 years agoUnstable section of cargo/config.toml takes bools
Robin Lambertz [Fri, 8 Jan 2021 17:06:22 +0000 (18:06 +0100)]
Unstable section of cargo/config.toml takes bools

3 years agoAuto merge of #9053 - sharnoff:master, r=alexcrichton
bors [Fri, 8 Jan 2021 16:44:12 +0000 (16:44 +0000)]
Auto merge of #9053 - sharnoff:master, r=alexcrichton

[doc] add note about empty environment variables for missing manifest keys

This is a small addition to the cargo book.

In [the section](https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates) about the environment variables cargo sets to provide information about a crate, there's no mention about the value of those environment variables is if the key isn't present in the manifest.

As can be seen [here](https://github.com/rust-lang/cargo/blob/94e21ada550f91f5d32f2f51635792a79aeb8d63/src/cargo/core/compiler/compilation.rs#L287)¹, the values default to the empty string (instead of, say, not being present), so this change just adds a sentence in the book to clarify that.

If the terminology could be improved or there's a better place for this to be included, I'm happy to change it :)

---

¹ To be clear, I did also play around with this and found that the environment variables were empty. The code reference was more to double-check that the behavior I saw was a consistent pattern.

3 years agoadd doc note about environment variables for missing manifest keys
sharnoff [Thu, 7 Jan 2021 20:08:48 +0000 (20:08 +0000)]
add doc note about environment variables for missing manifest keys

3 years agoAuto merge of #9051 - matthiaskrgr:clippy_v18, r=ehuss
bors [Wed, 6 Jan 2021 20:59:07 +0000 (20:59 +0000)]
Auto merge of #9051 - matthiaskrgr:clippy_v18, r=ehuss

another round of clippy lint fixes

3 years agoAuto merge of #9050 - bishtpawan:master, r=alexcrichton
bors [Wed, 6 Jan 2021 15:28:00 +0000 (15:28 +0000)]
Auto merge of #9050 - bishtpawan:master, r=alexcrichton

Updated display message of cargo metadata --help

Resolved Issue #8928

3 years agoFix more clippy warnings;
Matthias Krüger [Wed, 6 Jan 2021 13:12:30 +0000 (14:12 +0100)]
Fix more clippy warnings;

clippy::comparison_to_empty
clippy::needless_question_mark
clippy::needless_borrow
clippy::match_like_matches_macro
clippy::vec_init_then_push
clippy::redundant_clone
clippy::nonminimal_bool
clippy::ptr_arg

3 years agofix clippy::unnecessary_wraps.
Matthias Krüger [Wed, 6 Jan 2021 13:15:31 +0000 (14:15 +0100)]
fix clippy::unnecessary_wraps.

Make functions that return Options but only ever return Ok() return the wrapped value directly and remove redundant matching

3 years agoreduce nesting of if x { } else { if y {} else {} } expressions by concerting to...
Matthias Krüger [Wed, 6 Jan 2021 12:59:17 +0000 (13:59 +0100)]
reduce nesting of if x { } else { if y {} else {} } expressions by concerting to if x {} else if y {} else {} (clippy::collapsible_else_if)

3 years agoUpdate display message for cargo metadata
bishtpawan [Wed, 6 Jan 2021 10:48:08 +0000 (16:18 +0530)]
Update display message for cargo metadata