mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Make --explain
subcommand return 1 for missing lints
This commit is contained in:
parent
a94aac607c
commit
894d5dafac
@ -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 New Issue
Block a user