From 062b2099044ed1d65f6100d0d0ca8cd76102246e Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Wed, 14 Jun 2023 12:23:02 +0900 Subject: [PATCH 1/3] Ignore `main()` in `no_test` code fences --- clippy_lints/src/doc.rs | 5 ++++- tests/ui/doc/needless_doctest_main.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/ui/doc/needless_doctest_main.rs diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 384aca7fe..0617c3ea5 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -571,6 +571,7 @@ fn check_doc<'a, Events: Iterator, Range, Span)> = Vec::new(); @@ -584,6 +585,8 @@ fn check_doc<'a, Events: Iterator, Range, Range Date: Wed, 14 Jun 2023 12:36:17 +0900 Subject: [PATCH 2/3] run `cargo dev fmt` --- tests/ui/doc/needless_doctest_main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/ui/doc/needless_doctest_main.rs b/tests/ui/doc/needless_doctest_main.rs index fb32aac94..666b7e67b 100644 --- a/tests/ui/doc/needless_doctest_main.rs +++ b/tests/ui/doc/needless_doctest_main.rs @@ -8,7 +8,6 @@ //! m.insert(1u32, 2u32); //! } //! ``` -//! /// some description here /// ```rust,no_test From 867bd153836edd4441e4ca4481cfbe06f450d8c7 Mon Sep 17 00:00:00 2001 From: Kisaragi Marine Date: Wed, 14 Jun 2023 12:53:36 +0900 Subject: [PATCH 3/3] add main function to test itself --- tests/ui/doc/needless_doctest_main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ui/doc/needless_doctest_main.rs b/tests/ui/doc/needless_doctest_main.rs index 666b7e67b..f1a2c0575 100644 --- a/tests/ui/doc/needless_doctest_main.rs +++ b/tests/ui/doc/needless_doctest_main.rs @@ -16,3 +16,5 @@ /// } /// ``` fn foo() {} + +fn main() {}