#![warn(clippy::non_send_field_in_send_ty)] #![feature(extern_types)] use std::cell::UnsafeCell; use std::ptr::NonNull; use std::sync::{Arc, Mutex, MutexGuard}; // disrustor / RUSTSEC-2020-0150 pub struct RingBuffer { data: Vec>, capacity: usize, mask: usize, } unsafe impl Send for RingBuffer {} // noise_search / RUSTSEC-2020-0141 pub struct MvccRwLock { raw: *const T, lock: Mutex>, } unsafe impl Send for MvccRwLock {} // async-coap / RUSTSEC-2020-0124 pub struct ArcGuard { inner: T, head: Arc, } unsafe impl Send for ArcGuard {} // rusb / RUSTSEC-2020-0098 extern "C" { type libusb_device_handle; } pub trait UsbContext { // some user trait that does not guarantee `Send` } pub struct DeviceHandle { context: T, handle: NonNull, } unsafe impl Send for DeviceHandle {} // Other basic tests pub struct MultiField { field1: T, field2: T, field3: T, } unsafe impl Send for MultiField {} pub enum MyOption { MySome(T), MyNone, } unsafe impl Send for MyOption {} // Raw pointers are allowed extern "C" { type SomeFfiType; } pub struct FpTest { vec: Vec<*const SomeFfiType>, } unsafe impl Send for FpTest {} // Test attributes #[allow(clippy::non_send_field_in_send_ty)] pub struct AttrTest1(T); pub struct AttrTest2 { #[allow(clippy::non_send_field_in_send_ty)] field: T, } pub enum AttrTest3 { #[allow(clippy::non_send_field_in_send_ty)] Enum1(T), Enum2(T), } unsafe impl Send for AttrTest1 {} unsafe impl Send for AttrTest2 {} unsafe impl Send for AttrTest3 {} // Multiple non-overlapping `Send` for a single type pub struct Complex { field1: A, field2: B, } unsafe impl

Send for Complex {} // `MutexGuard` is non-Send unsafe impl Send for Complex> {} fn main() {}