Skip to content

Commit 469eb49

Browse files
committed
Add test case for comments between item and attr
1 parent 4b9d230 commit 469eb49

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

tests/ui/empty_line_after_outer_attribute.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11

22
#![warn(empty_line_after_outer_attr)]
33

4+
// This should produce a warning
5+
#[crate_type = "lib"]
6+
7+
/// some comment
8+
fn with_one_newline_and_comment() { assert!(true) }
9+
10+
// This should not produce a warning
11+
#[crate_type = "lib"]
12+
/// some comment
13+
fn with_no_newline_and_comment() { assert!(true) }
14+
15+
416
// This should produce a warning
517
#[crate_type = "lib"]
618

tests/ui/empty_line_after_outer_attribute.stderr

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,28 @@ error: Found an empty line after an outer attribute. Perhaps you forgot to add a
33
|
44
5 | / #[crate_type = "lib"]
55
6 | |
6-
7 | | fn with_one_newline() { assert!(true) }
6+
7 | | /// some comment
7+
8 | | fn with_one_newline_and_comment() { assert!(true) }
78
| |_
89
|
910
= note: `-D empty-line-after-outer-attr` implied by `-D warnings`
1011

1112
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
12-
--> $DIR/empty_line_after_outer_attribute.rs:10:1
13+
--> $DIR/empty_line_after_outer_attribute.rs:17:1
1314
|
14-
10 | / #[crate_type = "lib"]
15-
11 | |
16-
12 | |
17-
13 | | fn with_two_newlines() { assert!(true) }
15+
17 | / #[crate_type = "lib"]
16+
18 | |
17+
19 | | fn with_one_newline() { assert!(true) }
1818
| |_
1919

20+
error: Found an empty line after an outer attribute. Perhaps you forgot to add a '!' to make it an inner attribute?
21+
--> $DIR/empty_line_after_outer_attribute.rs:22:1
22+
|
23+
22 | / #[crate_type = "lib"]
24+
23 | |
25+
24 | |
26+
25 | | fn with_two_newlines() { assert!(true) }
27+
| |_
28+
29+
error: aborting due to 3 previous errors
30+

0 commit comments

Comments
 (0)