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