Skip to content

Commit bef2200

Browse files
authored
Merge pull request #2419 from phansch/fix_doc_comment_false_positive
Fix false positive in empty_line_after_outer_attr
2 parents 0283018 + a64724f commit bef2200

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clippy_lints/src/attrs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
262262
}
263263

264264
for attr in attrs {
265+
if attr.is_sugared_doc {
266+
return;
267+
}
265268
if attr.style == AttrStyle::Outer {
266269
if !is_present_in_source(cx, attr.span) {
267270
return;
@@ -276,7 +279,7 @@ fn check_attrs(cx: &LateContext, span: Span, name: &Name, attrs: &[Attribute]) {
276279
cx,
277280
EMPTY_LINE_AFTER_OUTER_ATTR,
278281
attr_to_item_span,
279-
&format!("Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?")
282+
"Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?"
280283
);
281284

282285
}

tests/ui/empty_line_after_outer_attribute.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ struct Foo {
4747
mod foo {
4848
}
4949

50+
/// This doc comment should not produce a warning
51+
52+
/** This is also a doc comment and should not produce a warning
53+
*/
54+
5055
// This should not produce a warning
5156
#[allow(non_camel_case_types)]
5257
#[allow(missing_docs)]

0 commit comments

Comments
 (0)