5295 Commits

Author SHA1 Message Date
André Rocha
c2ff988c9f Reorganize integration tests as one crate with many modules. Issue #4867. 2018-02-21 13:33:51 -05:00
bors
b80af359e2 Auto merge of #5058 - sfackler:patch-2, r=Mark-Simulacrum
Update default codegen-units

It's been 16 since rustc 1.24.
2018-02-19 22:31:29 +00:00
Steven Fackler
0c46ede78c
Update default codegen-units
It's been 16 since rustc 1.24.
2018-02-19 14:29:48 -08:00
bors
e55d158971 Auto merge of #5051 - cardoe:fix-doc-instructions, r=matklad
update contributing to show how to build the docs

The contributing guide referenced a script that was deleted in
1271bb4de0c0 so it wasn't possible to follow the contributing guide
successfully prior to contributing doc improvements.
2018-02-19 21:39:17 +00:00
bors
00eb24dc5e Auto merge of #5041 - pwoolcoc:display-path-to-custom-commands-when-verbose, r=matklad
When -v is passed with --list, display path to custom commands

With this change, output of `cargo --list` changes slightly when 1 or more `-v` flags are passed:

```
 ± ./target/debug/cargo --list -v
Installed Commands:
    add                  /path/to/home/.cargo/bin/cargo-add
    bench
    build
    canoe                /path/to/home/.cargo/bin/cargo-canoe
    check
    clean
    do                   /path/to/home/.cargo/bin/cargo-do
    doc
    fetch
    fmt                  /path/to/home/.cargo/bin/cargo-fmt
    ...
```
2018-02-19 21:09:48 +00:00
bors
4f1c6dba48 Auto merge of #4953 - alexcrichton:rename-via-as, r=matklad
Implement renaming dependencies in the manifest

This commit implements a new unstable feature for manifests which allows
renaming a crate when depending on it. For example you can do:

```toml
cargo-features = ["dependencies-as"]

...

[dependencies]
foo = "0.1"
bar = { version = "0.1", registry = "custom", package = "foo" }
baz = { git = "https://github.com/foo/bar", package = "foo" }
```

Here three crates will be imported but they'll be made available to the Rust
source code via the names `foo` (crates.io), `bar` (the custom registry), and
`baz` (the git dependency). The *package* name, however, will be `foo` for all
of them. In other words the git repository here would be searched for a crate
called `foo`. For example:

```rust
extern crate foo; // crates.io
extern crate bar; // registry `custom`
extern crate baz; // git repository
```

The intention here is to enable a few use cases:

* Enable depending on the same named crate from different registries
* Allow depending on multiple versions of a crate from one registry
* Removing the need for `extern crate foo as bar` syntactically in Rust source

Currently I don't think we're ready to stabilize this so it's just a nightly
feature, but I'm hoping we can continue to iterate on it!

cc #1311
2018-02-19 20:21:26 +00:00
bors
0a37d76ed2 Auto merge of #5050 - cardoe:add-dependency-info, r=matklad
doc: add explicit example with ^ and leading 0

Since the leading 0 is treated a bit special, its worth it to have an
explicit example to match the above example of the major version being >
0.
2018-02-19 19:51:32 +00:00
Doug Goldstein
e59171aab0
update contributing to show how to build the docs
The contributing guide referenced a script that was deleted in
1271bb4de0c0 so it wasn't possible to follow the contributing guide
successfully prior to contributing doc improvements.
2018-02-17 22:41:32 -06:00
Doug Goldstein
996197094c
doc: add explicit example with ^ and leading 0
Since the leading 0 is treated a bit special, its worth it to have an
explicit example to match the above example of the major version being >
0.
2018-02-17 22:28:40 -06:00
Paul Woolcock
f76db9c790 When -v is passed with --list, display path to custom commands 2018-02-14 12:27:19 -05:00
bors
489f570d47 Auto merge of #5037 - Eh2406:conflict_tracking, r=alexcrichton
Conflict tracking

This is an alternative implementation of #4834. This is slower but hopefully more flexible and clearer. The idea is to keep a list of `PackageId`'s that have caused us to skip a `Candidate`. Then we can use the list when we are backtracking if any items in our list have not been activated then we will have new `Candidate`'s to try so we should stop backtracking. Or to say that another way; We can continue backtracking as long as all the items in our list is still activated.

Next this new framework was used to make the error messages more focused. We only need to list the versions that conflict, as opposed to all previously activated versions.

Why is this more flexible?
1. It is not limited to conflicts within the same package. If `RemainingCandidates.next` skips something  because of a links attribute, that is easy to record, just add the `PackageId` to the set `conflicting_prev_active`.
2. Arbitrary things can add conflicts to the backtracking. If we fail to activate because some dependency needs a feature that does not exist, that is easy to record, just add the `PackageId` to the set `conflicting_activations`.
3. All things that could cause use to fail will be in the error messages, as the error messages loop over the set.
4. With a simple extension, replacing the `HashSet` with a `HashMap<_, Reason>`, we can customize the error messages to show the nature of the conflict.

