]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc-ui/lint-missing-doc-code-example.rs
Rollup merge of #103236 - tspiteri:redoc-int-adc-sbb, r=m-ou-se
[rust.git] / tests / rustdoc-ui / lint-missing-doc-code-example.rs
1 #![feature(rustdoc_missing_doc_code_examples)]
2 #![deny(missing_docs)]
3 #![deny(rustdoc::missing_doc_code_examples)]
4
5 //! crate level doc
6 //! ```
7 //! println!("hello"):
8 //! ```
9
10
11 /// doc
12 ///
13 /// ```
14 /// println!("hello");
15 /// ```
16 pub fn test() {
17 }
18
19 #[allow(missing_docs)]
20 pub mod module1 { //~ ERROR
21 }
22
23 #[allow(rustdoc::missing_doc_code_examples)]
24 /// doc
25 pub mod module2 {
26
27   /// doc
28   pub fn test() {}
29 }
30
31 /// doc
32 ///
33 /// ```
34 /// println!("hello");
35 /// ```
36 pub mod module3 {
37
38   /// doc
39   //~^ ERROR
40   pub fn test() {}
41 }
42
43 /// Doc, but no code example and it's fine!
44 pub const Const: u32 = 0;
45 /// Doc, but no code example and it's fine!
46 pub static Static: u32 = 0;
47 /// Doc, but no code example and it's fine!
48 pub type Type = u32;
49
50 /// Doc
51 //~^ ERROR
52 pub struct Struct {
53     /// Doc, but no code example and it's fine!
54     pub field: u32,
55 }
56
57 /// Doc
58 //~^ ERROR
59 pub enum Enum {
60     /// Doc, but no code example and it's fine!
61     X,
62 }
63
64 /// Doc
65 //~^ ERROR
66 #[repr(C)]
67 pub union Union {
68     /// Doc, but no code example and it's fine!
69     a: i32,
70     /// Doc, but no code example and it's fine!
71     b: f32,
72 }
73
74 // no code example and it's fine!
75 impl Clone for Struct {
76     fn clone(&self) -> Self {
77         Self { field: self.field }
78     }
79 }
80
81
82
83 /// doc
84 ///
85 /// ```
86 /// println!("hello");
87 /// ```
88 #[derive(Clone)]
89 pub struct NiceStruct;
90
91 #[doc(hidden)]
92 pub mod foo {
93     pub fn bar() {}
94 }
95
96 fn babar() {}
97
98
99 mod fofoo {
100     pub fn tadam() {}
101 }