7683 Commits

Author SHA1 Message Date
Alex Crichton
e9428cbadd Remove Freshness from DependencyQueue
Ever since the inception of Cargo and the advent of incremental
compilation at the crate level via Cargo, Cargo has tracked whether it
needs to recompile something at a unit level in its "dependency queue"
which manages when items are ready for execution. Over time we've fixed
lots and lots of bugs related to incremental compilation, and perhaps
one of the most impactful realizations was that the model Cargo started
with fundamentally doesn't handle interrupting Cargo halfway through and
resuming the build later.

The previous model relied upon implicitly propagating "dirtiness" based
on whether the one of the dependencies of a build was rebuilt or not.
This information is not available, however, if Cargo is interrupted and
resumed (or performs a subset of steps and then later performs more).
We've fixed this in a number of places historically but the purpose of
this commit is to put a nail in this coffin once and for all.

Implicit propagation of whether a unit is fresh or dirty is no longer
present at all. Instead Cargo should always know, irrespective of it's
in-memory state, whether a unit needs to be recompiled or not. This
commit actually turns up a few bugs in the test suite, so later commits
will be targeted at fixing this.

Note that this required a good deal of work on the `fingerprint` module
to fix some longstanding bugs (like #6780) and some serious hoops had to
be jumped through for others (like #6779). While these were fallout from
this change they weren't necessarily the primary motivation, but rather
to help make `fingerprints` a bit more straightforward in what's an
already confusing system!

Closes #6780
2019-04-10 10:42:08 -07:00
Alex Crichton
f16efff150 Run cargo fmt 2019-04-10 10:42:07 -07:00
bors
449411f11d Auto merge of #6837 - ehuss:remove-alt-reg-test, r=Eh2406
testsuite: cleanup for `alternative-registries`

Remove some `alternative-registries` features that were accidentally left
behind.
2019-04-10 02:14:35 +00:00
Eric Huss
c495e0a654 testsuite: cleanup for alternative-registries
Remove some `alternative-registries` features that were accidentally left
behind.
2019-04-09 19:08:43 -07:00
bors
0216dcd418 Auto merge of #6824 - ehuss:improve-test-rerun-hint, r=alexcrichton
Improve error message to rerun a test in a workspace.

In a non-virtual workspace, if you run `cargo test --all` and something fails, it tells you to rerun `--test foo`, but if `foo` is not the default, then it won't work without a `-p` flag.  This tries to be a little more careful about when `-p` is needed in the hint.
2019-04-08 17:58:06 +00:00
bors
73036daa8f Auto merge of #6829 - ehuss:fix-mutable-borrow, r=alexcrichton
Fix mutable_borrow_reservation_conflict warning.

nightly-2019-04-08 added a more restrictive borrowing rule (rust-lang/rust#58739).
2019-04-08 17:32:47 +00:00
Eric Huss
f9f339a2c8 Fix mutable_borrow_reservation_conflict warning. 2019-04-08 10:05:45 -07:00
Eric Huss
44c535ab09 Improve error message to rerun a test in a workspace. 2019-04-05 18:52:22 -07:00
bors
f5b60ac5cc Auto merge of #6798 - ehuss:install-upgrade, r=alexcrichton
Add install-upgrade.

This implements the feature described in #6667. Instead of failing when `cargo install` detects a package is already installed, it will upgrade if the versions don't match, or do nothing (exit 0) if it is considered "up-to-date".

Closes #6667.

Notes:
- This feature rejects ambiguous `--version` input (such as `1.0`). This is not required, but seemed like a reasonable time to make the change.
- There is a slight change to the output on stable which reports what was installed/replaced.
- Added better support for `*` in `--version` (don't show warning).
2019-04-05 18:29:47 +00:00
Eric Huss
5a9ff8a621 install-upgrade: Add some more comments. 2019-04-05 10:48:23 -07:00
bors
b08e4cbb7c Auto merge of #6823 - spl:clarify-install-path, r=alexcrichton
Clarify docs of install without <crate>

This is an attempt to clarify the documentation of `install` without `<crate>`. I found it confusing trying to determine to which behavior “this” referred as well as whether “supported” meant “maintained” or “worked.”
2019-04-05 13:26:24 +00:00
Sean Leather
3ed4ad8dd1 Clarify docs of install without <crate> 2019-04-05 12:57:55 +02:00
bors
6f3e9c367a Auto merge of #6820 - ehuss:fix-edition-link, r=alexcrichton
Fix doc link.

The rust linkchecker does not like directory-style links.
0.36.0
2019-04-04 14:11:33 +00:00
Eric Huss
9ecdfe0475 install-upgrade: Fix bugs, more comments, review updates. 2019-04-03 18:05:55 -07:00
Eric Huss
c98ee9bdc9 Fix doc link.
The rust linkchecker does not like directory-style links.
2019-04-03 16:45:24 -07:00
bors
d62dcd6af4 Auto merge of #6818 - dtolnay:comma, r=alexcrichton
Accept trailing comma in test of impl Debug for PackageId

The standard library is planning to begin emitting trailing commas in multiline Debug representations to align with the dominant style in modern Rust code -- https://github.com/rust-lang/rust/pull/59076.

```diff
  PackageId {
      name: "foo",
      version: "1.0.0",
-     source: "registry `https://github.com/rust-lang/crates.io-index`"
+     source: "registry `https://github.com/rust-lang/crates.io-index`",
  }
```

For now, change this tests to accept both with and without trailing comma. Once the trailing comma change reaches the stable channel we will be able to remove one of the cases.
2019-04-03 20:25:19 +00:00
David Tolnay
1b10b701b5
Accept trailing comma in test of impl Debug for PackageId
The standard library is planning to begin emitting trailing commas in
multiline Debug representations to align with the dominant style in
modern Rust code.

      PackageId {
          name: "foo",
          version: "1.0.0",
    -     source: "registry `https://github.com/rust-lang/crates.io-index`"
    +     source: "registry `https://github.com/rust-lang/crates.io-index`",
      }

For now, change this tests to accept both with and without trailing
comma. Once the trailing comma change reaches the stable channel we will
be able to remove one of the cases.
2019-04-03 13:21:30 -07:00
bors
b9bba2dda7 Auto merge of #6814 - ehuss:offline-optional-dep, r=alexcrichton
Resolve: Be less strict while offline.

When offline, the resolver was requiring everything to be downloaded, even dependencies that are not used. This changes it so that the resolver can still resolve unavailable dependencies when offline. This pushes the failure to a later stage of Cargo where it attempts to download the dependency. This makes `-Z offline` work for target-cfg or optional dependencies that are not being used.

Fixes #6014.

This changes the error message significantly for the "unavailable" case (see test diff). I personally think the new error message is clearer, although it is shorter and provides less information. The old error message seemed large and scary, and was a little hard for me to grok. However, I'd be willing to look at tweaking the error behavior if not everyone agrees.
2019-04-02 22:03:55 +00:00
bors
11b17b5891 Auto merge of #6815 - ehuss:doc-downloads, r=Eh2406
Add some docs for `Downloads`.

Rather than fight with rustfmt which didn't like the inline comment, I decided to just add some more elaborate docs.
2019-04-02 21:29:56 +00:00
Eric Huss
aa8e2577f3 Add some docs for Downloads. 2019-04-02 14:19:53 -07:00
bors
c866f48e40 Auto merge of #6776 - Eh2406:resolver-simplification, r=alexcrichton
Resolver: A dep is equivalent to one of the things it can resolve to.

This is a series of small changes to the resolver, each one on its own is not worth the cherne, but somehow all together we can add a new optimization rule. The result is that the test in #6283 is no longer exponencial (still a large polynomial, cubick?) and so N can be bumped from 3 to 20. This also means that we pass with all the cases reported in #6258. Resolution is NP-Hard, so we are moving the slow cases around. To reduce the chance that we will be flooded by new bad cases I run the 4 proptests overnight, and they did not find a new exponencial case.

I would recommend reviewing this commit by commit. As each change is pretty simple on its own, but the mixed diff is harder to follow. This is submitted as one big PR as that is @alexcrichton's preference.

A special thanks to @nex3, our conversation was important in convincing me that several of these changes would be needed even in an eventual PubGrub based system. And, the question "why would PubGrub not have a problem with #6283" was wat crystallized this optimization opportunity in my mind.
2019-04-02 20:44:10 +00:00
Eric Huss
2378a9be3d Resolve: Be less strict while offline. 2019-04-02 13:27:42 -07:00
Eric Huss
e023a6672b Add install-upgrade. 2019-04-02 08:40:34 -07:00
bors
6bdb9d3b11 Auto merge of #6811 - ehuss:include-proc-macro, r=alexcrichton
Include proc-macros in `build-override`.

This adds proc-macros (and their dependencies) to the `build-override` profile setting.  The motivation is that these are all "build time" dependencies, and as such should probably behave the same.  See the discussion on the [tracking issue](https://github.com/rust-lang/rust/issues/48683#issuecomment-472705245).  My intent is that this paves the way for stabilizing without necessarily waiting for #6577.

The only change here is the line in `with_for_host`, the rest is just renaming for clarity.

This also includes some of the testsuite changes from #6577 to make it easier to check for compiler flags.
2019-04-02 14:52:18 +00:00
bors
86b888845c Auto merge of #6809 - ehuss:glossary-feature, r=alexcrichton
Update glossary for `feature`.

Added the newly documented `target_feature` to help people disambiguate
the various usages.
2019-04-02 14:27:14 +00:00
bors
95f94231c7 Auto merge of #6812 - ehuss:wasm-example, r=alexcrichton
Don't include metadata in wasm binary examples.

This removes the metadata hash from wasm example binaries, and consequently also includes the `.wasm` files in the artifact JSON message.

Closes #6810.

I renamed a method and added a new one to maybe make things a little clearer. This cannot be easily tested (see #4973).
2019-04-02 14:02:15 +00:00
Eric Huss
5d09137bb6 Don't include metadata in wasm binary examples. 2019-04-01 16:53:23 -07:00
Eric Huss
3cf913ef93 Include proc-macros in build-override. 2019-04-01 16:05:04 -07:00
Eric Huss
e65516e5ab Update glossary for feature.
Added the newly documented `target_feature` to help people disambiguate
the various usages.
2019-04-01 14:43:02 -07:00
bors
025b01edd0 Auto merge of #6759 - yaahallo:cargo-clippy, r=alexcrichton
Cargo clippy

resolves https://github.com/rust-lang/rust-clippy/issues/3837
2019-04-01 17:23:19 +00:00
Alex Crichton
842da62afb Remove no longer needed fields in BuildConfig
Now the fields are just all represented as `rustc_wrapper` which
internally contains all process configuration that's later passed down
to `Rustc` as necessary.
2019-04-01 10:22:23 -07:00
bors
d04d75be44 Auto merge of #6800 - ehuss:git-cli-force, r=alexcrichton
Support force-pushed repos with git-fetch-with-cli.

If a git repo had a force push, then the `git-fetch-with-cli` feature would fail to fetch an update.  This adds the `--force` flag to force the fetch.  There's a bit of a lengthy discussion in the [git docs](https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt-ltrefspecgt) about why this is needed when a refspec is supplied.

I also changed it to remove the `--quiet` flag and to capture the output, which is only displayed on error.  I'm not sure what the reasoning for the `--quiet` flag was, but I don't see any harm since the output was previously unused.  This can maybe help people debug problems, however in this situation
all you would see is ` ! [rejected]        master     -> master  (non-fast-forward)` which isn't terribly informative.

Fixes #6795.
2019-04-01 16:19:17 +00:00
bors
fccca68ef8 Auto merge of #6801 - ehuss:install-flags, r=Eh2406
cargo install: Be more restrictive about cli flags.

Several flags in `cargo install` are silently ignored depending on what is used. This adds some validation so that invalid combinations are rejected.  I have been sorta confused by these in the past.

- The 3 source flags (`--git`, `--path`, and `--registry`) are mutually exclusive.
- The `--git` flags (branch, tag, rev) are only valid if `--git` is specified.
- `--registry` requires a crate name (otherwise it would be ignored and treated as a path source).
- `--version` is only used when a crate name is specified.
2019-04-01 14:12:58 +00:00
bors
8cf0c95c19 Auto merge of #6806 - ehuss:warn-semver-metadata, r=Eh2406
Warn on version req with metadata.

Metadata in a version requirement (such as `1.0.0+1234`) is ignored. This adds a warning that it will be ignored.

On crates.io I found about 5 crates, plus a few dozen google-* crates (presumably all created by the same person) which have dependencies of this form.

See discussion at https://github.com/rust-lang/cargo/issues/6504#issuecomment-451254084. cc rust-lang/crates.io#1059 for ongoing discussion about what to do about publishing such versions.
2019-04-01 12:55:31 +00:00
bors
c1384e831d Auto merge of #6805 - ehuss:hint-workspace-exclude, r=alexcrichton
Add more suggestions on how to deal with excluding a package from a workspace.

Closes #5418
2019-04-01 12:31:20 +00:00
bors
527017fd24 Auto merge of #6804 - ehuss:install-path-config2, r=alexcrichton
Allow `cargo install --path P` to load config from P.

`cargo install` was changed to ignore configs except for the home directory (#6026). However, it seems like there are legitimate needs when using `--path`, so allow loading from that path, too.

Closes #6498.
Closes #6397.
2019-04-01 12:06:29 +00:00
bors
d338c49d5f Auto merge of #6803 - ehuss:doc-open-multi, r=alexcrichton
Allow `cargo doc --open` with multiple packages.

If `cargo doc --open` builds multiple packages, open the first one. This seems pretty natural to me (the first one on the command line, or the first default member if `default-members` is specified, or the root of a workspace). Rustdoc shows a list of crates in the sidebar, so if it doesn't open the one the user wants, it's a trivial matter of clicking on the crate name.

@alexcrichton specifically asked for an error [here](https://github.com/rust-lang/cargo/pull/1828#discussion-diff-39650485). However, at the time I don't think rustdoc dynamically generated the "Crates" listing in the sidebar. Alex, I wonder if your stance still holds?

Closes #5145
2019-04-01 11:42:02 +00:00
bors
5ba4ef3853 Auto merge of #6791 - ehuss:unstable-help, r=Eh2406
Add some help and documentation for unstable flags.

This is intended to give a little extra information about unstable flags.

- `-Z help` tells you if you can't use it on stable.
- `-Z help` includes link to the unstable chapter.
- `--out-dir` and `--build-plan` on stable give more information about what channels are and a link to their respective tracking issues.  Add links in the man pages, too.
2019-04-01 11:17:42 +00:00
bors
038edb6ab7 Auto merge of #6807 - ehuss:libc-warning, r=alexcrichton
Fix unused import warning.

2019-04-01 nightly introduced a new warning (presumably rust-lang/rust#58805).
2019-04-01 10:53:57 +00:00
Eric Huss
ee6e1c560c Fix unused import warning. 2019-03-31 19:37:26 -07:00
Eric Huss
70e4e87c17 Warn on version req with metadata. 2019-03-31 18:53:54 -07:00
Eric Huss
d7a9212409 Add more suggestions on how to deal with excluding a package from a workspace. 2019-03-31 17:52:36 -07:00
Eric Huss
fe8f29432d Allow cargo install --path P to load config from P. 2019-03-31 17:13:44 -07:00
Eric Huss
59af340d8f Allow cargo doc --open with multiple packages. 2019-03-31 15:47:03 -07:00
bors
4986d8ce89 Auto merge of #6802 - ehuss:new-empty-email, r=Eh2406
new/init: Don't include email if it is empty.

For `cargo new` or `cargo init`, if the email address is empty, don't include an empty `<>` in the `authors` field in `Cargo.toml`. This can be useful if you want to include an email address in the git config, but you don't want it in new manifest files.

Closes #4892
2019-03-31 21:14:56 +00:00
Eric Huss
4282274e64 new/init: Don't include email if it is empty. 2019-03-31 14:05:49 -07:00
Eric Huss
b666a9faa3 cargo install: Be more restrictive about cli flags. 2019-03-31 12:38:16 -07:00
Eric Huss
1667b75abc Support force-pushed repos with git-fetch-with-cli. 2019-03-31 10:06:23 -07:00
bors
ede459e251 Auto merge of #6799 - ehuss:fix-member_manifest_version_error-network, r=alexcrichton
Fix member_manifest_version_error accessing the network.

This test was updating the registry via github.  Add a `.cargo/config` file so that it doesn't.
2019-03-31 12:23:06 +00:00
Eric Huss
f01428b647 Fix member_manifest_version_error accessing the network. 2019-03-30 19:12:32 -07:00