diff --git a/libc-test/build.rs b/libc-test/build.rs index 48f952f9f7c83..123ac8d5ace30 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4503,11 +4503,11 @@ fn test_linux(target: &str) { true } - // The `inotify_event` and `cmsghdr` types contain Flexible Array Member fields (the - // `name` and `data` fields respectively) which have unspecified calling convention. - // The roundtripping tests deliberately pass the structs by value to check "by value" - // layout consistency, but this would be UB for the these types. + // The following types contain Flexible Array Member fields which have unspecified calling + // convention. The roundtripping tests deliberately pass the structs by value to check "by + // value" layout consistency, but this would be UB for the these types. "inotify_event" => true, + "fanotify_event_info_fid" => true, "cmsghdr" => true, // FIXME: the call ABI of max_align_t is incorrect on these platforms: diff --git a/src/macros.rs b/src/macros.rs index 7090e6d1d1538..2344551840f26 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -82,16 +82,11 @@ macro_rules! s { __item! { #[repr(C)] #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + #[derive(Copy, Clone)] #[allow(deprecated)] $(#[$attr])* pub struct $i { $($field)* } } - #[allow(deprecated)] - impl ::Copy for $i {} - #[allow(deprecated)] - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } ); } @@ -106,13 +101,10 @@ macro_rules! s_paren { )*) => ($( __item! { #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + #[derive(Copy, Clone)] $(#[$attr])* pub struct $i ( $($field)* ); } - impl ::Copy for $i {} - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } )*); } @@ -130,28 +122,19 @@ macro_rules! s_no_extra_traits { (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] + #[derive(Copy, Clone)] $(#[$attr])* pub union $i { $($field)* } } - - impl ::Copy for $i {} - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } ); (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] + #[derive(Copy, Clone)] $(#[$attr])* pub struct $i { $($field)* } } - #[allow(deprecated)] - impl ::Copy for $i {} - #[allow(deprecated)] - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } ); } @@ -177,13 +160,10 @@ macro_rules! e { )*) => ($( __item! { #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + #[derive(Copy, Clone)] $(#[$attr])* pub enum $i { $($field)* } } - impl ::Copy for $i {} - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } )*); }