Skip to content

Commit a2bf96f

Browse files
committed
make it pass dogfood
1 parent 113ae89 commit a2bf96f

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

clippy_dev/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ fn update_lints(update_mode: &UpdateMode) {
9898
"../src/lintlist/mod.rs",
9999
&format!(
100100
"\
101-
//! This file is managed by util/dev update_lints. Do not edit.
101+
//! This file is managed by `util/dev update_lints`. Do not edit.
102102
103103
pub mod lint;
104+
pub use lint::Level;
104105
pub use lint::Lint;
105-
pub use lint::LintLevel;
106106
pub use lint::LINT_LEVELS;
107107
108108
pub const ALL_LINTS: [Lint; {}] = {:#?};\n",

src/driver.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
110110
}
111111
}
112112

113+
#[allow(clippy::find_map, clippy::filter_map)]
113114
fn describe_lints() {
114115
use lintlist::*;
115116
use std::collections::HashSet;
@@ -129,11 +130,10 @@ Available lint options:
129130
LINT_LEVELS
130131
.iter()
131132
.find(|level_mapping| level_mapping.0 == lint.group)
132-
.map(|(_, level)| level)
133-
.map(|level| match level {
134-
LintLevel::Allow => "allow",
135-
LintLevel::Warn => "warn",
136-
LintLevel::Deny => "deny",
133+
.map(|(_, level)| match level {
134+
Level::Allow => "allow",
135+
Level::Warn => "warn",
136+
Level::Deny => "deny",
137137
})
138138
.unwrap()
139139
};
@@ -142,15 +142,15 @@ Available lint options:
142142
// The sort doesn't case-fold but it's doubtful we care.
143143
lints.sort_by_cached_key(|x: &&Lint| (lint_level(x), x.name));
144144

145-
let max_name_len = lints
145+
let max_lint_name_len = lints
146146
.iter()
147147
.map(|lint| lint.name.len())
148148
.map(|len| len + "clippy::".len())
149149
.max()
150150
.unwrap_or(0);
151151

152152
let padded = |x: &str| {
153-
let mut s = " ".repeat(max_name_len - x.chars().count());
153+
let mut s = " ".repeat(max_lint_name_len - x.chars().count());
154154
s.push_str(x);
155155
s
156156
};
@@ -178,8 +178,8 @@ Available lint options:
178178

179179
print_lints(&lints);
180180

181-
let max_name_len = std::cmp::max(
182-
"warnings".len(),
181+
let max_group_name_len = std::cmp::max(
182+
"all".len(),
183183
lint_groups
184184
.iter()
185185
.map(|group| group.len())
@@ -188,15 +188,16 @@ Available lint options:
188188
.unwrap_or(0),
189189
);
190190

191-
let padded = |x: &str| {
192-
let mut s = " ".repeat(max_name_len - x.chars().count());
191+
let padded_group = |x: &str| {
192+
let mut s = " ".repeat(max_group_name_len - x.chars().count());
193193
s.push_str(x);
194194
s
195195
};
196196

197197
println!("Lint groups provided by clippy:\n");
198-
println!(" {} sub-lints", padded("name"));
199-
println!(" {} ---------", padded("----"));
198+
println!(" {} sub-lints", padded_group("name"));
199+
println!(" {} ---------", padded_group("----"));
200+
println!(" {} the set of all clippy lints", padded_group("clippy::all"));
200201

201202
let print_lint_groups = || {
202203
for group in lint_groups {
@@ -208,7 +209,7 @@ Available lint options:
208209
.map(|name| name.replace("_", "-"))
209210
.collect::<Vec<String>>()
210211
.join(", ");
211-
println!(" {} {}", padded(&scoped(&name)), desc);
212+
println!(" {} {}", padded_group(&scoped(&name)), desc);
212213
}
213214
println!("\n");
214215
};

src/lintlist/lint.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ pub struct Lint {
99
}
1010

1111
#[derive(PartialOrd, PartialEq, Ord, Eq)]
12-
pub enum LintLevel {
12+
pub enum Level {
1313
Allow,
1414
Warn,
1515
Deny,
1616
}
1717

18-
pub const LINT_LEVELS: [(&str, LintLevel); 8] = [
19-
("correctness", LintLevel::Deny),
20-
("style", LintLevel::Warn),
21-
("complexity", LintLevel::Warn),
22-
("perf", LintLevel::Warn),
23-
("restriction", LintLevel::Allow),
24-
("pedantic", LintLevel::Allow),
25-
("nursery", LintLevel::Allow),
26-
("cargo", LintLevel::Allow),
18+
pub const LINT_LEVELS: [(&str, Level); 8] = [
19+
("correctness", Level::Deny),
20+
("style", Level::Warn),
21+
("complexity", Level::Warn),
22+
("perf", Level::Warn),
23+
("restriction", Level::Allow),
24+
("pedantic", Level::Allow),
25+
("nursery", Level::Allow),
26+
("cargo", Level::Allow),
2727
];

src/lintlist/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//! This file is managed by util/dev update_lints. Do not edit.
1+
//! This file is managed by `util/dev update_lints`. Do not edit.
22
33
pub mod lint;
4+
pub use lint::Level;
45
pub use lint::Lint;
5-
pub use lint::LintLevel;
66
pub use lint::LINT_LEVELS;
77

88
pub const ALL_LINTS: [Lint; 304] = [

0 commit comments

Comments
 (0)