11104 Commits

Author SHA1 Message Date
Eric Huss
b67454c660 Make it easier to run testsuite with a custom toolchain. 2021-07-11 14:02:47 -07:00
bors
18f25982ae Auto merge of #9666 - hi-rustin:rustin-patch-warn, r=ehuss
Warning when using features in patch

part of https://github.com/rust-lang/cargo/issues/3034
2021-07-09 19:29:28 +00:00
hi-rustin
a846226f71 Remove unrelated cases
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-09 13:15:13 +08:00
hi-rustin
8d2103f212 Warning when using features in patch
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-07-08 15:25:13 +08:00
bors
cc80b40f1c Auto merge of #9655 - jyn514:verbose, r=ehuss
Unify cargo and rustc's error reporting

Fixes https://github.com/rust-lang/rust/issues/86854.

 ## Don't print "run the command again with --verbose"

Here is a typical error seen by users of Cargo:

```
error[E0601]: `main` function not found in crate `wrong`
  |
  = note: consider adding a `main` function to `src/main.rs`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.
error: could not compile `wrong`

To learn more, run the command again with --verbose.
```

The `--verbose` output is not particularly helpful in this case. The
error is unrelated to what cargo is doing, and passing `--verbose` will
not give useful information about how to proceed. Additionally, it's
unclear that `--verbose` is referring to the cargo command and not
rustc; this is especially true when cargo is wrapped by another build
system (such as Meson, x.py, or Make).

This omits the "run the command again with --verbose" output. --verbose
is still shown in `cargo build --help`, but it's not singled out above
all the other options.

 ##  Combine rustc and cargo's diagnostic summaries

This works by introspecting rustc's error output, using the JSON format
to determine whether it's a warning or error, then skipping it
altogether if it's a summary of the diagnostics printed.

Before:

```
$ cargo check --message-format short
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: aborting due to 2 previous errors; 1 warning emitted
error: could not compile `wrong`
```

After:

```
$ cargo check --message-format short
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: could not compile `wrong` due to 2 previous errors; 1 warning emitted
```
2021-07-07 16:51:14 +00:00
Joshua Nelson
9c7cc545d7 Combine rustc and cargo's diagnostic summaries
This works by introspecting rustc's error output, using the JSON format
to determine whether it's a warning or error, then skipping it
altogether if it's a summary of the diagnostics printed.

Before:

```
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: aborting due to 2 previous errors; 1 warning emitted
error: could not compile `wrong`

```

After:

```
$ cargo check --message-format short
src/main.rs:1:10: warning: trait objects without an explicit `dyn` are deprecated
src/main.rs:1:1: error[E0601]: `main` function not found in crate `wrong`
src/main.rs:1:9: error[E0038]: the trait `Clone` cannot be made into an object
error: could not compile `wrong` due to 2 previous errors; 1 warning emitted
```
2021-07-06 19:46:27 -04:00
Joshua Nelson
768b5658c2 Don't print "run the command again with --verbose"
Here is a typical error seen by users of Cargo:

```
error[E0601]: `main` function not found in crate `wrong`
  |
  = note: consider adding a `main` function to `src/main.rs`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.
error: could not compile `wrong`

To learn more, run the command again with --verbose.
```

The `--verbose` output is not particularly helpful in this case. The
error is unrelated to what cargo is doing, and passing `--verbose` will
not give useful information about how to proceed. Additionally, it's
unclear that `--verbose` is referring to the cargo command and not
rustc; this is especially true when cargo is wrapped by another build
system (such as Meson, x.py, or Make).

This omits the "run the command again with --verbose" output. --verbose
is still shown in `cargo build --help`, but it's not singled out above
all the other options.
2021-07-05 16:27:51 -04:00
bors
3ebb5f15a9 Auto merge of #9649 - ehuss:edition2021-report-tweaking, r=alexcrichton
Adjust the edition2021 resolver diff report.

