@@ -19,7 +19,7 @@ pub use self::c_str::{CStr, FromBytesUntilNulError, FromBytesWithNulError};
1919
2020mod c_str;
2121
22- macro_rules! type_alias_no_nz {
22+ macro_rules! type_alias {
2323 {
2424 $Docfile: tt, $Alias: ident = $Real: ty;
2525 $( $Cfg: tt ) *
@@ -31,49 +31,24 @@ macro_rules! type_alias_no_nz {
3131 }
3232}
3333
34- // To verify that the NonZero types in this file's macro invocations correspond
35- //
36- // 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'
37- //
38- // NB this does not check that the main c_* types are right.
39-
40- macro_rules! type_alias {
41- {
42- $Docfile: tt, $Alias: ident = $Real: ty, $NZAlias: ident = $NZReal: ty;
43- $( $Cfg: tt ) *
44- } => {
45- type_alias_no_nz! { $Docfile, $Alias = $Real; $( $Cfg ) * }
46-
47- #[ doc = concat!( "Type alias for `NonZero` version of [`" , stringify!( $Alias) , "`]" ) ]
48- #[ unstable( feature = "raw_os_nonzero" , issue = "82363" ) ]
49- $( $Cfg ) *
50- pub type $NZAlias = $NZReal;
51- }
52- }
53-
54- type_alias ! { "c_char.md" , c_char = c_char_definition:: c_char, NonZero_c_char = c_char_definition:: NonZero_c_char ;
55- #[ doc( cfg( all( ) ) ) ] }
34+ type_alias ! { "c_char.md" , c_char = c_char_definition:: c_char; #[ doc( cfg( all( ) ) ) ] }
5635
57- type_alias ! { "c_schar.md" , c_schar = i8 , NonZero_c_schar = NonZeroI8 ; }
58- type_alias ! { "c_uchar.md" , c_uchar = u8 , NonZero_c_uchar = NonZeroU8 ; }
59- type_alias ! { "c_short.md" , c_short = i16 , NonZero_c_short = NonZeroI16 ; }
60- type_alias ! { "c_ushort.md" , c_ushort = u16 , NonZero_c_ushort = NonZeroU16 ; }
36+ type_alias ! { "c_schar.md" , c_schar = i8 ; }
37+ type_alias ! { "c_uchar.md" , c_uchar = u8 ; }
38+ type_alias ! { "c_short.md" , c_short = i16 ; }
39+ type_alias ! { "c_ushort.md" , c_ushort = u16 ; }
6140
62- type_alias ! { "c_int.md" , c_int = c_int_definition:: c_int, NonZero_c_int = c_int_definition:: NonZero_c_int ;
63- #[ doc( cfg( all( ) ) ) ] }
64- type_alias ! { "c_uint.md" , c_uint = c_int_definition:: c_uint, NonZero_c_uint = c_int_definition:: NonZero_c_uint ;
65- #[ doc( cfg( all( ) ) ) ] }
41+ type_alias ! { "c_int.md" , c_int = c_int_definition:: c_int; #[ doc( cfg( all( ) ) ) ] }
42+ type_alias ! { "c_uint.md" , c_uint = c_int_definition:: c_uint; #[ doc( cfg( all( ) ) ) ] }
6643
67- type_alias ! { "c_long.md" , c_long = c_long_definition:: c_long, NonZero_c_long = c_long_definition:: NonZero_c_long ;
68- #[ doc( cfg( all( ) ) ) ] }
69- type_alias ! { "c_ulong.md" , c_ulong = c_long_definition:: c_ulong, NonZero_c_ulong = c_long_definition:: NonZero_c_ulong ;
70- #[ doc( cfg( all( ) ) ) ] }
44+ type_alias ! { "c_long.md" , c_long = c_long_definition:: c_long; #[ doc( cfg( all( ) ) ) ] }
45+ type_alias ! { "c_ulong.md" , c_ulong = c_long_definition:: c_ulong; #[ doc( cfg( all( ) ) ) ] }
7146
72- type_alias ! { "c_longlong.md" , c_longlong = i64 , NonZero_c_longlong = NonZeroI64 ; }
73- type_alias ! { "c_ulonglong.md" , c_ulonglong = u64 , NonZero_c_ulonglong = NonZeroU64 ; }
47+ type_alias ! { "c_longlong.md" , c_longlong = i64 ; }
48+ type_alias ! { "c_ulonglong.md" , c_ulonglong = u64 ; }
7449
75- type_alias_no_nz ! { "c_float.md" , c_float = f32 ; }
76- type_alias_no_nz ! { "c_double.md" , c_double = f64 ; }
50+ type_alias ! { "c_float.md" , c_float = f32 ; }
51+ type_alias ! { "c_double.md" , c_double = f64 ; }
7752
7853/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++).
7954///
@@ -152,11 +127,9 @@ mod c_char_definition {
152127 target_os = "horizon"
153128 ) ) ] {
154129 pub type c_char = u8 ;
155- pub type NonZero_c_char = crate :: num:: NonZeroU8 ;
156130 } else {
157131 // On every other target, c_char is signed.
158132 pub type c_char = i8 ;
159- pub type NonZero_c_char = crate :: num:: NonZeroI8 ;
160133 }
161134 }
162135}
@@ -165,14 +138,10 @@ mod c_int_definition {
165138 cfg_if ! {
166139 if #[ cfg( any( target_arch = "avr" , target_arch = "msp430" ) ) ] {
167140 pub type c_int = i16 ;
168- pub type NonZero_c_int = crate :: num:: NonZeroI16 ;
169141 pub type c_uint = u16 ;
170- pub type NonZero_c_uint = crate :: num:: NonZeroU16 ;
171142 } else {
172143 pub type c_int = i32 ;
173- pub type NonZero_c_int = crate :: num:: NonZeroI32 ;
174144 pub type c_uint = u32 ;
175- pub type NonZero_c_uint = crate :: num:: NonZeroU32 ;
176145 }
177146 }
178147}
@@ -181,15 +150,11 @@ mod c_long_definition {
181150 cfg_if ! {
182151 if #[ cfg( all( target_pointer_width = "64" , not( windows) ) ) ] {
183152 pub type c_long = i64 ;
184- pub type NonZero_c_long = crate :: num:: NonZeroI64 ;
185153 pub type c_ulong = u64 ;
186- pub type NonZero_c_ulong = crate :: num:: NonZeroU64 ;
187154 } else {
188155 // The minimal size of `long` in the C standard is 32 bits
189156 pub type c_long = i32 ;
190- pub type NonZero_c_long = crate :: num:: NonZeroI32 ;
191157 pub type c_ulong = u32 ;
192- pub type NonZero_c_ulong = crate :: num:: NonZeroU32 ;
193158 }
194159 }
195160}
0 commit comments