diff options
| author | Jane Lusby <jlusby42@gmail.com> | 2019-06-10 15:47:31 -0700 |
|---|---|---|
| committer | Jane Lusby <jlusby42@gmail.com> | 2019-06-12 12:29:37 -0700 |
| commit | a2bf96f1c607096a7dfac8065e7bd7a0be72974e (patch) | |
| tree | 4ed385e0150074b031f3405d91ab997e41ea0189 | |
| parent | 113ae891d927e4a0e4b4f79f60cd477b3a2ff8cc (diff) | |
| download | rust-a2bf96f1c607096a7dfac8065e7bd7a0be72974e.tar.gz rust-a2bf96f1c607096a7dfac8065e7bd7a0be72974e.zip | |
make it pass dogfood
| -rw-r--r-- | clippy_dev/src/main.rs | 4 | ||||
| -rw-r--r-- | src/driver.rs | 29 | ||||
| -rw-r--r-- | src/lintlist/lint.rs | 20 | ||||
| -rw-r--r-- | src/lintlist/mod.rs | 4 |
4 files changed, 29 insertions, 28 deletions
diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index b793112b3f9..fedbb661763 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -98,11 +98,11 @@ fn update_lints(update_mode: &UpdateMode) { "../src/lintlist/mod.rs", &format!( "\ -//! This file is managed by util/dev update_lints. Do not edit. +//! This file is managed by `util/dev update_lints`. Do not edit. pub mod lint; +pub use lint::Level; pub use lint::Lint; -pub use lint::LintLevel; pub use lint::LINT_LEVELS; pub const ALL_LINTS: [Lint; {}] = {:#?};\n", diff --git a/src/driver.rs b/src/driver.rs index 6ccd09962d3..468951cd4b0 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -110,6 +110,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks { } } +#[allow(clippy::find_map, clippy::filter_map)] fn describe_lints() { use lintlist::*; use std::collections::HashSet; @@ -129,11 +130,10 @@ Available lint options: LINT_LEVELS .iter() .find(|level_mapping| level_mapping.0 == lint.group) - .map(|(_, level)| level) - .map(|level| match level { - LintLevel::Allow => "allow", - LintLevel::Warn => "warn", - LintLevel::Deny => "deny", + .map(|(_, level)| match level { + Level::Allow => "allow", + Level::Warn => "warn", + Level::Deny => "deny", }) .unwrap() }; @@ -142,7 +142,7 @@ Available lint options: // The sort doesn't case-fold but it's doubtful we care. lints.sort_by_cached_key(|x: &&Lint| (lint_level(x), x.name)); - let max_name_len = lints + let max_lint_name_len = lints .iter() .map(|lint| lint.name.len()) .map(|len| len + "clippy::".len()) @@ -150,7 +150,7 @@ Available lint options: .unwrap_or(0); let padded = |x: &str| { - let mut s = " ".repeat(max_name_len - x.chars().count()); + let mut s = " ".repeat(max_lint_name_len - x.chars().count()); s.push_str(x); s }; @@ -178,8 +178,8 @@ Available lint options: print_lints(&lints); - let max_name_len = std::cmp::max( - "warnings".len(), + let max_group_name_len = std::cmp::max( + "all".len(), lint_groups .iter() .map(|group| group.len()) @@ -188,15 +188,16 @@ Available lint options: .unwrap_or(0), ); - let padded = |x: &str| { - let mut s = " ".repeat(max_name_len - x.chars().count()); + let padded_group = |x: &str| { + let mut s = " ".repeat(max_group_name_len - x.chars().count()); s.push_str(x); s }; println!("Lint groups provided by clippy:\n"); - println!(" {} sub-lints", padded("name")); - println!(" {} ---------", padded("----")); + println!(" {} sub-lints", padded_group("name")); + println!(" {} ---------", padded_group("----")); + println!(" {} the set of all clippy lints", padded_group("clippy::all")); let print_lint_groups = || { for group in lint_groups { @@ -208,7 +209,7 @@ Available lint options: .map(|name| name.replace("_", "-")) .collect::<Vec<String>>() .join(", "); - println!(" {} {}", padded(&scoped(&name)), desc); + println!(" {} {}", padded_group(&scoped(&name)), desc); } println!("\n"); }; diff --git a/src/lintlist/lint.rs b/src/lintlist/lint.rs index 65e5e8472ba..c817d83b33a 100644 --- a/src/lintlist/lint.rs +++ b/src/lintlist/lint.rs @@ -9,19 +9,19 @@ pub struct Lint { } #[derive(PartialOrd, PartialEq, Ord, Eq)] -pub enum LintLevel { +pub enum Level { Allow, Warn, Deny, } -pub const LINT_LEVELS: [(&str, LintLevel); 8] = [ - ("correctness", LintLevel::Deny), - ("style", LintLevel::Warn), - ("complexity", LintLevel::Warn), - ("perf", LintLevel::Warn), - ("restriction", LintLevel::Allow), - ("pedantic", LintLevel::Allow), - ("nursery", LintLevel::Allow), - ("cargo", LintLevel::Allow), +pub const LINT_LEVELS: [(&str, Level); 8] = [ + ("correctness", Level::Deny), + ("style", Level::Warn), + ("complexity", Level::Warn), + ("perf", Level::Warn), + ("restriction", Level::Allow), + ("pedantic", Level::Allow), + ("nursery", Level::Allow), + ("cargo", Level::Allow), ]; diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs index 2fc0853a4de..3317ccb5ed0 100644 --- a/src/lintlist/mod.rs +++ b/src/lintlist/mod.rs @@ -1,8 +1,8 @@ -//! This file is managed by util/dev update_lints. Do not edit. +//! This file is managed by `util/dev update_lints`. Do not edit. pub mod lint; +pub use lint::Level; pub use lint::Lint; -pub use lint::LintLevel; pub use lint::LINT_LEVELS; pub const ALL_LINTS: [Lint; 304] = [ |