This makes some adjustments to the report given on `cargo fix --edition` when there are differences in the feature resolver.

- Tweak the wording to be clearer.
- Removed the "activated dependencies" differences. This doesn't actually work (dependencies aren't ever completely removed), and isn't all that interesting (since it would be duplicating the same information from the feature differences).
2021-07-02 20:35:38 +00:00
Eric Huss
5559e028a8 Adjust the edition2021 resolver diff report. 2021-07-02 13:01:58 -07:00
bors
0a38a2138d Auto merge of #9647 - ehuss:fingerprint-linker, r=alexcrichton
Include the linker in the fingerprint.

This adds the linker from the `[target]` config table to the fingerprint. Previously, changing the value would not trigger a rebuild.
2021-07-02 15:10:51 +00:00
bors
6e31c1338d Auto merge of #9646 - ehuss:windows-case-disable, r=alexcrichton
Temporarily disable windows env test.

This temporarily disables the `target_in_environment_contains_lower_case` test on Windows until https://github.com/rust-lang/rust/pull/85270 gets into nightly.  That PR changes it so that env vars are case-preserved on Windows.  My intent is that after that is in nightly, we can remove the windows-specific code in `Config`, and this test should work the same on all platforms.

Closes #9630
2021-07-02 14:47:02 +00:00
bors
b74705419e Auto merge of #9645 - ehuss:git-package-wt_deleted, r=alexcrichton
Handle git deleted files with dirty worktree.

When listing git files for things like `cargo package`, it was including unstaged deleted files. This is because the file is still in the index, so it was included in the list.  `cargo package --allow-dirty` would then fail with a confusing "file not found" error.

This fixes it by keeping a set of deleted files, and skipping those. This allows `cargo package --allow-dirty` to work.

Closes #9580
2021-07-02 14:22:23 +00:00
bors
b0e2cc5b60 Auto merge of #9644 - ehuss:offline-and-frozen, r=alexcrichton
Adjust error message with offline and frozen.

Using --offline with --frozen when the lock file needed to be updated gave a confusing error message. This updates it to make it slightly clearer.

Closes #9572
2021-07-02 13:56:54 +00:00
Eric Huss
28c3bef71a Include the linker in the fingerprint. 2021-07-01 20:33:48 -07:00
Eric Huss
c10864a3c4 Temporarily disable windows env test. 2021-07-01 19:41:13 -07:00
Eric Huss
97a135049a Handle git deleted files with dirty worktree. 2021-07-01 18:10:35 -07:00
Eric Huss
dd8fa9183d Adjust error message with offline and frozen. 2021-07-01 16:59:19 -07:00
bors
4952979031 Auto merge of #9531 - 5225225:cargo-doc-open-fix, r=ehuss
Fix `BorrowMutError` when calling `cargo doc --open`

~~I'm not sure why the existing test suite didn't catch this, it definitely calls `cargo doc --open`.~~

I had

```toml
[doc.extern-map]
std = "local"
```

in my `.cargo/config.toml`. Will write a test case that sets that and then tries to run `cargo doc --open`.

Closes #9530
2021-07-01 01:14:50 +00:00
bors
01d059af9b Auto merge of #9635 - toothbrush7777777:patch-1, r=alexcrichton
Exclude `target` from content-indexing on Windows

This has a noticeable performance improvement for most projects, especially when the storage device is a hard drive.

Closes #8694
2021-06-30 17:57:59 +00:00
bors
a15fec7817 Auto merge of #9642 - ehuss:2021-edition-disable, r=alexcrichton
Temporarily ignore 2021 edition fix.

The latest nightly broke the interaction of `--force-warns` and `--cap-lints`.  Since this will likely take at least a few days to fix, I am temporarily disabling this test to get cargo's CI working again.
2021-06-30 16:45:52 +00:00
Eric Huss
aab51362d7 Temporarily ignore 2021 edition fix. 2021-06-30 09:36:22 -07:00
bors
d6384de0bc Auto merge of #9638 - ehuss:ignore-future_incompat, r=alexcrichton
Temporarily disable future_incompat tests.

