Files
rust/tests/ui/traits/enum-negative-send-impl.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
485 B
Rust
Raw Normal View History

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.
#![feature(negative_impls)]
2015-01-11 13:14:39 +01:00
use std::marker::Send;
struct NoSend;
impl !Send for NoSend {}
2025-06-29 23:13:37 +05:00
enum Container {
WithNoSend(NoSend),
}
2025-06-29 23:13:37 +05:00
fn requires_send<T: Send>(_: T) {}
fn main() {
2025-06-29 23:13:37 +05:00
let container = Container::WithNoSend(NoSend);
requires_send(container);
//~^ ERROR `NoSend` cannot be sent between threads safely
}