]> git.lizzy.rs Git - rust.git/blob - tests/ui/missing-doc.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / missing-doc.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 /* This file incorporates work covered by the following copyright and
11  * permission notice:
12  *   Copyright 2013 The Rust Project Developers. See the COPYRIGHT
13  *   file at the top-level directory of this distribution and at
14  *   http://rust-lang.org/COPYRIGHT.
15  *
16  *   Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
17  *   http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
18  *   <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
19  *   option. This file may not be copied, modified, or distributed
20  *   except according to those terms.
21  */
22
23 #![warn(clippy::missing_docs_in_private_items)]
24 // When denying at the crate level, be sure to not get random warnings from the
25 // injected intrinsics by the compiler.
26 #![allow(dead_code)]
27 #![feature(associated_type_defaults)]
28
29 //! Some garbage docs for the crate here
30 #![doc = "More garbage"]
31
32 type Typedef = String;
33 pub type PubTypedef = String;
34
35 struct Foo {
36     a: isize,
37     b: isize,
38 }
39
40 pub struct PubFoo {
41     pub a: isize,
42     b: isize,
43 }
44
45 #[allow(clippy::missing_docs_in_private_items)]
46 pub struct PubFoo2 {
47     pub a: isize,
48     pub c: isize,
49 }
50
51 mod module_no_dox {}
52 pub mod pub_module_no_dox {}
53
54 /// dox
55 pub fn foo() {}
56 pub fn foo2() {}
57 fn foo3() {}
58 #[allow(clippy::missing_docs_in_private_items)]
59 pub fn foo4() {}
60
61 /// dox
62 pub trait A {
63     /// dox
64     fn foo(&self);
65     /// dox
66     fn foo_with_impl(&self) {}
67 }
68
69 #[allow(clippy::missing_docs_in_private_items)]
70 trait B {
71     fn foo(&self);
72     fn foo_with_impl(&self) {}
73 }
74
75 pub trait C {
76     fn foo(&self);
77     fn foo_with_impl(&self) {}
78 }
79
80 #[allow(clippy::missing_docs_in_private_items)]
81 pub trait D {
82     fn dummy(&self) {}
83 }
84
85 /// dox
86 pub trait E {
87     type AssociatedType;
88     type AssociatedTypeDef = Self;
89
90     /// dox
91     type DocumentedType;
92     /// dox
93     type DocumentedTypeDef = Self;
94     /// dox
95     fn dummy(&self) {}
96 }
97
98 impl Foo {
99     pub fn foo() {}
100     fn bar() {}
101 }
102
103 impl PubFoo {
104     pub fn foo() {}
105     /// dox
106     pub fn foo1() {}
107     fn foo2() {}
108     #[allow(clippy::missing_docs_in_private_items)]
109     pub fn foo3() {}
110 }
111
112 #[allow(clippy::missing_docs_in_private_items)]
113 trait F {
114     fn a();
115     fn b(&self);
116 }
117
118 // should need to redefine documentation for implementations of traits
119 impl F for Foo {
120     fn a() {}
121     fn b(&self) {}
122 }
123
124 // It sure is nice if doc(hidden) implies allow(missing_docs), and that it
125 // applies recursively
126 #[doc(hidden)]
127 mod a {
128     pub fn baz() {}
129     pub mod b {
130         pub fn baz() {}
131     }
132 }
133
134 enum Baz {
135     BazA { a: isize, b: isize },
136     BarB,
137 }
138
139 pub enum PubBaz {
140     PubBazA { a: isize },
141 }
142
143 /// dox
144 pub enum PubBaz2 {
145     /// dox
146     PubBaz2A {
147         /// dox
148         a: isize,
149     },
150 }
151
152 #[allow(clippy::missing_docs_in_private_items)]
153 pub enum PubBaz3 {
154     PubBaz3A { b: isize },
155 }
156
157 #[doc(hidden)]
158 pub fn baz() {}
159
160 const FOO: u32 = 0;
161 /// dox
162 pub const FOO1: u32 = 0;
163 #[allow(clippy::missing_docs_in_private_items)]
164 pub const FOO2: u32 = 0;
165 #[doc(hidden)]
166 pub const FOO3: u32 = 0;
167 pub const FOO4: u32 = 0;
168
169 static BAR: u32 = 0;
170 /// dox
171 pub static BAR1: u32 = 0;
172 #[allow(clippy::missing_docs_in_private_items)]
173 pub static BAR2: u32 = 0;
174 #[doc(hidden)]
175 pub static BAR3: u32 = 0;
176 pub static BAR4: u32 = 0;
177
178 mod internal_impl {
179     /// dox
180     pub fn documented() {}
181     pub fn undocumented1() {}
182     pub fn undocumented2() {}
183     fn undocumented3() {}
184     /// dox
185     pub mod globbed {
186         /// dox
187         pub fn also_documented() {}
188         pub fn also_undocumented1() {}
189         fn also_undocumented2() {}
190     }
191 }
192 /// dox
193 pub mod public_interface {
194     pub use internal_impl::documented as foo;
195     pub use internal_impl::globbed::*;
196     pub use internal_impl::undocumented1 as bar;
197     pub use internal_impl::{documented, undocumented2};
198 }
199
200 fn main() {}