Commit graph

3806 commits

Author SHA1 Message Date
Nick Flueckiger 4234077bc2 Re-add backticks 2021-02-14 13:15:35 +01:00
Nick Flueckiger d3aed3585e Update wording and use if let 2021-02-14 13:00:20 +01:00
Nick Flueckiger 86c6e42741 Fix windows test case 2021-02-14 00:20:21 +01:00
Nick Flueckiger c86310210c Update windows check 2021-02-13 23:20:43 +01:00
Nick Flueckiger 6af31941f3 Adapt implementation with reviewer suggestions and requested changes 2021-02-13 21:17:18 +01:00
Nick Flueckiger 6ea8abc805 Correct target 2021-02-13 12:19:00 +01:00
Nick Flueckiger dd4b95fb9f Lint 2021-02-13 12:14:24 +01:00
Nick Flueckiger a7ae6352a3 Exclude test on windows 2021-02-13 11:59:38 +01:00
Nick Flueckiger 11c82a8af8 Implement uppercase env map for key case mismatch 2021-02-13 11:46:13 +01:00
Eric Huss 9cb8f41ec9 Prevent testsuite from loading config out of sandbox. 2021-02-10 17:39:38 -08:00
bors ab64d1393b Auto merge of #9153 - calavera:strip_options, r=ehuss
Allow `true` and `false` as options for `strip` option

