@@ -12,24 +12,27 @@ use ::fmt;
1212/// and `*mut c_void` is equivalent to C's `void*`. That said, this is
1313/// *not* the same as C's `void` return type, which is Rust's `()` type.
1414///
15- /// Ideally, this type would be equivalent to [`!`], but currently it may
16- /// be more ideal to use `c_void` for FFI purposes.
15+ /// To model pointers to opaque types in FFI, until `extern type` is
16+ /// stabilized, it is recommended to use a newtype wrapper around an empty
17+ /// byte array. See the [Nomicon] for details.
1718///
18- /// [`!`]: ../../std/primitive.never.html
1919/// [pointer]: ../../std/primitive.pointer.html
20+ /// [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
2021// N.B., for LLVM to recognize the void pointer type and by extension
2122// functions like malloc(), we need to have it represented as i8* in
2223// LLVM bitcode. The enum used here ensures this and prevents misuse
23- // of the "raw" type by only having private variants.. We need two
24+ // of the "raw" type by only having private variants. We need two
2425// variants, because the compiler complains about the repr attribute
25- // otherwise.
26+ // otherwise and we need at least one variant as otherwise the enum
27+ // would be uninhabited and at least dereferencing such pointers would
28+ // be UB.
2629#[ repr( u8 ) ]
2730#[ stable( feature = "raw_os" , since = "1.1.0" ) ]
2831pub enum c_void {
29- #[ unstable( feature = "c_void_variant" , reason = "should not have to exist " ,
32+ #[ unstable( feature = "c_void_variant" , reason = "temporary implementation detail " ,
3033 issue = "0" ) ]
3134 #[ doc( hidden) ] __variant1,
32- #[ unstable( feature = "c_void_variant" , reason = "should not have to exist " ,
35+ #[ unstable( feature = "c_void_variant" , reason = "temporary implementation detail " ,
3336 issue = "0" ) ]
3437 #[ doc( hidden) ] __variant2,
3538}
@@ -49,7 +52,7 @@ impl fmt::Debug for c_void {
4952#[ unstable( feature = "c_variadic" ,
5053 reason = "the `c_variadic` feature has not been properly tested on \
5154 all supported platforms",
52- issue = "27745 " ) ]
55+ issue = "44930 " ) ]
5356extern {
5457 type VaListImpl ;
5558}
@@ -74,7 +77,7 @@ impl fmt::Debug for VaListImpl {
7477#[ unstable( feature = "c_variadic" ,
7578 reason = "the `c_variadic` feature has not been properly tested on \
7679 all supported platforms",
77- issue = "27745 " ) ]
80+ issue = "44930 " ) ]
7881struct VaListImpl {
7982 stack : * mut ( ) ,
8083 gr_top : * mut ( ) ,
@@ -90,7 +93,7 @@ struct VaListImpl {
9093#[ unstable( feature = "c_variadic" ,
9194 reason = "the `c_variadic` feature has not been properly tested on \
9295 all supported platforms",
93- issue = "27745 " ) ]
96+ issue = "44930 " ) ]
9497struct VaListImpl {
9598 gpr : u8 ,
9699 fpr : u8 ,
@@ -106,7 +109,7 @@ struct VaListImpl {
106109#[ unstable( feature = "c_variadic" ,
107110 reason = "the `c_variadic` feature has not been properly tested on \
108111 all supported platforms",
109- issue = "27745 " ) ]
112+ issue = "44930 " ) ]
110113struct VaListImpl {
111114 gp_offset : i32 ,
112115 fp_offset : i32 ,
@@ -120,7 +123,7 @@ struct VaListImpl {
120123#[ unstable( feature = "c_variadic" ,
121124 reason = "the `c_variadic` feature has not been properly tested on \
122125 all supported platforms",
123- issue = "27745 " ) ]
126+ issue = "44930 " ) ]
124127#[ repr( transparent) ]
125128pub struct VaList < ' a > ( & ' a mut VaListImpl ) ;
126129
@@ -140,7 +143,7 @@ mod sealed_trait {
140143 #[ unstable( feature = "c_variadic" ,
141144 reason = "the `c_variadic` feature has not been properly tested on \
142145 all supported platforms",
143- issue = "27745 " ) ]
146+ issue = "44930 " ) ]
144147 pub trait VaArgSafe { }
145148}
146149
@@ -150,7 +153,7 @@ macro_rules! impl_va_arg_safe {
150153 #[ unstable( feature = "c_variadic" ,
151154 reason = "the `c_variadic` feature has not been properly tested on \
152155 all supported platforms",
153- issue = "27745 " ) ]
156+ issue = "44930 " ) ]
154157 impl sealed_trait:: VaArgSafe for $t { }
155158 ) +
156159 }
@@ -163,20 +166,20 @@ impl_va_arg_safe!{f64}
163166#[ unstable( feature = "c_variadic" ,
164167 reason = "the `c_variadic` feature has not been properly tested on \
165168 all supported platforms",
166- issue = "27745 " ) ]
169+ issue = "44930 " ) ]
167170impl < T > sealed_trait:: VaArgSafe for * mut T { }
168171#[ unstable( feature = "c_variadic" ,
169172 reason = "the `c_variadic` feature has not been properly tested on \
170173 all supported platforms",
171- issue = "27745 " ) ]
174+ issue = "44930 " ) ]
172175impl < T > sealed_trait:: VaArgSafe for * const T { }
173176
174177impl < ' a > VaList < ' a > {
175178 /// Advance to the next arg.
176179 #[ unstable( feature = "c_variadic" ,
177180 reason = "the `c_variadic` feature has not been properly tested on \
178181 all supported platforms",
179- issue = "27745 " ) ]
182+ issue = "44930 " ) ]
180183 pub unsafe fn arg < T : sealed_trait:: VaArgSafe > ( & mut self ) -> T {
181184 va_arg ( self )
182185 }
@@ -185,7 +188,7 @@ impl<'a> VaList<'a> {
185188 #[ unstable( feature = "c_variadic" ,
186189 reason = "the `c_variadic` feature has not been properly tested on \
187190 all supported platforms",
188- issue = "27745 " ) ]
191+ issue = "44930 " ) ]
189192 pub unsafe fn copy < F , R > ( & self , f : F ) -> R
190193 where F : for < ' copy > FnOnce ( VaList < ' copy > ) -> R {
191194 #[ cfg( any( all( not( target_arch = "aarch64" ) , not( target_arch = "powerpc" ) ,
0 commit comments