rust/tests/ui/traits/negative-bounds/simple.rs
2023-12-28 00:43:35 +01:00

42 lines
788 B
Rust

#![feature(negative_bounds, negative_impls)]
fn not_copy<T: !Copy>() {}
fn neg_param_env<T: !Copy>() {
not_copy::<T>();
}
fn pos_param_env<T: Copy>() {
not_copy::<T>();
//~^ ERROR the trait bound `T: !Copy` is not satisfied
}
fn unknown<T>() {
not_copy::<T>();
//~^ ERROR the trait bound `T: !Copy` is not satisfied
}
struct NotCopyable;
impl !Copy for NotCopyable {}
fn neg_impl() {
not_copy::<NotCopyable>();
}
#[derive(Copy, Clone)]
struct Copyable;
fn pos_impl() {
not_copy::<Copyable>();
//~^ ERROR the trait bound `Copyable: !Copy` is not satisfied
}
struct NotNecessarilyCopyable;
fn unknown_impl() {
not_copy::<NotNecessarilyCopyable>();
//~^ ERROR the trait bound `NotNecessarilyCopyable: !Copy` is not satisfied
}
fn main() {}