2 //! This file tests for the `DOC_MARKDOWN` lint.
4 #![allow(dead_code, incomplete_features)]
5 #![warn(clippy::doc_markdown)]
6 #![feature(custom_inner_attributes, generic_const_exprs, const_option)]
9 /// The `foo_bar` function does _nothing_. See also `foo::bar`. (note the dot there)
10 /// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not `Foo::some_fun`
11 /// which should be reported only once despite being __doubly bad__.
12 /// Here be `::a::global:path`, and _`::another::global::path`_. :: is not a path though.
13 /// Import an item from `::awesome::global::blob::` (Intended postfix)
14 /// These are the options for `::Cat`: (Intended trailing single colon, shouldn't be linted)
15 /// That's not code ~`NotInCodeBlock`~.
16 /// `be_sure_we_got_to_the_end_of_it`
20 /// That one tests multiline ticks.
30 /// `be_sure_we_got_to_the_end_of_it`
31 fn multiline_codeblock() {
34 /// This _is a test for
37 /// `be_sure_we_got_to_the_end_of_it`
41 /// This tests units. See also #835.
42 /// kiB MiB GiB TiB PiB EiB
43 /// kib Mib Gib Tib Pib Eib
46 /// 32kiB 32MiB 32GiB 32TiB 32PiB 32EiB
47 /// 32kib 32Mib 32Gib 32Tib 32Pib 32Eib
48 /// 32kB 32MB 32GB 32TB 32PB 32EB
49 /// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb
51 /// `be_sure_we_got_to_the_end_of_it`
55 /// This tests allowed identifiers.
56 /// KiB MiB GiB TiB PiB EiB
62 /// ClojureScript CoffeeScript JavaScript PureScript TypeScript
66 /// OpenGL OpenMP OpenSSH OpenSSL OpenStreetMap OpenDNS
71 /// TeX LaTeX BibTeX BibLaTeX
73 /// CamelCase (see also #2395)
74 /// `be_sure_we_got_to_the_end_of_it`
78 /// This test has [a `link_with_underscores`][chunked-example] inside it. See #823.
79 /// See also [the issue tracker](https://github.com/rust-lang/rust-clippy/search?q=clippy::doc_markdown&type=Issues)
80 /// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link].
81 /// It can also be [`inline_link2`].
83 /// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example
84 /// [inline_link]: https://foobar
85 /// [inline_link2]: https://foobar
86 /// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and
87 /// `multiline_ticks` functions.
89 /// expression of the type `_ <bit_op> m <cmp_op> c` (where `<bit_op>`
90 /// is one of {`&`, '|'} and `<cmp_op>` is one of {`!=`, `>=`, `>` ,
91 /// `be_sure_we_got_to_the_end_of_it`
94 multiline_codeblock();
99 /// ## `CamelCaseThing`
100 /// Talks about `CamelCaseThing`. Titles should be ignored; see issue #897.
102 /// # `CamelCaseThing`
104 /// Not a title #897 `CamelCaseThing`
105 /// `be_sure_we_got_to_the_end_of_it`
109 /// I am confused by brackets? (`x_y`)
110 /// I am confused by brackets? (foo `x_y`)
111 /// I am confused by brackets? (`x_y` foo)
112 /// `be_sure_we_got_to_the_end_of_it`
116 /// Diesel queries also have a similar problem to [Iterator][iterator], where
118 /// returning them from a function requires exposing the implementation of that
119 /// function. The [`helper_types`][helper_types] module exists to help with this,
120 /// but you might want to hide the return type or have it conditionally change.
121 /// Boxing can achieve both.
123 /// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html
124 /// [helper_types]: ../helper_types/index.html
125 /// `be_sure_we_got_to_the_end_of_it`
132 /// bar](https://doc.rust-lang.org/stable/std/iter/trait.IteratorFooBar.html)
136 /** E.g., serialization of an empty list: `FooBar`
138 That's in a code block: `PackedNode`
142 `be_sure_we_got_to_the_end_of_it`
147 /** E.g., serialization of an empty list: `FooBar`
149 That's in a code block: PackedNode
153 `be_sure_we_got_to_the_end_of_it`
158 /// Tests more than three quotes:
164 /// `be_sure_we_got_to_the_end_of_it`
168 #[cfg_attr(feature = "a", doc = " ```")]
169 #[cfg_attr(not(feature = "a"), doc = " ```ignore")]
171 /// let s = "localhost:10000".to_string();
172 /// println!("{}", s);
178 * This is a doc comment that should not be a list
179 *This would also be an error under a strict common mark interpretation
183 /// An iterator over `mycrate::Collection`'s values.
184 /// It should not lint a `'static` lifetime in ticks.
187 /// This should not cause the lint to trigger:
188 /// #REQ-data-family.lint_partof_exists
191 /// This should not cause an ICE:
193 fn pulldown_cmark_crash() {}
195 /// This should not lint
196 /// (regression test for #7758)
197 /// [plain text][path::to::item]
198 fn intra_doc_link() {}
200 // issue #7033 - generic_const_exprs ICE
201 struct S<T, const N: usize>
202 where [(); N.checked_next_power_of_two().unwrap()]: {
203 arr: [T; N.checked_next_power_of_two().unwrap()],
207 impl<T: Copy + Default, const N: usize> S<T, N>
208 where [(); N.checked_next_power_of_two().unwrap()]: {
211 arr: [T::default(); N.checked_next_power_of_two().unwrap()],