about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-11-11 06:26:21 +0000
committerbors <bors@rust-lang.org>2018-11-11 06:26:21 +0000
commitb76ee83254ec0398da554f25c2168d917ba60f1c (patch)
treeb2d4ff143f4ceda8c5de52252d5f273aa66e2207 /src/libcore
parent9b8f9029762da90a88c8ca6f8ff7690177ec696a (diff)
parent7031e4e7c7b2ab5041aaf9ac54b3bd92169ab908 (diff)
downloadrust-b76ee83254ec0398da554f25c2168d917ba60f1c.tar.gz
rust-b76ee83254ec0398da554f25c2168d917ba60f1c.zip
Auto merge of #55859 - pietroalbini:rollup, r=kennytm
Rollup of 17 pull requests

Successful merges:

 - #55630 (resolve: Filter away macro prelude in modules with `#[no_implicit_prelude]` on 2018 edition)
 - #55687 (Take supertraits into account when calculating associated types)
 - #55745 (Convert `outlives_components`' return value to a `SmallVec` outparam.)
 - #55764 (Fix Rc/Arc allocation layout)
 - #55792 (Prevent ICE in const-prop array oob check)
 - #55799 (Removed unneeded instance of `// revisions` from a lint test)
 - #55800 (Fix ICE in `return_type_impl_trait`)
 - #55801 (NLL: Update box insensitivity test)
 - #55802 (Don't inline virtual calls (take 2))
 - #55816 (Use `SmallVec` to avoid allocations in `from_decimal_string`.)
 - #55819 (Typecheck patterns of all match arms first, so we get types for bindings)
 - #55822 (ICE with #![feature(nll)] and elided lifetimes)
 - #55828 (Add missing `rustc_promotable` attribute to unsigned `min_value` and `max_value`)
 - #55839 (Fix docstring spelling mistakes)
 - #55844 (Fix documentation typos.)
 - #55845 (Set BINARYEN_TRAP_MODE=clamp)
 - #55856 (rustdoc: refactor: move all static-file include!s into a single module)
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/alloc.rs21
-rw-r--r--src/libcore/future/future.rs2
-rw-r--r--src/libcore/lib.rs2
-rw-r--r--src/libcore/macros.rs7
-rw-r--r--src/libcore/mem.rs8
-rw-r--r--src/libcore/num/mod.rs2
-rw-r--r--src/libcore/pin.rs4
-rw-r--r--src/libcore/ptr.rs8
8 files changed, 36 insertions, 18 deletions
diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs
index 113a85abecb..58639808fae 100644
--- a/src/libcore/alloc.rs
+++ b/src/libcore/alloc.rs
@@ -218,6 +218,23 @@ impl Layout {
         len_rounded_up.wrapping_sub(len)
     }
 
+    /// Creates a layout by rounding the size of this layout up to a multiple
+    /// of the layout's alignment.
+    ///
+    /// Returns `Err` if the padded size would overflow.
+    ///
+    /// This is equivalent to adding the result of `padding_needed_for`
+    /// to the layout's current size.
+    #[unstable(feature = "alloc_layout_extra", issue = "55724")]
+    #[inline]
+    pub fn pad_to_align(&self) -> Result<Layout, LayoutErr> {
+        let pad = self.padding_needed_for(self.align());
+        let new_size = self.size().checked_add(pad)
+            .ok_or(LayoutErr { private: () })?;
+
+        Layout::from_size_align(new_size, self.align())
+    }
+
     /// Creates a layout describing the record for `n` instances of
     /// `self`, with a suitable amount of padding between each to
     /// ensure that each instance is given its requested size and
@@ -506,7 +523,7 @@ pub unsafe trait GlobalAlloc {
         ptr
     }
 
-    /// Shink or grow a block of memory to the given `new_size`.
+    /// Shrink or grow a block of memory to the given `new_size`.
     /// The block is described by the given `ptr` pointer and `layout`.
     ///
     /// If this returns a non-null pointer, then ownership of the memory block
