mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Make --explain
subcommand return 1 for missing lints
This commit is contained in:
parent
a94aac607c
commit
894d5dafac
2 changed files with 6 additions and 2 deletions
|
@ -495,7 +495,7 @@ pub(crate) struct LintInfo {
|
|||
explanation: &'static str,
|
||||
}
|
||||
|
||||
pub fn explain(name: &str) {
|
||||
pub fn explain(name: &str) -> i32 {
|
||||
let target = format!("clippy::{}", name.to_ascii_uppercase());
|
||||
if let Some(info) = declared_lints::LINTS.iter().find(|info| info.lint.name == target) {
|
||||
println!("{}", info.explanation);
|
||||
|
@ -512,8 +512,10 @@ pub fn explain(name: &str) {
|
|||
println!(" - {}: {} (default: {})", conf.name, conf.doc, conf.default);
|
||||
}
|
||||
}
|
||||
0
|
||||
} else {
|
||||
println!("unknown lint: {name}");
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,9 @@ pub fn main() {
|
|||
if let Some(pos) = env::args().position(|a| a == "--explain") {
|
||||
if let Some(mut lint) = env::args().nth(pos + 1) {
|
||||
lint.make_ascii_lowercase();
|
||||
clippy_lints::explain(&lint.strip_prefix("clippy::").unwrap_or(&lint).replace('-', "_"));
|
||||
process::exit(clippy_lints::explain(
|
||||
&lint.strip_prefix("clippy::").unwrap_or(&lint).replace('-', "_"),
|
||||
));
|
||||
} else {
|
||||
show_help();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue