diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/tools/clippy/tests/ui/doc | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/doc')
-rw-r--r-- | src/tools/clippy/tests/ui/doc/doc-fixable.fixed | 215 | ||||
-rw-r--r-- | src/tools/clippy/tests/ui/doc/doc-fixable.rs | 215 | ||||
-rw-r--r-- | src/tools/clippy/tests/ui/doc/doc-fixable.stderr | 333 | ||||
-rw-r--r-- | src/tools/clippy/tests/ui/doc/issue_1832.rs | 9 | ||||
-rw-r--r-- | src/tools/clippy/tests/ui/doc/issue_902.rs | 7 | ||||
-rw-r--r-- | src/tools/clippy/tests/ui/doc/unbalanced_ticks.rs | 43 | ||||
-rw-r--r-- | src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr | 79 |
7 files changed, 901 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/doc/doc-fixable.fixed b/src/tools/clippy/tests/ui/doc/doc-fixable.fixed new file mode 100644 index 000000000..747801b40 --- /dev/null +++ b/src/tools/clippy/tests/ui/doc/doc-fixable.fixed @@ -0,0 +1,215 @@ +// run-rustfix +//! This file tests for the `DOC_MARKDOWN` lint. + +#![allow(dead_code, incomplete_features)] +#![warn(clippy::doc_markdown)] +#![feature(custom_inner_attributes, generic_const_exprs, const_option)] +#![rustfmt::skip] + +/// The `foo_bar` function does _nothing_. See also `foo::bar`. (note the dot there) +/// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not `Foo::some_fun` +/// which should be reported only once despite being __doubly bad__. +/// Here be `::a::global:path`, and _`::another::global::path`_. :: is not a path though. +/// Import an item from `::awesome::global::blob::` (Intended postfix) +/// These are the options for `::Cat`: (Intended trailing single colon, shouldn't be linted) +/// That's not code ~`NotInCodeBlock`~. +/// `be_sure_we_got_to_the_end_of_it` +fn foo_bar() { +} + +/// That one tests multiline ticks. +/// ```rust +/// foo_bar FOO_BAR +/// _foo bar_ +/// ``` +/// +/// ~~~rust +/// foo_bar FOO_BAR +/// _foo bar_ +/// ~~~ +/// `be_sure_we_got_to_the_end_of_it` +fn multiline_codeblock() { +} + +/// This _is a test for +/// multiline +/// emphasis_. +/// `be_sure_we_got_to_the_end_of_it` +fn test_emphasis() { +} + +/// This tests units. See also #835. +/// kiB MiB GiB TiB PiB EiB +/// kib Mib Gib Tib Pib Eib +/// kB MB GB TB PB EB +/// kb Mb Gb Tb Pb Eb +/// 32kiB 32MiB 32GiB 32TiB 32PiB 32EiB +/// 32kib 32Mib 32Gib 32Tib 32Pib 32Eib +/// 32kB 32MB 32GB 32TB 32PB 32EB +/// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb +/// NaN +/// `be_sure_we_got_to_the_end_of_it` +fn test_units() { +} + +/// This tests allowed identifiers. +/// KiB MiB GiB TiB PiB EiB +/// DirectX +/// ECMAScript +/// GPLv2 GPLv3 +/// GitHub GitLab +/// IPv4 IPv6 +/// ClojureScript CoffeeScript JavaScript PureScript TypeScript +/// NaN NaNs +/// OAuth GraphQL +/// OCaml +/// OpenGL OpenMP OpenSSH OpenSSL OpenStreetMap OpenDNS +/// WebGL +/// TensorFlow +/// TrueType +/// iOS macOS FreeBSD +/// TeX LaTeX BibTeX BibLaTeX +/// MinGW +/// CamelCase (see also #2395) +/// `be_sure_we_got_to_the_end_of_it` +fn test_allowed() { +} + +/// This test has [a `link_with_underscores`][chunked-example] inside it. See #823. +/// See also [the issue tracker](https://github.com/rust-lang/rust-clippy/search?q=clippy::doc_markdown&type=Issues) +/// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link]. +/// It can also be [`inline_link2`]. +/// +/// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example +/// [inline_link]: https://foobar +/// [inline_link2]: https://foobar +/// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and +/// `multiline_ticks` functions. +/// +/// expression of the type `_ <bit_op> m <cmp_op> c` (where `<bit_op>` +/// is one of {`&`, '|'} and `<cmp_op>` is one of {`!=`, `>=`, `>` , +/// `be_sure_we_got_to_the_end_of_it` +fn main() { + foo_bar(); + multiline_codeblock(); + test_emphasis(); + test_units(); +} + +/// ## `CamelCaseThing` +/// Talks about `CamelCaseThing`. Titles should be ignored; see issue #897. +/// +/// # `CamelCaseThing` +/// +/// Not a title #897 `CamelCaseThing` +/// `be_sure_we_got_to_the_end_of_it` +fn issue897() { +} + +/// I am confused by brackets? (`x_y`) +/// I am confused by brackets? (foo `x_y`) +/// I am confused by brackets? (`x_y` foo) +/// `be_sure_we_got_to_the_end_of_it` +fn issue900() { +} + +/// Diesel queries also have a similar problem to [Iterator][iterator], where +/// /// More talking +/// returning them from a function requires exposing the implementation of that +/// function. The [`helper_types`][helper_types] module exists to help with this, +/// but you might want to hide the return type or have it conditionally change. +/// Boxing can achieve both. +/// +/// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html +/// [helper_types]: ../helper_types/index.html +/// `be_sure_we_got_to_the_end_of_it` +fn issue883() { +} + +/// `foo_bar +/// baz_quz` +/// [foo +/// bar](https://doc.rust-lang.org/stable/std/iter/trait.IteratorFooBar.html) +fn multiline() { +} + +/** E.g., serialization of an empty list: `FooBar` +``` +That's in a code block: `PackedNode` +``` + +And `BarQuz` too. +`be_sure_we_got_to_the_end_of_it` +*/ +fn issue1073() { +} + +/** E.g., serialization of an empty list: `FooBar` +``` +That's in a code block: PackedNode +``` + +And `BarQuz` too. +`be_sure_we_got_to_the_end_of_it` +*/ +fn issue1073_alt() { +} + +/// Tests more than three quotes: +/// ```` +/// DoNotWarn +/// ``` +/// StillDont +/// ```` +/// `be_sure_we_got_to_the_end_of_it` +fn four_quotes() { +} + +#[cfg_attr(feature = "a", doc = " ```")] +#[cfg_attr(not(feature = "a"), doc = " ```ignore")] +/// fn main() { +/// let s = "localhost:10000".to_string(); +/// println!("{}", s); +/// } +/// ``` +fn issue_1469() {} + +/** + * This is a doc comment that should not be a list + *This would also be an error under a strict common mark interpretation + */ +fn issue_1920() {} + +/// An iterator over `mycrate::Collection`'s values. +/// It should not lint a `'static` lifetime in ticks. +fn issue_2210() {} + +/// This should not cause the lint to trigger: +/// #REQ-data-family.lint_partof_exists +fn issue_2343() {} + +/// This should not cause an ICE: +/// __|_ _|__||_| +fn pulldown_cmark_crash() {} + +/// This should not lint +/// (regression test for #7758) +/// [plain text][path::to::item] +fn intra_doc_link() {} + +// issue #7033 - generic_const_exprs ICE +struct S<T, const N: usize> +where [(); N.checked_next_power_of_two().unwrap()]: { + arr: [T; N.checked_next_power_of_two().unwrap()], + n: usize, +} + +impl<T: Copy + Default, const N: usize> S<T, N> +where [(); N.checked_next_power_of_two().unwrap()]: { + fn new() -> Self { + Self { + arr: [T::default(); N.checked_next_power_of_two().unwrap()], + n: 0, + } + } +} diff --git a/src/tools/clippy/tests/ui/doc/doc-fixable.rs b/src/tools/clippy/tests/ui/doc/doc-fixable.rs new file mode 100644 index 000000000..f3cf96615 --- /dev/null +++ b/src/tools/clippy/tests/ui/doc/doc-fixable.rs @@ -0,0 +1,215 @@ +// run-rustfix +//! This file tests for the `DOC_MARKDOWN` lint. + +#![allow(dead_code, incomplete_features)] +#![warn(clippy::doc_markdown)] +#![feature(custom_inner_attributes, generic_const_exprs, const_option)] +#![rustfmt::skip] + +/// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) +/// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun +/// which should be reported only once despite being __doubly bad__. +/// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. +/// Import an item from ::awesome::global::blob:: (Intended postfix) +/// These are the options for ::Cat: (Intended trailing single colon, shouldn't be linted) +/// That's not code ~NotInCodeBlock~. +/// be_sure_we_got_to_the_end_of_it +fn foo_bar() { +} + +/// That one tests multiline ticks. +/// ```rust +/// foo_bar FOO_BAR +/// _foo bar_ +/// ``` +/// +/// ~~~rust +/// foo_bar FOO_BAR +/// _foo bar_ +/// ~~~ +/// be_sure_we_got_to_the_end_of_it +fn multiline_codeblock() { +} + +/// This _is a test for +/// multiline +/// emphasis_. +/// be_sure_we_got_to_the_end_of_it +fn test_emphasis() { +} + +/// This tests units. See also #835. +/// kiB MiB GiB TiB PiB EiB +/// kib Mib Gib Tib Pib Eib +/// kB MB GB TB PB EB +/// kb Mb Gb Tb Pb Eb +/// 32kiB 32MiB 32GiB 32TiB 32PiB 32EiB +/// 32kib 32Mib 32Gib 32Tib 32Pib 32Eib +/// 32kB 32MB 32GB 32TB 32PB 32EB +/// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb +/// NaN +/// be_sure_we_got_to_the_end_of_it +fn test_units() { +} + +/// This tests allowed identifiers. +/// KiB MiB GiB TiB PiB EiB +/// DirectX +/// ECMAScript +/// GPLv2 GPLv3 +/// GitHub GitLab +/// IPv4 IPv6 +/// ClojureScript CoffeeScript JavaScript PureScript TypeScript +/// NaN NaNs +/// OAuth GraphQL +/// OCaml +/// OpenGL OpenMP OpenSSH OpenSSL OpenStreetMap OpenDNS +/// WebGL +/// TensorFlow +/// TrueType +/// iOS macOS FreeBSD +/// TeX LaTeX BibTeX BibLaTeX +/// MinGW +/// CamelCase (see also #2395) +/// be_sure_we_got_to_the_end_of_it +fn test_allowed() { +} + +/// This test has [a link_with_underscores][chunked-example] inside it. See #823. +/// See also [the issue tracker](https://github.com/rust-lang/rust-clippy/search?q=clippy::doc_markdown&type=Issues) +/// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link]. +/// It can also be [inline_link2]. +/// +/// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example +/// [inline_link]: https://foobar +/// [inline_link2]: https://foobar +/// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and +/// `multiline_ticks` functions. +/// +/// expression of the type `_ <bit_op> m <cmp_op> c` (where `<bit_op>` +/// is one of {`&`, '|'} and `<cmp_op>` is one of {`!=`, `>=`, `>` , +/// be_sure_we_got_to_the_end_of_it +fn main() { + foo_bar(); + multiline_codeblock(); + test_emphasis(); + test_units(); +} + +/// ## CamelCaseThing +/// Talks about `CamelCaseThing`. Titles should be ignored; see issue #897. +/// +/// # CamelCaseThing +/// +/// Not a title #897 CamelCaseThing +/// be_sure_we_got_to_the_end_of_it +fn issue897() { +} + +/// I am confused by brackets? (`x_y`) +/// I am confused by brackets? (foo `x_y`) +/// I am confused by brackets? (`x_y` foo) +/// be_sure_we_got_to_the_end_of_it +fn issue900() { +} + +/// Diesel queries also have a similar problem to [Iterator][iterator], where +/// /// More talking +/// returning them from a function requires exposing the implementation of that +/// function. The [`helper_types`][helper_types] module exists to help with this, +/// but you might want to hide the return type or have it conditionally change. +/// Boxing can achieve both. +/// +/// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html +/// [helper_types]: ../helper_types/index.html +/// be_sure_we_got_to_the_end_of_it +fn issue883() { +} + +/// `foo_bar +/// baz_quz` +/// [foo +/// bar](https://doc.rust-lang.org/stable/std/iter/trait.IteratorFooBar.html) +fn multiline() { +} + +/** E.g., serialization of an empty list: FooBar +``` +That's in a code block: `PackedNode` +``` + +And BarQuz too. +be_sure_we_got_to_the_end_of_it +*/ +fn issue1073() { +} + +/** E.g., serialization of an empty list: FooBar +``` +That's in a code block: PackedNode +``` + +And BarQuz too. +be_sure_we_got_to_the_end_of_it +*/ +fn issue1073_alt() { +} + +/// Tests more than three quotes: +/// ```` +/// DoNotWarn +/// ``` +/// StillDont +/// ```` +/// be_sure_we_got_to_the_end_of_it +fn four_quotes() { +} + +#[cfg_attr(feature = "a", doc = " ```")] +#[cfg_attr(not(feature = "a"), doc = " ```ignore")] +/// fn main() { +/// let s = "localhost:10000".to_string(); +/// println!("{}", s); +/// } +/// ``` +fn issue_1469() {} + +/** + * This is a doc comment that should not be a list + *This would also be an error under a strict common mark interpretation + */ +fn issue_1920() {} + +/// An iterator over mycrate::Collection's values. +/// It should not lint a `'static` lifetime in ticks. +fn issue_2210() {} + +/// This should not cause the lint to trigger: +/// #REQ-data-family.lint_partof_exists +fn issue_2343() {} + +/// This should not cause an ICE: +/// __|_ _|__||_| +fn pulldown_cmark_crash() {} + +/// This should not lint +/// (regression test for #7758) +/// [plain text][path::to::item] +fn intra_doc_link() {} + +// issue #7033 - generic_const_exprs ICE +struct S<T, const N: usize> +where [(); N.checked_next_power_of_two().unwrap()]: { + arr: [T; N.checked_next_power_of_two().unwrap()], + n: usize, +} + +impl<T: Copy + Default, const N: usize> S<T, N> +where [(); N.checked_next_power_of_two().unwrap()]: { + fn new() -> Self { + Self { + arr: [T::default(); N.checked_next_power_of_two().unwrap()], + n: 0, + } + } +} diff --git a/src/tools/clippy/tests/ui/doc/doc-fixable.stderr b/src/tools/clippy/tests/ui/doc/doc-fixable.stderr new file mode 100644 index 000000000..40345370c --- /dev/null +++ b/src/tools/clippy/tests/ui/doc/doc-fixable.stderr @@ -0,0 +1,333 @@ +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:9:9 + | +LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) + | ^^^^^^^ + | + = note: `-D clippy::doc-markdown` implied by `-D warnings` +help: try + | +LL | /// The `foo_bar` function does _nothing_. See also foo::bar. (note the dot there) + | ~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:9:51 + | +LL | /// The foo_bar function does _nothing_. See also foo::bar. (note the dot there) + | ^^^^^^^^ + | +help: try + | +LL | /// The foo_bar function does _nothing_. See also `foo::bar`. (note the dot there) + | ~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:10:83 + | +LL | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not Foo::some_fun + | ^^^^^^^^^^^^^ + | +help: try + | +LL | /// Markdown is _weird_. I mean _really weird_. This /_ is ok. So is `_`. But not `Foo::some_fun` + | ~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:12:13 + | +LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. + | ^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// Here be `::a::global:path`, and _::another::global::path_. :: is not a path though. + | ~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:12:36 + | +LL | /// Here be ::a::global:path, and _::another::global::path_. :: is not a path though. + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// Here be ::a::global:path, and _`::another::global::path`_. :: is not a path though. + | ~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:13:25 + | +LL | /// Import an item from ::awesome::global::blob:: (Intended postfix) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// Import an item from `::awesome::global::blob::` (Intended postfix) + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:14:31 + | +LL | /// These are the options for ::Cat: (Intended trailing single colon, shouldn't be linted) + | ^^^^^ + | +help: try + | +LL | /// These are the options for `::Cat`: (Intended trailing single colon, shouldn't be linted) + | ~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:15:22 + | +LL | /// That's not code ~NotInCodeBlock~. + | ^^^^^^^^^^^^^^ + | +help: try + | +LL | /// That's not code ~`NotInCodeBlock`~. + | ~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:16:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:30:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:37:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:51:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:74:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:78:22 + | +LL | /// This test has [a link_with_underscores][chunked-example] inside it. See #823. + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// This test has [a `link_with_underscores`][chunked-example] inside it. See #823. + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:81:21 + | +LL | /// It can also be [inline_link2]. + | ^^^^^^^^^^^^ + | +help: try + | +LL | /// It can also be [`inline_link2`]. + | ~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:91:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:99:8 + | +LL | /// ## CamelCaseThing + | ^^^^^^^^^^^^^^ + | +help: try + | +LL | /// ## `CamelCaseThing` + | ~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:102:7 + | +LL | /// # CamelCaseThing + | ^^^^^^^^^^^^^^ + | +help: try + | +LL | /// # `CamelCaseThing` + | ~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:104:22 + | +LL | /// Not a title #897 CamelCaseThing + | ^^^^^^^^^^^^^^ + | +help: try + | +LL | /// Not a title #897 `CamelCaseThing` + | ~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:105:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:112:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:125:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:136:43 + | +LL | /** E.g., serialization of an empty list: FooBar + | ^^^^^^ + | +help: try + | +LL | /** E.g., serialization of an empty list: `FooBar` + | ~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:141:5 + | +LL | And BarQuz too. + | ^^^^^^ + | +help: try + | +LL | And `BarQuz` too. + | ~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:142:1 + | +LL | be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | `be_sure_we_got_to_the_end_of_it` + | + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:147:43 + | +LL | /** E.g., serialization of an empty list: FooBar + | ^^^^^^ + | +help: try + | +LL | /** E.g., serialization of an empty list: `FooBar` + | ~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:152:5 + | +LL | And BarQuz too. + | ^^^^^^ + | +help: try + | +LL | And `BarQuz` too. + | ~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:153:1 + | +LL | be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | `be_sure_we_got_to_the_end_of_it` + | + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:164:5 + | +LL | /// be_sure_we_got_to_the_end_of_it + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// `be_sure_we_got_to_the_end_of_it` + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: item in documentation is missing backticks + --> $DIR/doc-fixable.rs:183:22 + | +LL | /// An iterator over mycrate::Collection's values. + | ^^^^^^^^^^^^^^^^^^^ + | +help: try + | +LL | /// An iterator over `mycrate::Collection`'s values. + | ~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 30 previous errors + diff --git a/src/tools/clippy/tests/ui/doc/issue_1832.rs b/src/tools/clippy/tests/ui/doc/issue_1832.rs new file mode 100644 index 000000000..10586f16d --- /dev/null +++ b/src/tools/clippy/tests/ui/doc/issue_1832.rs @@ -0,0 +1,9 @@ +/// Ok: <http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels> +/// +/// Not ok: http://www.unicode.org +/// Not ok: https://www.unicode.org +/// Not ok: http://www.unicode.org/ +/// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels +fn issue_1832() {} + +fn main() {} diff --git a/src/tools/clippy/tests/ui/doc/issue_902.rs b/src/tools/clippy/tests/ui/doc/issue_902.rs new file mode 100644 index 000000000..4b0c835dd --- /dev/null +++ b/src/tools/clippy/tests/ui/doc/issue_902.rs @@ -0,0 +1,7 @@ +/// See [NIST SP 800-56A, revision 2]. +/// +/// [NIST SP 800-56A, revision 2]: +/// https://github.com/rust-lang/rust-clippy/issues/902#issuecomment-261919419 +fn issue_902_comment() {} + +fn main() {} diff --git a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.rs b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.rs new file mode 100644 index 000000000..8e8324b30 --- /dev/null +++ b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.rs @@ -0,0 +1,43 @@ +//! This file tests for the `DOC_MARKDOWN` lint, specifically cases +//! where ticks are unbalanced (see issue #6753). + +#![allow(dead_code)] +#![warn(clippy::doc_markdown)] + +/// This is a doc comment with `unbalanced_tick marks and several words that +/// should be `encompassed_by` tick marks because they `contain_underscores`. +/// Because of the initial `unbalanced_tick` pair, the error message is +/// very `confusing_and_misleading`. +fn main() {} + +/// This paragraph has `unbalanced_tick marks and should stop_linting. +/// +/// This paragraph is fine and should_be linted normally. +/// +/// Double unbalanced backtick from ``here to here` should lint. +/// +/// Double balanced back ticks ``start end`` is fine. +fn multiple_paragraphs() {} + +/// ``` +/// // Unbalanced tick mark in code block shouldn't warn: +/// ` +/// ``` +fn in_code_block() {} + +/// # `Fine` +/// +/// ## not_fine +/// +/// ### `unbalanced +/// +/// - This `item has unbalanced tick marks +/// - This item needs backticks_here +fn other_markdown() {} + +#[rustfmt::skip] +/// - ```rust +/// /// `lol` +/// pub struct Struct; +/// ``` +fn iss_7421() {} diff --git a/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr new file mode 100644 index 000000000..a462b9887 --- /dev/null +++ b/src/tools/clippy/tests/ui/doc/unbalanced_ticks.stderr @@ -0,0 +1,79 @@ +error: backticks are unbalanced + --> $DIR/unbalanced_ticks.rs:7:1 + | +LL | / /// This is a doc comment with `unbalanced_tick marks and several words that +LL | | /// should be `encompassed_by` tick marks because they `contain_underscores`. +LL | | /// Because of the initial `unbalanced_tick` pair, the error message is +LL | | /// very `confusing_and_misleading`. + | |____________________________________^ + | + = note: `-D clippy::doc-markdown` implied by `-D warnings` + = help: a backtick may be missing a pair + +error: backticks are unbalanced + --> $DIR/unbalanced_ticks.rs:13:1 + | +LL | /// This paragraph has `unbalanced_tick marks and should stop_linting. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: a backtick may be missing a pair + +error: item in documentation is missing backticks + --> $DIR/unbalanced_ticks.rs:15:32 + | +LL | /// This paragraph is fine and should_be linted normally. + | ^^^^^^^^^ + | +help: try + | +LL | /// This paragraph is fine and `should_be` linted normally. + | ~~~~~~~~~~~ + +error: backticks are unbalanced + --> $DIR/unbalanced_ticks.rs:17:1 + | +LL | /// Double unbalanced backtick from ``here to here` should lint. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: a backtick may be missing a pair + +error: item in documentation is missing backticks + --> $DIR/unbalanced_ticks.rs:30:8 + | +LL | /// ## not_fine + | ^^^^^^^^ + | +help: try + | +LL | /// ## `not_fine` + | ~~~~~~~~~~ + +error: backticks are unbalanced + --> $DIR/unbalanced_ticks.rs:32:1 + | +LL | /// ### `unbalanced + | ^^^^^^^^^^^^^^^^^^^ + | + = help: a backtick may be missing a pair + +error: backticks are unbalanced + --> $DIR/unbalanced_ticks.rs:34:1 + | +LL | /// - This `item has unbalanced tick marks + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: a backtick may be missing a pair + +error: item in documentation is missing backticks + --> $DIR/unbalanced_ticks.rs:35:23 + | +LL | /// - This item needs backticks_here + | ^^^^^^^^^^^^^^ + | +help: try + | +LL | /// - This item needs `backticks_here` + | ~~~~~~~~~~~~~~~~ + +error: aborting due to 8 previous errors + |