From 2484a182399918eab2e25b3532936eebf09d9bb5 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 24 Oct 2022 17:25:30 +0200 Subject: [PATCH 1/5] Add `compile_fail` to `let_underscore_drop` example --- compiler/rustc_lint/src/let_underscore.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_lint/src/let_underscore.rs b/compiler/rustc_lint/src/let_underscore.rs index 78f355ec3d0ae..b51c1679f9f31 100644 --- a/compiler/rustc_lint/src/let_underscore.rs +++ b/compiler/rustc_lint/src/let_underscore.rs @@ -11,7 +11,7 @@ declare_lint! { /// scope. /// /// ### Example - /// ``` + /// ```compile_fail /// struct SomeStruct; /// impl Drop for SomeStruct { /// fn drop(&mut self) { From 3ff010bdbc0b138e8761cedcec4d6174b2e7ab61 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 24 Oct 2022 17:30:29 +0200 Subject: [PATCH 2/5] Update compiler/rustc_lint/src/let_underscore.rs --- compiler/rustc_lint/src/let_underscore.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_lint/src/let_underscore.rs b/compiler/rustc_lint/src/let_underscore.rs index b51c1679f9f31..c59f56756c6b7 100644 --- a/compiler/rustc_lint/src/let_underscore.rs +++ b/compiler/rustc_lint/src/let_underscore.rs @@ -11,7 +11,7 @@ declare_lint! { /// scope. /// /// ### Example - /// ```compile_fail + /// ```rust,compile_fail /// struct SomeStruct; /// impl Drop for SomeStruct { /// fn drop(&mut self) { From 6b5f2753f75d5f9f10eee9252a1346a72f1c9ee2 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 24 Oct 2022 18:00:41 +0200 Subject: [PATCH 3/5] Update let_underscore.rs --- compiler/rustc_lint/src/let_underscore.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_lint/src/let_underscore.rs b/compiler/rustc_lint/src/let_underscore.rs index c59f56756c6b7..11ceb4e22ae83 100644 --- a/compiler/rustc_lint/src/let_underscore.rs +++ b/compiler/rustc_lint/src/let_underscore.rs @@ -11,7 +11,7 @@ declare_lint! { /// scope. /// /// ### Example - /// ```rust,compile_fail + /// ``` /// struct SomeStruct; /// impl Drop for SomeStruct { /// fn drop(&mut self) { @@ -56,7 +56,7 @@ declare_lint! { /// of at end of scope, which is typically incorrect. /// /// ### Example - /// ```compile_fail + /// ```rust,compile_fail /// use std::sync::{Arc, Mutex}; /// use std::thread; /// let data = Arc::new(Mutex::new(0)); From 8ecbb7e39a2bbd082fbac4b05eb715bda2c91fce Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 24 Oct 2022 21:25:30 +0200 Subject: [PATCH 4/5] fix the lint as requested --- src/tools/lint-docs/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/tools/lint-docs/src/lib.rs b/src/tools/lint-docs/src/lib.rs index 857feb7732536..3842a649c6f96 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -37,10 +37,8 @@ impl Lint { } fn is_ignored(&self) -> bool { - self.doc - .iter() - .filter(|line| line.starts_with("```rust")) - .all(|line| line.contains(",ignore")) + let blocks: Vec<_> = self.doc.iter().filter(|line| line.starts_with("```rust")).collect(); + !blocks.is_empty() && blocks.iter().all(|line| line.contains(",ignore")) } /// Checks the doc style of the lint. From 30b522365bf3a2be8248c1572054e5988db0e1fd Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Tue, 25 Oct 2022 00:59:32 +0200 Subject: [PATCH 5/5] Fix failing examples --- compiler/rustc_lint/src/let_underscore.rs | 2 +- .../rustc_lint/src/opaque_hidden_inferred_bound.rs | 14 +++++++++----- compiler/rustc_lint_defs/src/builtin.rs | 8 ++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_lint/src/let_underscore.rs b/compiler/rustc_lint/src/let_underscore.rs index 11ceb4e22ae83..e1177c10414d8 100644 --- a/compiler/rustc_lint/src/let_underscore.rs +++ b/compiler/rustc_lint/src/let_underscore.rs @@ -11,7 +11,7 @@ declare_lint! { /// scope. /// /// ### Example - /// ``` + /// ```rust /// struct SomeStruct; /// impl Drop for SomeStruct { /// fn drop(&mut self) { diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 7f6f4a0abb4a5..ccc53707f7cf9 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -26,19 +26,23 @@ declare_lint! { /// /// ### Example /// - /// ``` + /// ```rust + /// trait Duh {} + /// + /// impl Duh for i32 {} + /// /// trait Trait { - /// type Assoc: Send; + /// type Assoc: Duh; /// } /// /// struct Struct; /// - /// impl Trait for Struct { - /// type Assoc = i32; + /// impl Trait for F { + /// type Assoc = F; /// } /// /// fn test() -> impl Trait { - /// Struct + /// 42 /// } /// ``` /// diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 61ee467f59577..1fc2c4548649a 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -605,7 +605,7 @@ declare_lint! { /// /// ### Example /// - /// ``` + /// ```rust /// #[warn(unused_tuple_struct_fields)] /// struct S(i32, i32, i32); /// let s = S(1, 2, 3); @@ -1154,7 +1154,7 @@ declare_lint! { /// /// ### Example /// - /// ```compile_fail + /// ```rust,compile_fail /// #[repr(packed)] /// pub struct Foo { /// field1: u64, @@ -2615,7 +2615,7 @@ declare_lint! { /// /// ### Example /// - /// ```compile_fail + /// ```rust,compile_fail /// # #![allow(unused)] /// enum E { /// A, @@ -3986,7 +3986,7 @@ declare_lint! { /// /// ### Example /// - /// ``` + /// ```rust /// #![allow(test_unstable_lint)] /// ``` ///