@@ -757,7 +774,7 @@ pub unsafe trait Alloc {
     // realloc. alloc_excess, realloc_excess
 
     /// Returns a pointer suitable for holding data described by
-    /// a new layout with `layout`’s alginment and a size given
+    /// a new layout with `layout`’s alignment and a size given
     /// by `new_size`. To
     /// accomplish this, this may extend or shrink the allocation
     /// referenced by `ptr` to fit the new layout.
diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs
index 9176e0d32cb..0c870f9e404 100644
--- a/src/libcore/future/future.rs
+++ b/src/libcore/future/future.rs
@@ -17,7 +17,7 @@ use ops;
 use pin::Pin;
 use task::{Poll, LocalWaker};
 
-/// A future represents an asychronous computation.
+/// A future represents an asynchronous computation.
 ///
 /// A future is a value that may not have finished computing yet. This kind of
 /// "asynchronous value" makes it possible for a thread to continue doing useful
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 1bbc7892c6b..c69d4441121 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -228,7 +228,7 @@ mod nonzero;
 mod tuple;
 mod unit;
 
-// Pull in the the `coresimd` crate directly into libcore. This is where all the
+// Pull in the `coresimd` crate directly into libcore. This is where all the
 // architecture-specific (and vendor-specific) intrinsics are defined. AKA
 // things like SIMD and such. Note that the actual source for all this lies in a
 // different repository, rust-lang-nursery/stdsimd. That's why the setup here is
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index a0c87f13e5d..c008b78e450 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -350,9 +350,8 @@ macro_rules! try {
 /// assert_eq!(v, b"s = \"abc 123\"");
 /// ```
 ///
-/// Note: This macro can be used in `no_std` setups as well
-/// In a `no_std` setup you are responsible for the
-/// implementation details of the components.
+/// Note: This macro can be used in `no_std` setups as well.
+/// In a `no_std` setup you are responsible for the implementation details of the components.
 ///
 /// ```no_run
 /// # extern crate core;
@@ -440,7 +439,7 @@ macro_rules! writeln {
 ///
 /// If the determination that the code is unreachable proves incorrect, the
 /// program immediately terminates with a [`panic!`].  The function [`unreachable_unchecked`],
-/// which belongs to the [`std::hint`] module, informs the compilier to
+/// which belongs to the [`std::hint`] module, informs the compiler to
 /// optimize the code out of the release version entirely.
 ///
 /// [`panic!`]:  ../std/macro.panic.html
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 1d0b194487e..8c4ff02aa14 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -202,7 +202,7 @@ pub fn forget<T>(t: T) {
 ///
 /// ## Size of Enums
 ///
-/// Enums that carry no data other than the descriminant have the same size as C enums
+/// Enums that carry no data other than the discriminant have the same size as C enums
 /// on the platform they are compiled for.
 ///
 /// ## Size of Unions
@@ -1081,7 +1081,7 @@ impl<T> MaybeUninit<T> {
     ///
     /// # Unsafety
     ///
-    /// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
+    /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
     /// state, otherwise this will immediately cause undefined behavior.
     #[unstable(feature = "maybe_uninit", issue = "53491")]
     pub unsafe fn into_inner(self) -> T {
@@ -1092,7 +1092,7 @@ impl<T> MaybeUninit<T> {
     ///
     /// # Unsafety
     ///
-    /// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
+    /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
     /// state, otherwise this will immediately cause undefined behavior.
     #[unstable(feature = "maybe_uninit", issue = "53491")]
     pub unsafe fn get_ref(&self) -> &T {
@@ -1103,7 +1103,7 @@ impl<T> MaybeUninit<T> {
     ///
     /// # Unsafety
     ///
-    /// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized
+    /// It is up to the caller to guarantee that the `MaybeUninit` really is in an initialized
     /// state, otherwise this will immediately cause undefined behavior.
     #[unstable(feature = "maybe_uninit", issue = "53491")]
     pub unsafe fn get_mut(&mut self) -> &mut T {
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 090147c9fe4..30b7b454684 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -2152,6 +2152,7 @@ Basic usage:
 ", $Feature, "assert_eq!(", stringify!($SelfT), "::min_value(), 0);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_promotable]
             #[inline]
             pub const fn min_value() -> Self { 0 }
         }
@@ -2168,6 +2169,7 @@ Basic usage:
 stringify!($MaxV), ");", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_promotable]
             #[inline]
             pub const fn max_value() -> Self { !0 }
         }
diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs
index 68de82d2945..308dd9c79fa 100644
--- a/src/libcore/pin.rs
+++ b/src/libcore/pin.rs
@@ -3,7 +3,7 @@
 //! It is sometimes useful to have objects that are guaranteed to not move,
 //! in the sense that their placement in memory does not change, and can thus be relied upon.
 //!
-//! A prime example of such a scenario would be building self-referencial structs,
+//! A prime example of such a scenario would be building self-referential structs,
 //! since moving an object with pointers to itself will invalidate them,
 //! which could cause undefined behavior.
 //!
@@ -39,7 +39,7 @@
 //! use std::marker::Pinned;
 //! use std::ptr::NonNull;
 //!
-//! // This is a self referencial struct since the slice field points to the data field.
+//! // This is a self-referential struct since the slice field points to the data field.
 //! // We cannot inform the compiler about that with a normal reference,
 //! // since this pattern cannot be described with the usual borrowing rules.
 //! // Instead we use a raw pointer, though one which is known to not be null,
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 62ccf6c865c..827e297c84d 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -120,7 +120,7 @@ pub use intrinsics::write_bytes;
 ///
 /// Additionally, if `T` is not [`Copy`], using the pointed-to value after
 /// calling `drop_in_place` can cause undefined behavior. Note that `*to_drop =
-/// foo` counts as a use because it will cause the the value to be dropped
+/// foo` counts as a use because it will cause the value to be dropped
 /// again. [`write`] can be used to overwrite data without causing it to be
 /// dropped.
 ///
@@ -371,7 +371,7 @@ pub(crate) unsafe fn swap_nonoverlapping_one<T>(x: *mut T, y: *mut T) {
 #[inline]
 unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) {
     // The approach here is to utilize simd to swap x & y efficiently. Testing reveals
-    // that swapping either 32 bytes or 64 bytes at a time is most efficient for intel
+    // that swapping either 32 bytes or 64 bytes at a time is most efficient for Intel
     // Haswell E processors. LLVM is more able to optimize if we give a struct a
     // #[repr(simd)], even if we don't actually use this struct directly.
     //
@@ -1005,7 +1005,7 @@ impl<T: ?Sized> *const T {
     /// # Null-unchecked version
     ///
     /// If you are sure the pointer can never be null and are looking for some kind of
-    /// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>, know that you can
+    /// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>`, know that you can
     /// dereference the pointer directly.
     ///
     /// ```
@@ -1625,7 +1625,7 @@ impl<T: ?Sized> *mut T {
     /// # Null-unchecked version
     ///
     /// If you are sure the pointer can never be null and are looking for some kind of
-    /// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>, know that you can
+    /// `as_ref_unchecked` that returns the `&T` instead of `Option<&T>`, know that you can
     /// dereference the pointer directly.
     ///
     /// ```