diff --git a/src/bin/cargo/commands/clippy.rs b/src/bin/cargo/commands/clippy.rs index 4aa412ceeca..b206609b09d 100644 --- a/src/bin/cargo/commands/clippy.rs +++ b/src/bin/cargo/commands/clippy.rs @@ -4,7 +4,7 @@ use cargo::ops; use cargo::util; pub fn cli() -> App { - subcommand("clippy-preview") + subcommand("clippy") .about("Checks a package to catch common mistakes and improve your Rust code.") .arg(Arg::with_name("args").multiple(true)) .arg_package_spec( @@ -63,13 +63,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let mode = CompileMode::Check { test: false }; let mut compile_opts = args.compile_options(config, mode, Some(&ws))?; - if !config.cli_unstable().unstable_options { - return Err(failure::format_err!( - "`clippy-preview` is unstable, pass `-Z unstable-options` to enable it" - ) - .into()); - } - let mut wrapper = util::process(util::config::clippy_driver()); if let Some(clippy_args) = args.values_of("args") { diff --git a/src/bin/cargo/commands/mod.rs b/src/bin/cargo/commands/mod.rs index 16e02774db3..9e5b25a89c7 100644 --- a/src/bin/cargo/commands/mod.rs +++ b/src/bin/cargo/commands/mod.rs @@ -43,7 +43,7 @@ pub fn builtin_exec(cmd: &str) -> Option) -> Cli "build" => build::exec, "check" => check::exec, "clean" => clean::exec, - "clippy-preview" => clippy::exec, + "clippy" => clippy::exec, "doc" => doc::exec, "fetch" => fetch::exec, "fix" => fix::exec, diff --git a/src/doc/man/cargo-clippy.adoc b/src/doc/man/cargo-clippy.adoc new file mode 100644 index 00000000000..402c711e15d --- /dev/null +++ b/src/doc/man/cargo-clippy.adoc @@ -0,0 +1,96 @@ += cargo-clippy(1) +:idprefix: cargo_clippy_ +:doctype: manpage +:actionverb: Clippy + +== NAME + +cargo-clippy - Check the current package with clippy + +== SYNOPSIS + +`cargo clippy [_OPTIONS_]` + +== DESCRIPTION + +Check a local package and all of its local dependencies for common mistakes +with clippy. + +== OPTIONS + +To allow or deny a lint from the command line you can use `cargo clippy --` +with: + + -W --warn OPT Set lint warnings + -A --allow OPT Set lint allowed + -D --deny OPT Set lint denied + -F --forbid OPT Set lint forbidden + +You can use tool lints to allow or deny lints from your code, eg.: + + #[allow(clippy::needless_lifetimes)] + +=== Package Selection + +include::options-packages.adoc[] + +=== Target Selection + +When no target selection options are given, `cargo clippy` will check all +binary and library targets of the selected packages. Binaries are skipped if +they have `required-features` that are missing. + +include::options-targets.adoc[] + +include::options-features.adoc[] + +=== Compilation Options + +include::options-target-triple.adoc[] + +include::options-release.adoc[] + +include::options-profile.adoc[] + +=== Output Options + +include::options-target-dir.adoc[] + +=== Display Options + +include::options-display.adoc[] + +include::options-message-format.adoc[] + +=== Manifest Options + +include::options-manifest-path.adoc[] + +include::options-locked.adoc[] + +=== Common Options + +include::options-common.adoc[] + +=== Miscellaneous Options + +include::options-jobs.adoc[] + +include::section-profiles.adoc[] + +include::section-environment.adoc[] + +include::section-exit-status.adoc[] + +== EXAMPLES + +. Check the local package for common mistakes: + + cargo clippy + +. Check all targets, including unit tests: + + cargo clippy --all-targets --profile=test + +== SEE ALSO +man:cargo[1], man:cargo-build[1], man:cargo-check[1] diff --git a/src/doc/man/generated/cargo-clippy.html b/src/doc/man/generated/cargo-clippy.html new file mode 100644 index 00000000000..660c94da986 --- /dev/null +++ b/src/doc/man/generated/cargo-clippy.html @@ -0,0 +1,479 @@ +

NAME

+
+

cargo-clippy - Check the current package with clippy

+
+
+

SYNOPSIS

+
+
+

cargo clippy [OPTIONS]

+
+
+
+
+

DESCRIPTION

+
+
+

Check a local package and all of its local dependencies for common mistakes +with clippy.

+
+
+
+
+

OPTIONS

+
+
+

To allow or deny a lint from the command line you can use cargo clippy -- +with:

+
+
+
+
-W --warn OPT       Set lint warnings
+-A --allow OPT      Set lint allowed
+-D --deny OPT       Set lint denied
+-F --forbid OPT     Set lint forbidden
+
+
+
+

You can use tool lints to allow or deny lints from your code, eg.:

+
+
+
+
#[allow(clippy::needless_lifetimes)]
+
+
+
+

Package Selection

+
+

By default, when no package selection options are given, the packages selected +depend on the selected manifest file (based on the current working directory if +--manifest-path is not given). If the manifest is the root of a workspace then +the workspaces default members are selected, otherwise only the package defined +by the manifest will be selected.

+
+
+

The default members of a workspace can be set explicitly with the +workspace.default-members key in the root manifest. If this is not set, a +virtual workspace will include all workspace members (equivalent to passing +--workspace), and a non-virtual workspace will include only the root crate itself.

+
+
+
+
-p SPEC…​
+
--package SPEC…​
+
+

Clippy only the specified packages. See cargo-pkgid(1) for the +SPEC format. This flag may be specified multiple times.

+
+
--workspace
+
+

Clippy all members in the workspace.

+
+
--all
+
+

Deprecated alias for --workspace.

+
+
--exclude SPEC…​
+
+

Exclude the specified packages. Must be used in conjunction with the +--workspace flag. This flag may be specified multiple times.

+
+
+
+
+
+

Target Selection

+
+

When no target selection options are given, cargo clippy will check all +binary and library targets of the selected packages. Binaries are skipped if +they have required-features that are missing.

+
+
+

Passing target selection flags will clippy only the +specified targets.

+
+
+
+
--lib
+
+

Clippy the package’s library.

+
+
--bin NAME…​
+
+

Clippy the specified binary. This flag may be specified multiple times.

+
+
--bins
+
+

Clippy all binary targets.

+
+
--example NAME…​
+
+

Clippy the specified example. This flag may be specified multiple times.

+
+
--examples
+
+

Clippy all example targets.

+
+
--test NAME…​
+
+

Clippy the specified integration test. This flag may be specified multiple +times.

+
+
--tests
+
+

Clippy all targets in test mode that have the test = true manifest +flag set. By default this includes the library and binaries built as +unittests, and integration tests. Be aware that this will also build any +required dependencies, so the lib target may be built twice (once as a +unittest, and once as a dependency for binaries, integration tests, etc.). +Targets may be enabled or disabled by setting the test flag in the +manifest settings for the target.

+
+
--bench NAME…​
+
+

Clippy the specified benchmark. This flag may be specified multiple times.

+
+
--benches
+
+

Clippy all targets in benchmark mode that have the bench = true +manifest flag set. By default this includes the library and binaries built +as benchmarks, and bench targets. Be aware that this will also build any +required dependencies, so the lib target may be built twice (once as a +benchmark, and once as a dependency for binaries, benchmarks, etc.). +Targets may be enabled or disabled by setting the bench flag in the +manifest settings for the target.

+
+
--all-targets
+
+

Clippy all targets. This is equivalent to specifying --lib --bins +--tests --benches --examples.

+
+
+
+
+
+

Feature Selection

+
+

When no feature options are given, the default feature is activated for +every selected package.

+
+
+
+
--features FEATURES
+
+

Space or comma separated list of features to activate. These features only +apply to the current directory’s package. Features of direct dependencies +may be enabled with <dep-name>/<feature-name> syntax.

+
+
--all-features
+
+

Activate all available features of all selected packages.

+
+
--no-default-features
+
+

Do not activate the default feature of the current directory’s +package.

+
+
+
+
+
+

Compilation Options

+
+
+
--target TRIPLE
+
+

Clippy for the given architecture. The default is the host +architecture. The general format of the triple is +<arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for a +list of supported targets.

+
+

This may also be specified with the build.target +config value.

+
+
+
--release
+
+

Clippy optimized artifacts with the release profile. See the +PROFILES section for details on how this affects profile selection.

+
+
--profile NAME
+
+

Changes clippy behavior. Currently only test is +supported, which will clippy with the +#[cfg(test)] attribute enabled. This is useful to have it +clippy unit tests which are usually excluded via +the cfg attribute. This does not change the actual profile used.

+
+
+
+
+
+

Output Options

+
+
+
--target-dir DIRECTORY
+
+

Directory for all generated artifacts and intermediate files. May also be +specified with the CARGO_TARGET_DIR environment variable, or the +build.target-dir config value. Defaults +to target in the root of the workspace.

+
+
+
+
+
+

Display Options

+
+
+
-v
+
--verbose
+
+

Use verbose output. May be specified twice for "very verbose" output which +includes extra output such as dependency warnings and build script output. +May also be specified with the term.verbose +config value.

+
+
-q
+
--quiet
+
+

No output printed to stdout.

+
+
--color WHEN
+
+

Control when colored output is used. Valid values:

+
+
    +
  • +

    auto (default): Automatically detect if color support is available on the +terminal.

    +
  • +
  • +

    always: Always display colors.

    +
  • +
  • +

    never: Never display colors.

    +
  • +
+
+
+

May also be specified with the term.color +config value.

+
+
+
--message-format FMT
+
+

The output format for diagnostic messages. Can be specified multiple times +and consists of comma-separated values. Valid values:

+
+
    +
  • +

    human (default): Display in a human-readable text format.

    +
  • +
  • +

    short: Emit shorter, human-readable text messages.

    +
  • +
  • +

    json: Emit JSON messages to stdout.

    +
  • +
  • +

    json-diagnostic-short: Ensure the rendered field of JSON messages contains +the "short" rendering from rustc.

    +
  • +
  • +

    json-diagnostic-rendered-ansi: Ensure the rendered field of JSON messages +contains embedded ANSI color codes for respecting rustc’s default color +scheme.

    +
  • +
  • +

    json-render-diagnostics: Instruct Cargo to not include rustc diagnostics in +in JSON messages printed, but instead Cargo itself should render the +JSON diagnostics coming from rustc. Cargo’s own JSON diagnostics and others +coming from rustc are still emitted.

    +
  • +
+
+
+
+
+
+
+

Manifest Options

+
+
+
--manifest-path PATH
+
+

Path to the Cargo.toml file. By default, Cargo searches in the current +directory or any parent directory for the Cargo.toml file.

+
+
--frozen
+
--locked
+
+

Either of these flags requires that the Cargo.lock file is +up-to-date. If the lock file is missing, or it needs to be updated, Cargo will +exit with an error. The --frozen flag also prevents Cargo from +attempting to access the network to determine if it is out-of-date.

+
+

These may be used in environments where you want to assert that the +Cargo.lock file is up-to-date (such as a CI build) or want to avoid network +access.

+
+
+
--offline
+
+

Prevents Cargo from accessing the network for any reason. Without this +flag, Cargo will stop with an error if it needs to access the network and +the network is not available. With this flag, Cargo will attempt to +proceed without the network if possible.

+
+

Beware that this may result in different dependency resolution than online +mode. Cargo will restrict itself to crates that are downloaded locally, even +if there might be a newer version as indicated in the local copy of the index. +See the cargo-fetch(1) command to download dependencies before going +offline.

+
+
+

May also be specified with the net.offline config value.

+
+
+
+
+
+
+

Common Options

+
+
+
-h
+
--help
+
+

Prints help information.

+
+
-Z FLAG…​
+
+

Unstable (nightly-only) flags to Cargo. Run cargo -Z help for +details.

+
+
+
+
+
+

Miscellaneous Options

+
+
+
-j N
+
--jobs N
+
+

Number of parallel jobs to run. May also be specified with the +build.jobs config value. Defaults to +the number of CPUs.

+
+
+
+
+
+
+
+

PROFILES

+
+
+

Profiles may be used to configure compiler options such as optimization levels +and debug settings. See +the reference +for more details.

+
+
+

Profile selection depends on the target and crate being built. By default the +dev or test profiles are used. If the --release flag is given, then the +release or bench profiles are used.

+
+ +++++ + + + + + + + + + + + + + + + + + + + +
TargetDefault Profile--release Profile

lib, bin, example

dev

release

test, bench, or any target
+ in "test" or "bench" mode

test

bench

+
+

Dependencies use the dev/release profiles.

+
+
+
+
+

ENVIRONMENT

+
+
+

See the reference for +details on environment variables that Cargo reads.

+
+
+
+
+

Exit Status

+
+
+
+
0
+
+

Cargo succeeded.

+
+
101
+
+

Cargo failed to complete.

+
+
+
+
+
+
+

EXAMPLES

+
+
+
    +
  1. +

    Check the local package for common mistakes:

    +
    +
    +
    cargo clippy
    +
    +
    +
  2. +
  3. +

    Check all targets, including unit tests:

    +
    +
    +
    cargo clippy --all-targets --profile=test
    +
    +
    +
  4. +
+
+
+
+
+

SEE ALSO

+ +
\ No newline at end of file diff --git a/src/doc/src/SUMMARY.md b/src/doc/src/SUMMARY.md index 1f6bd2cb96d..b307c4d1bb3 100644 --- a/src/doc/src/SUMMARY.md +++ b/src/doc/src/SUMMARY.md @@ -37,6 +37,7 @@ * [build](commands/cargo-build.md) * [check](commands/cargo-check.md) * [clean](commands/cargo-clean.md) + * [clippy](commands/cargo-clippy.md) * [doc](commands/cargo-doc.md) * [fetch](commands/cargo-fetch.md) * [fix](commands/cargo-fix.md) diff --git a/src/doc/src/commands/cargo-clippy.md b/src/doc/src/commands/cargo-clippy.md new file mode 100644 index 00000000000..e7e04b52b78 --- /dev/null +++ b/src/doc/src/commands/cargo-clippy.md @@ -0,0 +1,3 @@ +# cargo clippy +{{#include command-common.html}} +{{#include ../../man/generated/cargo-clippy.html}} diff --git a/src/etc/man/cargo-clippy.1 b/src/etc/man/cargo-clippy.1 new file mode 100644 index 00000000000..68b1e218596 --- /dev/null +++ b/src/etc/man/cargo-clippy.1 @@ -0,0 +1,528 @@ +'\" t +.\" Title: cargo-clippy +.\" Author: [see the "AUTHORS" section] +.\" Generator: Asciidoctor 1.5.5 +.\" Date: 2019-09-23 +.\" Manual: \ \& +.\" Source: \ \& +.\" Language: English +.\" +.TH "CARGO\-CLIPPY" "1" "2019-09-23" "\ \&" "\ \&" +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.ss \n[.ss] 0 +.nh +.ad l +.de URL +\\$2 \(laURL: \\$1 \(ra\\$3 +.. +.if \n[.g] .mso www.tmac +.LINKSTYLE blue R < > +.SH "NAME" +cargo\-clippy \- Check the current package with clippy +.SH "SYNOPSIS" +.sp +\f[CR]cargo clippy [\fIOPTIONS\fP]\fP +.SH "DESCRIPTION" +.sp +Check a local package and all of its local dependencies for common mistakes +with clippy. +.SH "OPTIONS" +.sp +To allow or deny a lint from the command line you can use \f[CR]cargo clippy \-\-\fP +with: +.sp +.if n \{\ +.RS 4 +.\} +.nf +\-W \-\-warn OPT Set lint warnings +\-A \-\-allow OPT Set lint allowed +\-D \-\-deny OPT Set lint denied +\-F \-\-forbid OPT Set lint forbidden +.fi +.if n \{\ +.RE +.\} +.sp +You can use tool lints to allow or deny lints from your code, eg.: +.sp +.if n \{\ +.RS 4 +.\} +.nf +#[allow(clippy::needless_lifetimes)] +.fi +.if n \{\ +.RE +.\} +.SS "Package Selection" +.sp +By default, when no package selection options are given, the packages selected +depend on the selected manifest file (based on the current working directory if +\f[CR]\-\-manifest\-path\fP is not given). If the manifest is the root of a workspace then +the workspaces default members are selected, otherwise only the package defined +by the manifest will be selected. +.sp +The default members of a workspace can be set explicitly with the +\f[CR]workspace.default\-members\fP key in the root manifest. If this is not set, a +virtual workspace will include all workspace members (equivalent to passing +\f[CR]\-\-workspace\fP), and a non\-virtual workspace will include only the root crate itself. +.sp +\fB\-p\fP \fISPEC\fP..., \fB\-\-package\fP \fISPEC\fP... +.RS 4 +Clippy only the specified packages. See \fBcargo\-pkgid\fP(1) for the +SPEC format. This flag may be specified multiple times. +.RE +.sp +\fB\-\-workspace\fP +.RS 4 +Clippy all members in the workspace. +.RE +.sp +\fB\-\-all\fP +.RS 4 +Deprecated alias for \f[CR]\-\-workspace\fP. +.RE +.sp +\fB\-\-exclude\fP \fISPEC\fP... +.RS 4 +Exclude the specified packages. Must be used in conjunction with the +\f[CR]\-\-workspace\fP flag. This flag may be specified multiple times. +.RE +.SS "Target Selection" +.sp +When no target selection options are given, \f[CR]cargo clippy\fP will check all +binary and library targets of the selected packages. Binaries are skipped if +they have \f[CR]required\-features\fP that are missing. +.sp +Passing target selection flags will clippy only the +specified targets. +.sp +\fB\-\-lib\fP +.RS 4 +Clippy the package\(cqs library. +.RE +.sp +\fB\-\-bin\fP \fINAME\fP... +.RS 4 +Clippy the specified binary. This flag may be specified multiple times. +.RE +.sp +\fB\-\-bins\fP +.RS 4 +Clippy all binary targets. +.RE +.sp +\fB\-\-example\fP \fINAME\fP... +.RS 4 +Clippy the specified example. This flag may be specified multiple times. +.RE +.sp +\fB\-\-examples\fP +.RS 4 +Clippy all example targets. +.RE +.sp +\fB\-\-test\fP \fINAME\fP... +.RS 4 +Clippy the specified integration test. This flag may be specified multiple +times. +.RE +.sp +\fB\-\-tests\fP +.RS 4 +Clippy all targets in test mode that have the \f[CR]test = true\fP manifest +flag set. By default this includes the library and binaries built as +unittests, and integration tests. Be aware that this will also build any +required dependencies, so the lib target may be built twice (once as a +unittest, and once as a dependency for binaries, integration tests, etc.). +Targets may be enabled or disabled by setting the \f[CR]test\fP flag in the +manifest settings for the target. +.RE +.sp +\fB\-\-bench\fP \fINAME\fP... +.RS 4 +Clippy the specified benchmark. This flag may be specified multiple times. +.RE +.sp +\fB\-\-benches\fP +.RS 4 +Clippy all targets in benchmark mode that have the \f[CR]bench = true\fP +manifest flag set. By default this includes the library and binaries built +as benchmarks, and bench targets. Be aware that this will also build any +required dependencies, so the lib target may be built twice (once as a +benchmark, and once as a dependency for binaries, benchmarks, etc.). +Targets may be enabled or disabled by setting the \f[CR]bench\fP flag in the +manifest settings for the target. +.RE +.sp +\fB\-\-all\-targets\fP +.RS 4 +Clippy all targets. This is equivalent to specifying \f[CR]\-\-lib \-\-bins +\-\-tests \-\-benches \-\-examples\fP. +.RE +.SS "Feature Selection" +.sp +When no feature options are given, the \f[CR]default\fP feature is activated for +every selected package. +.sp +\fB\-\-features\fP \fIFEATURES\fP +.RS 4 +Space or comma separated list of features to activate. These features only +apply to the current directory\(cqs package. Features of direct dependencies +may be enabled with \f[CR]/\fP syntax. +.RE +.sp +\fB\-\-all\-features\fP +.RS 4 +Activate all available features of all selected packages. +.RE +.sp +\fB\-\-no\-default\-features\fP +.RS 4 +Do not activate the \f[CR]default\fP feature of the current directory\(cqs +package. +.RE +.SS "Compilation Options" +.sp +\fB\-\-target\fP \fITRIPLE\fP +.RS 4 +Clippy for the given architecture. The default is the host +architecture. The general format of the triple is +\f[CR]\-\-\-\fP. Run \f[CR]rustc \-\-print target\-list\fP for a +list of supported targets. +.sp +This may also be specified with the \f[CR]build.target\fP +.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." +.RE +.sp +\fB\-\-release\fP +.RS 4 +Clippy optimized artifacts with the \f[CR]release\fP profile. See the +PROFILES section for details on how this affects profile selection. +.RE +.sp +\fB\-\-profile\fP \fINAME\fP +.RS 4 +Changes clippy behavior. Currently only \f[CR]test\fP is +supported, which will clippy with the +\f[CR]#[cfg(test)]\fP attribute enabled. This is useful to have it +clippy unit tests which are usually excluded via +the \f[CR]cfg\fP attribute. This does not change the actual profile used. +.RE +.SS "Output Options" +.sp +\fB\-\-target\-dir\fP \fIDIRECTORY\fP +.RS 4 +Directory for all generated artifacts and intermediate files. May also be +specified with the \f[CR]CARGO_TARGET_DIR\fP environment variable, or the +\f[CR]build.target\-dir\fP \c +.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." +Defaults +to \f[CR]target\fP in the root of the workspace. +.RE +.SS "Display Options" +.sp +\fB\-v\fP, \fB\-\-verbose\fP +.RS 4 +Use verbose output. May be specified twice for "very verbose" output which +includes extra output such as dependency warnings and build script output. +May also be specified with the \f[CR]term.verbose\fP +.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." +.RE +.sp +\fB\-q\fP, \fB\-\-quiet\fP +.RS 4 +No output printed to stdout. +.RE +.sp +\fB\-\-color\fP \fIWHEN\fP +.RS 4 +Control when colored output is used. Valid values: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]auto\fP (default): Automatically detect if color support is available on the +terminal. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]always\fP: Always display colors. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]never\fP: Never display colors. +.RE +.sp +May also be specified with the \f[CR]term.color\fP +.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." +.RE +.sp +\fB\-\-message\-format\fP \fIFMT\fP +.RS 4 +The output format for diagnostic messages. Can be specified multiple times +and consists of comma\-separated values. Valid values: +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]human\fP (default): Display in a human\-readable text format. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]short\fP: Emit shorter, human\-readable text messages. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]json\fP: Emit JSON messages to stdout. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]json\-diagnostic\-short\fP: Ensure the \f[CR]rendered\fP field of JSON messages contains +the "short" rendering from rustc. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]json\-diagnostic\-rendered\-ansi\fP: Ensure the \f[CR]rendered\fP field of JSON messages +contains embedded ANSI color codes for respecting rustc\(cqs default color +scheme. +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +\f[CR]json\-render\-diagnostics\fP: Instruct Cargo to not include rustc diagnostics in +in JSON messages printed, but instead Cargo itself should render the +JSON diagnostics coming from rustc. Cargo\(cqs own JSON diagnostics and others +coming from rustc are still emitted. +.RE +.RE +.SS "Manifest Options" +.sp +\fB\-\-manifest\-path\fP \fIPATH\fP +.RS 4 +Path to the \f[CR]Cargo.toml\fP file. By default, Cargo searches in the current +directory or any parent directory for the \f[CR]Cargo.toml\fP file. +.RE +.sp +\fB\-\-frozen\fP, \fB\-\-locked\fP +.RS 4 +Either of these flags requires that the \f[CR]Cargo.lock\fP file is +up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will +exit with an error. The \f[CR]\-\-frozen\fP flag also prevents Cargo from +attempting to access the network to determine if it is out\-of\-date. +.sp +These may be used in environments where you want to assert that the +\f[CR]Cargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network +access. +.RE +.sp +\fB\-\-offline\fP +.RS 4 +Prevents Cargo from accessing the network for any reason. Without this +flag, Cargo will stop with an error if it needs to access the network and +the network is not available. With this flag, Cargo will attempt to +proceed without the network if possible. +.sp +Beware that this may result in different dependency resolution than online +mode. Cargo will restrict itself to crates that are downloaded locally, even +if there might be a newer version as indicated in the local copy of the index. +See the \fBcargo\-fetch\fP(1) command to download dependencies before going +offline. +.sp +May also be specified with the \f[CR]net.offline\fP \c +.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." +.RE +.SS "Common Options" +.sp +\fB\-h\fP, \fB\-\-help\fP +.RS 4 +Prints help information. +.RE +.sp +\fB\-Z\fP \fIFLAG\fP... +.RS 4 +Unstable (nightly\-only) flags to Cargo. Run \f[CR]cargo \-Z help\fP for +details. +.RE +.SS "Miscellaneous Options" +.sp +\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP +.RS 4 +Number of parallel jobs to run. May also be specified with the +\f[CR]build.jobs\fP \c +.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." +Defaults to +the number of CPUs. +.RE +.SH "PROFILES" +.sp +Profiles may be used to configure compiler options such as optimization levels +and debug settings. See +.URL "https://doc.rust\-lang.org/cargo/reference/manifest.html#the\-profile\-sections" "the reference" "" +for more details. +.sp +Profile selection depends on the target and crate being built. By default the +\f[CR]dev\fP or \f[CR]test\fP profiles are used. If the \f[CR]\-\-release\fP flag is given, then the +\f[CR]release\fP or \f[CR]bench\fP profiles are used. +.TS +allbox tab(:); +lt lt lt. +T{ +.sp +Target +T}:T{ +.sp +Default Profile +T}:T{ +.sp +\f[CR]--release\fP Profile +T} +T{ +.sp +lib, bin, example +T}:T{ +.sp +\f[CR]dev\fP +T}:T{ +.sp +\f[CR]release\fP +T} +T{ +.sp +test, bench, or any target +.br + in "test" or "bench" mode +T}:T{ +.sp +\f[CR]test\fP +T}:T{ +.sp +\f[CR]bench\fP +T} +.TE +.sp +.sp +Dependencies use the \f[CR]dev\fP/\f[CR]release\fP profiles. +.SH "ENVIRONMENT" +.sp +See \c +.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " " +for +details on environment variables that Cargo reads. +.SH "EXIT STATUS" +.sp +0 +.RS 4 +Cargo succeeded. +.RE +.sp +101 +.RS 4 +Cargo failed to complete. +.RE +.SH "EXAMPLES" +.sp +.RS 4 +.ie n \{\ +\h'-04' 1.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 1." 4.2 +.\} +Check the local package for common mistakes: +.sp +.if n \{\ +.RS 4 +.\} +.nf +cargo clippy +.fi +.if n \{\ +.RE +.\} +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04' 2.\h'+01'\c +.\} +.el \{\ +.sp -1 +.IP " 2." 4.2 +.\} +Check all targets, including unit tests: +.sp +.if n \{\ +.RS 4 +.\} +.nf +cargo clippy \-\-all\-targets \-\-profile=test +.fi +.if n \{\ +.RE +.\} +.RE +.SH "SEE ALSO" +.sp +\fBcargo\fP(1), \fBcargo\-build\fP(1), \fBcargo\-check\fP(1) \ No newline at end of file diff --git a/tests/testsuite/cache_messages.rs b/tests/testsuite/cache_messages.rs index 7a104e959f3..e76f907688e 100644 --- a/tests/testsuite/cache_messages.rs +++ b/tests/testsuite/cache_messages.rs @@ -320,13 +320,13 @@ fn clippy() { .file("src/lib.rs", "pub fn f() { assert!(true); }") .build(); - p.cargo("clippy-preview -Zunstable-options -Zcache-messages") + p.cargo("clippy -Zcache-messages") .masquerade_as_nightly_cargo() .with_stderr_contains("[..]assert!(true)[..]") .run(); // Again, reading from the cache. - p.cargo("clippy-preview -Zunstable-options -Zcache-messages") + p.cargo("clippy -Zcache-messages") .masquerade_as_nightly_cargo() .with_stderr_contains("[..]assert!(true)[..]") .run(); diff --git a/tests/testsuite/clippy.rs b/tests/testsuite/clippy.rs index 5e5000ff83f..2cef4458eb8 100644 --- a/tests/testsuite/clippy.rs +++ b/tests/testsuite/clippy.rs @@ -26,13 +26,13 @@ fn clippy_force_rebuild() { .file("src/lib.rs", "pub fn f() { assert!(true); }") .build(); - p.cargo("clippy-preview -Zunstable-options -v") + p.cargo("clippy -v") .masquerade_as_nightly_cargo() .with_stderr_contains("[..]assert!(true)[..]") .run(); // Make sure it runs again. - p.cargo("clippy-preview -Zunstable-options -v") + p.cargo("clippy -v") .masquerade_as_nightly_cargo() .with_stderr_contains("[FRESH] dep1 v0.1.0") .with_stderr_contains("[..]assert!(true)[..]") @@ -61,13 +61,13 @@ fn clippy_passes_args() { .file("src/lib.rs", "pub fn f() { assert!(true); }") .build(); - p.cargo("clippy-preview -Zunstable-options -v -- -Aclippy::assertions_on_constants") + p.cargo("clippy -v -- -Aclippy::assertions_on_constants") .masquerade_as_nightly_cargo() .with_stderr_does_not_contain("[..]assert!(true)[..]") .run(); // Make sure it runs again. - p.cargo("clippy-preview -Zunstable-options -v") + p.cargo("clippy -v") .masquerade_as_nightly_cargo() .with_stderr_contains("[..]assert!(true)[..]") .run();