about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel E. Moelius III <sam@moeli.us>2021-03-15 05:40:21 -0400
committerSamuel E. Moelius III <sam@moeli.us>2021-03-15 05:40:21 -0400
commitf7c5742ca65c37a1b6801fc6bb0522b991645b1e (patch)
tree84b90715d0dab543f76218c1facfc66150b2a307
parent52c25e9136f533c350fa1916b5bf5103f69c0f4d (diff)
downloadrust-f7c5742ca65c37a1b6801fc6bb0522b991645b1e.tar.gz
rust-f7c5742ca65c37a1b6801fc6bb0522b991645b1e.zip
Do not show docs link when lint doesn't start with "clippy::"
-rw-r--r--clippy_utils/src/diagnostics.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/clippy_utils/src/diagnostics.rs b/clippy_utils/src/diagnostics.rs
index 269be217c2d..e9c9cb12b9d 100644
--- a/clippy_utils/src/diagnostics.rs
+++ b/clippy_utils/src/diagnostics.rs
@@ -8,14 +8,16 @@ use std::env;
 
 fn docs_link(diag: &mut DiagnosticBuilder<'_>, lint: &'static Lint) {
     if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
-        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)
-        ));
+        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
+            ));
+        }
     }
 }