]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc-ui/lint-missing-doc-code-example.rs
Rollup merge of #87440 - twetzel59:fix-barrier-no-op, r=yaahc
[rust.git] / src / test / rustdoc-ui / lint-missing-doc-code-example.rs
1 #![deny(missing_docs)]
2 #![deny(rustdoc::missing_doc_code_examples)]
3
4 //! crate level doc
5 //! ```
6 //! println!("hello"):
7 //! ```
8
9
10 /// doc
11 ///
12 /// ```
13 /// println!("hello");
14 /// ```
15 pub fn test() {
16 }
17
18 #[allow(missing_docs)]
19 pub mod module1 { //~ ERROR
20 }
21
22 #[allow(rustdoc::missing_doc_code_examples)]
23 /// doc
24 pub mod module2 {
25
26   /// doc
27   pub fn test() {}
28 }
29
30 /// doc
31 ///
32 /// ```
33 /// println!("hello");
34 /// ```
35 pub mod module3 {
36
37   /// doc
38   //~^ ERROR
39   pub fn test() {}
40 }
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 pub 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 }
72
73 // no code example and it's fine!
74 impl Clone for Struct {
75     fn clone(&self) -> Self {
76         Self { field: self.field }
77     }
78 }
79
80
81
82 /// doc
83 ///
84 /// ```
85 /// println!("hello");
86 /// ```
87 #[derive(Clone)]
88 pub struct NiceStruct;
89
90 #[doc(hidden)]
91 pub mod foo {
92     pub fn bar() {}
93 }
94
95 fn babar() {}
96
97
98 mod fofoo {
99     pub fn tadam() {}
100 }