Skip to content

Commit 7a05f13

Browse files
Strenghten tests for missing_doc_code_examples lint
1 parent dadde88 commit 7a05f13

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

Diff for: src/test/rustdoc-ui/lint-missing-doc-code-example.rs

+31
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,34 @@ pub mod module3 {
3838
//~^ ERROR
3939
pub fn test() {}
4040
}
41+
42+
/// Doc, but no code example and it's fine!
43+
pub const Const: u32 = 0;
44+
/// Doc, but no code example and it's fine!
45+
pub static Static: u32 = 0;
46+
/// Doc, but no code example and it's fine!
47+
pub type Type = u32;
48+
49+
/// Doc
50+
//~^ ERROR
51+
pub struct Struct {
52+
/// Doc, but no code example and it's fine!
53+
pub field: u32,
54+
}
55+
56+
/// Doc
57+
//~^ ERROR
58+
pub enum Enum {
59+
/// Doc, but no code example and it's fine!
60+
X,
61+
}
62+
63+
/// Doc
64+
//~^ ERROR
65+
#[repr(C)]
66+
union Union {
67+
/// Doc, but no code example and it's fine!
68+
a: i32,
69+
/// Doc, but no code example and it's fine!
70+
b: f32,
71+
}
+23-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
11
error: missing code example in this documentation
2-
--> $DIR/lint-missing-doc-code-example.rs:19:1
2+
--> $DIR/lint-missing-doc-code-example.rs:49:1
33
|
4-
LL | / mod module1 {
5-
LL | | }
6-
| |_^
4+
LL | /// Doc
5+
| ^^^^^^^
76
|
87
note: the lint level is defined here
98
--> $DIR/lint-missing-doc-code-example.rs:2:9
109
|
1110
LL | #![deny(missing_doc_code_examples)]
1211
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1312

13+
error: missing code example in this documentation
14+
--> $DIR/lint-missing-doc-code-example.rs:63:1
15+
|
16+
LL | /// Doc
17+
| ^^^^^^^
18+
19+
error: missing code example in this documentation
20+
--> $DIR/lint-missing-doc-code-example.rs:56:1
21+
|
22+
LL | /// Doc
23+
| ^^^^^^^
24+
25+
error: missing code example in this documentation
26+
--> $DIR/lint-missing-doc-code-example.rs:19:1
27+
|
28+
LL | / mod module1 {
29+
LL | | }
30+
| |_^
31+
1432
error: missing code example in this documentation
1533
--> $DIR/lint-missing-doc-code-example.rs:37:3
1634
|
1735
LL | /// doc
1836
| ^^^^^^^
1937

20-
error: aborting due to 2 previous errors
38+
error: aborting due to 5 previous errors
2139

0 commit comments

Comments
 (0)