initial commit for help improvements on clippy-driver

This commit is contained in:
Jane Lusby 2019-06-04 17:32:03 -07:00
parent a1eb60f8ea
commit cf88c8487a
3 changed files with 2332 additions and 0 deletions

View file

@ -87,6 +87,28 @@ fn print_lints() {
fn update_lints(update_mode: &UpdateMode) {
let lint_list: Vec<Lint> = gather_all().collect();
std::fs::write(
"../src/lintlist.rs",
&format!(
"\
/// Lint data parsed from the Clippy source code.
#[derive(Clone, PartialEq, Debug)]
pub struct Lint {{
pub name: &'static str,
pub group: &'static str,
pub desc: &'static str,
pub deprecation: Option<&'static str>,
pub module: &'static str,
}}
pub const ALL_LINTS: [Lint; {}] = {:#?};",
lint_list.len(),
lint_list
),
)
.expect("can write to file");
let usable_lints: Vec<Lint> = Lint::usable_lints(lint_list.clone().into_iter()).collect();
let lint_count = usable_lints.len();

View file

@ -15,6 +15,8 @@ use rustc_tools_util::*;
use std::path::Path;
use std::process::{exit, Command};
mod lintlist;
/// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If
/// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`.
fn arg_value<'a>(
@ -120,6 +122,40 @@ pub fn main() {
exit(0);
}
if std::env::args().any(|a| a == "--help" || a == "-h") {
println!(
"\
Checks a package to catch common mistakes and improve your Rust code.
Usage:
cargo clippy [options] [--] [<opts>...]
Common options:
-h, --help Print this message
-V, --version Print version info and exit
Other options are the same as `cargo check`.
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)]
"
);
for lint in &lintlist::ALL_LINTS[..] {
println!("clippy::{},", lint.name);
}
exit(0);
}
let mut orig_args: Vec<String> = env::args().collect();
// Get the sysroot, looking from most specific to this invocation to the least:

2274
src/lintlist.rs Normal file

File diff suppressed because it is too large Load diff