The `array_into_iter` lint is no longer future-breaking (via https://github.com/rust-lang/rust/pull/86330), so these tests won't work anymore.  This disables the tests until https://github.com/rust-lang/rust/pull/86478 is merged to provide a way to start testing again.
2021-06-29 19:01:57 +00:00
Eric Huss
e7df0d136c Temporarily disable future_incompat tests. 2021-06-29 11:56:03 -07:00
Toothbrush
c973a6d0af
rustfmt 2021-06-29 18:18:28 +01:00
Toothbrush
684391e444
Change if cfg!(..) { } to #[cfg!(..)] { }
This fixes builds on non-Windows platforms.
2021-06-29 17:19:14 +01:00
Toothbrush
f1c8e56909
Format exclude_from_content_indexing 2021-06-28 21:45:59 +01:00
Toothbrush
9d96a88961
Exclude target from content-indexing on Windows
This has a noticeable performance improvement for most projects, especially when the storage device is a hard drive.

Closes #8694
2021-06-28 20:12:44 +01:00
5225225
950c415583 Fully match stderr, return if not nightly, shorten file 2021-06-28 19:01:16 +01:00
bors
36917524b9 Auto merge of #9625 - hi-rustin:rustin-msg, r=ehuss
Include toolchain specification in error message

close https://github.com/rust-lang/rustup/issues/2795
2021-06-25 17:17:55 +00:00
hi-rustin
00bf7706bc Include toolchain specification in error message
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-06-25 22:01:46 +08:00
bors
4c27c96645 Auto merge of #9612 - Bryysen:master, r=alexcrichton
Error when packaging with git dependencies without version

If `cargo package` is run on a package that specifies a git dependency
without a version, cargo will error. This should help with clarifying
that git dependencies will be stripped when packaging, and that the
dependency has to be fetched from a registry.
Closes #9442
2021-06-23 21:38:32 +00:00
bors
a5e7a1d41f Auto merge of #9615 - danieleades:refactor/simplify-block, r=joshtriplett
simply 'if' block
2021-06-23 15:37:42 +00:00
bors
e5917a2823 Auto merge of #9614 - danieleades:refactor/closures-and-iterators, r=Eh2406
tidy some closures and iterators
2021-06-23 14:00:49 +00:00
bors
58be9793af Auto merge of #9620 - danieleades:refactor/use-writeln, r=Eh2406
use 'writeln' instead of appending newline character
2021-06-23 13:33:38 +00:00
Daniel Eades
706c8242e3 use 'writeln' instead of appending newline character 2021-06-23 12:20:18 +01:00
Daniel Eades
c6e5b6c34f simply 'if' block 2021-06-23 11:22:04 +01:00
Daniel Eades
8501a5b20c tidy some closures and iterators 2021-06-23 11:10:02 +01:00
Bryysen
4e1910d9d3 Error when packaging with git dependencies without version
If `cargo package` is run on a package that specifies a git dependency
without a version, cargo will error. This should help with clarifying
that git dependencies will be stripped when packaging, and that the
dependency has to be fetched from a registry.
2021-06-23 02:01:29 +02:00
bors
9233aa06c8 Auto merge of #9607 - hi-rustin:rustin-patch-cargo-toml, r=ehuss
Detect incorrectly named cargo.toml

close https://github.com/rust-lang/cargo/issues/9541
2021-06-22 21:32:55 +00:00
bors
a2589dda38 Auto merge of #9574 - ehuss:weak-namespaced, r=alexcrichton
Unify weak and namespaced features.

This unifies weak and namespaced features in order to simplify the syntax and semantics.  Previously there were four different ways to specify the feature of a dependency:

* `package-name/feature-name` — Enables feature `package-name` on self and enables `feature-name` on the dependency. (Today's behavior.)
* `package-name?/feature-name` — Only enables `feature-name` on the given package if it that package is enabled and will also activates a feature named `package-name` (which must be defined implicitly or explicitly).
* `dep:package-name/feature-name` — Enables dependency `package-name`, and enables `feature-name` on that dependency. This does NOT enable a feature named "package-name".
* `dep:package-name?/feature-name` — Only enables `feature-name` on the given package if it that package is enabled.  This does NOT enable a feature named "package-name".

This changes it so there are only two:

* `package-name/feature-name` — Today's behavior.
* `package-name?/feature-name` — Only enables `feature-name` on the given package if it that package is enabled.  This does NOT enable a feature named "package-name" (the same behavior as `dep:package-name?/feature-name` above).

This is a fairly subtle change, and in most cases probably won't be noticed.  However, it simplifies things which helps with writing documentation and explaining how it works.
2021-06-22 21:02:31 +00:00
bors
32238b4747 Auto merge of #9563 - ehuss:link-cdylib-warning, r=alexcrichton
Change `rustc-cdylib-link-arg` error to a warning.

In #9523, an error was added if `cargo:rustc-cdylib-link-arg` was issued in a build script without actually having a cdylib target. This uncovered that there was an unintentional change in #8441 to cause those link args to be applied to transitive dependencies.

This changes it so that the error is now a warning, with a note that this may become an error in the future. It also changes it so that the unstable `rustc-link-arg*` instructions only apply to the package that emitted them.
2021-06-22 19:27:25 +00:00
hi-rustin
b3a1d0ceba Only testing on linux 2021-06-22 15:36:32 +08:00
hi-rustin
cb1a3f05f0 Detect incorrectly named cargo.toml for build 2021-06-22 15:31:28 +08:00
hi-rustin
a2f903275a Detect incorrectly named cargo.toml for install --path 2021-06-22 15:31:28 +08:00
hi-rustin
d9daaf7a84 Detect incorrectly named cargo.toml for install --git 2021-06-22 15:31:21 +08:00
bors
8130be7a4c Auto merge of #9606 - ehuss:future-incompat-enhancements, r=alexcrichton
Updates to future-incompatible reporting.

This includes several changes to future-incompatible reports:

- Now able to retain multiple reports on disk (currently 5).
- `cargo report future-incompatibilities` will now show the last report without `--id`.
- Changed `cargo report future-incompatibilities` to display the report on stdout. Although these are "diagnostics", I see this more as a human-readable "report", which might benefit from being more easily piped (like to a pager). I also expect all other report subcommands to print to stdout.
- Fixed a bug where saving the reports to disk was not truncating the file. If multiple reports were saved, and future ones were *shorter* than a previous one, the on-disk structure would be corrupted.
- Reports are now always stored with ANSI escape codes, and the color filtering is done only when displayed.
- Some slight adjustments to the formatting of the report.
- When the wrong `--id` is passed, show available reports.
- Give a slightly better error message when there are no reports.
- Fixed bug where "0 dependencies has warnings" was unconditionally displayed (it should only be displayed if --future-incompat-report is used)
- Added `future-incompat` as an alias for the `future-incompatibilities` subcommand which can be quite a verbose command.
- When showing the note at the end of the build, make sure the list is unique (for example, if a single package had multiple targets that trigger a warning).
- Added a note at the bottom of the report that indicates if newer versions of a package are available.
2021-06-21 17:51:53 +00:00
Eric Huss
afe7314ede Don't trigger an update when looking for suggestions. 2021-06-21 09:55:29 -07:00
Eric Huss
a93bfcbdff Print reports using shell to handle old Windows colors properly. 2021-06-21 09:50:42 -07:00
Eric Huss
7e2b31a6bd Add ON_DISK_VERSION constant. 2021-06-21 09:49:43 -07:00
Eric Huss
71cb59b6ef Future-incompat report: Add suggestions of newer versions. 2021-06-21 09:49:43 -07:00