about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-09-16 23:13:30 +0000
committerbors <bors@rust-lang.org>2018-09-16 23:13:30 +0000
commit5aac93c8fb4dfe16a9690b41c1b9c040608677cb (patch)
tree859a2d2bf65630a6d0a1a0e9cb5db84d6ee95370 /src/libstd
parentcb6d2dfa8923902b0992a1522dc4a45a9d3ba690 (diff)
parent23e345bc0c79c43753b224ab127f5c06d553e4c4 (diff)
downloadrust-5aac93c8fb4dfe16a9690b41c1b9c040608677cb.tar.gz
rust-5aac93c8fb4dfe16a9690b41c1b9c040608677cb.zip
Auto merge of #53910 - IsaacWoods:unify_cvoid, r=SimonSapin
Move std::os::raw::c_void into libcore and re-export in libstd

Implements the first part of [RFC 2521](https://github.com/rust-lang/rfcs/pull/2521).

cc #53856
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ffi/mod.rs3
-rw-r--r--src/libstd/os/raw/mod.rs37
2 files changed, 5 insertions, 35 deletions
diff --git a/src/libstd/ffi/mod.rs b/src/libstd/ffi/mod.rs
index a37a5e8ae82..a3345df5e0d 100644
--- a/src/libstd/ffi/mod.rs
+++ b/src/libstd/ffi/mod.rs
@@ -171,5 +171,8 @@ pub use self::c_str::{FromBytesWithNulError};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::os_str::{OsString, OsStr};
 
+#[stable(feature = "raw_os", since = "1.1.0")]
+pub use core::ffi::c_void;
+
 mod c_str;
 mod os_str;
diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs
index dc33747c05b..95faf3a5dd6 100644
--- a/src/libstd/os/raw/mod.rs
+++ b/src/libstd/os/raw/mod.rs
@@ -18,8 +18,6 @@
 
 #![stable(feature = "raw_os", since = "1.1.0")]
 
-use fmt;
-
 #[doc(include = "os/raw/char.md")]
 #[cfg(any(all(target_os = "linux", any(target_arch = "aarch64",
                                        target_arch = "arm",
@@ -83,40 +81,9 @@ use fmt;
 #[doc(include = "os/raw/double.md")]
 #[stable(feature = "raw_os", since = "1.1.0")] pub type c_double = f64;
 
-/// Equivalent to C's `void` type when used as a [pointer].
-///
-/// In essence, `*const c_void` is equivalent to C's `const void*`
-/// and `*mut c_void` is equivalent to C's `void*`. That said, this is
-/// *not* the same as C's `void` return type, which is Rust's `()` type.
-///
-/// Ideally, this type would be equivalent to [`!`], but currently it may
-/// be more ideal to use `c_void` for FFI purposes.
-///
-/// [`!`]: ../../primitive.never.html
-/// [pointer]: ../../primitive.pointer.html
-// NB: For LLVM to recognize the void pointer type and by extension
-//     functions like malloc(), we need to have it represented as i8* in
-//     LLVM bitcode. The enum used here ensures this and prevents misuse
-//     of the "raw" type by only having private variants.. We need two
-//     variants, because the compiler complains about the repr attribute
-//     otherwise.
-#[repr(u8)]
 #[stable(feature = "raw_os", since = "1.1.0")]
-pub enum c_void {
-    #[unstable(feature = "c_void_variant", reason = "should not have to exist",
-               issue = "0")]
-    #[doc(hidden)] __variant1,
-    #[unstable(feature = "c_void_variant", reason = "should not have to exist",
-               issue = "0")]
-    #[doc(hidden)] __variant2,
-}
-
-#[stable(feature = "std_debug", since = "1.16.0")]
-impl fmt::Debug for c_void {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        f.pad("c_void")
-    }
-}
+#[doc(no_inline)]
+pub use core::ffi::c_void;
 
 #[cfg(test)]
 #[allow(unused_imports)]