fix code blocks in doc comments inconsistently using 3 or 4 spaces of indentation

This commit is contained in:
Antoni Spaanderman 2024-08-12 18:42:13 +02:00
parent 52192aa321
commit d7f1252ddf
No known key found for this signature in database
GPG Key ID: AE0B68E552E5DF8C
3 changed files with 8 additions and 6 deletions

View File

@ -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() {}

View File

@ -2702,10 +2702,10 @@ declare_clippy_lint! {
/// }
/// })
/// }
/// ```
/// ```
///
/// After:
/// ```rust
/// After:
/// ```rust
/// use std::{fmt, num::ParseIntError};
///
/// #[derive(Debug)]

View File

@ -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]);