]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/await_holding_invalid.rs
Auto merge of #8937 - Jarcho:merge_match_passes, r=llogiq
[rust.git] / clippy_lints / src / await_holding_invalid.rs
index 36b4f7faa19fc7c0dd701aeb1fc88f2ecc515306..5b7c4591504e1cbaa3710a1cad5b684b4f13efbe 100644 (file)
     ///
     /// ### Example
     ///
-    /// The `tracing` library has types which should not be held across `await`
-    /// points.
-    ///
     /// ```toml
     /// await-holding-invalid-types = [
-    ///   "tracing::span::Entered",
-    ///   "tracing::span::EnteredSpan",
+    ///   # You can specify a type name
+    ///   "CustomLockType",
+    ///   # You can (optionally) specify a reason
+    ///   { path = "OtherCustomLockType", reason = "Relies on a thread local" }
     /// ]
     /// ```
     ///
     /// ```rust
     /// # async fn baz() {}
+    /// struct CustomLockType;
+    /// struct OtherCustomLockType;
     /// async fn foo() {
-    ///   let _entered = tracing::info_span!("baz").entered();
-    ///   baz().await;
+    ///   let _x = CustomLockType;
+    ///   let _y = OtherCustomLockType;
+    ///   baz().await; // Lint violation
     /// }
     /// ```
     #[clippy::version = "1.49.0"]
     pub AWAIT_HOLDING_INVALID_TYPE,
     suspicious,
-    "inside an async function, holding a type across an await point which is not safe to be held across an await point"
+    "holding a type across an await point which is not allowed to be held as per the configuration"
 }
 
 impl_lint_pass!(AwaitHolding => [AWAIT_HOLDING_LOCK, AWAIT_HOLDING_REFCELL_REF, AWAIT_HOLDING_INVALID_TYPE]);
@@ -266,10 +268,10 @@ fn emit_invalid_type(cx: &LateContext<'_>, span: Span, disallowed: &DisallowedTy
         cx,
         AWAIT_HOLDING_INVALID_TYPE,
         span,
-        &format!("`{type_name}` may not be held across an `await` point according to config",),
+        &format!("`{type_name}` may not be held across an `await` point per `clippy.toml`",),
         |diag| {
             if let Some(reason) = reason {
-                diag.note(format!("{reason} (according to clippy.toml)"));
+                diag.note(reason.clone());
             }
         },
     );