4068 Commits

Author SHA1 Message Date
Eric Huss
dbfdd49559 Move is_ci to cargo-util. 2021-03-20 17:42:32 -07:00
Eric Huss
888100352a Move ProcessBuilder to cargo-util. 2021-03-20 15:19:03 -07:00
Mukund Lakshman
54742ce726 Use serde's error message option to avoid implementing Deserialize. 2021-03-19 23:22:39 +00:00
Eric Huss
85854b1884 Refactor feature handling, and improve error messages. 2021-03-19 14:59:53 -07:00
bors
c9ce0ec40d Auto merge of #9279 - Revantus:offline_precise, r=alexcrichton
Allow `cargo update` to operate with the --offline flag

Closes #9248

Limiting to `--precise` operations as the package should be cached locally prior to the usage of offline.

Added an additional test to [offline.rs](tests/testsuite/offline.rs).
2021-03-18 18:23:28 +00:00
Revantus
61a8f711df Fix offline tests. Rename to cached/not_cached. 2021-03-18 08:33:55 -06:00
Revantus
8ae547233f Remove eager fail for update --offline 2021-03-18 08:04:42 -06:00
Jon Gjengset
4a90ab6910 Add -Zallow-features to match rustc's -Z 2021-03-17 15:23:48 -07:00
bors
90691f2bfe Auto merge of #9268 - ehuss:2021-fix-edition-v2-warning, r=alexcrichton
Add report if `cargo fix --edition` changes features.

This adds a small report if using `cargo fix --edition` to transition from 2018 to 2021 to determine if the new resolver will result in different features.

There is a gauntlet of checks that must pass before it even tries to show the differences:
* If the resolver is already specified, skip.
* If in a virtual workspace, skip (no way to specify global edition).
* If not migrating the root package, skip. The edition only changes the resolver in the root package.
* If not migrating all targets, skip. It's uncertain if the user intends to set the package edition or not.

Closes #9048
2021-03-16 21:36:55 +00:00
bors
841179ee60 Auto merge of #9275 - ehuss:features-non-member, r=alexcrichton
Fix --feature pkg/feat for V1 resolver for non-member.

#8997 had an unintended regression where `-p foo --feature foo/feat` syntax where `foo` is an **optional non-member** fails with an error that `foo` did not match any packages.  The issue is that the member/feature selection routine needed to slot this into the features for the package in the current working directory (it was incorrectly treating `foo` as a workspace member).

V2 outright does not allow specifying features for non-workspace members.

Fixes #9265
2021-03-16 20:55:20 +00:00
Eric Huss
501499c5f9 Add report if cargo fix --edition changes features. 2021-03-16 11:39:21 -07:00
Eric Huss
e50292a153 Fix doc duplicate removal of root units. 2021-03-16 10:32:08 -07:00
bors
695465c79a Auto merge of #9204 - jonhoo:patch-in-config, r=alexcrichton
Support [patch] in .cargo/config files

This patch adds support for `[patch]` sections in `.cargo/config.toml`
files. Patches from config files defer to `[patch]` in `Cargo.toml` if
both provide a patch for the same crate.

The current implementation merge config patches into the workspace
manifest patches. It's unclear if that's the right long-term plan, or
whether these patches should be stored separately (though likely still
in the manifest). Regardless, they _should_ likely continue to be
parsed when the manifest is parsed so that errors and such occur in the
same place regardless of where a patch is specified.

Fixes #5539.
2021-03-15 16:58:26 +00:00
Aaron Hill
f9512ff822
Emit note when --future-incompat-report had nothing to report 2021-03-14 23:22:51 -04:00
Eric Huss
6b320cb801 Fix --feature pkg/feat for V1 resolver for non-member. 2021-03-14 19:05:12 -07:00
Aaron Hill
63ed725fd8
Add --future-incompat-report support to cargo test
This was missed in the original PR
2021-03-14 15:50:01 -04:00
Revantus
06eed4afe4 Allowing update --offline with precise flags
Adding additional test for updating against changed offline
dependancies.

rust-lang/cargo#9248
2021-03-14 07:17:59 -06:00
Eric Huss
8ce2a1bef3 Fix issue with filtering exclusive target dependencies. 2021-03-11 11:41:00 -08:00
bors
0f3f47e3c3 Auto merge of #9188 - weihanglo:issue-9041, r=ehuss
Package ID specification urls must contain a host