@alexcrichton, @aidanhs, Does the logic look right? Does this seem clearer to you?
2018-02-14 16:52:47 +00:00
Eh2406
889909342c Don't store conflicting_activations for backtracking.
If we need it later we can always add it back in.
2018-02-14 11:22:02 -05:00
bors
e2c5d2e65a Auto merge of #5040 - daboross:patch-1, r=alexcrichton
Remove cargo-only downloads from installation docs

This also copies extra instructions for installing rust from https://doc.rust-lang.org/book/first-edition/getting-started.html#installing-rust-1.

I wasn't able to test the changes locally, but they're fairly minimal, so I trust they will render alright.

Fixes #5027.
2018-02-14 15:47:45 +00:00
David Ross
3e4d1558ab
Remove cargo-only downloads from installation docs
This also copies extra instructions for installing rust from https://doc.rust-lang.org/book/first-edition/getting-started.html#installing-rust-1.

Fixes https://github.com/rust-lang/cargo/issues/5027.
2018-02-13 22:17:15 -08:00
bors
d0ca5bcd6b Auto merge of #5039 - lawliet89:docopt-bounds, r=alexcrichton
Fix DocOpt deserialization type bounds

This is wrt https://github.com/docopt/docopt.rs/pull/222

DocOpt does not support deserializing borrowed types.

This change was reverted in
7292a374e6
because it broke crates like Cargo etc.
2018-02-14 06:13:12 +00:00
Yong Wen Chua
7e92513deb Fix DocOpt deserialization type bounds
This is wrt https://github.com/docopt/docopt.rs/pull/222

DocOpt does not support deserializing borrowed types.

This change was reverted in
7292a374e6
because it broke crates like Cargo etc.
2018-02-14 09:58:20 +08:00
bors
5891aecf37 Auto merge of #5029 - matklad:new-defaults-to-bin, r=withoutboats
New defaults to bin

So this switches `cargo new` default from `--lib` to `--bin`, as discussed on IRC.

The first two commits are just refactorings, and the last one actually flips the switch. Surprisingly enough, no tests need to be modified it seems!

r? @withoutboats
2018-02-13 11:03:57 +00:00
Eh2406
a028221478 Use the conflict tracking in the error messages to only show the versions that are in conflict 2018-02-12 22:26:55 -05:00
Alex Crichton
79942fea1b Implement renaming dependencies in the manifest
This commit implements a new unstable feature for manifests which allows
renaming a crate when depending on it. For example you can do:

```toml
cargo-features = ["dependencies-as"]

...

[dependencies]
foo = "0.1"
bar = { version = "0.1", registry = "custom", package = "foo" }
baz = { git = "https://github.com/foo/bar", package = "foo" }
```

Here three crates will be imported but they'll be made available to the Rust
source code via the names `foo` (crates.io), `bar` (the custom registry), and
`baz` (the git dependency). The *package* name, however, will be `foo` for all
of them. In other words the git repository here would be searched for a crate
called `foo`. For example:

```rust
extern crate foo; // crates.io
extern crate bar; // registry `custom`
extern crate baz; // git repository
```

The intention here is to enable a few use cases:

* Enable depending on the same named crate from different registries
* Allow depending on multiple versions of a crate from one registry
* Removing the need for `extern crate foo as bar` syntactically in Rust source

Currently I don't think we're ready to stabilize this so it's just a nightly
feature, but I'm hoping we can continue to iterate on it!
2018-02-12 15:15:39 -08:00
bors
2d42bcf41f Auto merge of #5033 - alexcrichton:update-deps, r=matklad
Update dependencies

Just a few major updates here and there
2018-02-12 22:32:11 +00:00
Alex Crichton
b90bb7d6a8 Update dependencies
Just a few major updates here and there
2018-02-12 14:30:18 -08:00
bors
3d0d90fb1d Auto merge of #5032 - matklad:lazycell, r=alexcrichton
Switch to lazycell from crate.io

This switches from a home-grown implementation of `lazycell` to the one from crates.io.

There are no particularly large improvements here, but our own lazy cell is definitely unsafe in theory, because of potential reentrancy in `get_or_try_init`, and the one from crates.io does not have at least this hole :-)

Note that `rustc` already has `lazycell` in its Cargo.lock (because of clippy I guess?), albeit with a lower version, 0.5.
2018-02-12 22:02:00 +00:00
bors
40486ce2e2 Auto merge of #5031 - matthiaskrgr:readme_docs, r=alexcrichton
readme: add link to the cargo documentation on docs.rs

