Skip to content

Commit c37f101

Browse files
committed
add filter empty lines in empty-docs lint
1 parent e6c20e5 commit c37f101

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

clippy_lints/src/empty_docs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use rustc_ast::ast::*;
33
use rustc_lint::{EarlyContext, EarlyLintPass};
4-
use rustc_session::{declare_lint_pass, declare_tool_lint};
4+
use rustc_session::declare_lint_pass;
55

66
declare_clippy_lint! {
77
/// ### What it does
@@ -35,6 +35,7 @@ fn trim_comment(comment: &str) -> String {
3535
.trim()
3636
.split("\n")
3737
.map(|comment| comment.trim().trim_matches('*').trim_matches('!'))
38+
.filter(|line| !line.is_empty())
3839
.collect::<Vec<&str>>()
3940
.join("")
4041
}

tests/ui/empty_docs.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: empty doc comment
2-
--> $DIR/empty_docs.rs:11:5
2+
--> tests/ui/empty_docs.rs:11:5
33
|
44
LL | ///
55
| ^^^
@@ -9,15 +9,15 @@ LL | ///
99
= help: to override `-D warnings` add `#[allow(clippy::empty_docs)]`
1010

1111
error: empty doc comment
12-
--> $DIR/empty_docs.rs:13:5
12+
--> tests/ui/empty_docs.rs:13:5
1313
|
1414
LL | ///
1515
| ^^^
1616
|
1717
= help: consider removing or fill it
1818

1919
error: empty doc comment
20-
--> $DIR/empty_docs.rs:16:5
20+
--> tests/ui/empty_docs.rs:16:5
2121
|
2222
LL | / /**
2323
LL | | *
@@ -27,15 +27,15 @@ LL | | */
2727
= help: consider removing or fill it
2828

2929
error: empty doc comment
30-
--> $DIR/empty_docs.rs:6:5
30+
--> tests/ui/empty_docs.rs:6:5
3131
|
3232
LL | //!
3333
| ^^^
3434
|
3535
= help: consider removing or fill it
3636

3737
error: empty doc comment
38-
--> $DIR/empty_docs.rs:8:5
38+
--> tests/ui/empty_docs.rs:8:5
3939
|
4040
LL | //!!
4141
| ^^^^

0 commit comments

Comments
 (0)