9617 Commits

Author SHA1 Message Date
Alex Crichton
6514c289d2 Improve git error messages a bit
This commit is targeted at further improving the error messages
generated from git errors. For authentication errors the actual URL
fetched is now printed out as well if it's different from the original
URL. This should help handle `insteadOf` logic where SSH urls are used
instead of HTTPS urls and users can know to track that down.

Otherwise the logic about recommending `net.git-fetch-with-cli` was
tweaked a bit and moved to the same location as the rest of our error
reporting.

Note that a change piggy-backed here as well is that `Caused by:` errors
are now automatically all tabbed over a bit instead of only having the
first line tabbed over. This required a good number of tests to be
updated, but it's just an updated in renderings.
2020-06-25 08:47:15 -07:00
bors
c26576f9ad Auto merge of #8387 - robinmoussu:master, r=alexcrichton
Adding environment variable CARGO_PKG_LICENSE_FILE

When #8325 was added, only CARGO_PKG_LICENSE was added. However, the field license [may be empty](https://doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields) if the license_field is filled in.
2020-06-23 16:21:21 +00:00
bors
fd600f3a40 Auto merge of #8391 - bl2e:install-target-dir, r=alexcrichton
Enable "--target-dir" in "cargo install"

Issue #8263
2020-06-23 15:48:36 +00:00
bors
78c16716e6 Auto merge of #8323 - naerbnic:add_workspace_metadata_table, r=alexcrichton
Add support for `workspace.metadata` table

Implements feature request #8309

Additionally includes the information in the output of "cargo metadata" through a new top-level field `metadata`, similar to the per-package `metadata` field
2020-06-23 15:18:10 +00:00
bors
10ae887ffb Auto merge of #8398 - ehuss:clean-reserved-name, r=Eh2406
Fix overzealous `clean -p` for reserved names.

#8210 changed the way `clean -p` worked, but in some ways it is a little too sloppy.  If a package has a test named `build`, then it would delete the `build` directory thinking an executable named "build" exists.  This changes it so that it does not attempt to delete tests/benches from the uplift directory.
2020-06-22 21:07:37 +00:00
Eric Huss
6263d726f6 Fix overzealous clean -p for reserved names. 2020-06-22 12:56:10 -07:00
bors
b3b25ab6c5 Auto merge of #8395 - ehuss:fix-opt-dep-order, r=Eh2406
Fix order-dependent feature resolution.

There is a situation where if you have `pkg/feature` syntax, and `pkg` is an optional dependency, but also a dev-dependency, and the dev-dependency appears before the (optional) normal dependency in the summary, then the optional dependency would not get activated. This is because the feature code used `find` to get the first entry.

Fixes #8394
2020-06-22 00:35:00 +00:00
Eric Huss
ab73b2c35c Fix order-dependent feature resolution. 2020-06-21 17:28:36 -07:00
bl2e
538d925920 Fix post-execution path checks to be compatible with Windows 2020-06-20 23:37:56 -07:00
bl2e
bb3754276a Fix test compatibility for Windows 2020-06-20 23:01:35 -07:00
bl2e
291fb41665 Reference options-target-dir in cargo install documentation 2020-06-20 21:29:23 -07:00
bl2e
1f2de1e0a7 Add test for cargo install option --target-dir 2020-06-20 17:50:20 -07:00
bl2e
35d3f6dcb0 Enable --target-dir support in install subcommand 2020-06-20 17:49:44 -07:00
bors
442de291ca Auto merge of #8389 - hbina:spelling, r=ehuss
Correct mispelling of `cargo`.
2020-06-20 19:29:18 +00:00
Hanif Bin Ariffin
08ba47d3d1 Correct mispelling of cargo. 2020-06-20 14:33:20 -04:00
bors
d25ecc800e Auto merge of #8386 - crlf0710:master, r=ehuss
Add missing license field.

Hi, i was playing with `cargo-deny`, and found that it says this crate doesn't have a license field. So i'm going ahead and add it for consistency.
2020-06-20 16:06:52 +00:00
Robin Moussu
3b39e3a73d Adding environment variable CARGO_PKG_LICENSE_FILE 2020-06-20 12:01:35 +02:00
bors
c8ae267490 Auto merge of #8325 - kerkmann:license-field-as-environment-variable, r=joshtriplett
Adding environment variable CARGO_PKG_LICENSE

Fixes #8024
2020-06-20 03:35:31 +00:00
CrLF0710
ad0940c9ad Add missing license field. 2020-06-20 10:03:25 +08:00
bors
b80fc85f8c Auto merge of #8363 - alexcrichton:less-git-data, r=ehuss
Cut down on data fetch from git dependencies

Currently Cargo pretty heavily over-approximates data fetch for git
dependencies. For the index it fetches precisely one branch, but for all
other git dependencies Cargo will fetch all branches and all tags all
the time. In each of these situations, however, Cargo knows if one
branch is desired or if only one tag is desired.

This commit updates Cargo's fetching logic to plumb the desired
`GitReference` all the way down to `fetch`. In that one location we then
determine what to fetch. Namely if a branch or tag is explicitly
selected then we only fetch that one reference from the remote, cutting
down on the amount of traffic to the git remote.

Additionally a bugfix included here is that the GitHub fast path for
checking if a repository is up-to-date now works for non-`master`-based
branch dependencies.
2020-06-18 17:14:16 +00:00
Alex Crichton
ddc27999c1 Update how locked git commits are fetched
This commit refactors various logic of the git source internals to
ensure that if we have a locked revision that we plumb the desired
branch/tag all the way through to the `fetch`. Previously we'd switch to
`Rev` very early on, but the fetching logic for `Rev` is very eager and
fetches too much, so instead we only resolve the locked revision later
on.

Internally this does some various refactoring to try to make various
bits and pieces of logic a bit easyer to grok, although it's still
perhaps not the cleanest implementation.
2020-06-16 09:36:49 -07:00
Alex Crichton
437e5d7ee1 Strip .git from urls on GitHub fast-path 2020-06-16 08:31:19 -07:00
Alex Crichton
869642bb09 Cut down on data fetch from git dependencies
Currently Cargo pretty heavily over-approximates data fetch for git
dependencies. For the index it fetches precisely one branch, but for all
other git dependencies Cargo will fetch all branches and all tags all
the time. In each of these situations, however, Cargo knows if one
branch is desired or if only one tag is desired.

This commit updates Cargo's fetching logic to plumb the desired
`GitReference` all the way down to `fetch`. In that one location we then
determine what to fetch. Namely if a branch or tag is explicitly
selected then we only fetch that one reference from the remote, cutting
down on the amount of traffic to the git remote.

Additionally a bugfix included here is that the GitHub fast path for
checking if a repository is up-to-date now works for non-`master`-based
branch dependencies.
2020-06-16 08:01:33 -07:00
bors
089cbb80b7 Auto merge of #8359 - ehuss:doctest-xcompile-linker, r=alexcrichton
Support linker with -Zdoctest-xcompile.

This adds support for `-Clinker` with `-Zdoctest-xcompile`.

I'm not entirely sure how `-Zdoctest-xcompile` was supposed to work without setting the linker. I tested this with std on arm-unknown-linux-gnueabihf with qemu. It seems to work (although it was quite slow).

Closes #7529.
2020-06-15 14:38:34 +00:00
bors
4e14cc101a Auto merge of #8358 - ehuss:fix-target-host-doctest, r=alexcrichton
Fix doctests not running with --target=HOST.

There was a regression in #8167 where `cargo test --target=$HOST` stopped running doctests. This caused doctests to silently stop running in rust-lang/rust (https://github.com/rust-lang/rust/issues/73286).  This PR restores the original behavior where `--target=$HOST` behaves as-if it is a normal host test.

There was a discussion about this at https://github.com/rust-lang/cargo/pull/8167#pullrequestreview-402196323, but I think I let it slip through the cracks.
2020-06-15 14:05:10 +00:00
bors
56636e94ca Auto merge of #8344 - kellda:install-index-flag, r=ehuss
Allow passing a registry index url directly to `cargo install`

Fixes #8318
2020-06-14 18:32:58 +00:00
Eric Huss
a0fb62f516 Add --index to install man page. 2020-06-14 11:32:17 -07:00
Eric Huss
b4476d74f3 Support linker with -Zdoctest-xcompile. 2020-06-13 21:19:22 -07:00
Eric Huss
1bf67a0402 Fix doctests not running with --target=HOST. 2020-06-13 20:56:29 -07:00
naerbnic
16f3b8ddcf
Update src/doc/src/reference/manifest.md
Add a link to the mdbook generated link

Co-authored-by: Eric Huss <eric@huss.org>
2020-06-11 17:01:19 -07:00
naerbnic
2a529c1887
Update src/doc/src/reference/workspaces.md
Remove anchor to use the mdbook generated link instead.

Co-authored-by: Eric Huss <eric@huss.org>
2020-06-11 17:01:03 -07:00
bors
79c769c3d7 Auto merge of #8353 - ehuss:fix-missing-readme, r=alexcrichton
Fix failure with missing readme.

#8277 added implicit README support, but it also rejected parsing any manifest where the README was missing.  This causes a problem because the README is often missing in many registry packages (for various reasons).

This removes the validation at parsing time.  Cargo has historically not had hard enforcement at the parsing stage.  Whether or not the readme exists has always been enforced during publishing. I have added some extra context to the error message, and added a test to that effect.

Fixes #8351
2020-06-11 22:13:37 +00:00
Eric Huss
7a5f0369cb Fix failure with missing readme. 2020-06-11 14:55:33 -07:00
bors
ee417cbc2f Auto merge of #8349 - ehuss:fix-lto, r=alexcrichton
Some LTO fixes.

This reworks the LTO computation a little to address a few issues:

- `cargo build` in a project with both a lib and bin would not engage the optimization introduced in #8192 where the lib *should* be compiled with `-C linker-plugin-lto` (bitcode only). This happened because the old code was starting root units as `Lto::None`. The solution here is to conditionally choose the starting Lto for roots.
- A project with a dylib dependency would fail to build. It was building the dylib with `-C linker-plugin-lto` which is not valid.
- A project with a bin/lib would build the lib differently based on whether or not it was selected. This changes it so that the lib is built the same. See `lto::between_builds`, where the second build the lib is now fresh.
- Tests/benchmarks of a `lib` target will now support LTO.
- Treats example libs a little more consistently as regular libs.

I scattered some comments throughout, hopefully it's not too difficult to follow.

Closes #8337
2020-06-11 15:34:15 +00:00
Eric Huss
62a61dd103 Some LTO fixes. 2020-06-10 16:02:35 -07:00
kellda
1e0d38061c Add test for cargo install --index 2020-06-10 15:26:26 +00:00
bors
1ec223effb Auto merge of #8277 - tverghis:default-readme, r=alexcrichton
Default values for `readme` if not specified

If the a value for `readme` is not specified in Cargo.toml, we will now check for the existence of files named `README.md`, `README.txt` or `README`. If one does exist, the name of that file will be defaulted in to the manifest for the project.

This behavior can be suppressed if `readme` is set to `false`.

Closes #8133
2020-06-09 20:03:14 +00:00
Tarun Verghis
58ee013f17 Create README file so tests pass 2020-06-09 00:15:28 -07:00
Tarun Verghis
b0a3cc6b7a Assume README.md if readme=true 2020-06-09 00:03:15 -07:00
Daniél Kerkmann
1e800abcab
Merge branch 'master' into license-field-as-environment-variable 2020-06-08 21:24:02 +02:00
bors
5eb53f7d3f Auto merge of #8342 - ehuss:fix-tree-completions, r=alexcrichton
Fix tree completions.

During #8062, the flags were changed, but the completions weren't updated.

Fixes #8330
2020-06-08 14:47:36 +00:00
bors
22a112bff1 Auto merge of #8267 - drmikehenry:prefix, r=alexcrichton
Support `{prefix}` and `{lowerprefix}` markers in `config.json` `dl` key

Hello,

The crates.io-index Git repository uses a nice directory structure to keep individual directory sizes under control.

When mirroring crates.io, it's useful to store crate files in a similar directory structure for the same reasons.

Cargo provides "markers" for use in the `dl` key of the `config.json` file in crates.io-index to allow flexibility in mapping a crate's name and version into a URL for the crate.  The marker `{crate}` is replaced by the crate's name, and the marker `{version}` is replaced with the crate's version.  The default URL template is `https://crates.io/api/v1/crates/{crate}/{version}/download`.

Currently, if a mirror of crates.io stores crates in a directory structure similar to that of crates.io-index, it's up to the server to construct the directory name from the crate name.  This eliminates trivial web servers and `file:` URLs from hosting such a tree of crates.

This pull requests adds two new markers for the `dl` key in `config.json`, allowing Cargo to supply the directory name as part of the URL.  The marker `{lowerprefix}` is the same directory name used within crates.io-index; it is calculated from the crate name converted to lowercase.  The marker `{prefix}` is similar, but it uses the crate name as-is (without case conversion), which is useful for supporting older versions of Cargo that lack these markers; for example, nginx rewrite rules can easily construct `{prefix}` but can't perform case-conversion to construct `{lowerprefix}`.  These new markers will provide implementation flexibility and simplicity for crate mirror servers.
2020-06-08 14:19:43 +00:00
bors
6f9d808323 Auto merge of #8270 - reggaemuffin:8251-binary-name-env-var, r=ehuss
Add environment variables to identify the binary and crate name

Closes #8251

This adds `CARGO_BIN_NAME` and `CARGO_CRATE_NAME` to rustc/rustdoc process env.

`CARGO_BIN_NAME` is added for binary compilation units, `CARGO_CRATE_NAME` is added for binary and library units.

The `build::crate_env_vars` test was updated to test for this. The test is currently only checking behavior for the binary compile unit.

Documentation was updated to reflect the added environment variables.
2020-06-08 13:53:33 +00:00
kellda
3fbd5aefd4 Add --index flag to cargo install 2020-06-08 12:48:47 +00:00
Brian Chin
ae66a01690 Reformat 2020-06-07 15:59:35 -07:00
Brian Chin
224cb99b43 Inline load_workspace_metadata() into Workspace::new() 2020-06-07 15:57:28 -07:00
Eric Huss
45523c23da Fix tree completions. 2020-06-07 15:09:47 -07:00
Daniél Kerkmann
8c99e2026b
Change test 'MIT' license to 'MIT OR Apache-2.0' 2020-06-06 10:24:06 +02:00
bors
fb0e392399 Auto merge of #8336 - ehuss:version-bump, r=alexcrichton
Bump to 0.47.0, update changelog
2020-06-05 19:44:27 +00:00
bors
c4274471e3 Auto merge of #8334 - Eh2406:small-nits, r=alexcrichton
Nits: Remove unneeded mut and loop

just some small nits.
2020-06-05 19:02:19 +00:00