[Rendered](https://github.com/matthiaskrgr/cargo/blob/readme_docs/README.md)

Background: I was searching for cargo source code doc a while back, found the cargo book and crates.io doc relatively quickly but not the actual source code doc which I only found (after way to much time had passed)  when I looked up the cargo crate on crates.io and found the "Documentation" link :/

Hope this improves the situation a bit in the future.
2018-02-12 20:53:27 +00:00
Matthias Krüger
ddffe6063c readme: add link to the cargo documentation on docs.rs 2018-02-12 21:04:06 +01:00
Aleksey Kladov
9cb10e68a2 Switch cargo new default to --bin 2018-02-12 21:38:24 +03:00
Aleksey Kladov
7f3e86e069 Switch to lazycell from crate.io 2018-02-12 21:33:31 +03:00
bors
cb30fba4a3 Auto merge of #5030 - alexcrichton:better-poll, r=matklad
Don't spin on empty fds in `read2` on Unix

This commit fixes what I think is some pathological behavior in Cargo where if
one stdio stream is closed before another then Cargo can accidentally spin in a
tight loop and not block appropriately. Previously, for example, if stderr
closed before stdout then Cargo would spin in a `poll` loop continuously getting
notified that stderr is closed.

The behavior is now changed so after a file descriptor is done we stop passing
it to `poll` and instead only pass the one remaining readable file descriptor.
2018-02-12 17:53:00 +00:00
Alex Crichton
ec991ebcb9 Don't spin on empty fds in read2 on Unix
This commit fixes what I think is some pathological behavior in Cargo where if
one stdio stream is closed before another then Cargo can accidentally spin in a
tight loop and not block appropriately. Previously, for example, if stderr
closed before stdout then Cargo would spin in a `poll` loop continuously getting
notified that stderr is closed.

The behavior is now changed so after a file descriptor is done we stop passing
it to `poll` and instead only pass the one remaining readable file descriptor.
2018-02-12 09:27:11 -08:00
Aleksey Kladov
9e5721c2b7 Refactor NewOptions to make it slightly more clear 2018-02-12 19:57:31 +03:00
Aleksey Kladov
d48cbf6df3 Cleanup 2018-02-12 19:31:48 +03:00
Eh2406
201fdba8f3 More directly track conflicts in backtracking, hopefully this will be easier to extend. 2018-02-11 16:52:58 -05:00
bors
43a62ba28c Auto merge of #5025 - Eh2406:error_mesges, r=alexcrichton
better resolver error messages

This is a start on beter resolver error messages. This is mostly trying to copy the `links` messages. In the process I found that we wor not testing the common case of having found candidates and still not resolving.

Any advice?
2018-02-09 18:50:24 +00:00
Eh2406
0117eb1fec better error messages 2018-02-09 11:52:14 -05:00
bors
8c2f353e4a Auto merge of #5024 - debris:helpful_message, r=alexcrichton
Add helpful message when running cargo doc --open

Add helpful message when running cargo doc --open in the root of the workspace.

closes #4962

old output:

```
 Documenting foo v0.1.0 (file:///Users/marek/projects/ethcore/tmp/dupa/foo)
 Documenting bar v0.1.0 (file:///Users/marek/projects/ethcore/tmp/dupa/bar)
    Finished dev [unoptimized + debuginfo] target(s) in 0.78 secs
error: Passing multiple packages and `open` is not supported
```

new output:

```
 Documenting foo v0.1.0 (file:///Users/marek/projects/ethcore/tmp/dupa/foo)
 Documenting bar v0.1.0 (file:///Users/marek/projects/ethcore/tmp/dupa/bar)
    Finished dev [unoptimized + debuginfo] target(s) in 0.81 secs
error: Passing multiple packages and `open` is not supported.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
  foo
  bar
```
2018-02-09 00:22:00 +00:00
debris
bd7ba3c89c Add helpful message when running cargo doc --open in the root of the workspace, fixes #4962 2018-02-08 22:50:35 +01:00
Eh2406
5a5b5fce42 generalize the path_to_top from the links errors 2018-02-08 14:13:07 -05:00
Eh2406
22ff9fcb91 test for the most common cargo resolver error 2018-02-08 14:13:07 -05:00
bors
5bfcaa1cd1 Auto merge of #5020 - stefanbirkner:linkfix, r=alexcrichton
Fix link to documentation
2018-02-07 23:11:35 +00:00
Stefan Birkner
43ff35f7ff
Fix link to documentation 2018-02-07 23:36:54 +01:00
bors
6d9fd1ceac Auto merge of #5018 - brotzeit:clippy, r=alexcrichton
apply clippy suggestions

I want to try if this actually works =)

There are many other clippy suggestions. I wonder if I can take them for granted or if some of them would be refused.

