Skip to content

Commit 389fef3

Browse files
committed
Replace Void with never type
1 parent 6265286 commit 389fef3

File tree

18 files changed

+44
-60
lines changed

18 files changed

+44
-60
lines changed

library/std/src/sys/hermit/fs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::sys::hermit::abi;
99
use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
1010
use crate::sys::hermit::fd::FileDesc;
1111
use crate::sys::time::SystemTime;
12-
use crate::sys::{unsupported, Void};
12+
use crate::sys::unsupported;
1313
use crate::sys_common::os_str_bytes::OsStrExt;
1414

1515
pub use crate::sys_common::fs::copy;
@@ -22,11 +22,11 @@ fn cstr(path: &Path) -> io::Result<CString> {
2222
#[derive(Debug)]
2323
pub struct File(FileDesc);
2424

25-
pub struct FileAttr(Void);
25+
pub struct FileAttr(!);
2626

27-
pub struct ReadDir(Void);
27+
pub struct ReadDir(!);
2828

29-
pub struct DirEntry(Void);
29+
pub struct DirEntry(!);
3030

3131
#[derive(Clone, Debug)]
3232
pub struct OpenOptions {
@@ -41,9 +41,9 @@ pub struct OpenOptions {
4141
mode: i32,
4242
}
4343

44-
pub struct FilePermissions(Void);
44+
pub struct FilePermissions(!);
4545

46-
pub struct FileType(Void);
46+
pub struct FileType(!);
4747

4848
#[derive(Debug)]
4949
pub struct DirBuilder {}

library/std/src/sys/hermit/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ pub fn unsupported_err() -> crate::io::Error {
6161
)
6262
}
6363

64-
// This enum is used as the storage for a bunch of types which can't actually
65-
// exist.
66-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
67-
pub enum Void {}
68-
6964
pub unsafe fn strlen(start: *const c_char) -> usize {
7065
let mut str = start;
7166

library/std/src/sys/hermit/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::str;
66
use crate::sync::Arc;
77
use crate::sys::hermit::abi;
88
use crate::sys::hermit::abi::IpAddress::{Ipv4, Ipv6};
9-
use crate::sys::{unsupported, Void};
9+
use crate::sys::unsupported;
1010
use crate::sys_common::AsInner;
1111
use crate::time::Duration;
1212

@@ -411,7 +411,7 @@ impl fmt::Debug for UdpSocket {
411411
}
412412
}
413413

414-
pub struct LookupHost(Void);
414+
pub struct LookupHost(!);
415415

416416
impl LookupHost {
417417
pub fn port(&self) -> u16 {

library/std/src/sys/hermit/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::path::{self, PathBuf};
99
use crate::str;
1010
use crate::sync::Mutex;
1111
use crate::sys::hermit::abi;
12-
use crate::sys::{unsupported, Void};
12+
use crate::sys::unsupported;
1313
use crate::sys_common::os_str_bytes::*;
1414
use crate::vec;
1515

@@ -29,7 +29,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> {
2929
unsupported()
3030
}
3131

32-
pub struct SplitPaths<'a>(&'a Void);
32+
pub struct SplitPaths<'a>(&'a !);
3333

3434
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
3535
panic!("unsupported")

library/std/src/sys/sgx/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ pub fn decode_error_kind(code: i32) -> ErrorKind {
115115
}
116116
}
117117

118-
// This enum is used as the storage for a bunch of types which can't actually
119-
// exist.
120-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
121-
pub enum Void {}
122-
123118
pub unsafe fn strlen(mut s: *const c_char) -> usize {
124119
let mut n = 0;
125120
while unsafe { *s } != 0 {

library/std/src/sys/sgx/net.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::io::{self, IoSlice, IoSliceMut};
55
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs};
66
use crate::sync::Arc;
77
use crate::sys::fd::FileDesc;
8-
use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner, Void};
8+
use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner};
99
use crate::time::Duration;
1010

1111
use super::abi::usercalls;
@@ -310,7 +310,7 @@ impl FromInner<Socket> for TcpListener {
310310
}
311311
}
312312

