about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--clippy_lints/src/doc/mod.rs2
-rw-r--r--clippy_lints/src/methods/mod.rs6
-rw-r--r--clippy_lints/src/utils/internal_lints/metadata_collector.rs6
3 files changed, 8 insertions, 6 deletions
diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs
index d7b3a7c74f3..762d5595e14 100644
--- a/clippy_lints/src/doc/mod.rs
+++ b/clippy_lints/src/doc/mod.rs
@@ -309,7 +309,7 @@ declare_clippy_lint! {
     /// ### Known problems
     /// Inner doc comments can only appear before items, so there are certain cases where the suggestion
     /// made by this lint is not valid code. For example:
-    /// ```rs
+    /// ```rust
     /// fn foo() {}
     /// ///!
     /// fn bar() {}
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
index 1d7b10fe8f0..d7126990edb 100644
--- a/clippy_lints/src/methods/mod.rs
+++ b/clippy_lints/src/methods/mod.rs
@@ -2702,10 +2702,10 @@ declare_clippy_lint! {
     ///             }
     ///         })
     /// }
-    ///  ```
+    /// ```
     ///
-    ///  After:
-    ///  ```rust
+    /// After:
+    /// ```rust
     /// use std::{fmt, num::ParseIntError};
     ///
     /// #[derive(Debug)]
diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs
index 57f45aa3e48..c73ec262637 100644
--- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs
+++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs
@@ -687,10 +687,12 @@ fn cleanup_docs(docs_collection: &Vec<String>) -> String {
                     .trim()
                     .split(',')
                     // remove rustdoc directives
-                    .find(|&s| !matches!(s, "" | "ignore" | "no_run" | "should_panic"))
+                    .find(|&s| !matches!(s, "" | "ignore" | "no_run" | "should_panic" | "compile_fail"))
                     // if no language is present, fill in "rust"
                     .unwrap_or("rust");
-                let len_diff = line.len() - line.trim_start().len();
+                let len_diff = line
+                    .strip_prefix(' ')
+                    .map_or(0, |line| line.len() - line.trim_start().len());
                 if len_diff != 0 {
                     // We put back the indentation.
                     docs.push_str(&line[..len_diff]);