Resolves https://github.com/rust-lang/cargo/issues/9041

Not sure which commit breaks this. Cargo shipped with rust 1.46 didn't unwrap on a `None` but 1.47 did. Even checkouted to 149022b1d8f382e69c1616f6a46b69ebf59e2dea (cargo of rust 1.46), it still unwrap unexpectedly.

So I ended up following the [Specification grammer](https://doc.rust-lang.org/cargo/reference/pkgid-spec.html#specification-grammar) to make sure there is a `host` in the pkgid urls.

<details>
<summary>See console output</summary>

cargo of rust 1.46
```console
$ cargo +1.46 -vV
cargo 1.46.0 (149022b1d 2020-07-17)
release: 1.46.0
commit-hash: 149022b1d8f382e69c1616f6a46b69ebf59e2dea
commit-date: 2020-07-17

$ cargo +1.46 pkgid /path
error: package ID specification `/path` matched no packages
```

cargo of rust 1.47

```console
$ cargo +1.47 -vV
cargo 1.47.0 (f3c7e066a 2020-08-28)
release: 1.47.0
commit-hash: f3c7e066ad66e05439cf8eab165a2de580b41aaf
commit-date: 2020-08-28

$ cargo +1.47 pkgid /path
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/tools/cargo/src/cargo/core/package_id_spec.rs:234:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

cargo on commit 149022b1d8f382e69c1616f6a46b69ebf59e2dea

```console
$ git checkout 149022b1d8f382e69c1616f6a46b69ebf59e2dea
$ cargo run -- pkgid /path
   Compiling cargo-platform v0.1.1 ([..]/cargo/crates/cargo-platform)
   Compiling crates-io v0.31.1 ([..]/cargo/crates/crates-io)
   Compiling cargo v0.47.0 ([..]/cargo)
    Finished dev [unoptimized + debuginfo] target(s) in 22.90s
     Running `target/debug/cargo pkgid /path`
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/cargo/core/package_id_spec.rs:234:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
</details>
2021-03-09 18:47:47 +00:00
Jon Gjengset
6bc97fc223 Merge branch 'master' into patch-in-config 2021-03-08 13:54:22 -08:00
Jon Gjengset
6995e1dd1b Extract config patch on use 2021-03-08 13:53:29 -08:00
Eric Huss
95827ad3bf Fix filter_platform to run on targets other than x86. 2021-03-08 07:54:01 -08:00
Eric Huss
9ea3503680 Fix some minor formatting issues. 2021-03-05 14:01:01 -08:00
Aaron Hill
f03d47ce4b
Address review comments 2021-03-04 15:21:16 -05:00
Aaron Hill
6177c6584b
Implement future incompatibility report support
cc rust-lang/rust#71249

This implements the Cargo side of 'Cargo report future-incompat'

Based on feedback from alexcrichton and est31, I'm implemented this a
flag `--future-compat-report` on `cargo check/build/rustc`, rather than
a separate `cargo describe-future-incompatibilities` command. This
allows us to avoid writing additional information to disk (beyond the
pre-existing recording of rustc command outputs).

This PR contains:

* Gating of all functionality behind `-Z report-future-incompat`.
  Without this flag, all user output is unchanged.
* Passing `-Z emit-future-incompat-report` to rustc when
  `-Z report-future-incompat` is enabled
* Parsing the rustc JSON future incompat report, and displaying it
  it a user-readable format.
* Emitting a warning at the end of a build if any crates had
  future-incompat reports
* A `--future-incompat-report` flag, which shows the full report for
  each affected crate.
* Tests for all of the above.

At the moment, we can use the `array_into_iter` to write a test.
However, we might eventually get to a point where rustc is not currently
emitting future-incompat reports for any lints. What would we want the
cargo tests to do in this situation?

This functionality didn't require any significant internal changes to
Cargo, with one exception: we now process captured command output for
all units, not just ones where we want to display warnings. This may
result in a slightly longer time to run `cargo build/check/rustc` from
a full cache. since we do slightly more work for each upstream
dependency. Doing this seems unavoidable with the current architecture,
since we need to process captured command outputs to detect
any future-incompat-report messages that were emitted.
2021-03-04 15:21:15 -05:00
bors
c69409658a Auto merge of #9022 - nagisa:nagisa/manifest_path, r=alexcrichton
Add the path to the manifest in json output

This allows consumers of the json messages to avoid guessing where
exactly the package root is. Having access to the package root is
difficult by virtue of requiring logic to guess its location by e.g.
walking filesystem from the source file.

This guessing logic becomes further complicated in presence of
workspaces and nigh impossible to implement correctly in instances where
artifacts end up produced from paths above the package root (e.g.
`../foo.rs`).

Since Cargo has access to this data in the first place, there doesn't
seem to be much reason to force consumers to invent their own, possibly
flawed, logic.
2021-03-04 19:50:20 +00:00
Simonas Kazlauskas
548300b20f Add the path to the manifest in json output
This allows consumers of the json messages to avoid guessing where
exactly the package root is. Having access to the package root is
difficult by virtue of requiring logic to guess its location by e.g.
walking filesystem from the source file.

This guessing logic becomes further complicated in presence of
workspaces and nigh impossible to implement correctly in instances where
artifacts end up produced from paths above the package root (e.g.
`../foo.rs`).

Since Cargo has access to this data in the first place, there doesn't
seem to be much reason to force consumers to invent their own, possibly
flawed, logic.
2021-03-04 20:09:51 +02:00
bors
99e714c05b Auto merge of #9230 - kornelski:nobinaries, r=alexcrichton
Explain `cargo install` is not for libraries

On a few occasions I've seen novice users assume that `cargo install` works like `npm install` or `apt install`, and they're confused that they can't use library dependencies this way.

I've expanded the error message to hopefully clarify the misconception.
2021-03-04 18:01:51 +00:00
Jon Gjengset
ce0b8e8574 Merge remote-tracking branch 'upstream/master' into patch-in-config 2021-03-03 09:20:28 -08:00
Kornel
3f7f0942cd track_caller on custom assert functions 2021-03-03 17:17:07 +00:00
Kornel
6977dee109 Explain cargo install is not for libraries 2021-03-03 17:10:56 +00:00
bors
b219f0eb7a Auto merge of #9181 - jyn514:computer-says-no, r=ehuss
Forbid setting `RUSTC_BOOTSTRAP` from a build script on stable

Instead, recommend `RUSTC_BOOTSTRAP=crate_name`. If cargo is using a nightly toolchain, or if RUSTC_BOOTSTRAP was set in *cargo*'s build environment, the error is downgraded to a warning, since the variable won't affect the build.

This is mostly the same as suggested in https://github.com/rust-lang/cargo/issues/7088#issuecomment-713867773, except that `RUSTC_BOOTSTRAP=` values other than 1 are treated the same as `RUSTC_BOOTSTRAP=1`. My reasoning was that https://github.com/rust-lang/rust/pull/77802 is now on 1.50 stable, so some crates may have started using it, and I would still prefer not to give hard errors when there's no workaround.

Closes https://github.com/rust-lang/cargo/issues/7088.

r? `@joshtriplett`
2021-03-03 03:19:33 +00:00
bors
c68432f1e5 Auto merge of #9226 - matklad:utf8everywhere, r=alexcrichton
Don't panic when printing JSON with non-utf8 paths

Before:

    λ cd \Xff/foo/ && cargo verify-project && cargo metadata
    {"success":"true"}
    warning: please specify `--format-version` flag explicitly to avoid compatibility problems
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("path contains invalid UTF-8 characters", line: 0, column: 0)', /rustc/a5a775e3f9e8043dad405e00aee0ae60882a7b71/src/tools/cargo/src/cargo/core/shell.rs:346:51
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After:

    λ cd \Xff/foo/ && $cargo verify-project && $cargo metadata
    {"success":"true"}
    warning: please specify `--format-version` flag explicitly to avoid compatibility problems
    error: path contains invalid UTF-8 characters

I am pretty  sure that this has zero real-world impact, but the diff is
small, so why not handle it?
2021-03-02 18:26:29 +00:00
Aleksey Kladov
dd5806d146 Don't panic when printing JSON with non-utf8 paths
Before:

    λ cd \Xff/foo/ && cargo verify-project && cargo metadata
    {"success":"true"}
    warning: please specify `--format-version` flag explicitly to avoid compatibility problems
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("path contains invalid UTF-8 characters", line: 0, column: 0)', /rustc/a5a775e3f9e8043dad405e00aee0ae60882a7b71/src/tools/cargo/src/cargo/core/shell.rs:346:51
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After:

    λ cd \Xff/foo/ && $cargo verify-project && $cargo metadata
    {"success":"true"}
    warning: please specify `--format-version` flag explicitly to avoid compatibility problems
    error: path contains invalid UTF-8 characters

I am pretty  sure that this has zero real-world impact, but the diff is
small, so why not handle it?
2021-03-02 20:27:52 +03:00
Weihang Lo
ade33c20d1
teset(pkgid): suggestion for bad parsing 2021-03-02 16:18:21 +08:00
Weihang Lo
2e3a74cc95
test(pkgid): bad file URL suggestion 2021-03-02 08:40:59 +08:00
Eric Huss
83487e41a9 Detect changes for JSON spec targets. 2021-03-01 12:19:14 -08:00
bors
ccf781ab90 Auto merge of #9213 - ehuss:registry-api-errors, r=alexcrichton
Minor update to registry API error messages.

This is a minor update to the registry API errors, trying to make them a little clearer and more helpful. My concerns were:

* `api errors (status 200 OK): some error message` — why was there both an error and 200 OK?
* `api errors` — What is an "api error" anyways?  The user is probably not familiar with the "registry API".
* Adds the URL of the server it is actually talking to, in case you may be confused when using a registry other than crates.io. This also tries to make it clearer that the message is coming from the remote server, and not cargo itself.
2021-03-01 15:13:36 +00:00
Weihang Lo
153146ecc5
test(vendor): respect to Cargo.toml [package.exclude] 2021-03-01 22:06:57 +08:00
Eric Huss
e58c544f37 Some minor code cleanup. 2021-02-28 19:03:06 -08:00
Eric Huss
c9bd6e12e1 Minor update to registry API error messages. 2021-02-27 12:38:17 -08:00
Jon Gjengset
140a7707ad Only apply config patches on resolve 2021-02-26 09:29:33 -08:00
bors
f3e63d6ab4 Auto merge of #8939 - Andy-Python-Programmer:master, r=alexcrichton
Throw error if CARGO_TARGET_DIR is an empty string

This pull request makes the target dir to be target/ if `CARGO_TARGET_DIR` is `` with spaces trimmed and not delete the current project.

Fixes: #8866
2021-02-25 19:40:08 +00:00
bors
6780fbd22a Auto merge of #9207 - ehuss:testsuite-splitdebug, r=Eh2406
testsuite: Use split debuginfo on macos.

This switches the testsuite to use "unpacked" debuginfo on macos, which is a substantial performance boost. On my system, the testsuite runs 1.55 times faster with this change.  Along with #9206, total testsuite time is 3.1 times faster.
2021-02-25 19:06:49 +00:00
Eric Huss
c73765f9c3 testsuite: Improve performance when using rustup. 2021-02-25 09:07:48 -08:00
Eric Huss
0f78dbd38e testsuite: Use split debuginfo on macos. 2021-02-25 09:06:11 -08:00
unknown
b5b2e489d6 Fix tests 2021-02-25 18:48:05 +11:00
unknown
019b4e111e Fixes error message 2021-02-25 18:10:59 +11:00
Jon Gjengset
8178f22ee9 Support [patch] in .cargo/config files
This patch adds support for `[patch]` sections in `.cargo/config.toml`
files. Patches from config files defer to `[patch]` in `Cargo.toml` if
both provide a patch for the same crate.

The current implementation merge config patches into the workspace
manifest patches. It's unclear if that's the right long-term plan, or
whether these patches should be stored separately (though likely still
in the manifest). Regardless, they _should_ likely continue to be
parsed when the manifest is parsed so that errors and such occur in the
same place regardless of where a patch is specified.

Fixes #5539.
2021-02-24 14:34:21 -08:00
Joshua Nelson
09677c83c2 Be less unix-centric in error messages
Co-authored-by: Eric Huss <eric@huss.org>
2021-02-24 15:50:09 -05:00