Remove raw_os_nonzero feature.

This commit is contained in:
Markus Reiter 2024-01-24 03:19:51 +01:00
parent fb4bca04fa
commit bf4de3a874
No known key found for this signature in database
GPG Key ID: 245293B51702655B
7 changed files with 26 additions and 67 deletions

View File

@ -11,7 +11,6 @@
use crate::fmt; use crate::fmt;
use crate::marker::PhantomData; use crate::marker::PhantomData;
use crate::num::*;
use crate::ops::{Deref, DerefMut}; use crate::ops::{Deref, DerefMut};
#[stable(feature = "core_c_str", since = "1.64.0")] #[stable(feature = "core_c_str", since = "1.64.0")]
@ -19,7 +18,7 @@ pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
mod c_str; mod c_str;
macro_rules! type_alias_no_nz { macro_rules! type_alias {
{ {
$Docfile:tt, $Alias:ident = $Real:ty; $Docfile:tt, $Alias:ident = $Real:ty;
$( $Cfg:tt )* $( $Cfg:tt )*
@ -31,49 +30,24 @@ macro_rules! type_alias_no_nz {
} }
} }
// To verify that the NonZero types in this file's macro invocations correspond type_alias! { "c_char.md", c_char = c_char_definition::c_char; #[doc(cfg(all()))] }
//
// perl -n < library/std/src/os/raw/mod.rs -e 'next unless m/type_alias\!/; die "$_ ?" unless m/, (c_\w+) = (\w+), NonZero_(\w+) = NonZero(\w+)/; die "$_ ?" unless $3 eq $1 and $4 eq ucfirst $2'
//
// NB this does not check that the main c_* types are right.
macro_rules! type_alias { type_alias! { "c_schar.md", c_schar = i8; }
{ type_alias! { "c_uchar.md", c_uchar = u8; }
$Docfile:tt, $Alias:ident = $Real:ty, $NZAlias:ident = $NZReal:ty; type_alias! { "c_short.md", c_short = i16; }
$( $Cfg:tt )* type_alias! { "c_ushort.md", c_ushort = u16; }
} => {
type_alias_no_nz! { $Docfile, $Alias = $Real; $( $Cfg )* }
#[doc = concat!("Type alias for `NonZero` version of [`", stringify!($Alias), "`]")] type_alias! { "c_int.md", c_int = c_int_definition::c_int; #[doc(cfg(all()))] }
#[unstable(feature = "raw_os_nonzero", issue = "82363")] type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint; #[doc(cfg(all()))] }
$( $Cfg )*
pub type $NZAlias = $NZReal;
}
}
type_alias! { "c_char.md", c_char = c_char_definition::c_char, NonZero_c_char = c_char_definition::NonZero_c_char; type_alias! { "c_long.md", c_long = c_long_definition::c_long; #[doc(cfg(all()))] }
#[doc(cfg(all()))] } type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong; #[doc(cfg(all()))] }
type_alias! { "c_schar.md", c_schar = i8, NonZero_c_schar = NonZeroI8; } type_alias! { "c_longlong.md", c_longlong = i64; }
type_alias! { "c_uchar.md", c_uchar = u8, NonZero_c_uchar = NonZeroU8; } type_alias! { "c_ulonglong.md", c_ulonglong = u64; }
type_alias! { "c_short.md", c_short = i16, NonZero_c_short = NonZeroI16; }
type_alias! { "c_ushort.md", c_ushort = u16, NonZero_c_ushort = NonZeroU16; }
type_alias! { "c_int.md", c_int = c_int_definition::c_int, NonZero_c_int = c_int_definition::NonZero_c_int; type_alias! { "c_float.md", c_float = f32; }
#[doc(cfg(all()))] } type_alias! { "c_double.md", c_double = f64; }
type_alias! { "c_uint.md", c_uint = c_int_definition::c_uint, NonZero_c_uint = c_int_definition::NonZero_c_uint;
#[doc(cfg(all()))] }
type_alias! { "c_long.md", c_long = c_long_definition::c_long, NonZero_c_long = c_long_definition::NonZero_c_long;
#[doc(cfg(all()))] }
type_alias! { "c_ulong.md", c_ulong = c_long_definition::c_ulong, NonZero_c_ulong = c_long_definition::NonZero_c_ulong;
#[doc(cfg(all()))] }
type_alias! { "c_longlong.md", c_longlong = i64, NonZero_c_longlong = NonZeroI64; }
type_alias! { "c_ulonglong.md", c_ulonglong = u64, NonZero_c_ulonglong = NonZeroU64; }
type_alias_no_nz! { "c_float.md", c_float = f32; }
type_alias_no_nz! { "c_double.md", c_double = f64; }
/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++). /// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++).
/// ///
@ -152,11 +126,9 @@ mod c_char_definition {
target_os = "horizon" target_os = "horizon"
))] { ))] {
pub type c_char = u8; pub type c_char = u8;
pub type NonZero_c_char = crate::num::NonZeroU8;
} else { } else {
// On every other target, c_char is signed. // On every other target, c_char is signed.
pub type c_char = i8; pub type c_char = i8;
pub type NonZero_c_char = crate::num::NonZeroI8;
} }
} }
} }
@ -165,14 +137,10 @@ mod c_int_definition {
cfg_if! { cfg_if! {
if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] { if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] {
pub type c_int = i16; pub type c_int = i16;
pub type NonZero_c_int = crate::num::NonZeroI16;
pub type c_uint = u16; pub type c_uint = u16;
pub type NonZero_c_uint = crate::num::NonZeroU16;
} else { } else {
pub type c_int = i32; pub type c_int = i32;
pub type NonZero_c_int = crate::num::NonZeroI32;
pub type c_uint = u32; pub type c_uint = u32;
pub type NonZero_c_uint = crate::num::NonZeroU32;
} }
} }
} }
@ -181,15 +149,11 @@ mod c_long_definition {
cfg_if! { cfg_if! {
if #[cfg(all(target_pointer_width = "64", not(windows)))] { if #[cfg(all(target_pointer_width = "64", not(windows)))] {
pub type c_long = i64; pub type c_long = i64;
pub type NonZero_c_long = crate::num::NonZeroI64;
pub type c_ulong = u64; pub type c_ulong = u64;
pub type NonZero_c_ulong = crate::num::NonZeroU64;
} else { } else {
// The minimal size of `long` in the C standard is 32 bits // The minimal size of `long` in the C standard is 32 bits
pub type c_long = i32; pub type c_long = i32;
pub type NonZero_c_long = crate::num::NonZeroI32;
pub type c_ulong = u32; pub type c_ulong = u32;
pub type NonZero_c_ulong = crate::num::NonZeroU32;
} }
} }
} }

