bors [Tue, 23 Feb 2021 16:39:45 +0000 (16:39 +0000)]
Auto merge of #9105 - Swatinem:rustdoc-run-cwd, r=alexcrichton
Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for the doctests.
This was first landed in #8954 but later backed out in #8996 because it changed the CWD of rustdoc test invocations.
The second try relies on the new `--test-run-directory` rustdoc option which was added in https://github.com/rust-lang/rust/pull/81264 to explicitly control the rustdoc test cwd.
bors [Tue, 23 Feb 2021 15:22:59 +0000 (15:22 +0000)]
Auto merge of #9175 - wickerwaka:env-section, r=alexcrichton
Add support for [env] section in .cargo/config.toml
This adds support for an `[env]` section in the config.toml files. Environment variables set in this section will be applied to the environment of any processes executed by cargo.
This is implemented to follow the recommendations in https://github.com/rust-lang/cargo/pull/8839#issuecomment-725678657
Variables have optional `force` and `relative` flags. `force` means the variable can override an existing environment variable. `relative` means the variable represents a path relative to the location of the directory that contains the `.cargo/` directory that contains the `config.toml` file. A relative variable will have an absolute path prepended to it before setting it in the environment.
```
[env]
FOOBAR = "Apple"
PATH_TO_SOME_TOOL = { value = "bin/tool", relative = true }
USERNAME = { value = "test_user", force = true }
```
Arpad Borsos [Mon, 22 Feb 2021 19:06:03 +0000 (20:06 +0100)]
Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for the doctests.
This was first landed in #8954 but later backed out in #8996 because it changed the CWD of rustdoc test invocations.
The second try relies on the new `--test-run-directory` rustdoc option which was added in https://github.com/rust-lang/rust/pull/81264 to explicitly control the rustdoc test cwd.
bors [Mon, 22 Feb 2021 15:48:02 +0000 (15:48 +0000)]
Auto merge of #9161 - ehuss:index-v-features2, r=alexcrichton
Add schema field and `features2` to the index.
This adds a `v` field to the index which indicates a format version for an index entry. If Cargo encounters a version newer than it understands, it will ignore those entries. This makes it safer to make changes to the index entries (such as adding new things), and not need to worry about how older cargos will react to it. In particular, this will make it safer to run `cargo update` on older versions if we ever decide to add new things to the index.
Currently this is not written anywhere, and is intended as a safety guard for the future. For now I will leave it undocumented until we actually decide to start using it.
This also moves the new syntax for namespaced features and weak dependency features into a new field ("features2") in the index. This is necessary to avoid breaking Cargo versions older than 1.19, which fail to parse the index even if there is a Cargo.lock file.
It is intended that only crates.io will bother with creating this field. Other registries don't need to bother, since they generally don't support Cargo older than 1.19.
I'm uncertain exactly when we should try to update crates.io to start accepting this, as that is a somewhat permanent decision.
Martin Donlon [Sat, 20 Feb 2021 21:49:08 +0000 (13:49 -0800)]
Change env section parsing
`untagged` enum variants are not recognised by serde if the variant contains a `Value<T>` type.
This change uses an transparent "inner" enum `Value<T>` member, which is handled correctly by serde.
Eric Huss [Fri, 19 Feb 2021 18:51:38 +0000 (10:51 -0800)]
Include the index version in the index cache.
This is intended to help prevent the following scenario from happening:
1. Old cargo builds an index cache.
2. Old cargo finds an index entry it cannot parse, skipping it,
and saving the cache without the entry.
3. New cargo loads the cache with the missing entry, and never sees
the new entries that it understands.
This may result in more cache thrashing, but that seems better than
having new cargos missing entries.
bors [Thu, 18 Feb 2021 15:49:14 +0000 (15:49 +0000)]
Auto merge of #9182 - alexcrichton:fix-lto-off, r=ehuss
Propagate `lto=off` harder
This commit fixes an issue with LTO calculation for various units when
`lto=off` is specified in the profile. This ensures now that `lto=off`
is passed to all transitive dependencies as well to disable thin-local
LTO. As an added bonus this also passed `embed-bitcode=no` whenever
`lto=off` is specified since we know we won't be using bitcode anyway.
Alex Crichton [Wed, 17 Feb 2021 19:40:38 +0000 (11:40 -0800)]
Propagate `lto=off` harder
This commit fixes an issue with LTO calculation for various units when
`lto=off` is specified in the profile. This ensures now that `lto=off`
is passed to all transitive dependencies as well to disable thin-local
LTO. As an added bonus this also passed `embed-bitcode=no` whenever
`lto=off` is specified since we know we won't be using bitcode anyway.
Martin Donlon [Tue, 16 Feb 2021 04:21:22 +0000 (20:21 -0800)]
Add `-Z configurable-env` to gate [env] usage
Added the `-Z configurable-env` option which controls whether the data from the [env] section is used. Updated the tests to pass the flag and to masquerade as the nightly cargo.
Martin Donlon [Mon, 15 Feb 2021 23:17:00 +0000 (15:17 -0800)]
Add support for [env] section in .cargo/config.toml
This adds support for an `[env]` section in the config.toml files. Environment variables set in this section will be applied to the environment of any processes executed by cargo.
```
[env]
FOOBAR = "Apple"
PATH_TO_SOME_TOOL = { value = "bin/tool", relative = true }
USERNAME = { value = "test_user", force = true }
```
bors [Mon, 15 Feb 2021 18:01:39 +0000 (18:01 +0000)]
Auto merge of #9173 - casey:patch-2, r=ehuss
Remove mention of --message-format taking multiple values
I tried passing multiple values to `--message-format`, as is mentioned in the docs, and it didn't work:
```
$ cargo test --message-format human,json
error: cannot specify two kinds of `message-format` arguments
$ cargo test --message-format human --message-format json
error: cannot specify two kinds of `message-format` arguments
````
It's entirely possible I misunderstood the docs, but just in case I didn't, I thought I'd open this PR to remove the bit that mentions that the flag accepts multiple values.
bors [Sun, 14 Feb 2021 19:35:20 +0000 (19:35 +0000)]
Auto merge of #9169 - Liberatys:emit-warning-on-env-variable-case-mismatch, r=ehuss
Emit warning on env variable case mismatch
When running a command like `cargo --target TRIPPLE` cargo expects to find the environment variable CARGO_TARGET_[TRIPPLE]_* with uppercase and underscores. This check emits a warning if the checked environment variable has a mismatching case and/or contains dashes rather than underscores. The warning contains the given env variable as well as an explanation for the cause of the warning.
The check is skipped on windows as environment variables are treated as case insensitive on the platform.
bors [Sat, 13 Feb 2021 21:57:02 +0000 (21:57 +0000)]
Auto merge of #8640 - CPerezz:doc_versioning, r=ehuss
Implement Rustdoc versioning checks
Before compiling, we need to make sure that if there were any previous docs already compiled, they were compiled with the same Rustc version that we're currently using. Otherways we must remove the `doc/` folder and compile again.
This is important because as stated in #8461 the .js/.html&.css files that are generated by Rustc don't have any versioning. Therefore, we can fall in weird bugs and behaviours if we mix different compiler versions of these js/.html&.css files.
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.
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.
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.
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.
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.
CPerezz [Thu, 4 Feb 2021 00:03:04 +0000 (01:03 +0100)]
Improve RustDocFingerprint::remove_doc_dirs
We were not filtering the cases where the doc folder
paths did not exist.
Also, we were overrwriting the error when it doesn't
make sense. We now return the first one by folding the
results of the doc_dirs removal resolutions.
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.
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`.)
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.
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.
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.
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
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.
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.
CPerezz [Sun, 31 Jan 2021 22:43:27 +0000 (23:43 +0100)]
Check target-dependant doc folders
When checking the fingerprint for rustdoc and applying
the corresponding logic, we don't only need to consider
the `target/doc` folder (Host target) but also triple targets.
So now the actual compilation targets are checked during the
rustdoc_fingerprint processing and they're treated as the Host/doc
folder.
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.
CPerezz [Wed, 27 Jan 2021 00:14:31 +0000 (01:14 +0100)]
Address latest reivew suggestions
- Instead of `fs` we use the `utils::paths` functions
to interact with the filesystem.
- The doc fingerprint is now stored under `target/` instead
of `target/doc/`.
- The code in `compile` has been reduced to a single function call.
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.