about summary refs log tree commit diff
path: root/clippy_lints
diff options
context:
space:
mode:
authorblyxyas <blyxyas@gmail.com>2024-10-01 19:39:18 +0200
committerblyxyas <blyxyas@gmail.com>2024-10-01 19:43:19 +0200
commit13e2633f193838eadcddd5bf5842b9ce0a1f17dd (patch)
treee85f97e05099653e72e4726a18ccc6f6bcfb75a9 /clippy_lints
parentdaf730caedb638696ee704e22942617cf5848e5f (diff)
Also sanitize configuration
Diffstat (limited to 'clippy_lints')
-rw-r--r--clippy_lints/src/lib.rs26
1 files changed, 1 insertions, 25 deletions
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 0bfbb92dfda..71e7b56408e 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -396,7 +396,7 @@ mod zero_sized_map_values;
 mod zombie_processes;
 // end lints modules, do not remove this comment, it’s used in `update_lints`
 
-use clippy_config::{Conf, get_configuration_metadata};
+use clippy_config::{Conf, get_configuration_metadata, sanitize_explanation};
 use clippy_utils::macros::FormatArgsStorage;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_lint::{Lint, LintId};
@@ -522,30 +522,6 @@ impl LintInfo {
     }
 }
 
-// Remove code tags and code behind '# 's, as they are not needed for the lint docs and --explain
-pub fn sanitize_explanation(raw_docs: &str) -> String {
-    // Remove tags and hidden code:
-    let mut explanation = String::with_capacity(128);
-    let mut in_code = false;
-    for line in raw_docs.lines().map(|line| line.trim()) {
-        if let Some(lang) = line.strip_prefix("```") {
-            let tag = lang.split_once(',').map_or(lang, |(left, _)| left);
-            if !in_code && matches!(tag, "" | "rust" | "ignore" | "should_panic" | "no_run" | "compile_fail") {
-                explanation += "```rust\n";
-            } else {
-                explanation += line;
-                explanation.push('\n');
-            }
-            in_code = !in_code;
-        } else if !(in_code && line.starts_with("# ")) {
-            explanation += line;
-            explanation.push('\n');
-        }
-    }
-
-    explanation
-}
-
 pub fn explain(name: &str) -> i32 {
     let target = format!("clippy::{}", name.to_ascii_uppercase());