Replace Void with never type

This commit is contained in:
Christiaan Dirkx 2021-04-14 02:37:36 +02:00
parent 62652865b6
commit 389fef3b30
18 changed files with 44 additions and 60 deletions

View file

@ -9,7 +9,7 @@ use crate::sys::hermit::abi;
use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
use crate::sys::hermit::fd::FileDesc;
use crate::sys::time::SystemTime;
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::sys_common::os_str_bytes::OsStrExt;
pub use crate::sys_common::fs::copy;
@ -22,11 +22,11 @@ fn cstr(path: &Path) -> io::Result<CString> {
#[derive(Debug)]
pub struct File(FileDesc);
pub struct FileAttr(Void);
pub struct FileAttr(!);
pub struct ReadDir(Void);
pub struct ReadDir(!);
pub struct DirEntry(Void);
pub struct DirEntry(!);
#[derive(Clone, Debug)]
pub struct OpenOptions {
@ -41,9 +41,9 @@ pub struct OpenOptions {
mode: i32,
}
pub struct FilePermissions(Void);
pub struct FilePermissions(!);
pub struct FileType(Void);
pub struct FileType(!);
#[derive(Debug)]
pub struct DirBuilder {}

View file

@ -61,11 +61,6 @@ pub fn unsupported_err() -> crate::io::Error {
)
}
// This enum is used as the storage for a bunch of types which can't actually
// exist.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub enum Void {}
pub unsafe fn strlen(start: *const c_char) -> usize {
let mut str = start;

View file

@ -6,7 +6,7 @@ use crate::str;
use crate::sync::Arc;
use crate::sys::hermit::abi;
use crate::sys::hermit::abi::IpAddress::{Ipv4, Ipv6};
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::sys_common::AsInner;
use crate::time::Duration;
@ -411,7 +411,7 @@ impl fmt::Debug for UdpSocket {
}
}
pub struct LookupHost(Void);
pub struct LookupHost(!);
impl LookupHost {
pub fn port(&self) -> u16 {

View file

@ -9,7 +9,7 @@ use crate::path::{self, PathBuf};
use crate::str;
use crate::sync::Mutex;
use crate::sys::hermit::abi;
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::sys_common::os_str_bytes::*;
use crate::vec;
@ -29,7 +29,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> {
unsupported()
}
pub struct SplitPaths<'a>(&'a Void);
pub struct SplitPaths<'a>(&'a !);
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
panic!("unsupported")

View file

@ -115,11 +115,6 @@ pub fn decode_error_kind(code: i32) -> ErrorKind {
}
}
// This enum is used as the storage for a bunch of types which can't actually
// exist.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub enum Void {}
pub unsafe fn strlen(mut s: *const c_char) -> usize {
let mut n = 0;
while unsafe { *s } != 0 {

View file

@ -5,7 +5,7 @@ use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs};
use crate::sync::Arc;
use crate::sys::fd::FileDesc;
use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner, Void};
use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner};
use crate::time::Duration;
use super::abi::usercalls;
@ -310,7 +310,7 @@ impl FromInner<Socket> for TcpListener {
}
}
pub struct UdpSocket(Void);
pub struct UdpSocket(!);
impl UdpSocket {
pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
@ -462,7 +462,7 @@ impl fmt::Display for NonIpSockAddr {
}
}
pub struct LookupHost(Void);
pub struct LookupHost(!);
impl LookupHost {
fn new(host: String) -> io::Result<LookupHost> {

View file

@ -10,7 +10,7 @@ use crate::str;
use crate::sync::atomic::{AtomicUsize, Ordering};
use crate::sync::Mutex;
use crate::sync::Once;
use crate::sys::{decode_error_kind, sgx_ineffective, unsupported, Void};
use crate::sys::{decode_error_kind, sgx_ineffective, unsupported};
use crate::vec;
pub fn errno() -> i32 {
@ -35,7 +35,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> {
sgx_ineffective(())
}
pub struct SplitPaths<'a>(&'a Void);
pub struct SplitPaths<'a>(&'a !);
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
panic!("unsupported")

View file

@ -36,11 +36,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
(1, 2)
}
// This enum is used as the storage for a bunch of types which can't actually
// exist.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub enum Void {}
pub unsafe fn strlen(mut s: *const c_char) -> usize {
// SAFETY: The caller must guarantee `s` points to a valid 0-terminated string.
unsafe {

View file

@ -4,22 +4,22 @@ use crate::hash::{Hash, Hasher};
use crate::io::{self, IoSlice, IoSliceMut, SeekFrom};
use crate::path::{Path, PathBuf};
use crate::sys::time::SystemTime;
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
pub struct File(Void);
pub struct File(!);
pub struct FileAttr(Void);
pub struct FileAttr(!);
pub struct ReadDir(Void);
pub struct ReadDir(!);
pub struct DirEntry(Void);
pub struct DirEntry(!);
#[derive(Clone, Debug)]
pub struct OpenOptions {}
pub struct FilePermissions(Void);
pub struct FilePermissions(!);
pub struct FileType(Void);
pub struct FileType(!);
#[derive(Debug)]
pub struct DirBuilder {}

View file

@ -2,10 +2,10 @@ use crate::convert::TryFrom;
use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::time::Duration;
pub struct TcpStream(Void);
pub struct TcpStream(!);
impl TcpStream {
pub fn connect(_: io::Result<&SocketAddr>) -> io::Result<TcpStream> {
@ -107,7 +107,7 @@ impl fmt::Debug for TcpStream {
}
}
pub struct TcpListener(Void);
pub struct TcpListener(!);
impl TcpListener {
pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> {
@ -157,7 +157,7 @@ impl fmt::Debug for TcpListener {
}
}
pub struct UdpSocket(Void);
pub struct UdpSocket(!);
impl UdpSocket {
pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> {
@ -291,7 +291,7 @@ impl fmt::Debug for UdpSocket {
}
}
pub struct LookupHost(Void);
pub struct LookupHost(!);
impl LookupHost {
pub fn port(&self) -> u16 {

View file

@ -1,4 +1,4 @@
use super::{unsupported, Void};
use super::unsupported;
use crate::error::Error as StdError;
use crate::ffi::{OsStr, OsString};
use crate::fmt;
@ -21,7 +21,7 @@ pub fn chdir(_: &path::Path) -> io::Result<()> {
unsupported()
}
pub struct SplitPaths<'a>(&'a Void);
pub struct SplitPaths<'a>(&'a !);
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
panic!("unsupported")
@ -62,7 +62,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
unsupported()
}
pub struct Env(Void);
pub struct Env(!);
impl Iterator for Env {
type Item = (OsString, OsString);

View file

@ -1,7 +1,6 @@
use crate::io::{self, IoSlice, IoSliceMut};
use crate::sys::Void;
pub struct AnonPipe(Void);
pub struct AnonPipe(!);
impl AnonPipe {
pub fn read(&self, _buf: &mut [u8]) -> io::Result<usize> {

View file

@ -5,7 +5,7 @@ use crate::marker::PhantomData;
use crate::path::Path;
use crate::sys::fs::File;
use crate::sys::pipe::AnonPipe;
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::sys_common::process::{CommandEnv, CommandEnvs};
pub use crate::ffi::OsString as EnvKey;
@ -94,7 +94,7 @@ impl fmt::Debug for Command {
}
}
pub struct ExitStatus(Void);
pub struct ExitStatus(!);
impl ExitStatus {
pub fn success(&self) -> bool {
@ -146,7 +146,7 @@ impl ExitCode {
}
}
pub struct Process(Void);
pub struct Process(!);
impl Process {
pub fn id(&self) -> u32 {

View file

@ -1,9 +1,9 @@
use super::{unsupported, Void};
use super::unsupported;
use crate::ffi::CStr;
use crate::io;
use crate::time::Duration;
pub struct Thread(Void);
pub struct Thread(!);
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;

View file

@ -5,7 +5,7 @@ use crate::convert::TryFrom;
use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::sys_common::FromInner;
use crate::time::Duration;
@ -343,7 +343,7 @@ impl fmt::Debug for UdpSocket {
}
}
pub struct LookupHost(Void);
pub struct LookupHost(!);
impl LookupHost {
pub fn port(&self) -> u16 {

View file

@ -10,7 +10,7 @@ use crate::os::wasi::prelude::*;
use crate::path::{self, PathBuf};
use crate::str;
use crate::sys::memchr;
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::vec;
// Add a few symbols not in upstream `libc` just yet.
@ -87,7 +87,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> {
}
}
pub struct SplitPaths<'a>(&'a Void);
pub struct SplitPaths<'a>(&'a !);
pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
panic!("unsupported")

View file

@ -3,10 +3,10 @@
use crate::ffi::CStr;
use crate::io;
use crate::mem;
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::time::Duration;
pub struct Thread(Void);
pub struct Thread(!);
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;

View file

@ -1,9 +1,9 @@
use crate::ffi::CStr;
use crate::io;
use crate::sys::{unsupported, Void};
use crate::sys::unsupported;
use crate::time::Duration;
pub struct Thread(Void);
pub struct Thread(!);
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;