]> git.lizzy.rs Git - rust.git/blob - tests/ui/doc.rs
Merge remote-tracking branch 'upstream/beta' into backport_remerge
[rust.git] / tests / ui / doc.rs
1 //! This file tests for the `DOC_MARKDOWN` lint.
2
3 #![allow(dead_code, incomplete_features)]
4 #![warn(clippy::doc_markdown)]
5 #![feature(custom_inner_attributes, const_generics, const_evaluatable_checked, const_option)]
6 #![rustfmt::skip]
7
8 /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
9 /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun
10 /// which should be reported only once despite being __doubly bad__.
11 /// Here be ::a::global:path.
12 /// That's not code ~NotInCodeBlock~.
13 /// be_sure_we_got_to_the_end_of_it
14 fn foo_bar() {
15 }
16
17 /// That one tests multiline ticks.
18 /// ```rust
19 /// foo_bar FOO_BAR
20 /// _foo bar_
21 /// ```
22 ///
23 /// ~~~rust
24 /// foo_bar FOO_BAR
25 /// _foo bar_
26 /// ~~~
27 /// be_sure_we_got_to_the_end_of_it
28 fn multiline_codeblock() {
29 }
30
31 /// This _is a test for
32 /// multiline
33 /// emphasis_.
34 /// be_sure_we_got_to_the_end_of_it
35 fn test_emphasis() {
36 }
37
38 /// This tests units. See also #835.
39 /// kiB MiB GiB TiB PiB EiB
40 /// kib Mib Gib Tib Pib Eib
41 /// kB MB GB TB PB EB
42 /// kb Mb Gb Tb Pb Eb
43 /// 32kiB 32MiB 32GiB 32TiB 32PiB 32EiB
44 /// 32kib 32Mib 32Gib 32Tib 32Pib 32Eib
45 /// 32kB 32MB 32GB 32TB 32PB 32EB
46 /// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb
47 /// NaN
48 /// be_sure_we_got_to_the_end_of_it
49 fn test_units() {
50 }
51
52 /// This tests allowed identifiers.
53 /// KiB MiB GiB TiB PiB EiB
54 /// DirectX
55 /// ECMAScript
56 /// GPLv2 GPLv3
57 /// GitHub GitLab
58 /// IPv4 IPv6
59 /// ClojureScript CoffeeScript JavaScript PureScript TypeScript
60 /// NaN NaNs
61 /// OAuth GraphQL
62 /// OCaml
63 /// OpenGL OpenMP OpenSSH OpenSSL OpenStreetMap OpenDNS
64 /// WebGL
65 /// TensorFlow
66 /// TrueType
67 /// iOS macOS FreeBSD
68 /// TeX LaTeX BibTeX BibLaTeX
69 /// MinGW
70 /// CamelCase (see also #2395)
71 /// be_sure_we_got_to_the_end_of_it
72 fn test_allowed() {
73 }
74
75 /// This test has [a link_with_underscores][chunked-example] inside it. See #823.
76 /// See also [the issue tracker](https://github.com/rust-lang/rust-clippy/search?q=clippy::doc_markdown&type=Issues)
77 /// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link].
78 /// It can also be [inline_link2].
79 ///
80 /// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example
81 /// [inline_link]: https://foobar
82 /// [inline_link2]: https://foobar
83 /// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and
84 /// `multiline_ticks` functions.
85 ///
86 /// expression of the type  `_ <bit_op> m <cmp_op> c` (where `<bit_op>`
87 /// is one of {`&`, '|'} and `<cmp_op>` is one of {`!=`, `>=`, `>` ,
88 /// be_sure_we_got_to_the_end_of_it
89 fn main() {
90     foo_bar();
91     multiline_codeblock();
92     test_emphasis();
93     test_units();
94 }
95
96 /// ## CamelCaseThing
97 /// Talks about `CamelCaseThing`. Titles should be ignored; see issue #897.
98 ///
99 /// # CamelCaseThing
100 ///
101 /// Not a title #897 CamelCaseThing
102 /// be_sure_we_got_to_the_end_of_it
103 fn issue897() {
104 }
105
106 /// I am confused by brackets? (`x_y`)
107 /// I am confused by brackets? (foo `x_y`)
108 /// I am confused by brackets? (`x_y` foo)
109 /// be_sure_we_got_to_the_end_of_it
110 fn issue900() {
111 }
112
113 /// Diesel queries also have a similar problem to [Iterator][iterator], where
114 /// /// More talking
115 /// returning them from a function requires exposing the implementation of that
116 /// function. The [`helper_types`][helper_types] module exists to help with this,
117 /// but you might want to hide the return type or have it conditionally change.
118 /// Boxing can achieve both.
119 ///
120 /// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html
121 /// [helper_types]: ../helper_types/index.html
122 /// be_sure_we_got_to_the_end_of_it
123 fn issue883() {
124 }
125
126 /// `foo_bar
127 /// baz_quz`
128 /// [foo
129 /// bar](https://doc.rust-lang.org/stable/std/iter/trait.IteratorFooBar.html)
130 fn multiline() {
131 }
132
133 /** E.g., serialization of an empty list: FooBar
134 ```
135 That's in a code block: `PackedNode`
136 ```
137
138 And BarQuz too.
139 be_sure_we_got_to_the_end_of_it
140 */
141 fn issue1073() {
142 }
143
144 /** E.g., serialization of an empty list: FooBar
145 ```
146 That's in a code block: PackedNode
147 ```
148
149 And BarQuz too.
150 be_sure_we_got_to_the_end_of_it
151 */
152 fn issue1073_alt() {
153 }
154
155 /// Tests more than three quotes:
156 /// ````
157 /// DoNotWarn
158 /// ```
159 /// StillDont
160 /// ````
161 /// be_sure_we_got_to_the_end_of_it
162 fn four_quotes() {
163 }
164
165 /// See [NIST SP 800-56A, revision 2].
166 ///
167 /// [NIST SP 800-56A, revision 2]:
168 ///     https://github.com/rust-lang/rust-clippy/issues/902#issuecomment-261919419
169 fn issue_902_comment() {}
170
171 #[cfg_attr(feature = "a", doc = " ```")]
172 #[cfg_attr(not(feature = "a"), doc = " ```ignore")]
173 /// fn main() {
174 ///     let s = "localhost:10000".to_string();
175 ///     println!("{}", s);
176 /// }
177 /// ```
178 fn issue_1469() {}
179
180 /**
181  * This is a doc comment that should not be a list
182  *This would also be an error under a strict common mark interpretation
183  */
184 fn issue_1920() {}
185
186 /// Ok: <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels>
187 ///
188 /// Not ok: http://www.unicode.org
189 /// Not ok: https://www.unicode.org
190 /// Not ok: http://www.unicode.org/
191 /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
192 fn issue_1832() {}
193
194 /// An iterator over mycrate::Collection's values.
195 /// It should not lint a `'static` lifetime in ticks.
196 fn issue_2210() {}
197
198 /// This should not cause the lint to trigger:
199 /// #REQ-data-family.lint_partof_exists
200 fn issue_2343() {}
201
202 /// This should not cause an ICE:
203 /// __|_ _|__||_|
204 fn pulldown_cmark_crash() {}
205
206 // issue #7033 - const_evaluatable_checked ICE
207 struct S<T, const N: usize>
208 where [(); N.checked_next_power_of_two().unwrap()]: {
209     arr: [T; N.checked_next_power_of_two().unwrap()],
210     n: usize,
211 }
212
213 impl<T: Copy + Default, const N: usize> S<T, N>
214 where [(); N.checked_next_power_of_two().unwrap()]: {
215     fn new() -> Self {
216         Self {
217             arr: [T::default(); N.checked_next_power_of_two().unwrap()],
218             n: 0,
219         }
220     }
221 }