]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/lint-missing-doc.rs
Auto merge of #22541 - Manishearth:rollup, r=Gankro
[rust.git] / src / test / compile-fail / lint-missing-doc.rs
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // When denying at the crate level, be sure to not get random warnings from the
12 // injected intrinsics by the compiler.
13 #![deny(missing_docs)]
14 #![allow(dead_code)]
15
16 //! Some garbage docs for the crate here
17 #![doc="More garbage"]
18
19 type Typedef = String;
20 pub type PubTypedef = String; //~ ERROR: missing documentation
21
22 struct Foo {
23     a: isize,
24     b: isize,
25 }
26
27 pub struct PubFoo { //~ ERROR: missing documentation
28     pub a: isize,      //~ ERROR: missing documentation
29     b: isize,
30 }
31
32 #[allow(missing_docs)]
33 pub struct PubFoo2 {
34     pub a: isize,
35     pub c: isize,
36 }
37
38 mod module_no_dox {}
39 pub mod pub_module_no_dox {} //~ ERROR: missing documentation
40
41 /// dox
42 pub fn foo() {}
43 pub fn foo2() {} //~ ERROR: missing documentation
44 fn foo3() {}
45 #[allow(missing_docs)] pub fn foo4() {}
46
47 /// dox
48 pub trait A {
49     /// dox
50     fn foo(&self);
51     /// dox
52     fn foo_with_impl(&self) {}
53 }
54
55 #[allow(missing_docs)]
56 trait B {
57     fn foo(&self);
58     fn foo_with_impl(&self) {}
59 }
60
61 pub trait C { //~ ERROR: missing documentation
62     fn foo(&self); //~ ERROR: missing documentation
63     fn foo_with_impl(&self) {} //~ ERROR: missing documentation
64 }
65
66 #[allow(missing_docs)]
67 pub trait D {
68     fn dummy(&self) { }
69 }
70
71 impl Foo {
72     pub fn foo() {}
73     fn bar() {}
74 }
75
76 impl PubFoo {
77     pub fn foo() {} //~ ERROR: missing documentation
78     /// dox
79     pub fn foo1() {}
80     fn foo2() {}
81     #[allow(missing_docs)] pub fn foo3() {}
82 }
83
84 #[allow(missing_docs)]
85 trait F {
86     fn a();
87     fn b(&self);
88 }
89
90 // should need to redefine documentation for implementations of traits
91 impl F for Foo {
92     fn a() {}
93     fn b(&self) {}
94 }
95
96 // It sure is nice if doc(hidden) implies allow(missing_docs), and that it
97 // applies recursively
98 #[doc(hidden)]
99 mod a {
100     pub fn baz() {}
101     pub mod b {
102         pub fn baz() {}
103     }
104 }
105
106 enum Baz {
107     BazA {
108         a: isize,
109         b: isize
110     },
111     BarB
112 }
113
114 pub enum PubBaz { //~ ERROR: missing documentation
115     PubBazA { //~ ERROR: missing documentation
116         a: isize, //~ ERROR: missing documentation
117     },
118 }
119
120 /// dox
121 pub enum PubBaz2 {
122     /// dox
123     PubBaz2A {
124         /// dox
125         a: isize,
126     },
127 }
128
129 #[allow(missing_docs)]
130 pub enum PubBaz3 {
131     PubBaz3A {
132         b: isize
133     },
134 }
135
136 #[doc(hidden)]
137 pub fn baz() {}
138
139 mod internal_impl {
140     /// dox
141     pub fn documented() {}
142     pub fn undocumented1() {} //~ ERROR: missing documentation
143     pub fn undocumented2() {} //~ ERROR: missing documentation
144     fn undocumented3() {}
145     /// dox
146     pub mod globbed {
147         /// dox
148         pub fn also_documented() {}
149         pub fn also_undocumented1() {} //~ ERROR: missing documentation
150         fn also_undocumented2() {}
151     }
152 }
153 /// dox
154 pub mod public_interface {
155     pub use internal_impl::documented as foo;
156     pub use internal_impl::undocumented1 as bar;
157     pub use internal_impl::{documented, undocumented2};
158     pub use internal_impl::globbed::*;
159 }
160
161 fn main() {}