@@ -622,7 +622,7 @@ impl EarlyLintPass for EarlyAttributes {
622
622
fn check_empty_line_after_outer_attr ( cx : & EarlyContext < ' _ > , item : & rustc_ast:: Item ) {
623
623
let mut iter = item. attrs . iter ( ) . peekable ( ) ;
624
624
while let Some ( attr) = iter. next ( ) {
625
- if matches ! ( attr. kind, AttrKind :: Normal ( ..) )
625
+ if ( matches ! ( attr. kind, AttrKind :: Normal ( ..) ) || matches ! ( attr . kind , AttrKind :: DocComment ( .. ) ) )
626
626
&& attr. style == AttrStyle :: Outer
627
627
&& is_present_in_source ( cx, attr. span )
628
628
{
@@ -639,13 +639,17 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It
639
639
let lines = without_block_comments ( lines) ;
640
640
641
641
if lines. iter ( ) . filter ( |l| l. trim ( ) . is_empty ( ) ) . count ( ) > 2 {
642
- span_lint (
643
- cx,
644
- EMPTY_LINE_AFTER_OUTER_ATTR ,
645
- begin_of_attr_to_item,
646
- "found an empty line after an outer attribute. \
647
- Perhaps you forgot to add a `!` to make it an inner attribute?",
648
- ) ;
642
+ let lint_mst = match attr. kind {
643
+ AttrKind :: Normal ( ..) => {
644
+ "found an empty line after an outer attribute. \
645
+ Perhaps you forgot to add a `!` to make it an inner attribute?"
646
+ } ,
647
+ AttrKind :: DocComment ( ..) => {
648
+ "found an empty line after an outer doc comment. \
649
+ Perhaps you need to use `//!` to make a comment on the module or remove the empty line?"
650
+ } ,
651
+ } ;
652
+ span_lint ( cx, EMPTY_LINE_AFTER_OUTER_ATTR , begin_of_attr_to_item, lint_mst) ;
649
653
}
650
654
}
651
655
}
0 commit comments