]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/missing_doc.rs
New upstream version 1.65.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / missing_doc.rs
1 // aux-build: proc_macro_with_span.rs
2
3 #![warn(clippy::missing_docs_in_private_items)]
4 // When denying at the crate level, be sure to not get random warnings from the
5 // injected intrinsics by the compiler.
6 #![allow(dead_code)]
7 //! Some garbage docs for the crate here
8 #![doc = "More garbage"]
9
10 extern crate proc_macro_with_span;
11
12 use proc_macro_with_span::with_span;
13 use std::arch::global_asm;
14
15 type Typedef = String;
16 pub type PubTypedef = String;
17
18 mod module_no_dox {}
19 pub mod pub_module_no_dox {}
20
21 /// dox
22 pub fn foo() {}
23 pub fn foo2() {}
24 fn foo3() {}
25 #[allow(clippy::missing_docs_in_private_items)]
26 pub fn foo4() {}
27
28 // It sure is nice if doc(hidden) implies allow(missing_docs), and that it
29 // applies recursively
30 #[doc(hidden)]
31 mod a {
32 pub fn baz() {}
33 pub mod b {
34 pub fn baz() {}
35 }
36 }
37
38 enum Baz {
39 BazA { a: isize, b: isize },
40 BarB,
41 }
42
43 pub enum PubBaz {
44 PubBazA { a: isize },
45 }
46
47 /// dox
48 pub enum PubBaz2 {
49 /// dox
50 PubBaz2A {
51 /// dox
52 a: isize,
53 },
54 }
55
56 #[allow(clippy::missing_docs_in_private_items)]
57 pub enum PubBaz3 {
58 PubBaz3A { b: isize },
59 }
60
61 #[doc(hidden)]
62 pub fn baz() {}
63
64 const FOO: u32 = 0;
65 /// dox
66 pub const FOO1: u32 = 0;
67 #[allow(clippy::missing_docs_in_private_items)]
68 pub const FOO2: u32 = 0;
69 #[doc(hidden)]
70 pub const FOO3: u32 = 0;
71 pub const FOO4: u32 = 0;
72
73 static BAR: u32 = 0;
74 /// dox
75 pub static BAR1: u32 = 0;
76 #[allow(clippy::missing_docs_in_private_items)]
77 pub static BAR2: u32 = 0;
78 #[doc(hidden)]
79 pub static BAR3: u32 = 0;
80 pub static BAR4: u32 = 0;
81
82 mod internal_impl {
83 /// dox
84 pub fn documented() {}
85 pub fn undocumented1() {}
86 pub fn undocumented2() {}
87 fn undocumented3() {}
88 /// dox
89 pub mod globbed {
90 /// dox
91 pub fn also_documented() {}
92 pub fn also_undocumented1() {}
93 fn also_undocumented2() {}
94 }
95 }
96 /// dox
97 pub mod public_interface {
98 pub use crate::internal_impl::documented as foo;
99 pub use crate::internal_impl::globbed::*;
100 pub use crate::internal_impl::undocumented1 as bar;
101 pub use crate::internal_impl::{documented, undocumented2};
102 }
103
104 fn main() {}
105
106 // Ensure global asm doesn't require documentation.
107 global_asm! { "" }
108
109 // Don't lint proc macro output with an unexpected span.
110 with_span!(span pub struct FooPm { pub field: u32});
111 with_span!(span pub struct FooPm2;);
112 with_span!(span pub enum FooPm3 { A, B(u32), C { field: u32 }});
113 with_span!(span pub fn foo_pm() {});
114 with_span!(span pub static FOO_PM: u32 = 0;);
115 with_span!(span pub const FOO2_PM: u32 = 0;);