rust/tests/ui/traits/copy-requires-all-fields-copy.rs
2025-07-05 00:50:51 +05:00

25 lines
481 B
Rust

//! Test that `Copy` cannot be implemented if any field doesn't implement `Copy`.
struct CantCopyThis;
struct IWantToCopyThis {
but_i_cant: CantCopyThis,
}
impl Copy for IWantToCopyThis {}
//~^ ERROR the trait `Copy` cannot be implemented for this type
enum CantCopyThisEither {
A,
B,
}
enum IWantToCopyThisToo {
ButICant(CantCopyThisEither),
}
impl Copy for IWantToCopyThisToo {}
//~^ ERROR the trait `Copy` cannot be implemented for this type
fn main() {}