Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not dereference uninhabited types refs in Clone implementations #3456

Merged
merged 1 commit into from Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/macros.rs
Expand Up @@ -120,6 +120,12 @@ macro_rules! s_no_extra_traits {
);
}

macro_rules! missing {
($($(#[$attr:meta])* pub enum $i:ident {})*) => ($(
$(#[$attr])* #[allow(missing_copy_implementations)] pub enum $i { }
)*);
}

macro_rules! e {
($($(#[$attr:meta])* pub enum $i:ident { $($field:tt)* })*) => ($(
__item! {
Expand Down
10 changes: 3 additions & 7 deletions src/unix/linux_like/linux/mod.rs
Expand Up @@ -53,13 +53,9 @@ pub type iconv_t = *mut ::c_void;
pub type sctp_assoc_t = ::__s32;

pub type eventfd_t = u64;
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos64_t {} // FIXME: fill this out with a struct
impl ::Copy for fpos64_t {}
impl ::Clone for fpos64_t {
fn clone(&self) -> fpos64_t {
*self
}
missing! {
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos64_t {} // FIXME: fill this out with a struct
}

s! {
Expand Down
10 changes: 3 additions & 7 deletions src/unix/linux_like/mod.rs
Expand Up @@ -6,13 +6,9 @@ pub type timer_t = *mut ::c_void;
pub type key_t = ::c_int;
pub type id_t = ::c_uint;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
impl ::Clone for timezone {
fn clone(&self) -> timezone {
*self
}
missing! {
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
}

s! {
Expand Down
30 changes: 8 additions & 22 deletions src/unix/mod.rs
Expand Up @@ -41,13 +41,9 @@ cfg_if! {
}
}

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum DIR {}
impl ::Copy for DIR {}
impl ::Clone for DIR {
fn clone(&self) -> DIR {
*self
}
missing! {
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum DIR {}
}
pub type locale_t = *mut ::c_void;

Expand Down Expand Up @@ -414,21 +410,11 @@ cfg_if! {
}
}

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum FILE {}
impl ::Copy for FILE {}
impl ::Clone for FILE {
fn clone(&self) -> FILE {
*self
}
}
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos_t {} // FIXME: fill this out with a struct
impl ::Copy for fpos_t {}
impl ::Clone for fpos_t {
fn clone(&self) -> fpos_t {
*self
}
missing! {
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum FILE {}
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum fpos_t {} // FIXME: fill this out with a struct
}

extern "C" {
Expand Down