]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/lint-missing-doc.rs
Update compile fail tests to use isize.
[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 #![allow(missing_copy_implementations)]
16
17 //! Some garbage docs for the crate here
18 #![doc="More garbage"]
19
20 type Typedef = String;
21 pub type PubTypedef = String; //~ ERROR: missing documentation
22
23 struct Foo {
24     a: isize,
25     b: isize,
26 }
27
28 pub struct PubFoo { //~ ERROR: missing documentation
29     pub a: isize,      //~ ERROR: missing documentation
30     b: isize,
31 }
32
33 #[allow(missing_docs)]
34 pub struct PubFoo2 {
35     pub a: isize,
36     pub c: isize,
37 }
38
39 mod module_no_dox {}
40 pub mod pub_module_no_dox {} //~ ERROR: missing documentation
41
42 /// dox
43 pub fn foo() {}
44 pub fn foo2() {} //~ ERROR: missing documentation
45 fn foo3() {}
46 #[allow(missing_docs)] pub fn foo4() {}
47
48 /// dox
49 pub trait A {
50     /// dox
51     fn foo();
52     /// dox
53     fn foo_with_impl() {}
54 }
55 #[allow(missing_docs)]
56 trait B {
57     fn foo();
58     fn foo_with_impl() {}
59 }
60 pub trait C { //~ ERROR: missing documentation
61     fn foo(); //~ ERROR: missing documentation
62     fn foo_with_impl() {} //~ ERROR: missing documentation
63 }
64 #[allow(missing_docs)] pub trait D {}
65
66 impl Foo {
67     pub fn foo() {}
68     fn bar() {}
69 }
70
71 impl PubFoo {
72     pub fn foo() {} //~ ERROR: missing documentation
73     /// dox
74     pub fn foo1() {}
75     fn foo2() {}
76     #[allow(missing_docs)] pub fn foo3() {}
77 }
78
79 #[allow(missing_docs)]
80 trait F {
81     fn a();
82     fn b(&self);
83 }
84
85 // should need to redefine documentation for implementations of traits
86 impl F for Foo {
87     fn a() {}
88     fn b(&self) {}
89 }
90
91 // It sure is nice if doc(hidden) implies allow(missing_docs), and that it
92 // applies recursively
93 #[doc(hidden)]
94 mod a {
95     pub fn baz() {}
96     pub mod b {
97         pub fn baz() {}
98     }
99 }
100
101 enum Baz {
102     BazA {
103         a: isize,
104         b: isize
105     },
106     BarB
107 }
108
109 pub enum PubBaz { //~ ERROR: missing documentation
110     PubBazA { //~ ERROR: missing documentation
111         a: isize, //~ ERROR: missing documentation
112     },
113 }
114
115 /// dox
116 pub enum PubBaz2 {
117     /// dox
118     PubBaz2A {
119         /// dox
120         a: isize,
121     },
122 }
123
124 #[allow(missing_docs)]
125 pub enum PubBaz3 {
126     PubBaz3A {
127         b: isize
128     },
129 }
130
131 #[doc(hidden)]
132 pub fn baz() {}
133
134 mod internal_impl {
135     /// dox
136     pub fn documented() {}
137     pub fn undocumented1() {} //~ ERROR: missing documentation
138     pub fn undocumented2() {} //~ ERROR: missing documentation
139     fn undocumented3() {}
140     /// dox
141     pub mod globbed {
142         /// dox
143         pub fn also_documented() {}
144         pub fn also_undocumented1() {} //~ ERROR: missing documentation
145         fn also_undocumented2() {}
146     }
147 }
148 /// dox
149 pub mod public_interface {
150     pub use internal_impl::documented as foo;
151     pub use internal_impl::undocumented1 as bar;
152     pub use internal_impl::{documented, undocumented2};
153     pub use internal_impl::globbed::*;
154 }
155
156 fn main() {}