77#![ warn( rust_2018_idioms, unused_lifetimes) ]
88// warn on rustc internal lints
99#![ warn( rustc:: internal) ]
10+ #![ allow( clippy:: ignored_unit_patterns) ]
1011
1112// FIXME: switch to something more ergonomic here, once available.
1213// (Currently there is no way to opt into sysroot crates without `extern crate`.)
@@ -26,6 +27,8 @@ use std::ops::Deref;
2627use std:: path:: Path ;
2728use std:: process:: exit;
2829
30+ use anstream:: println;
31+
2932/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
3033/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
3134fn arg_value < ' a , T : Deref < Target = str > > (
@@ -163,33 +166,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
163166}
164167
165168fn display_help ( ) {
166- println ! (
167- "\
168- Checks a package to catch common mistakes and improve your Rust code.
169-
170- Usage:
171- cargo clippy [options] [--] [<opts>...]
172-
173- Common options:
174- -h, --help Print this message
175- --rustc Pass all args to rustc
176- -V, --version Print version info and exit
177-
178- For the other options see `cargo check --help`.
179-
180- To allow or deny a lint from the command line you can use `cargo clippy --`
181- with:
182-
183- -W --warn OPT Set lint warnings
184- -A --allow OPT Set lint allowed
185- -D --deny OPT Set lint denied
186- -F --forbid OPT Set lint forbidden
187-
188- You can use tool lints to allow or deny lints from your code, eg.:
189-
190- #[allow(clippy::needless_lifetimes)]
191- "
192- ) ;
169+ println ! ( "{}" , help_message( ) ) ;
193170}
194171
195172const BUG_REPORT_URL : & str = "https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml" ;
@@ -292,3 +269,36 @@ pub fn main() {
292269 }
293270 } ) )
294271}
272+
273+ #[ must_use]
274+ fn help_message ( ) -> & ' static str {
275+ color_print:: cstr!(
276+ "Checks a package to catch common mistakes and improve your Rust code.
277+
278+ <green,bold>Usage</>:
279+ <cyan,bold>clippy-driver</> <cyan>[OPTIONS] [--] [<<ARGS>>...]</>
280+
281+ <green,bold>Common options:</>
282+ <cyan,bold>--no-deps</> Run Clippy only on the given crate, without linting the dependencies
283+ <cyan,bold>--fix</> Automatically apply lint suggestions. This flag implies <cyan>--no-deps</> and <cyan>--all-targets</>
284+ <cyan,bold>-h</>, <cyan,bold>--help</> Print this message
285+ <cyan,bold>-V</>, <cyan,bold>--version</> Print version info and exit
286+ <cyan,bold>--explain [LINT]</> Print the documentation for a given lint
287+
288+ See all options with <cyan,bold>cargo check --help</>.
289+
290+ <green,bold>Allowing / Denying lints</>
291+
292+ To allow or deny a lint from the command line you can use <cyan,bold>cargo clippy --</> with:
293+
294+ <cyan,bold>-W</> / <cyan,bold>--warn</> <cyan>[LINT]</> Set lint warnings
295+ <cyan,bold>-A</> / <cyan,bold>--allow</> <cyan>[LINT]</> Set lint allowed
296+ <cyan,bold>-D</> / <cyan,bold>--deny</> <cyan>[LINT]</> Set lint denied
297+ <cyan,bold>-F</> / <cyan,bold>--forbid</> <cyan>[LINT]</> Set lint forbidden
298+
299+ You can use tool lints to allow or deny lints from your code, e.g.:
300+
301+ <yellow,bold>#[allow(clippy::needless_lifetimes)]</>
302+ "
303+ )
304+ }
0 commit comments