rust/tests/ui/traits/enum-negative-send-impl.rs
2025-06-30 11:50:19 +05:00

23 lines
485 B
Rust

//! Test that enums inherit Send/!Send properties from their variants.
//!
//! Uses the unstable `negative_impls` feature to explicitly opt-out of Send.
#![feature(negative_impls)]
use std::marker::Send;
struct NoSend;
impl !Send for NoSend {}
enum Container {
WithNoSend(NoSend),
}
fn requires_send<T: Send>(_: T) {}
fn main() {
let container = Container::WithNoSend(NoSend);
requires_send(container);
//~^ ERROR `NoSend` cannot be sent between threads safely
}