Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 7 additions & 41 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,10 @@ pub type fsblkcnt_t = c_ulonglong;
pub type fsfilcnt_t = c_ulonglong;
pub type rlim_t = c_ulonglong;

// FIXME(fuchsia): why are these uninhabited types? that seems... wrong?
// Presumably these should be `()` or an `extern type` (when that stabilizes).
#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
}
#[derive(Debug)]
pub enum DIR {}
impl Copy for DIR {}
impl Clone for DIR {
fn clone(&self) -> DIR {
*self
}
}

#[derive(Debug)]
pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct
impl Copy for fpos64_t {}
impl Clone for fpos64_t {
fn clone(&self) -> fpos64_t {
*self
}
extern_ty! {
pub enum timezone {}
pub enum DIR {}
pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct
}

// PUB_STRUCT
Expand Down Expand Up @@ -3469,21 +3447,9 @@ fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar {
#[link(name = "fdio")]
extern "C" {}

#[derive(Debug)]
pub enum FILE {}
impl Copy for FILE {}
impl Clone for FILE {
fn clone(&self) -> FILE {
*self
}
}
#[derive(Debug)]
pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct
impl Copy for fpos_t {}
impl Clone for fpos_t {
fn clone(&self) -> fpos_t {
*self
}
extern_ty! {
pub enum FILE {}
pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct
}

extern "C" {
Expand Down
18 changes: 14 additions & 4 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,25 @@ macro_rules! s_no_extra_traits {
);
}

/// Specify that an enum should have no traits that aren't specified in the macro
/// invocation, i.e. no `Clone` or `Copy`.
macro_rules! missing {
/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`,
/// and `Copy`, but these aren't meaningful for extern types so they should eventually
/// be removed.
///
/// Really what we want here is something that also can't be named without indirection (in
/// ADTs or function signatures), but this doesn't exist.
macro_rules! extern_ty {
($(
$(#[$attr:meta])*
pub enum $i:ident {}
)*) => ($(
$(#[$attr])*
#[allow(missing_copy_implementations)]
// FIXME(1.0): the type is uninhabited so these traits are unreachable and could be
// removed.
#[::core::prelude::v1::derive(
::core::clone::Clone,
::core::marker::Copy,
::core::fmt::Debug,
)]
pub enum $i { }
)*);
}
Expand Down
18 changes: 3 additions & 15 deletions src/solid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,21 +395,9 @@ pub const SIGUSR1: c_int = 30;
pub const SIGUSR2: c_int = 31;
pub const SIGPWR: c_int = 32;

#[derive(Debug)]
pub enum FILE {}
impl Copy for FILE {}
impl Clone for FILE {
fn clone(&self) -> FILE {
*self
}
}
#[derive(Debug)]
pub enum fpos_t {}
impl Copy for fpos_t {}
impl Clone for fpos_t {
fn clone(&self) -> fpos_t {
*self
}
extern_ty! {
pub enum FILE {}
pub enum fpos_t {}
}

extern "C" {
Expand Down
3 changes: 1 addition & 2 deletions src/unix/aix/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::off_t;
use crate::prelude::*;

// Define lock_data_instrumented as an empty enum
missing! {
#[derive(Debug)]
extern_ty! {
pub enum lock_data_instrumented {}
}

Expand Down
9 changes: 2 additions & 7 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,8 @@ pub type copyfile_callback_t = Option<
pub type attrgroup_t = u32;
pub type vol_capabilities_set_t = [u32; 4];

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
extern_ty! {
pub enum timezone {}
}

c_enum! {
Expand Down
9 changes: 2 additions & 7 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ pub type vm_map_entry_t = *mut vm_map_entry;

pub type pmap = __c_anonymous_pmap;

#[derive(Debug)]
pub enum sem {}
impl Copy for sem {}
impl Clone for sem {
fn clone(&self) -> sem {
*self
}
extern_ty! {
pub enum sem {}
}

c_enum! {
Expand Down
9 changes: 2 additions & 7 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,8 @@ cfg_if! {

// link.h

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
extern_ty! {
pub enum timezone {}
}

impl siginfo_t {
Expand Down
18 changes: 3 additions & 15 deletions src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,9 @@ pub type id_t = u32;
pub type sem_t = *mut sem;
pub type key_t = c_long;

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
}
#[derive(Debug)]
pub enum sem {}
impl Copy for sem {}
impl Clone for sem {
fn clone(&self) -> sem {
*self
}
extern_ty! {
pub enum timezone {}
pub enum sem {}
}

s! {
Expand Down
18 changes: 4 additions & 14 deletions src/unix/cygwin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ pub type nlink_t = c_ushort;
pub type suseconds_t = c_long;
pub type useconds_t = c_ulong;

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
extern_ty! {
pub enum timezone {}
}

pub type sigset_t = c_ulong;
Expand Down Expand Up @@ -75,13 +70,8 @@ pub type nfds_t = c_uint;

pub type sem_t = *mut sem;

#[derive(Debug)]
pub enum sem {}
impl Copy for sem {}
impl Clone for sem {
fn clone(&self) -> sem {
*self
}
extern_ty! {
pub enum sem {}
}

pub type tcflag_t = c_uint;
Expand Down
9 changes: 2 additions & 7 deletions src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,8 @@ pub type ACTION = c_int;
pub type posix_spawnattr_t = *mut c_void;
pub type posix_spawn_file_actions_t = *mut c_void;

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
extern_ty! {
pub enum timezone {}
}

impl siginfo_t {
Expand Down
19 changes: 3 additions & 16 deletions src/unix/hurd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,22 +225,9 @@ pub type nl_item = c_int;

pub type iconv_t = *mut c_void;

#[derive(Debug)]
pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct
impl Copy for fpos64_t {}
impl Clone for fpos64_t {
fn clone(&self) -> fpos64_t {
*self
}
}

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
extern_ty! {
pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct
pub enum timezone {}
}

// structs
Expand Down
9 changes: 2 additions & 7 deletions src/unix/linux_like/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@ pub type statfs64 = crate::statfs;
pub type statvfs64 = crate::statvfs;
pub type dirent64 = crate::dirent;

#[derive(Debug)]
pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct
impl Copy for fpos64_t {}
impl Clone for fpos64_t {
fn clone(&self) -> fpos64_t {
*self
}
extern_ty! {
pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct
}

s! {
Expand Down
3 changes: 1 addition & 2 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ pub type eventfd_t = u64;

cfg_if! {
if #[cfg(not(target_env = "gnu"))] {
missing! {
#[derive(Debug)]
extern_ty! {
pub enum fpos64_t {} // FIXME(linux): fill this out with a struct
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ pub type timer_t = *mut c_void;
pub type key_t = c_int;
pub type id_t = c_uint;

missing! {
#[derive(Debug)]
extern_ty! {
pub enum timezone {}
}

Expand Down
9 changes: 3 additions & 6 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ cfg_if! {
}
}

missing! {
#[derive(Debug)]
extern_ty! {
pub enum DIR {}
}
pub type locale_t = *mut c_void;
Expand Down Expand Up @@ -585,15 +584,13 @@ cfg_if! {

cfg_if! {
if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] {
missing! {
#[derive(Debug)]
extern_ty! {
pub enum fpos_t {} // FIXME(unix): fill this out with a struct
}
}
}

missing! {
#[derive(Debug)]
extern_ty! {
pub enum FILE {}
}

Expand Down
9 changes: 2 additions & 7 deletions src/unix/nto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,8 @@ pub type sem_t = sync_t;

pub type nl_item = c_int;

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
extern_ty! {
pub enum timezone {}
}

s! {
Expand Down
9 changes: 2 additions & 7 deletions src/unix/redox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ pub type pid_t = usize;
pub type uid_t = c_int;
pub type gid_t = c_int;

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
extern_ty! {
pub enum timezone {}
}

s_no_extra_traits! {
Expand Down
19 changes: 3 additions & 16 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,9 @@ pub type lgrp_view_t = c_uint;
pub type posix_spawnattr_t = *mut c_void;
pub type posix_spawn_file_actions_t = *mut c_void;

#[derive(Debug)]
pub enum timezone {}
impl Copy for timezone {}
impl Clone for timezone {
fn clone(&self) -> timezone {
*self
}
}

#[derive(Debug)]
pub enum ucred_t {}
impl Copy for ucred_t {}
impl Clone for ucred_t {
fn clone(&self) -> ucred_t {
*self
}
extern_ty! {
pub enum timezone {}
pub enum ucred_t {}
}

s! {
Expand Down
Loading
Loading