From 7e26edce65df4e89be23aa22bcb3d3a2db723bf7 Mon Sep 17 00:00:00 2001 From: Lily Mara Date: Mon, 18 Apr 2022 11:16:35 -0700 Subject: [PATCH] fixup! Add `await_holding_invalid_type` lint --- clippy_lints/src/await_holding_invalid.rs | 5 +++++ .../await_holding_invalid_type.stderr | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/clippy_lints/src/await_holding_invalid.rs b/clippy_lints/src/await_holding_invalid.rs index 5659651c8426..022f82ebf51b 100644 --- a/clippy_lints/src/await_holding_invalid.rs +++ b/clippy_lints/src/await_holding_invalid.rs @@ -146,15 +146,20 @@ declare_clippy_lint! { /// /// ```toml /// await-holding-invalid-types = [ + /// # You can specify a type name /// "CustomLockType", + /// # You can (optionally) specify a reason + /// { type = "OtherCustomLockType", reason = "Relies on a thread local" } /// ] /// ``` /// /// ```rust /// # async fn baz() {} /// struct CustomLockType; + /// struct OtherCustomLockType; /// async fn foo() { /// let _x = CustomLockType; + /// let _y = CustomLockType; /// baz().await; // Lint violation /// } /// ``` diff --git a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr b/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr index eebdd624d243..62c45b54634f 100644 --- a/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr +++ b/tests/ui-toml/await_holding_invalid_type/await_holding_invalid_type.stderr @@ -1,25 +1,25 @@ -error: `std::string::String` may not be held across an `await` point according to config +error: `std::string::String` may not be held across an `await` point per `clippy.toml` --> $DIR/await_holding_invalid_type.rs:5:9 | LL | let _x = String::from("hello"); | ^^ | = note: `-D clippy::await-holding-invalid-type` implied by `-D warnings` - = note: strings are bad (according to clippy.toml) + = note: strings are bad -error: `std::net::Ipv4Addr` may not be held across an `await` point according to config +error: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml` --> $DIR/await_holding_invalid_type.rs:10:9 | LL | let _x = Ipv4Addr::new(127, 0, 0, 1); | ^^ -error: `std::string::String` may not be held across an `await` point according to config +error: `std::string::String` may not be held across an `await` point per `clippy.toml` --> $DIR/await_holding_invalid_type.rs:31:13 | LL | let _x = String::from("hi!"); | ^^ | - = note: strings are bad (according to clippy.toml) + = note: strings are bad error: aborting due to 3 previous errors