bors [Thu, 24 Oct 2019 20:33:33 +0000 (20:33 +0000)]
Auto merge of #7536 - ehuss:profile-override-warning-fix, r=alexcrichton
Fix profile override warning in a workspace.
Profile overrides would erroneously warn about unused packages in a workspace if the package was not being built. The fix here is to retain the `Resolve` for the entire workspace, and use that to determine the valid set of packages.
I think it would be good for a long-term goal to get rid of the second ("targeted") resolve. I'm still contemplating how a separate features resolver could achieve that, but it seems feasible long-term.
bors [Thu, 24 Oct 2019 19:48:28 +0000 (19:48 +0000)]
Auto merge of #7535 - ehuss:better-windows-errors, r=alexcrichton
Show better error message for Windows abnormal termination.
This helps display better error messages when there is an abnormal termination on Windows.
If rustc crashes, there was a slight mistake in #6270, where the error code was actually negative, so the message was getting hidden behind the `--verbose` flag. This changes it show that the abnormal error is always shown if rustc crashes in an unusual way.
This also changes `cargo test` to display a better message if the test crashes. Previously:
```
running 1 test
error: test failed, to rerun pass '--bin crash'
```
New:
```
running 1 test
error: test failed, to rerun pass '--bin crash'
I didn't add any tests because testing on this on Windows seems a little precarious. AFAIK, the exact error message depends on the processor (like x86 vs i686), and Windows version. I was concerned about chasing down every little nuance, though I'm willing to try if it seems important.
bors [Tue, 22 Oct 2019 14:18:30 +0000 (14:18 +0000)]
Auto merge of #7531 - ehuss:z-flag-parsing, r=alexcrichton
Use stricter -Z flag parsing.
This makes sure that toggle flags don't have any arguments (like `-Zno-index-update=foo`). It also provides slightly better error messages, like indicating which flag failed.
bors [Mon, 21 Oct 2019 17:59:52 +0000 (17:59 +0000)]
Auto merge of #7523 - bruceg:fix-zero-timestamps, r=alexcrichton
Set timestamp on generated files in archive to now
When generating files (Cargo.lock, Cargo.toml, and
.cargo_vcs_info.json), cargo neglected to set any timestamp on the file
in the archive. This results in them being created on disk with a
timestamp of 0 (Jan 1 1970 GMT) which is confusing another tool I use.
This patch alters the behavior to set the mtime to now.
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
bors [Mon, 21 Oct 2019 16:37:34 +0000 (16:37 +0000)]
Auto merge of #7460 - alexcrichton:panic-abort-tests, r=ehuss
Support rustc's `-Z panic-abort-tests` in Cargo
Recently added in rust-lang/rust#64158 the `-Z panic-abort-tests` flag
to the compiler itself will activate a mode in the `test` crate which
enables running tests even if they're compiled with `panic=abort`. It
effectively runs a test-per-process.
This commit brings the same support to Cargo, adding a `-Z
panic-abort-tests` flag to Cargo which allows building tests in
`panic=abort` mode. While I wanted to be sure to add support for this in
Cargo before we stabilize the flag in `rustc`, I don't actually know how
we're going to stabilize this here. Today Cargo will automatically
switch test targets to `panic=unwind`, and so if we actually were to
stabilize this flag then this configuration would break:
[profile.dev]
panic = 'abort'
In that case tests would be compiled with `panic=unwind` (due to how
profiles work today) which would clash with crates also being compiled
with `panic=abort`. I'm hopeful though that we can perhaps either figure
out a solution for this and maybe even integrate it with the ongoing
profiles work.
Alex Crichton [Mon, 30 Sep 2019 15:48:43 +0000 (08:48 -0700)]
Support rustc's `-Z panic-abort-tests` in Cargo
Recently added in rust-lang/rust#64158 the `-Z panic-abort-tests` flag
to the compiler itself will activate a mode in the `test` crate which
enables running tests even if they're compiled with `panic=abort`. It
effectively runs a test-per-process.
This commit brings the same support to Cargo, adding a `-Z
panic-abort-tests` flag to Cargo which allows building tests in
`panic=abort` mode. While I wanted to be sure to add support for this in
Cargo before we stabilize the flag in `rustc`, I don't actually know how
we're going to stabilize this here. Today Cargo will automatically
switch test targets to `panic=unwind`, and so if we actually were to
stabilize this flag then this configuration would break:
[profile.dev]
panic = 'abort'
In that case tests would be compiled with `panic=unwind` (due to how
profiles work today) which would clash with crates also being compiled
with `panic=abort`. I'm hopeful though that we can perhaps either figure
out a solution for this and maybe even integrate it with the ongoing
profiles work.
bors [Fri, 18 Oct 2019 22:20:14 +0000 (22:20 +0000)]
Auto merge of #7526 - ehuss:rustfmt, r=alexcrichton
rustfmt for nightly changes.
Something in the latest nightly versions of rustfmt has slightly changed the logic here. Fortunately stable ignores the new formatting, and it looks better to me anyways. I tend to always use nightly, so this helps me with a slight annoyance where this line keeps getting changed.
bors [Fri, 18 Oct 2019 17:07:21 +0000 (17:07 +0000)]
Auto merge of #7525 - ehuss:allow-all-features-virtual-ws, r=alexcrichton
Allow --all-features in root of virtual workspace.
Accidentally restricted in #7507, pointed out by @hjmallon, `--all-features` flag is allowed in the root of a virtual workspace. Added a test to demonstrate its strange behavior.
For anyone that is curious, [this line](https://github.com/rust-lang/cargo/blob/3a9abe3f065554a7fbc59f440df2baba4a6e47ee/src/cargo/ops/resolve.rs#L302) is the code responsible for this behavior.
Bruce Guenter [Thu, 17 Oct 2019 21:40:05 +0000 (15:40 -0600)]
Set timestamp on generated files in archive to now
When generating files (Cargo.lock, Cargo.toml, and
.cargo_vcs_info.json), cargo neglected to set any timestamp on the file
in the archive. This results in them being created on disk with a
timestamp of 0 (Jan 1 1970 GMT) which is confusing another tool I use.
This patch alters the behavior to set the mtime to now.
Signed-off-by: Bruce Guenter <bruce@untroubled.org>
bors [Tue, 15 Oct 2019 15:26:07 +0000 (15:26 +0000)]
Auto merge of #7507 - ehuss:virtual-ws-features, r=alexcrichton
Reject feature flags in a virtual workspace.
This generates an error if feature flags are used in the root of a virtual workspace. Previously these flags were completely ignored. In the interest of avoiding confusion, I think it would be good to be explicit that these don't currently work. This could alternatively be a warning, but I think it is better to reject it outright.
bors [Tue, 15 Oct 2019 14:38:29 +0000 (14:38 +0000)]
Auto merge of #7333 - ehuss:allow-dev-dep-path, r=alexcrichton
Allow publishing with dev-dependencies without a version.
This change allows dev-dependencies without a `version` key to be published. If a dev-dependency is missing the `version`, it will be stripped from the packaged manifest.
bors [Tue, 15 Oct 2019 13:48:13 +0000 (13:48 +0000)]
Auto merge of #7450 - ehuss:stabilize-cache-messages, r=alexcrichton
Stabilize cache-messages
This stabilizes the -Zcache-messages feature, making it always enabled.
## What is stabilized?
This feature is intended to redisplay previous warnings on a "fresh" build instead of displaying no output.
Users have occasionally indicated frustration when they know there are warnings, but no output is displayed when the build is fresh. This also improves the interaction between `cargo check` and `cargo clippy-preview`. This also simplifies the code, and opens more possibilities for `rustc` to send side-channel messages to Cargo.
Cargo will now use JSON output from `rustc` and `rustdoc` 100% of the time (`rustdoc --test` does not use JSON). Previously Cargo would only use JSON for pipelined crates.
Cargo will save the JSON output into a file named `output` in the `.fingerprint` directory. This file is only created when the compiler outputs a diagnostic message.
If a crate is being recompiled, and Cargo considers it to be "fresh", it will replay the output file to the console.
## Notable changes in this PR
- Fixed a bug where replays were erroneously including pipeline rmeta artifact json messages.
- clippy-preview is now included in the metadata hash, to force its artifacts to be separate from `cargo check`.
- clippy-preview is no longer force-enabled, under the assumption that caching and fingerprinting is accurate, and the cached messages will be replayed.
- clippy-preview's arguments are included in the fingerprint now that it is not force-enabled.
- Rustdoc colors and short messages were fixed when pipelining was stabilized, so updated tests.
The only notable issue with this is that switching between short and long human messages only replays the format from the first invocation. That is, if you do `cargo build` and it generates warnings, then running again with `--message-format=short` will still show the full length human messages. I'm personally fine with that behavior, even though it is not ideal. I think this feature overall improves the situation (where before *no* output was displayed). Being able to re-render between short/long is a very difficult problem, and unlikely to be fixable in the foreseeable future.
There was some concern expressed about being able to disable this. I think that would only be necessary if a severe bug is discovered. I do not feel that this change is risky enough to warrant a configurable option. If it does cause a problem, it can be quickly reverted with a one-line change to set `OutputOptions::cache_cell` to `None`. Since pipelining has been using JSON output for a while now without complaints, I feel pretty confident in it.
bors [Wed, 9 Oct 2019 16:55:15 +0000 (16:55 +0000)]
Auto merge of #7456 - alexcrichton:config-only-serde, r=ehuss
Migrate towards exclusively using serde for `Config`
This series of commits was spawned off a thought I had while reading https://github.com/rust-lang/cargo/issues/7253#issuecomment-535656059, although it ended up not really touching on that at all. I was a little unsettled about how unstructured the config accesses are throughout Cargo and we had sort of two systems (one serde which is nice, one which is more manual) for reading config values.
This PR converts everything to run through serde for deserializing values, except for `get_list` which is funky. There's only one usage of that with the `paths` key though and we can probably fix this soon-ish.
In any case, the highlights of this PR are:
* This PR is surprisingly large. I did a lot of movement in `config.rs` to try to make the file smaller and more understandable.
* The `Value` type which retains information about where it was deserialized from is very special, and has special treatment with serde's data model. That's what allows us to use that and serde at the same time.
* The `ConfigRelativePath` and `ConfigKey` structures have been revamped internally, but morally serve the same purposes as before.
* Cargo now has structured `struct` access for a bunch of its configuration (`net`, `http`, `build`, etc). I would ideally like to move toward a world where this is the *only* way to read configuration, or at least everything conventionally runs through those paths.
* Functionally, this PR should have no difference other than tweaks to error messages here and there, and perhaps more strict validation on commands where we validate more configuration on each run than we previously did.
* This isn't a 100% transition for Cargo yet, but I figured it would be a good idea to post this and get some feedback first.
* In the long run I want to remove `get_env`, `get_cv`, and `get_*_priv` from `Config` as internal details. I'd like to move this all to `de.rs` and have it walk down the tree of configuration as we deserialize a value. For now though these all remain in place and that refactoring is left to a future PR.
bors [Tue, 8 Oct 2019 01:16:07 +0000 (01:16 +0000)]
Auto merge of #7470 - alexcrichton:cyclic-error, r=Eh2406
Improve error message for cyclic dependencies
First reported in rust-lang/rust#65014 it looks like our error message
on cyclic dependencies may be confusing at times. It looks like this is
an issue because there are multiple paths through a graph for a
dependency, so using the generic `path_to_top` function isn't producing
the most useful path for this purpose.
We're already walking the graph though, so this commit adds an extra
parameter which collects the list of packages we've visited so far to
produce a hopefully always-accurate error message showing the chain of
dependencies end-to-end for what depends on what.
Alex Crichton [Fri, 27 Sep 2019 19:29:01 +0000 (12:29 -0700)]
Finish implementing `Value`, use it in helpers
Rewrite helpers like `get_bool` to use `get::<Option<Value<bool>>>`
instead of duplicating the logic that's already with the typed access of
configuration. This is more along the effort to centralize all
deserialization of configuration into typed values instead of using
ad-hoc accessors in a number of locations.
Alex Crichton [Fri, 27 Sep 2019 18:34:29 +0000 (11:34 -0700)]
Refactor `ConfigKey` to its own file
Also make it a little less allocation-heavy by tweaking the API to
encourage incremental building of the key and incremental destruction as
we walk throughout the configuration tree.
Alex Crichton [Wed, 2 Oct 2019 20:42:42 +0000 (13:42 -0700)]
Improve error message for cyclic dependencies
First reported in rust-lang/rust#65014 it looks like our error message
on cyclic dependencies may be confusing at times. It looks like this is
an issue because there are multiple paths through a graph for a
dependency, so using the generic `path_to_top` function isn't producing
the most useful path for this purpose.
We're already walking the graph though, so this commit adds an extra
parameter which collects the list of packages we've visited so far to
produce a hopefully always-accurate error message showing the chain of
dependencies end-to-end for what depends on what.
bors [Fri, 4 Oct 2019 17:07:14 +0000 (17:07 +0000)]
Auto merge of #7482 - alexcrichton:fix-bin, r=ehuss
Fix wrong directories in PATH on Windows
This fixes an accidental regression from #7425 where `PATH` was being
augmented on Windows with the wrong search path for target/host
libraries. This commit fixes the issue by simply always calculating the
host/target library paths for `TargetInfo`, and then we explicitly use
the same `TargetInfo` for filling out information in `Compilation`.
Alex Crichton [Fri, 4 Oct 2019 15:04:48 +0000 (08:04 -0700)]
Fix wrong directories in PATH on Windows
This fixes an accidental regression from #7425 where `PATH` was being
augmented on Windows with the wrong search path for target/host
libraries. This commit fixes the issue by simply always calculating the
host/target library paths for `TargetInfo`, and then we explicitly use
the same `TargetInfo` for filling out information in `Compilation`.
bors [Fri, 4 Oct 2019 14:50:53 +0000 (14:50 +0000)]
Auto merge of #7476 - tlively:emscripten-wasm-aux, r=alexcrichton
Mark Emscripten's .wasm files auxiliary
This fixes #7471 and fixes #7255 by preventing the .wasm file from
being treated as an executable binary, so `cargo test` and `cargo run`
will no longer try to execute it directly. This change is only made
for Emscripten, which outputs a .js file as the primary executable
entry point, as opposed to other WebAssembly targets for which the
.wasm file is the only output.
Thomas Lively [Thu, 3 Oct 2019 23:42:23 +0000 (16:42 -0700)]
Mark Emscripten's .wasm files auxiliary
This fixes #7471 and fixes #7255 by preventing the .wasm file from
being treated as an executable binary, so `cargo test` and `cargo run`
will no longer try to execute it directly. This change is only made
for emscripten, which outputs a .js file as the primary executable
entry point, as opposed to other WebAssembly targets for which the
.wasm file is the only output.
bors [Wed, 2 Oct 2019 17:55:29 +0000 (17:55 +0000)]
Auto merge of #7464 - alexcrichton:update-curl-sys, r=ehuss
Update `curl-sys` dependency requirement
Pulls in alexcrichton/curl-rust#304 which fixes a bug from the last curl
update in #7308. This bug was not introduced by the Cargo PR itself but
rather by updating the `curl` submodule in the `curl-sys` crate. Without
this bugfix all downloads of a crate will make a new connection to
crates.io, which drastically increases download time since setting up a
connection takes so long.
Alex Crichton [Tue, 1 Oct 2019 21:36:04 +0000 (14:36 -0700)]
Update `curl-sys` dependency requirement
Pulls in alexcrichton/curl-rust#304 which fixes a bug from the last curl
update in #7308. This bug was not introduced by the Cargo PR itself but
rather by updating the `curl` submodule in the `curl-sys` crate. Without
this bugfix all downloads of a crate will make a new connection to
crates.io, which drastically increases download time since setting up a
connection takes so long.
bors [Tue, 1 Oct 2019 20:35:54 +0000 (20:35 +0000)]
Auto merge of #7462 - hbina:redundant_borrow, r=ehuss
Removed redundant borrow
As described here https://rust-lang.github.io/rust-clippy/master/#needless_borrow.
rust-clippy is complaining that the related borrows are unnecessary.
bors [Tue, 1 Oct 2019 19:01:47 +0000 (19:01 +0000)]
Auto merge of #7361 - Eh2406:public_dependency-as-type_4, r=alexcrichton
Public dependency refactor and re-allow backjumping
There were **three** attempts at vanquishing exponential time spent in Public dependency resolution. All failures. All three started with some refactoring that seams worth saving. Specifically the data structure `public_dependency` that is used to test for Public dependency conflicts is large, tricky, and modified in line. So lets make it a type with a name and move the interactions into methods.
Next each attempt needed to know how far back to jump to undo any given dependency edge. I am fairly confident that any full solution will need this functionality. I also think any solution will need a way to represent richer conflicts than the existing "is this pid active". So let's keep the `still_applies` structure from the last attempt.
Last each attempt needs to pick a way to represent a Public dependency conflict. The last attempt used three facts about a situation.
- `a1`: `PublicDependency(p)` witch can be read as the package `p` can see the package `a1`
- `b`: `PublicDependency(p)` witch can be read as the package `p` can see the package `b`
- `a2`: `PubliclyExports(b)` witch can be read as the package `b` has the package `a2` in its publick interface.
This representation is good enough to allow for `backjumping`. I.E. `find_candidate` can go back several frames until the `age` when the Public dependency conflict was introduced. This optimization, added for normal dependencies in #4834, saves the most time in practice. So having it for Public dependency conflicts is important for allowing real world experimentation of the Public dependencies feature. We will have to alter/improve/replace this representation to unlock all of the important optimizations. But I don't know one that will work for all of them and this is a major step forward.
As described here https://rust-lang.github.io/rust-clippy/master/#needless_borrow.
rust-clippy is complaining that the related borrows are unnecessary.
Auto merge of #7417 - alexcrichton:less-hashing, r=Eh2406
Go back to not hashing `RUSTFLAGS` in `-Cmetadata`
This is a moral revert of #6503 but not a literal code revert. This
switches Cargo's behavior to avoid hashing compiler flags into
`-Cmetadata` since we've now had multiple requests of excluding flags
from the `-Cmetadata` hash: usage of `--remap-path-prefix` and PGO
options. These options should only affect how the compiler is
invoked/compiled and not radical changes such as symbol names, but
symbol names are changed based on `-Cmetadata`. Instead Cargo will still
track these flags internally, but only for reinvoking rustc, and not for
caching separately based on rustc flags.