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