///
/// ### 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]);
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());
}
},
);