Commit graph

32 commits

Author SHA1 Message Date
Ed Page 4bf1af0cd0 fix(update): Make -p more convenient by being positional
Generally, cargo avoids positional arguments.  Mostly for the commands
that might forward arguments to another command, like `cargo test`.
It also allows some flexibility in turning flags into options.

For `cargo add` and `cargo remove`, we decided to accept positionals
because the motivations didn't seem to apply as much (similar to `cargo
install`).

This applies the pattern to `cargo update` as well which is in the same
category of commands as `cargo add` and `cargo remove`.

As for `--help` formatting, I'm mixed on whether `[SPEC]...` should be at the top like
other positionals or should be relegated to "Package selection".  I went
with the latter mostly to make it easier to visualize the less common
choice.

Switching to a positional for `cargo update` (while keeping `-p` for
backwards compatibility) was referenced in #12425.
2023-08-23 11:57:36 -05:00
Weihang Lo b567a67d5c
test: bypass rustc --test impl details for -Zfuture-incompat-test
Switch to an empty `lib.rs` from `main.rs`.

See https://github.com/rust-lang/rust/issues/114804#issuecomment-1677233355
2023-08-14 13:40:47 +01:00
Scott Schafer 4934dffa5a chore: update future_incompat_report tests to use check 2023-02-20 12:21:27 -06:00
Eric Huss 1c3640e05c Add requirements to cargo_test. 2022-07-30 19:36:58 -07:00
Scott Schafer c239e407e7 add a reason to masquerade_as_nightly_cargo so it is searchable 2022-07-15 21:32:23 -05:00
Scott Schafer 4bc8fe85bd remove unneeded nightly flags from various tests 2022-07-14 19:55:44 -05:00
cuishuang 6f13c466d2 fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-05-08 01:07:28 +08:00
Ed Page cdec3838a8 Extend pkgid syntax with @ support
In addition to `foo:1.2.3`, we now support `foo@1.2.3` for pkgids.  We
are also making it the default way of rendering pkgid's for the user.

With cargo-add in #10472, we've decided to only use `@` in it and to add
it as an alternative to `:` in the rest of cargo.  `cargo-add`
originally used `@`.  When preparing it for merge, I switched to `:` to
be consistent with pkgids. When discussing this, it was felt `@` has
precedence in too many tools to switch to `:` but that we should instead
switch pkgid's to use `@`, in a backwards compatible way.

See also https://internals.rust-lang.org/t/feedback-on-cargo-add-before-its-merged/16024/26?u=epage
2022-04-19 16:00:15 -05:00
Aaron Hill 997bf3fffc
Stabilize future-incompat-report
Depends on https://github.com/rust-lang/rust/pull/91535
2021-12-05 14:14:32 -05:00
Aaron Hill 5c3b38086f
Adjust comments 2021-10-18 12:06:23 -05:00
Aaron Hill 958f2fc962
Display more information in report 2021-10-18 12:01:07 -05:00
Aaron Hill 6f18507092
Display update message in report 2021-10-12 17:02:13 -05:00
Aaron Hill 49ae189b3b
Combined newer versions into single list 2021-10-12 16:35:01 -05:00
Aaron Hill ce259228cd
Change package spec 2021-10-12 16:35:01 -05:00
Aaron Hill 20340e1e79
Rename arg and adjust tests 2021-10-12 16:35:01 -05:00
Aaron Hill d5538c3869
Make future-incompat-report output more user-friendly
When the user enables `--future-incompat-report`, we now display
a high-level summary of the problem, as well as several suggestions
for fixing the affected crates.

The command `cargo report future-incompatibilities` now takes
a `--crate` option, which can be used to display a report
(including the actual lint messages) for a single crate.
When this option is not used, we display the report for all
crates.
2021-10-12 16:35:01 -05:00
Aaron Hill 88679e07f2
Implement [future-incompat-report] config section
Currently, I've just implemented the `always` and `never` frequencies
from the RFC, which don't require tracking any additional state.
2021-08-19 15:59:36 -05:00
Eric Huss f00a85a871 Re-enable future-incompatible tests. 2021-07-16 05:45:29 -07:00
Eric Huss e7df0d136c Temporarily disable future_incompat tests. 2021-06-29 11:56:03 -07: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 71cb59b6ef Future-incompat report: Add suggestions of newer versions. 2021-06-21 09:49:43 -07:00
Eric Huss 1f7141f892 Add future-incompat as an alias for future-incompatibilities. 2021-06-21 09:49:43 -07:00
Eric Huss c2b02b3926 Updates to future-incompatible reporting. 2021-06-21 09:49:41 -07:00
Eric Huss ff49b829e6 Add report subcommand. 2021-04-30 13:01:21 -07:00
Matthias Krüger 1b7fa21f39 fix clippy warnings
fixes these clippy warnings:

map_collect_result_unit
needless_borrow
needless_return
into_iter_on_ref
manual_flatten
match_like_matches_macro
bool_comparison
2021-04-02 12:30:36 +02:00
bors 58a9613144 Auto merge of #9263 - Aaron1011:zero-incompat-note, r=ehuss
Emit note when `--future-incompat-report` had nothing to report
2021-03-22 22:59:56 +00:00
Aaron Hill f9512ff822
Emit note when --future-incompat-report had nothing to report 2021-03-14 23:22:51 -04: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
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