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

Replace Void in sys with never type #84212

Merged
merged 2 commits into from
Apr 22, 2021
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
62 changes: 31 additions & 31 deletions library/std/src/sys/hermit/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -41,146 +41,146 @@ pub struct OpenOptions {
mode: i32,
}

pub struct FilePermissions(Void);
pub struct FilePermissions(!);

pub struct FileType(Void);
pub struct FileType(!);

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

impl FileAttr {
pub fn size(&self) -> u64 {
match self.0 {}
self.0
}

pub fn perm(&self) -> FilePermissions {
match self.0 {}
self.0
}

pub fn file_type(&self) -> FileType {
match self.0 {}
self.0
}

pub fn modified(&self) -> io::Result<SystemTime> {
match self.0 {}
self.0
}

pub fn accessed(&self) -> io::Result<SystemTime> {
match self.0 {}
self.0
}

pub fn created(&self) -> io::Result<SystemTime> {
match self.0 {}
self.0
}
}

impl Clone for FileAttr {
fn clone(&self) -> FileAttr {
match self.0 {}
self.0
}
}

impl FilePermissions {
pub fn readonly(&self) -> bool {
match self.0 {}
self.0
}

pub fn set_readonly(&mut self, _readonly: bool) {
match self.0 {}
self.0
}
}

impl Clone for FilePermissions {
fn clone(&self) -> FilePermissions {
match self.0 {}
self.0
}
}

impl PartialEq for FilePermissions {
fn eq(&self, _other: &FilePermissions) -> bool {
match self.0 {}
self.0
}
}

impl Eq for FilePermissions {}

impl fmt::Debug for FilePermissions {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
self.0
}
}

impl FileType {
pub fn is_dir(&self) -> bool {
match self.0 {}
self.0
}

pub fn is_file(&self) -> bool {
match self.0 {}
self.0
}

pub fn is_symlink(&self) -> bool {
match self.0 {}
self.0
}
}

impl Clone for FileType {
fn clone(&self) -> FileType {
match self.0 {}
self.0
}
}

impl Copy for FileType {}

impl PartialEq for FileType {
fn eq(&self, _other: &FileType) -> bool {
match self.0 {}
self.0
}
}

impl Eq for FileType {}

impl Hash for FileType {
fn hash<H: Hasher>(&self, _h: &mut H) {
match self.0 {}
self.0
}
}

impl fmt::Debug for FileType {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
self.0
}
}

impl fmt::Debug for ReadDir {
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {}
self.0
}
}

impl Iterator for ReadDir {
type Item = io::Result<DirEntry>;

fn next(&mut self) -> Option<io::Result<DirEntry>> {
match self.0 {}
self.0
}
}

impl DirEntry {
pub fn path(&self) -> PathBuf {
match self.0 {}
self.0
}

pub fn file_name(&self) -> OsString {
match self.0 {}
self.0
}

pub fn metadata(&self) -> io::Result<FileAttr> {
match self.0 {}
self.0
}

pub fn file_type(&self) -> io::Result<FileType> {
match self.0 {}
self.0
}
}

Expand Down
5 changes: 0 additions & 5 deletions library/std/src/sys/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions library/std/src/sys/hermit/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -411,18 +411,18 @@ impl fmt::Debug for UdpSocket {
}
}

pub struct LookupHost(Void);
pub struct LookupHost(!);

impl LookupHost {
pub fn port(&self) -> u16 {
match self.0 {}
self.0
}
}

impl Iterator for LookupHost {
type Item = SocketAddr;
fn next(&mut self) -> Option<SocketAddr> {
match self.0 {}
self.0
}
}

Expand Down
6 changes: 3 additions & 3 deletions library/std/src/sys/hermit/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

pub struct SplitPaths<'a>(&'a Void);
pub struct SplitPaths<'a>(!, PhantomData<&'a ()>);

pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
panic!("unsupported")
Expand All @@ -38,7 +38,7 @@ pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> {
impl<'a> Iterator for SplitPaths<'a> {
type Item = PathBuf;
fn next(&mut self) -> Option<PathBuf> {
match *self.0 {}
self.0
}
}

Expand Down
5 changes: 0 additions & 5 deletions library/std/src/sys/sgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading