From 0ea449597e0d0c06dbfa5eccb2c7a785b7cec77e Mon Sep 17 00:00:00 2001 From: lucarlig Date: Sun, 25 Feb 2024 17:23:15 +0400 Subject: [PATCH] pop before trimming --- clippy_lints/src/doc/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/clippy_lints/src/doc/mod.rs b/clippy_lints/src/doc/mod.rs index 78d46928f35..7b085a36ea5 100644 --- a/clippy_lints/src/doc/mod.rs +++ b/clippy_lints/src/doc/mod.rs @@ -550,15 +550,13 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &[ suspicious_doc_comments::check(cx, attrs); let (fragments, _) = attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), true); - let mut doc = fragments - .iter() - .fold(String::new(), |mut acc, fragment| { - add_doc_fragment(&mut acc, fragment); - acc - }) - .trim() - .to_string(); + let mut doc = fragments.iter().fold(String::new(), |mut acc, fragment| { + add_doc_fragment(&mut acc, fragment); + acc + }); doc.pop(); + let doc = doc.trim().to_string(); + if doc.is_empty() { return Some(DocInfo { empty: true,