Skip to content

Commit 736e910

Browse files
Add test for new comment_within_doc lint
1 parent 878eccb commit 736e910

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

tests/ui/comment_within_doc.fixed

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![warn(clippy::comment_within_doc)]
2+
3+
//! Hello//!/ oups
4+
//! tadam
5+
//~^^^ comment_within_doc
6+
7+
/// Hello//// oups
8+
/// hehe
9+
//~^^^ comment_within_doc
10+
struct Bar;
11+
12+
mod b {
13+
//! targe//! // oups
14+
//! hello
15+
//
16+
/// nope/// // oups
17+
/// yep
18+
//~^^^ comment_within_doc
19+
//~^^^^^^^^ comment_within_doc
20+
struct Bar;
21+
}
22+
23+
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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
error: code comment surrounded by doc comments
2+
--> tests/ui/comment_within_doc.rs:3:10
3+
|
4+
LL | //! Hello
5+
| __________^
6+
| |__________|
7+
LL | || // oups
8+
| || ^
9+
| ||_|
10+
| |_help: did you mean to make it a doc comment?: `//!`
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:10
18+
|
19+
LL | /// Hello
20+
| __________^
21+
| |__________|
22+
LL | || // oups
23+
| || ^
24+
| ||_|
25+
| |_help: did you mean to make it a doc comment?: `///`
26+
|
27+
28+
error: code comment surrounded by doc comments
29+
--> tests/ui/comment_within_doc.rs:15:14
30+
|
31+
LL | //! targe
32+
| ______________^
33+
| |______________|
34+
LL | || // oups
35+
| ||_-__^
36+
| |__|
37+
| help: did you mean to make it a doc comment?: `//!`
38+
39+
error: code comment surrounded by doc comments
40+
--> tests/ui/comment_within_doc.rs:19:13
41+
|
42+
LL | /// nope
43+
| _____________^
44+
| |_____________|
45+
LL | || // oups
46+
| ||_-__^
47+
| |__|
48+
| help: did you mean to make it a doc comment?: `///`
49+
50+
error: aborting due to 4 previous errors
51+

0 commit comments

Comments
 (0)