Skip to content

Commit 0229d88

Browse files
Add test for new comment_within_doc lint
1 parent 546ddd9 commit 0229d88

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

tests/ui/comment_within_doc.fixed

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![warn(clippy::comment_within_doc)]
2+
3+
//! Hello
4+
//! oups
5+
//! tadam
6+
//~^^^ comment_within_doc
7+
8+
/// Hello
9+
/// oups
10+
/// hehe
11+
//~^^^ comment_within_doc
12+
struct Bar;
13+
14+
mod b {
15+
//! targe
16+
//! oups
17+
//! hello
18+
//
19+
/// nope
20+
/// oups
21+
/// yep
22+
//~^^^ comment_within_doc
23+
//~^^^^^^^^ comment_within_doc
24+
struct Bar;
25+
}
26+
27+
fn main() {}

tests/ui/comment_within_doc.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![warn(clippy::comment_within_doc)]
2+
3+
//! Hello
4+
// oups
5+
//! tadam
6+
//~^^^ comment_within_doc
7+
8+
/// Hello
9+
// oups
10+
/// hehe
11+
//~^^^ comment_within_doc
12+
struct Bar;
13+
14+
mod b {
15+
//! targe
16+
// oups
17+
//! hello
18+
//
19+
/// nope
20+
// oups
21+
/// yep
22+
//~^^^ comment_within_doc
23+
//~^^^^^^^^ comment_within_doc
24+
struct Bar;
25+
}
26+
27+
fn main() {}

tests/ui/comment_within_doc.stderr

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error: code comment surrounded by doc comments
2+
--> tests/ui/comment_within_doc.rs:3:1
3+
|
4+
LL | //! Hello
5+
| ^^^^^^^^^
6+
LL | // oups
7+
| --^^^^^
8+
| |
9+
| help: did you mean to make it a doc comment?: `//!`
10+
LL | //! tadam
11+
| ^^^^^^^^^
12+
|
13+
= note: `-D clippy::comment-within-doc` implied by `-D warnings`
14+
= help: to override `-D warnings` add `#[allow(clippy::comment_within_doc)]`
15+
16+
error: code comment surrounded by doc comments
17+
--> tests/ui/comment_within_doc.rs:8:1
18+
|
19+
LL | /// Hello
20+
| ^^^^^^^^^
21+
LL | // oups
22+
| --^^^^^
23+
| |
24+
| help: did you mean to make it a doc comment?: `///`
25+
LL | /// hehe
26+
| ^^^^^^^^
27+
28+
error: code comment surrounded by doc comments
29+
--> tests/ui/comment_within_doc.rs:15:5
30+
|
31+
LL | //! targe
32+
| ^^^^^^^^^
33+
LL | // oups
34+
| --^^^^^
35+
| |
36+
| help: did you mean to make it a doc comment?: `//!`
37+
LL | //! hello
38+
| ^^^^^^^^^
39+
40+
error: code comment surrounded by doc comments
41+
--> tests/ui/comment_within_doc.rs:19:5
42+
|
43+
LL | /// nope
44+
| ^^^^^^^^
45+
LL | // oups
46+
| --^^^^^
47+
| |
48+
| help: did you mean to make it a doc comment?: `///`
49+
LL | /// yep
50+
| ^^^^^^^
51+
52+
error: aborting due to 4 previous errors
53+

0 commit comments

Comments
 (0)