diff options
| author | bors <bors@rust-lang.org> | 2018-09-01 11:26:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-01 11:26:24 +0000 |
| commit | fea32f1b775b3f37fc4abfa6391c1bebe48af9d1 (patch) | |
| tree | ab51afef12f740e9b7e2ffd7595ce0869c7e45a1 /src/libcore | |
| parent | e6381a7f37402dd5f346256b3773ae2e72853fc3 (diff) | |
| parent | 2839f4f0e8d58c295e146999961b78e2cc47354f (diff) | |
| download | rust-fea32f1b775b3f37fc4abfa6391c1bebe48af9d1.tar.gz rust-fea32f1b775b3f37fc4abfa6391c1bebe48af9d1.zip | |
Auto merge of #53604 - oli-obk:min_const_fn, r=Centril,varkor
Implement the `min_const_fn` feature gate cc @RalfJung @eddyb r? @Centril implements the feature gate for #53555 I added a hack so the `const_fn` feature gate also enables the `min_const_fn` feature gate. This ensures that nightly users of `const_fn` don't have to touch their code at all. The `min_const_fn` checks are run first, and if they succeeded, the `const_fn` checks are run additionally to ensure we didn't miss anything.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/mem.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index f2852d98282..e00a22bf8b6 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -285,6 +285,15 @@ pub fn forget<T>(t: T) { /// [alignment]: ./fn.align_of.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg(not(stage0))] +pub const fn size_of<T>() -> usize { + intrinsics::size_of::<T>() +} + +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg(stage0)] +/// Ceci n'est pas la documentation pub const fn size_of<T>() -> usize { unsafe { intrinsics::size_of::<T>() } } @@ -334,6 +343,16 @@ pub fn size_of_val<T: ?Sized>(val: &T) -> usize { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(reason = "use `align_of` instead", since = "1.2.0")] +#[cfg(not(stage0))] +pub fn min_align_of<T>() -> usize { + intrinsics::min_align_of::<T>() +} + +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +#[rustc_deprecated(reason = "use `align_of` instead", since = "1.2.0")] +#[cfg(stage0)] +/// Ceci n'est pas la documentation pub fn min_align_of<T>() -> usize { unsafe { intrinsics::min_align_of::<T>() } } @@ -376,6 +395,15 @@ pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg(not(stage0))] +pub const fn align_of<T>() -> usize { + intrinsics::min_align_of::<T>() +} + +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +#[cfg(stage0)] +/// Ceci n'est pas la documentation pub const fn align_of<T>() -> usize { unsafe { intrinsics::min_align_of::<T>() } } |
