Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libc-test/test/check_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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::{
Expand Down
18 changes: 18 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Platform-agnostic support types.

use core::mem::MaybeUninit;

use crate::prelude::*;

/// A transparent wrapper over `MaybeUninit<T>` to represent uninitialized padding
/// while providing `Default`.
#[allow(unused)]
#[repr(transparent)]
#[derive(Clone, Copy)]
pub(crate) struct Padding<T: Copy>(MaybeUninit<T>);

impl<T: Copy> Default for Padding<T> {
fn default() -> Self {
Self(MaybeUninit::zeroed())
}
}