From 69ca324a53c35bb9cd77c5635a9ecc4f201eaa1c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 20 Oct 2021 15:57:44 +0200 Subject: [PATCH] Add test to ensure that the missing_doc_code_examples is not triggered on foreign trait implementations --- src/test/rustdoc-ui/doc-without-codeblock.rs | 9 +++++++++ src/test/rustdoc-ui/doc-without-codeblock.stderr | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/rustdoc-ui/doc-without-codeblock.rs b/src/test/rustdoc-ui/doc-without-codeblock.rs index 6812a454157b9..315fca195873a 100644 --- a/src/test/rustdoc-ui/doc-without-codeblock.rs +++ b/src/test/rustdoc-ui/doc-without-codeblock.rs @@ -11,3 +11,12 @@ pub mod foo { //~^ ERROR missing code example in this documentation pub fn bar() {} } + +// This impl is here to ensure the lint isn't emitted for foreign traits implementations. +impl std::ops::Neg for Foo { + type Output = Self; + + fn neg(self) -> Self::Output { + Self + } +} diff --git a/src/test/rustdoc-ui/doc-without-codeblock.stderr b/src/test/rustdoc-ui/doc-without-codeblock.stderr index aac537e9783cd..1c138044165f2 100644 --- a/src/test/rustdoc-ui/doc-without-codeblock.stderr +++ b/src/test/rustdoc-ui/doc-without-codeblock.stderr @@ -6,7 +6,7 @@ LL | | LL | | /// Some docs. LL | | ... | -LL | | pub fn bar() {} +LL | | } LL | | } | |_^ |