View File

@ -338,7 +338,6 @@
#![feature(portable_simd)] #![feature(portable_simd)]
#![feature(prelude_2024)] #![feature(prelude_2024)]
#![feature(ptr_as_uninit)] #![feature(ptr_as_uninit)]
#![feature(raw_os_nonzero)]
#![feature(slice_internals)] #![feature(slice_internals)]
#![feature(slice_ptr_get)] #![feature(slice_ptr_get)]
#![feature(slice_range)] #![feature(slice_range)]

View File

@ -1,11 +1,10 @@
use crate::fmt; use crate::fmt;
use crate::io::{self, Error, ErrorKind}; use crate::io::{self, Error, ErrorKind};
use crate::mem; use crate::mem;
use crate::num::NonZeroI32; use crate::num::{NonZero, NonZeroI32};
use crate::sys; use crate::sys;
use crate::sys::cvt; use crate::sys::cvt;
use crate::sys::process::process_common::*; use crate::sys::process::process_common::*;
use core::ffi::NonZero_c_int;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use crate::os::linux::process::PidFd; use crate::os::linux::process::PidFd;
@ -935,7 +934,7 @@ impl ExitStatus {
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not
// true for a platform pretending to be Unix, the tests (our doctests, and also // true for a platform pretending to be Unix, the tests (our doctests, and also
// process_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too. // process_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too.
match NonZero_c_int::try_from(self.0) { match NonZero::try_from(self.0) {
/* was nonzero */ Ok(failure) => Err(ExitStatusError(failure)), /* was nonzero */ Ok(failure) => Err(ExitStatusError(failure)),
/* was zero, couldn't convert */ Err(_) => Ok(()), /* was zero, couldn't convert */ Err(_) => Ok(()),
} }
@ -1092,7 +1091,7 @@ impl fmt::Display for ExitStatus {
} }
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]
pub struct ExitStatusError(NonZero_c_int); pub struct ExitStatusError(NonZero<c_int>);
impl Into<ExitStatus> for ExitStatusError { impl Into<ExitStatus> for ExitStatusError {
fn into(self) -> ExitStatus { fn into(self) -> ExitStatus {

View File

@ -1,9 +1,8 @@
use crate::fmt; use crate::fmt;
use crate::io; use crate::io;
use crate::num::NonZeroI32; use crate::num::{NonZero, NonZeroI32};
use crate::sys::pal::unix::unsupported::*; use crate::sys::pal::unix::unsupported::*;
use crate::sys::process::process_common::*; use crate::sys::process::process_common::*;
use core::ffi::NonZero_c_int;
use libc::{c_int, pid_t}; use libc::{c_int, pid_t};
@ -59,7 +58,7 @@ mod wait_status;
pub use wait_status::ExitStatus; pub use wait_status::ExitStatus;
#[derive(PartialEq, Eq, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub struct ExitStatusError(NonZero_c_int); pub struct ExitStatusError(NonZero<c_int>);
impl Into<ExitStatus> for ExitStatusError { impl Into<ExitStatus> for ExitStatusError {
fn into(self) -> ExitStatus { fn into(self) -> ExitStatus {

View File

@ -1,10 +1,9 @@
//! Emulated wait status for non-Unix #[cfg(unix) platforms //! Emulated wait status for non-Unix #[cfg(unix) platforms
//! //!
//! Separate module to facilitate testing against a real Unix implementation. //! Separate module to facilitate testing against a real Unix implementation.
use core::ffi::NonZero_c_int;
use crate::ffi::c_int; use crate::ffi::c_int;
use crate::fmt; use crate::fmt;
use crate::num::NonZero;
use super::ExitStatusError; use super::ExitStatusError;
@ -50,7 +49,7 @@ impl ExitStatus {
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not
// true for a platform pretending to be Unix, the tests (our doctests, and also // true for a platform pretending to be Unix, the tests (our doctests, and also
// process_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too. // process_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too.
match NonZero_c_int::try_from(self.wait_status) { match NonZero::try_from(self.wait_status) {
/* was nonzero */ Ok(failure) => Err(ExitStatusError(failure)), /* was nonzero */ Ok(failure) => Err(ExitStatusError(failure)),
/* was zero, couldn't convert */ Err(_) => Ok(()), /* was zero, couldn't convert */ Err(_) => Ok(()),
} }

View File

@ -1,11 +1,10 @@
use crate::fmt; use crate::fmt;
use crate::io::{self, Error, ErrorKind}; use crate::io::{self, Error, ErrorKind};
use crate::num::NonZeroI32; use crate::num::{NonZero, NonZeroI32};
use crate::sys; use crate::sys;
use crate::sys::cvt; use crate::sys::cvt;
use crate::sys::process::process_common::*; use crate::sys::process::process_common::*;
use crate::sys_common::thread; use crate::sys_common::thread;
use core::ffi::NonZero_c_int;
use libc::RTP_ID; use libc::RTP_ID;
use libc::{self, c_char, c_int}; use libc::{self, c_char, c_int};
@ -197,7 +196,7 @@ impl ExitStatus {
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not // https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html. If it is not
// true for a platform pretending to be Unix, the tests (our doctests, and also // true for a platform pretending to be Unix, the tests (our doctests, and also
// process_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too. // process_unix/tests.rs) will spot it. `ExitStatusError::code` assumes this too.
match NonZero_c_int::try_from(self.0) { match NonZero::try_from(self.0) {
Ok(failure) => Err(ExitStatusError(failure)), Ok(failure) => Err(ExitStatusError(failure)),
Err(_) => Ok(()), Err(_) => Ok(()),
} }
@ -249,7 +248,7 @@ impl fmt::Display for ExitStatus {
} }
#[derive(PartialEq, Eq, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Clone, Copy, Debug)]
pub struct ExitStatusError(NonZero_c_int); pub struct ExitStatusError(NonZero<c_int>);
impl Into<ExitStatus> for ExitStatusError { impl Into<ExitStatus> for ExitStatusError {
fn into(self) -> ExitStatus { fn into(self) -> ExitStatus {

View File

@ -7,17 +7,17 @@
use crate::ffi::CStr; use crate::ffi::CStr;
use crate::mem; use crate::mem;
use crate::num::NonZero;
pub use crate::os::raw::c_int; pub use crate::os::raw::c_int;
use crate::os::raw::{c_char, c_long, c_longlong, c_uint, c_ulong, c_ushort, c_void}; use crate::os::raw::{c_char, c_long, c_longlong, c_uint, c_ulong, c_ushort, c_void};
use crate::os::windows::io::{AsRawHandle, BorrowedHandle}; use crate::os::windows::io::{AsRawHandle, BorrowedHandle};
use crate::ptr; use crate::ptr;
use core::ffi::NonZero_c_ulong;
mod windows_sys; mod windows_sys;
pub use windows_sys::*; pub use windows_sys::*;
pub type DWORD = c_ulong; pub type DWORD = c_ulong;
pub type NonZeroDWORD = NonZero_c_ulong; pub type NonZeroDWORD = NonZero<c_ulong>;
pub type LARGE_INTEGER = c_longlong; pub type LARGE_INTEGER = c_longlong;
#[cfg_attr(target_vendor = "uwp", allow(unused))] #[cfg_attr(target_vendor = "uwp", allow(unused))]
pub type LONG = c_long; pub type LONG = c_long;