This follows the convention of `lto` and `debug` that allow `true` for
the highest level, and `false` for disabled.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2021-02-10 00:19:10 +00:00
bors 0608fcd99d Allow true and false as options for strip option
This follows the convention of `lto` and `debug` that allow `true` for
the highest level, and `false` for disabled.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2021-02-10 00:19:10 +00:00
bors 46bac2dc44 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.
2021-02-09 23:42:27 +00:00
Alex Crichton 9f2ce1ffef Squash warnings on the nightly channel 2021-02-09 07:30:08 -08:00
Alex Crichton 1fefa5de26 Add back in deleted tests 2021-02-09 07:29:01 -08:00
bjorn3 f5a3d55983 Fix warnings of the new non_fmt_panic lint 2021-02-06 19:10:42 +01:00
Eric Huss 5ebb605c9a Fix panic with doc collision orphan. 2021-02-05 10:02:34 -08:00
Alex Crichton 7dd9872c13 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.
2021-02-04 08:54:40 -08:00
Eric Huss 33f648ab3b Fix permission issue with cargo vendor. 2021-02-03 17:37:00 -08:00
bors aaaf296ab7 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.
2021-02-03 22:50:15 +00:00
Alex Crichton ffa9dbd348 Don't change the macOS default just yet 2021-02-03 14:06:41 -08:00
bors 537dc099d3 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`.)

Split from #9111.
2021-02-03 15:56:05 +00:00
Eric Huss 06b8d1cac1 Add a ResponseError for registry API interaction.
The intent here is to make it easier to work with API errors.

This also includes some new tests for checking network errors.
2021-02-02 17:44:57 -08:00
Eric Huss 340656e29d Add RegistryBuilder to help initializing test registries.
The intent here is to make it more flexible to create different registry
setups, and to reuse code a little more easily.
2021-02-02 15:48:48 -08:00
Eric Huss d8673d93d2 Fix env/cfg set for cargo test and cargo run. 2021-02-01 19:20:54 -08:00
Alex Crichton cc5e9df64a 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.
2021-02-01 11:29:25 -08:00
Alex Crichton ed4568e108 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.
2021-02-01 09:21:36 -08:00
bors e099df243b 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
2021-02-01 16:24:34 +00:00
Dirkjan Ochtman 040d27f39d Don't try to parse MSRV if feature is not enabled 2021-01-30 23:14:30 +01:00
CPerezz b526fadca4
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.

Closes #9106
2021-01-30 01:09:16 +01:00
Eric Huss fdb8ea1e03 Add some extra help to cargo new and invalid package names. 2021-01-24 13:21:25 -08:00
Eric Huss b04c7fb849 Add suggestion for bad package id. 2021-01-22 13:38:53 -08:00
bors ba3311e714 Auto merge of #9092 - ehuss:unstable-updates, r=alexcrichton
Unstable updates

This is a collection of updates for unstable/nightly feature support, intended to provide better messages for users and better internal and external documentation.  Separated by commit, in summary:

* Added comments and new docstrings for improved internal documentation.
* Added new documentation to the reference guide on how unstable things work.
  * Also added redirects for stabilized features so any external links won't be broken.
* Add a targeted error message if you put `cargo-features` in the wrong place in `Cargo.toml`.
* Remove `publish-lockfile`.  The feature was stabilized without the key in #7026 about 1.5 years ago.  Also added "removed" support for features, which prints out a more helpful error message.
* Add help messages about stabilized `-Z` flags (instead of spitting out an unhelpful error message).
* Add help messages about stabilized `cargo-features` features.
* Add more context to the error when using `cargo-features` on stable.
* Unhide nightly CLI flags. I changed my mind on how these should work. I think it is useful to "advertise" the existence of these options on stable. The error message if you try to use it should help guide on what to do.

Closes #9074.
2021-01-21 21:04:12 +00:00
Eric Huss 7bbef3defe Rework cargo-features a little.
* Add `removed` support.
* Include the version where it is stabilized.
* Include a links to the documentation in the error/warning messages.
2021-01-21 12:16:35 -08:00
Eric Huss 00615fc51a Add more helpful message with stabilized -Z flags.
Previously, when something was stabilized, Cargo would spit out a very
unhelpful error message about an unknown -Z flag. This changes it so
that it displays a helpful warning (or error).
2021-01-20 19:46:50 -08:00
Eric Huss ff349f0205 Remove publish-lockfile key from manifest.
The feature was stabilized without the key in #7026 about 1.5 years ago.
(Will follow up with an error message in a subsequent commit.)
2021-01-20 19:31:57 -08:00
Eric Huss d89a78ee19 Add error message for wrong cargo-features placement.
This is intended to help if the user puts cargo-features in the
wrong place in Cargo.toml.
2021-01-20 19:22:51 -08:00
bors 783bc43c66 Auto merge of #9077 - ehuss:fix-doc-resolver2-proc-macro, r=alexcrichton
Fix some issues with `cargo doc` and the new feature resolver.

This contains two related commits fixing some issues with `cargo doc` and the new feature resolver.

The first commit fixes a panic. The old code was using `UnitFor::new_normal` when computing doc units, but this was wrong. That essentially circumvents the new feature resolver, and breaks determining the correct features to use. I don't remember exactly what I was thinking when I wrote that, other than "rustdoc shouldn't care", but it does matter.

Unfortunately changing that makes collisions worse because it aggravates #6313, so the second commit adds some logic for removing some collisions automatically. Specifically:

- Prefers dependencies for the target over dependencies for the host (such as proc-macros).
- Prefers the "newest" version if it comes from the same source.

There are still plenty of situations where there can be collisions, but I'm uncertain on the best way to handle those.

Fixes #9064
2021-01-20 19:02:26 +00:00
bors 8e075c9cab Auto merge of #8037 - djc:rfc-2495, r=ehuss
Implement support for rust-version field in project metadata

Needs a bunch more work, but I'd like some early feedback! Remaining work:

- [x] Bikeshedding name (picked `rust-version` here over `msrv` or `min-rust-version`)
- [x] Failing test for local dependency with unsatisfied MSRV
- [x] Requirement cannot be smaller than 1.27
- [x] Requirement cannot be smaller than initial release of edition used
- [x] Check for `run`, `verify` and `publish` subcommands
- [x] More tests (would love feedback on this)
- [x] Handle pre-release identifiers
- [x] Disallow semver range operators
- [x] Feature gate it
- [x] Add documentation for unstable feature

Minimal version of `@moxian's` earlier take in #7801.

cc rust-lang/rust#65262
2021-01-20 16:12:56 +00:00
Dirkjan Ochtman c221fec911 Implement support for rust-version field in project metadata 2021-01-20 11:40:41 +01:00
Eric Huss a58b0c589a Remove some doc collisions.
There are some cases where `cargo doc` will try to document two things
with the same crate_name. This attempts to automatically remove some of
those duplicates based on some rules:

- Prefers dependencies for the target over dependencies for the host
  (such as proc-macros).
- Prefers the "newest" version if it comes from the same source.

There are still plenty of situations where there can be collisions, but
I'm uncertain on the best way to handle those.
2021-01-14 13:12:24 -08:00
Alex Crichton 4b4dc0a479 Fix a bug in Cargo's cyclic dep graph detection
Cargo's cyclic dependency graph detection turns out to have had a bug
for quite a long time as surfaced by #9073. The bug in Cargo has to do
with how dev-dependencies are handled. Cycles are "allowed" through
dev-dependencies because the dev-dependency can depend on the original
crate. Our cyclic graph detection, however, was too eagerly flagging a
package as known to not have a cycle before we had processed everything
about it.

The fix here was basically to just simplify the graph traversal. Instead
of traversing the raw `Resolve` this instead creates an alternate
in-memory graph which has the actual edges we care about for cycle
detection (e.g. every edge that wasn't induced via a dev-dependency).
With this simplified graph we then apply the exact same algorithm, but
this time it should be less buggy because we're not trying to do funky
things about switching sets about what's visited halfway through a
traversal.

Closes #9073
2021-01-14 10:43:06 -08:00
bors a73e5b7d56 Auto merge of #9066 - rubenrua:hotfix_sort_bins, r=ehuss
Sort available binaries when multiple

From:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-13, basic-tutorial-6, basic-tutorial-1, basic-tutorial-4, basic-tutorial-9, basic-tutorial-2, basic-tutorial-3, basic-tutorial-5, basic-tutorial-12, playback-tutorial-4, basic-tutorial-8, basic-tutorial-7
```

To:
```
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: basic-tutorial-1, basic-tutorial-12, basic-tutorial-13, basic-tutorial-2, basic-tutorial-3, basic-tutorial-4, basic-tutorial-5, basic-tutorial-6, basic-tutorial-7, basic-tutorial-8, basic-tutorial-9, playback-tutorial-4
```
2021-01-12 23:45:39 +00:00
rubenrua eb31d1ae9b Test for sort available binaries when multiple 2021-01-12 23:18:41 +01:00
Eric Huss d4b3a1d43c Fix panic with cargo doc and new resolver and proc-macros. 2021-01-12 09:17:49 -08:00
Alex Crichton 21a5efb483 Fix links vars showing up for testing packages
If a package is tested and the library for the package wasn't built
(e.g. only tested or it wasn't present) then the `links` env vars from
dependencies weren't showing up to the build script by accident. This
was an accidental regression from #8969.

The intention of #8969 was to exclude connections to build scripts
connected via dev-dependencies, but it only applied a heuristic because
the unit graph doesn't retain information about dev-dependencies. The
fix here is to instead actually retain information about
dev-dependencies which is only used for constructing the unit graph and
connecting build script executions to one another.

Closes #9063
2021-01-12 06:59:54 -08:00
Eric Huss a84689870f Fix unit_for computation on proc-macros in shared workspace. 2021-01-09 15:23:47 -08:00
bors 329895f5b5 Auto merge of #8994 - jonhoo:manifest-in-local-deps-meta, r=ehuss
metadata: Supply local path for path dependencies

This is potentially a simpler way to address #7483 than #8988.

/cc https://github.com/rust-lang/rustfmt/issues/4247

Fixes #7483.
2021-01-06 00:01:52 +00:00
bors 3bb0968e22 Auto merge of #8922 - m-ou-se:2021, r=alexcrichton
Add support for Rust edition 2021.

This adds support for `ediiton = "2021"`.

Related `rustc` PR: https://github.com/rust-lang/rust/pull/79576
2021-01-05 22:10:44 +00:00
bors 4aa52236c4 Auto merge of #8997 - ehuss:stabilize-features, r=alexcrichton
Stabilize -Zfeatures and -Zpackage-features.

This follows through with [RFC 2957](https://github.com/rust-lang/rfcs/pull/2957) to stabilize the new feature resolver, and `-Zpackage-features` command-line changes.

This also rewrites the "Features" chapter to try to expand it a little.

I decided to leave the `-Zfeatures` flag in for now for testing, but it can be removed at a later date.

There is a code change related to the `package-name/feature-name` syntax for the `--features` flag. I wanted to stabilize that for `resolver = "1"`, but I previously neglected to separate that behavior out, so it required change to `Workspace::members_with_features` to make that work (see the `resolver1_member_features` test).

Closes #4328
Closes #5364
Closes #7914
Closes #7915
Closes #7916
Closes #8088
Closes #8431
2021-01-05 21:39:20 +00:00