313-
pub struct UdpSocket(Void);
313+
pub struct UdpSocket(!);
314314

315315
impl UdpSocket {
316316
pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
@@ -462,7 +462,7 @@ impl fmt::Display for NonIpSockAddr {
462462
}
463463
}
464464

465-
pub struct LookupHost(Void);
465+
pub struct LookupHost(!);
466466

467467
impl LookupHost {
468468
fn new(host: String) -> io::Result<LookupHost> {

library/std/src/sys/sgx/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::str;
1010
use crate::sync::atomic::{AtomicUsize, Ordering};
1111
use crate::sync::Mutex;
1212
use crate::sync::Once;
13-
use crate::sys::{decode_error_kind, sgx_ineffective, unsupported, Void};
13+
use crate::sys::{decode_error_kind, sgx_ineffective, unsupported};
1414
use crate::vec;
1515

1616
pub fn errno() -> i32 {
@@ -35,7 +35,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> {
3535
sgx_ineffective(())
3636
}
3737

38-
pub struct SplitPaths<'a>(&'a Void);
38+
pub struct SplitPaths<'a>(&'a !);
3939

4040
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
4141
panic!("unsupported")

library/std/src/sys/unsupported/common.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
3636
(1, 2)
3737
}
3838

39-
// This enum is used as the storage for a bunch of types which can't actually
40-
// exist.
41-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
42-
pub enum Void {}
43-
4439
pub unsafe fn strlen(mut s: *const c_char) -> usize {
4540
// SAFETY: The caller must guarantee `s` points to a valid 0-terminated string.
4641
unsafe {

library/std/src/sys/unsupported/fs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ use crate::hash::{Hash, Hasher};
44
use crate::io::{self, IoSlice, IoSliceMut, SeekFrom};
55
use crate::path::{Path, PathBuf};
66
use crate::sys::time::SystemTime;
7-
use crate::sys::{unsupported, Void};
7+
use crate::sys::unsupported;
88

9-
pub struct File(Void);
9+
pub struct File(!);
1010

11-
pub struct FileAttr(Void);
11+
pub struct FileAttr(!);
1212

13-
pub struct ReadDir(Void);
13+
pub struct ReadDir(!);
1414

15-
pub struct DirEntry(Void);
15+
pub struct DirEntry(!);
1616

1717
#[derive(Clone, Debug)]
1818
pub struct OpenOptions {}
1919

20-
pub struct FilePermissions(Void);
20+
pub struct FilePermissions(!);
2121

22-
pub struct FileType(Void);
22+
pub struct FileType(!);
2323

2424
#[derive(Debug)]
2525
pub struct DirBuilder {}

library/std/src/sys/unsupported/net.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use crate::convert::TryFrom;
22
use crate::fmt;
33
use crate::io::{self, IoSlice, IoSliceMut};
44
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
5-
use crate::sys::{unsupported, Void};
5+
use crate::sys::unsupported;
66
use crate::time::Duration;
77

8-
pub struct TcpStream(Void);
8+
pub struct TcpStream(!);
99

1010
impl TcpStream {
1111
pub fn connect(_: io::Result<&SocketAddr>) -> io::Result<TcpStream> {
@@ -107,7 +107,7 @@ impl fmt::Debug for TcpStream {
107107
}
108108
}
109109

110-
pub struct TcpListener(Void);
110+
pub struct TcpListener(!);
111111

112112
impl TcpListener {
113113
pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
@@ -157,7 +157,7 @@ impl fmt::Debug for TcpListener {
157157
}
158158
}
159159

160-
pub struct UdpSocket(Void);
160+
pub struct UdpSocket(!);
161161

162162
impl UdpSocket {
163163
pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
@@ -291,7 +291,7 @@ impl fmt::Debug for UdpSocket {
291291
}
292292
}
293293

294-
pub struct LookupHost(Void);
294+
pub struct LookupHost(!);
295295

296296
impl LookupHost {
297297
pub fn port(&self) -> u16 {

library/std/src/sys/unsupported/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{unsupported, Void};
1+
use super::unsupported;
22
use crate::error::Error as StdError;
33
use crate::ffi::{OsStr, OsString};
44
use crate::fmt;
@@ -21,7 +21,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> {
2121
unsupported()
2222
}
2323

24-
pub struct SplitPaths<'a>(&'a Void);
24+
pub struct SplitPaths<'a>(&'a !);
2525

2626
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
2727
panic!("unsupported")
@@ -62,7 +62,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
6262
unsupported()
6363
}
6464

65-
pub struct Env(Void);
65+
pub struct Env(!);
6666

6767
impl Iterator for Env {
6868
type Item = (OsString, OsString);

library/std/src/sys/unsupported/pipe.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::io::{self, IoSlice, IoSliceMut};
2-
use crate::sys::Void;
32

4-
pub struct AnonPipe(Void);
3+
pub struct AnonPipe(!);
54

65
impl AnonPipe {
76
pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {

library/std/src/sys/unsupported/process.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::marker::PhantomData;
55
use crate::path::Path;
66
use crate::sys::fs::File;
77
use crate::sys::pipe::AnonPipe;
8-
use crate::sys::{unsupported, Void};
8+
use crate::sys::unsupported;
99
use crate::sys_common::process::{CommandEnv, CommandEnvs};
1010

1111
pub use crate::ffi::OsString as EnvKey;
@@ -94,7 +94,7 @@ impl fmt::Debug for Command {
9494
}
9595
}
9696

97-
pub struct ExitStatus(Void);
97+
pub struct ExitStatus(!);
9898

9999
impl ExitStatus {
100100
pub fn success(&self) -> bool {
@@ -146,7 +146,7 @@ impl ExitCode {
146146
}
147147
}
148148

149-
pub struct Process(Void);
149+
pub struct Process(!);
150150

151151
impl Process {
152152
pub fn id(&self) -> u32 {

library/std/src/sys/unsupported/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use super::{unsupported, Void};
1+
use super::unsupported;
22
use crate::ffi::CStr;
33
use crate::io;
44
use crate::time::Duration;
55

6-
pub struct Thread(Void);
6+
pub struct Thread(!);
77

88
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
99

library/std/src/sys/wasi/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::convert::TryFrom;
55
use crate::fmt;
66
use crate::io::{self, IoSlice, IoSliceMut};
77
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
8-
use crate::sys::{unsupported, Void};
8+
use crate::sys::unsupported;
99
use crate::sys_common::FromInner;
1010
use crate::time::Duration;
1111

@@ -343,7 +343,7 @@ impl fmt::Debug for UdpSocket {
343343
}
344344
}
345345

346-
pub struct LookupHost(Void);
346+
pub struct LookupHost(!);
347347

348348
impl LookupHost {
349349
pub fn port(&self) -> u16 {

library/std/src/sys/wasi/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::os::wasi::prelude::*;
1010
use crate::path::{self, PathBuf};
1111
use crate::str;
1212
use crate::sys::memchr;
13-
use crate::sys::{unsupported, Void};
13+
use crate::sys::unsupported;
1414
use crate::vec;
1515

1616
// Add a few symbols not in upstream `libc` just yet.
@@ -87,7 +87,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> {
8787
}
8888
}
8989

90-
pub struct SplitPaths<'a>(&'a Void);
90+
pub struct SplitPaths<'a>(&'a !);
9191

9292
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
9393
panic!("unsupported")

library/std/src/sys/wasi/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
use crate::ffi::CStr;
44
use crate::io;
55
use crate::mem;
6-
use crate::sys::{unsupported, Void};
6+
use crate::sys::unsupported;
77
use crate::time::Duration;
88

9-
pub struct Thread(Void);
9+
pub struct Thread(!);
1010

1111
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
1212

library/std/src/sys/wasm/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::ffi::CStr;
22
use crate::io;
3-
use crate::sys::{unsupported, Void};
3+
use crate::sys::unsupported;
44
use crate::time::Duration;
55

6-
pub struct Thread(Void);
6+
pub struct Thread(!);
77

88
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
99

0 commit comments

Comments
 (0)