For example:
```
warning: Constants have by default a `'static` lifetime
  --> src/cargo/lib.rs:53:23
   |
53 | pub const CARGO_ENV: &'static str = "CARGO";
   |                      -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = note: #[warn(const_static_lifetime)] on by default
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.185/index.html#const_static_lifetime
```
2018-02-07 02:06:13 +00:00
brotzeit
577b8a2431 apply clippy suggestions 2018-02-06 22:49:50 +01:00
bors
750df0ae37 Auto merge of #5011 - Manishearth:stealing-chickens-off-the-internet, r=alexcrichton
Implement RFC 2052: Epoches

Todo:

 - Make epoches affect the fingerprint
 - Tests

cc https://github.com/rust-lang/rust/issues/44581

Rust PR: https://github.com/rust-lang/rust/pull/48014

r? @acrichto
2018-02-06 18:27:28 +00:00
Manish Goregaokar
270f6e28a0 epoch -> rust 2018-02-06 09:33:30 -08:00
bors
cac9173c76 Auto merge of #5017 - matthiaskrgr:manifest_cgu_lto, r=alexcrichton
manifest reference: correct statement: codegen-units=x is not ignored if lto=true.

Also fix typo along the way.
2018-02-06 17:33:20 +00:00
bors
b7c2cfb86b Auto merge of #4834 - aidanhs:aphs-better-backtrack, r=alexcrichton
Make resolution backtracking smarter

There's no need to try every candidate for every dependency when backtracking - instead, only try candidates if they *could* change the eventual failure that caused backtracking in the first place, i.e.
1. if we've backtracked past the parent of the dep that failed
2. the number of activations for the dep has changed (activations are only ever added during resolution I believe)

The two new tests before:
```
$ /usr/bin/time cargo test --test resolve -- --test-threads 1 --nocapture resolving_with_constrained_sibling_
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running target/debug/deps/resolve-19b2a13e5a19eed8
38.45user 2.16system 0:42.00elapsed 96%CPU (0avgtext+0avgdata 47672maxresident)k
0inputs+1664096outputs (0major+10921minor)pagefaults 0swaps
```
After:
```
$ /usr/bin/time cargo test --test resolve -- --test-threads 1 --nocapture resolving_with_constrained_sibling_
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running target/debug/deps/resolve-19b2a13e5a19eed8
[...]
0.36user 0.01system 0:00.49elapsed 76%CPU (0avgtext+0avgdata 47464maxresident)k
0inputs+32outputs (0major+11602minor)pagefaults 0swaps
```

You observe the issue yourself with the following (it should fail, but hangs for a while instead - I didn't bother timing it and waiting for it to finish. With this PR it terminates almost instantly):
```
$ cargo new --bin x
     Created binary (application) `x` project
$ /bin/echo -e 'serde = "=1.0.9"\nrust-s3 = "0.8"' >> x/Cargo.toml
$ cd x && cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Resolving dependency graph...
```
2018-02-06 17:05:37 +00:00
Matthias Krüger
50d210c058 manifest reference: correct statement: codegen-units=x is not ignored if lto=true.
Also fix typo along the way.
2018-02-06 13:27:56 +01:00
bors
a99768918b Auto merge of #5013 - withoutboats:no-rust-rename, r=matklad
Do not rename packages on `cargo new`.

Prior to this commit, packages beginning with `rust` or ending with
`rs` were renamed automatically when created, unless they were
binaries. The ostensible purpose of this code was to avoid people
uploading "redundant" names to crates.io, which is a repository of
Rust packages.

This behavior was overly opinionated. It is not cargo's
responsibility to discourage users from naming their packages any
particular way. Without a sound technical reasons why packages
cannot be named a certain way, cargo should not be intervening in
users' package naming decisions.

It also did this by automatically renaming the package for the
user, as opposed to erroring. Though it printed a message about
the behavior, it did not give the user a choice to abort the
process; to overrule cargo they had to delete the new project
and start again using the `--name` argument.

`cargo new` is many users' first entrypoint to the Rust ecosystem.
This behavior teaches a user that Rust is opinionated and magical,
both of which are divisive attributes for a tool, and attributes
which do not generally describe Rust's attitude toward things like
names and formatting.

If crates.io wishes to enforce that users not upload packages with
names like this, it should be enforced by crates.io at publish
time.
2018-02-06 06:08:23 +00:00
Manish Goregaokar
5d615a69b7 Add tests for epoch 2018-02-05 22:02:25 -05:00
Manish Goregaokar
711b4fa3f4 Include the epoch in the fingerprint 2018-02-05 22:02:25 -05:00
Manish Goregaokar
2d1af7b56e Pass -Zepoch flag when epoch feature exists 2018-02-05 22:02:25 -05:00