show default lint levels
This commit is contained in:
@@ -102,6 +102,7 @@ fn update_lints(update_mode: &UpdateMode) {
|
|||||||
|
|
||||||
pub mod lint;
|
pub mod lint;
|
||||||
pub use lint::Lint;
|
pub use lint::Lint;
|
||||||
|
pub use lint::LINT_LEVELS;
|
||||||
|
|
||||||
pub const ALL_LINTS: [Lint; {}] = {:#?};\n",
|
pub const ALL_LINTS: [Lint; {}] = {:#?};\n",
|
||||||
sorted_usable_lints.len(),
|
sorted_usable_lints.len(),
|
||||||
|
|||||||
@@ -125,9 +125,17 @@ Available lint options:
|
|||||||
"
|
"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let lint_level = |lint: &Lint| {
|
||||||
|
LINT_LEVELS
|
||||||
|
.iter()
|
||||||
|
.find(|level_mapping| level_mapping.0 == lint.group)
|
||||||
|
.map(|(_, level)| level)
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let mut lints: Vec<_> = ALL_LINTS.iter().collect();
|
let mut lints: Vec<_> = ALL_LINTS.iter().collect();
|
||||||
// The sort doesn't case-fold but it's doubtful we care.
|
// The sort doesn't case-fold but it's doubtful we care.
|
||||||
lints.sort_by_cached_key(|x: &&Lint| ("unknown", x.name));
|
lints.sort_by_cached_key(|x: &&Lint| (lint_level(x), x.name));
|
||||||
|
|
||||||
let max_name_len = lints
|
let max_name_len = lints
|
||||||
.iter()
|
.iter()
|
||||||
@@ -153,7 +161,7 @@ Available lint options:
|
|||||||
let print_lints = |lints: &[&Lint]| {
|
let print_lints = |lints: &[&Lint]| {
|
||||||
for lint in lints {
|
for lint in lints {
|
||||||
let name = lint.name.replace("_", "-");
|
let name = lint.name.replace("_", "-");
|
||||||
println!(" {} {:7.7} {}", padded(&scoped(&name)), "unknown", lint.desc);
|
println!(" {} {:7.7} {}", padded(&scoped(&name)), lint_level(lint), lint.desc);
|
||||||
}
|
}
|
||||||
println!("\n");
|
println!("\n");
|
||||||
};
|
};
|
||||||
@@ -179,12 +187,12 @@ Available lint options:
|
|||||||
println!("Lint groups provided by rustc:\n");
|
println!("Lint groups provided by rustc:\n");
|
||||||
println!(" {} sub-lints", padded("name"));
|
println!(" {} sub-lints", padded("name"));
|
||||||
println!(" {} ---------", padded("----"));
|
println!(" {} ---------", padded("----"));
|
||||||
// println!(" {} all lints that are set to issue warnings", padded("warnings"));
|
|
||||||
|
|
||||||
let print_lint_groups = || {
|
let print_lint_groups = || {
|
||||||
for group in lint_groups {
|
for group in lint_groups {
|
||||||
let name = group.to_lowercase().replace("_", "-");
|
let name = group.to_lowercase().replace("_", "-");
|
||||||
let desc = lints.iter()
|
let desc = lints
|
||||||
|
.iter()
|
||||||
.filter(|&lint| lint.group == group)
|
.filter(|&lint| lint.group == group)
|
||||||
.map(|lint| lint.name)
|
.map(|lint| lint.name)
|
||||||
.map(|name| name.replace("_", "-"))
|
.map(|name| name.replace("_", "-"))
|
||||||
@@ -196,27 +204,6 @@ Available lint options:
|
|||||||
};
|
};
|
||||||
|
|
||||||
print_lint_groups();
|
print_lint_groups();
|
||||||
|
|
||||||
// print_lint_groups(builtin_groups);
|
|
||||||
|
|
||||||
// match (loaded_plugins, plugin.len(), plugin_groups.len()) {
|
|
||||||
// (false, 0, _) | (false, _, 0) => {
|
|
||||||
// println!("Compiler plugins can provide additional lints and lint groups. To see a \
|
|
||||||
// listing of these, re-run `rustc -W help` with a crate filename.");
|
|
||||||
// }
|
|
||||||
// (false, ..) => panic!("didn't load lint plugins but got them anyway!"),
|
|
||||||
// (true, 0, 0) => println!("This crate does not load any lint plugins or lint groups."),
|
|
||||||
// (true, l, g) => {
|
|
||||||
// if l > 0 {
|
|
||||||
// println!("Lint checks provided by plugins loaded by this crate:\n");
|
|
||||||
// print_lints(plugin);
|
|
||||||
// }
|
|
||||||
// if g > 0 {
|
|
||||||
// println!("Lint groups provided by plugins loaded by this crate:\n");
|
|
||||||
// print_lint_groups(plugin_groups);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_help() {
|
fn display_help() {
|
||||||
|
|||||||
@@ -7,3 +7,33 @@ pub struct Lint {
|
|||||||
pub deprecation: Option<&'static str>,
|
pub deprecation: Option<&'static str>,
|
||||||
pub module: &'static str,
|
pub module: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(PartialOrd, PartialEq, Ord, Eq)]
|
||||||
|
pub enum LintLevel {
|
||||||
|
Allow,
|
||||||
|
Warn,
|
||||||
|
Deny,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for LintLevel {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
|
let s = match self {
|
||||||
|
LintLevel::Allow => "allow",
|
||||||
|
LintLevel::Warn => "warn",
|
||||||
|
LintLevel::Deny => "deny",
|
||||||
|
};
|
||||||
|
|
||||||
|
write!(f, "{}", s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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),
|
||||||
|
];
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
pub mod lint;
|
pub mod lint;
|
||||||
pub use lint::Lint;
|
pub use lint::Lint;
|
||||||
|
pub use lint::LINT_LEVELS;
|
||||||
|
|
||||||
pub const ALL_LINTS: [Lint; 304] = [
|
pub const ALL_LINTS: [Lint; 304] = [
|
||||||
Lint {
|
Lint {
|
||||||
|
|||||||
Reference in New Issue
Block a user