Skip to content

Commit 143b5ce

Browse files
committed
Rename missing! to extern_ty!
Really what we are indicating with this macro invocation is that we need a type that can be specified behind indirection but never used directly, which is an extern type. Using an uninhabited enum gets us most of the way there and is about the best we can do for now. (backport <#4759>) (cherry picked from commit fe5ecb8)
1 parent f060e8f commit 143b5ce

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

src/macros.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,20 @@ macro_rules! s_no_extra_traits {
203203
);
204204
}
205205

206-
/// Specify that an enum should have no traits that aren't specified in the macro
207-
/// invocation, i.e. no `Clone` or `Copy`.
208-
macro_rules! missing {
206+
/// Create an uninhabited type that can't be constructed. It implements `Debug` but no
207+
/// other traits.
208+
///
209+
/// Really what we want here is something that also can't be named without indirection (in
210+
/// ADTs or function signatures), but this doesn't exist.
211+
macro_rules! extern_ty {
209212
($(
210213
$(#[$attr:meta])*
211214
pub enum $i:ident {}
212215
)*) => ($(
213216
$(#[$attr])*
214217
#[allow(missing_copy_implementations)]
218+
// FIXME(1.0): the type is uninhabited so this trait is unreachable.
219+
#[::core::prelude::v1::derive(::core::fmt::Debug)]
215220
pub enum $i { }
216221
)*);
217222
}

src/unix/aix/powerpc64.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::off_t;
22
use crate::prelude::*;
33

44
// Define lock_data_instrumented as an empty enum
5-
missing! {
6-
#[derive(Debug)]
5+
extern_ty! {
76
pub enum lock_data_instrumented {}
87
}
98

src/unix/linux_like/linux/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ pub type eventfd_t = u64;
6767

6868
cfg_if! {
6969
if #[cfg(not(target_env = "gnu"))] {
70-
missing! {
71-
#[derive(Debug)]
70+
extern_ty! {
7271
pub enum fpos64_t {} // FIXME(linux): fill this out with a struct
7372
}
7473
}

src/unix/linux_like/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ pub type timer_t = *mut c_void;
88
pub type key_t = c_int;
99
pub type id_t = c_uint;
1010

11-
missing! {
12-
#[derive(Debug)]
11+
extern_ty! {
1312
pub enum timezone {}
1413
}
1514

src/unix/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ cfg_if! {
3737
}
3838
}
3939

40-
missing! {
41-
#[derive(Debug)]
40+
extern_ty! {
4241
pub enum DIR {}
4342
}
4443
pub type locale_t = *mut c_void;
@@ -567,15 +566,13 @@ cfg_if! {
567566

568567
cfg_if! {
569568
if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] {
570-
missing! {
571-
#[derive(Debug)]
569+
extern_ty! {
572570
pub enum fpos_t {} // FIXME(unix): fill this out with a struct
573571
}
574572
}
575573
}
576574

577-
missing! {
578-
#[derive(Debug)]
575+
extern_ty! {
579576
pub enum FILE {}
580577
}
581578

0 commit comments

Comments
 (0)