diff --git a/libc-test/test/check_style.rs b/libc-test/test/check_style.rs index 24f793e4feb86..d1d7fdf4aa150 100644 --- a/libc-test/test/check_style.rs +++ b/libc-test/test/check_style.rs @@ -20,7 +20,7 @@ use style::{Result, StyleChecker}; const SKIP_PREFIXES: &[&str] = &[ // Don't run the style checker on the reorganized portion of the crate while we figure // out what style we want. - "new/", + "new/", "types.rs", ]; #[test] diff --git a/src/macros.rs b/src/macros.rs index 3a8db1890107c..8b723966dc761 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -64,6 +64,8 @@ macro_rules! cfg_if { /// Create an internal crate prelude with `core` reexports and common types. macro_rules! prelude { () => { + mod types; + /// Frequently-used types that are available on all platforms /// /// We need to reexport the core types so this works with `rust-dep-of-std`. @@ -72,14 +74,20 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use ::core::clone::Clone; #[allow(unused_imports)] + pub(crate) use ::core::default::Default; + #[allow(unused_imports)] pub(crate) use ::core::marker::{Copy, Send, Sync}; #[allow(unused_imports)] pub(crate) use ::core::option::Option; #[allow(unused_imports)] + pub(crate) use ::core::prelude::v1::derive; + #[allow(unused_imports)] pub(crate) use ::core::{fmt, hash, iter, mem}; #[allow(unused_imports)] pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; + #[allow(unused_imports)] + pub(crate) use crate::types::Padding; // Commonly used types defined in this crate #[allow(unused_imports)] pub(crate) use crate::{ diff --git a/src/types.rs b/src/types.rs new file mode 100644 index 0000000000000..d972d2390c9cd --- /dev/null +++ b/src/types.rs @@ -0,0 +1,18 @@ +//! Platform-agnostic support types. + +use core::mem::MaybeUninit; + +use crate::prelude::*; + +/// A transparent wrapper over `MaybeUninit` to represent uninitialized padding +/// while providing `Default`. +#[allow(unused)] +#[repr(transparent)] +#[derive(Clone, Copy)] +pub(crate) struct Padding(MaybeUninit); + +impl Default for Padding { + fn default() -> Self { + Self(MaybeUninit::zeroed()) + } +}