From 1491c6f3117749cbefd6d0dc9c425a64ecff4f8d Mon Sep 17 00:00:00 2001 From: Peter Kehl Date: Sat, 25 Mar 2023 06:19:52 -0700 Subject: Rustdoc Book refer to rustdoc::missing_doc_code_examples. Fixes #109592. --- src/doc/rustdoc/src/write-documentation/what-to-include.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/doc/rustdoc/src/write-documentation/what-to-include.md b/src/doc/rustdoc/src/write-documentation/what-to-include.md index e1e09aa4a8a..cf1e6a8d3ca 100644 --- a/src/doc/rustdoc/src/write-documentation/what-to-include.md +++ b/src/doc/rustdoc/src/write-documentation/what-to-include.md @@ -39,7 +39,7 @@ warning: 1 warning emitted As a library author, adding the lint `#![deny(missing_docs)]` is a great way to ensure the project does not drift away from being documented well, and `#![warn(missing_docs)]` is a good way to move towards comprehensive -documentation. In addition to docs, `#![deny(missing_doc_code_examples)]` +documentation. In addition to docs, `#![deny(rustdoc::missing_doc_code_examples)]` ensures each function contains a usage example. In our example above, the warning is resolved by adding crate level documentation. -- cgit 1.4.1-3-g733a5 From e0ec9c0b9c08677b967fb2f50978bcb4466152cd Mon Sep 17 00:00:00 2001 From: Ezra Shaw Date: Sat, 11 Mar 2023 21:22:42 +1300 Subject: rustdoc: tweak `some variants omitted` Don't display `// some variants omitted` if enum is marked `#[non_exhaustive]` --- src/librustdoc/html/render/print_item.rs | 2 +- tests/rustdoc/issue-108925.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/rustdoc/issue-108925.rs (limited to 'src') diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 579b5a9c723..674cd0d62d4 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1234,7 +1234,7 @@ fn item_enum(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, e: &clean:: w.write_str(",\n"); } - if variants_stripped { + if variants_stripped && !it.is_non_exhaustive() { w.write_str(" // some variants omitted\n"); } if toggle { diff --git a/tests/rustdoc/issue-108925.rs b/tests/rustdoc/issue-108925.rs new file mode 100644 index 00000000000..88aeb3c7f75 --- /dev/null +++ b/tests/rustdoc/issue-108925.rs @@ -0,0 +1,11 @@ +// @has issue_108925/enum.MyThing.html +// @has - '//code' 'Shown' +// @!has - '//code' 'NotShown' +// @!has - '//code' '// some variants omitted' +#[non_exhaustive] +pub enum MyThing { + Shown, + #[doc(hidden)] + NotShown, +} + -- cgit 1.4.1-3-g733a5