/// contains fields that are not safe to be sent across threads.
/// It tries to detect fields that can cause a soundness issue
/// when sent to another thread (e.g., `Rc`) while allowing `!Send` fields
- /// that are expected to exist in a `Send` type such as raw pointers.
+ /// that are expected to exist in a `Send` type, such as raw pointers.
///
/// ### Why is this bad?
/// Sending the struct to another thread effectively sends all of its fields,
/// or specify correct bounds on generic type parameters (`T: Send`).
#[clippy::version = "1.57.0"]
pub NON_SEND_FIELDS_IN_SEND_TY,
- suspicious,
+ nursery,
"there is a field that is not safe to be sent to another thread in a `Send` struct"
}
non_send_fields.push(NonSendField {
def: field_def,
ty: field_ty,
- generic_params: collect_generic_params(cx, field_ty),
+ generic_params: collect_generic_params(field_ty),
})
}
}
NON_SEND_FIELDS_IN_SEND_TY,
item.span,
&format!(
- "there are some fields in `{}` are not safe to be sent to another thread",
+ "some fields in `{}` are not safe to be sent to another thread",
snippet(cx, hir_impl.self_ty.span, "Unknown")
),
|diag| {
/// Given a type, collect all of its generic parameters.
/// Example: `MyStruct<P, Box<Q, R>>` => `vec![P, Q, R]`
-fn collect_generic_params<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Vec<Ty<'tcx>> {
- ty.walk(cx.tcx)
+fn collect_generic_params(ty: Ty<'_>) -> Vec<Ty<'_>> {
+ ty.walk()
.filter_map(|inner| match inner.unpack() {
GenericArgKind::Type(inner_ty) => Some(inner_ty),
_ => None,
/// Checks if the type contains any pointer-like types in substs (including nested ones)
fn contains_pointer_like<'tcx>(cx: &LateContext<'tcx>, target_ty: Ty<'tcx>) -> bool {
- for ty_node in target_ty.walk(cx.tcx) {
+ for ty_node in target_ty.walk() {
if let GenericArgKind::Type(inner_ty) = ty_node.unpack() {
match inner_ty.kind() {
ty::RawPtr(_) => {