]> git.lizzy.rs Git - rust.git/blob - tests/ui/missing-doc.rs
Auto merge of #4314 - chansuke:add-negation-to-is_empty, r=flip1995
[rust.git] / tests / ui / missing-doc.rs
1 #![warn(clippy::missing_docs_in_private_items)]
2 // When denying at the crate level, be sure to not get random warnings from the
3 // injected intrinsics by the compiler.
4 #![allow(dead_code)]
5 #![feature(associated_type_defaults, global_asm)]
6
7 //! Some garbage docs for the crate here
8 #![doc = "More garbage"]
9
10 type Typedef = String;
11 pub type PubTypedef = String;
12
13 struct Foo {
14     a: isize,
15     b: isize,
16 }
17
18 pub struct PubFoo {
19     pub a: isize,
20     b: isize,
21 }
22
23 #[allow(clippy::missing_docs_in_private_items)]
24 pub struct PubFoo2 {
25     pub a: isize,
26     pub c: isize,
27 }
28
29 mod module_no_dox {}
30 pub mod pub_module_no_dox {}
31
32 /// dox
33 pub fn foo() {}
34 pub fn foo2() {}
35 fn foo3() {}
36 #[allow(clippy::missing_docs_in_private_items)]
37 pub fn foo4() {}
38
39 /// dox
40 pub trait A {
41     /// dox
42     fn foo(&self);
43     /// dox
44     fn foo_with_impl(&self) {}
45 }
46
47 #[allow(clippy::missing_docs_in_private_items)]
48 trait B {
49     fn foo(&self);
50     fn foo_with_impl(&self) {}
51 }
52
53 pub trait C {
54     fn foo(&self);
55     fn foo_with_impl(&self) {}
56 }
57
58 #[allow(clippy::missing_docs_in_private_items)]
59 pub trait D {
60     fn dummy(&self) {}
61 }
62
63 /// dox
64 pub trait E {
65     type AssociatedType;
66     type AssociatedTypeDef = Self;
67
68     /// dox
69     type DocumentedType;
70     /// dox
71     type DocumentedTypeDef = Self;
72     /// dox
73     fn dummy(&self) {}
74 }
75
76 impl Foo {
77     pub fn foo() {}
78     fn bar() {}
79 }
80
81 impl PubFoo {
82     pub fn foo() {}
83     /// dox
84     pub fn foo1() {}
85     fn foo2() {}
86     #[allow(clippy::missing_docs_in_private_items)]
87     pub fn foo3() {}
88 }
89
90 #[allow(clippy::missing_docs_in_private_items)]
91 trait F {
92     fn a();
93     fn b(&self);
94 }
95
96 // should need to redefine documentation for implementations of traits
97 impl F for Foo {
98     fn a() {}
99     fn b(&self) {}
100 }
101
102 // It sure is nice if doc(hidden) implies allow(missing_docs), and that it
103 // applies recursively
104 #[doc(hidden)]
105 mod a {
106     pub fn baz() {}
107     pub mod b {
108         pub fn baz() {}
109     }
110 }
111
112 enum Baz {
113     BazA { a: isize, b: isize },
114     BarB,
115 }
116
117 pub enum PubBaz {
118     PubBazA { a: isize },
119 }
120
121 /// dox
122 pub enum PubBaz2 {
123     /// dox
124     PubBaz2A {
125         /// dox
126         a: isize,
127     },
128 }
129
130 #[allow(clippy::missing_docs_in_private_items)]
131 pub enum PubBaz3 {
132     PubBaz3A { b: isize },
133 }
134
135 #[doc(hidden)]
136 pub fn baz() {}
137
138 const FOO: u32 = 0;
139 /// dox
140 pub const FOO1: u32 = 0;
141 #[allow(clippy::missing_docs_in_private_items)]
142 pub const FOO2: u32 = 0;
143 #[doc(hidden)]
144 pub const FOO3: u32 = 0;
145 pub const FOO4: u32 = 0;
146
147 static BAR: u32 = 0;
148 /// dox
149 pub static BAR1: u32 = 0;
150 #[allow(clippy::missing_docs_in_private_items)]
151 pub static BAR2: u32 = 0;
152 #[doc(hidden)]
153 pub static BAR3: u32 = 0;
154 pub static BAR4: u32 = 0;
155
156 mod internal_impl {
157     /// dox
158     pub fn documented() {}
159     pub fn undocumented1() {}
160     pub fn undocumented2() {}
161     fn undocumented3() {}
162     /// dox
163     pub mod globbed {
164         /// dox
165         pub fn also_documented() {}
166         pub fn also_undocumented1() {}
167         fn also_undocumented2() {}
168     }
169 }
170 /// dox
171 pub mod public_interface {
172     pub use internal_impl::documented as foo;
173     pub use internal_impl::globbed::*;
174     pub use internal_impl::undocumented1 as bar;
175     pub use internal_impl::{documented, undocumented2};
176 }
177
178 fn main() {}
179
180 // Ensure global asm doesn't require documentation.
181 global_asm! { "" }