Do not show docs link when lint doesn't start with "clippy::"

This commit is contained in:
Samuel E. Moelius III 2021-03-15 05:40:21 -04:00
parent 52c25e9136
commit f7c5742ca6

View File

@ -8,16 +8,18 @@ use std::env;
fn docs_link(diag: &mut DiagnosticBuilder<'_>, lint: &'static Lint) {
if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
if let Some(lint) = lint.name_lower().strip_prefix("clippy::") {
diag.help(&format!(
"for further information visit https://rust-lang.github.io/rust-clippy/{}/index.html#{}",
&option_env!("RUST_RELEASE_NUM").map_or("master".to_string(), |n| {
// extract just major + minor version and ignore patch versions
format!("rust-{}", n.rsplitn(2, '.').nth(1).unwrap())
}),
lint.name_lower().replacen("clippy::", "", 1)
lint
));
}
}
}
/// Emit a basic lint message with a `msg` and a `span`.
///