2025-06-29 23:13:37 +05:00
|
|
|
//! Test that enums inherit Send/!Send properties from their variants.
|
|
|
|
|
//!
|
|
|
|
|
//! Uses the unstable `negative_impls` feature to explicitly opt-out of Send.
|
|
|
|
|
|
2020-01-09 05:56:38 -05:00
|
|
|
#![feature(negative_impls)]
|
2015-01-11 13:14:39 +01:00
|
|
|
|
|
|
|
|
use std::marker::Send;
|
|
|
|
|
|
|
|
|
|
struct NoSend;
|
|
|
|
|
impl !Send for NoSend {}
|
2014-01-22 14:03:02 -05:00
|
|
|
|
2025-06-29 23:13:37 +05:00
|
|
|
enum Container {
|
|
|
|
|
WithNoSend(NoSend),
|
2014-01-22 14:03:02 -05:00
|
|
|
}
|
2013-05-05 15:55:32 -04:00
|
|
|
|
2025-06-29 23:13:37 +05:00
|
|
|
fn requires_send<T: Send>(_: T) {}
|
2013-05-05 15:55:32 -04:00
|
|
|
|
|
|
|
|
fn main() {
|
2025-06-29 23:13:37 +05:00
|
|
|
let container = Container::WithNoSend(NoSend);
|
|
|
|
|
requires_send(container);
|
2018-06-09 16:53:36 -07:00
|
|
|
//~^ ERROR `NoSend` cannot be sent between threads safely
|
2013-05-05 15:55:32 -04:00
|
|
|
}
|