about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-06 14:53:37 +0000
committerbors <bors@rust-lang.org>2017-12-06 14:53:37 +0000
commit833785b090c30d4a359d901fb41bfafbe1607ce9 (patch)
tree3bae34d8913ec84c8325bd31096b16368fcdca41 /src/libcore
parent632ad19135a1f38c42761270ffc8a0d977b1db4c (diff)
parentbb239e294ee35aab4ddd7c7a306d0bf5bd8518b6 (diff)
downloadrust-833785b090c30d4a359d901fb41bfafbe1607ce9.tar.gz
rust-833785b090c30d4a359d901fb41bfafbe1607ce9.zip
Auto merge of #46538 - frewsxcv:rollup, r=frewsxcv
Rollup of 7 pull requests

- Successful merges: #46136, #46378, #46431, #46483, #46495, #46502, #46512
- Failed merges:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/macros.rs4
-rw-r--r--src/libcore/ptr.rs42
-rw-r--r--src/libcore/result.rs8
3 files changed, 46 insertions, 8 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index 6e3dbcbec9d..fe2df226115 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -596,9 +596,9 @@ mod builtin {
 
     /// Unconditionally causes compilation to fail with the given error message when encountered.
     ///
-    /// For more information, see the [RFC].
+    /// For more information, see the documentation for [`std::compile_error!`].
     ///
-    /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md
+    /// [`std::compile_error!`]: ../std/macro.compile_error.html
     #[stable(feature = "compile_error_macro", since = "1.20.0")]
     #[macro_export]
     #[cfg(dox)]
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index 5e70c8283f4..20f054f5a77 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -91,8 +91,12 @@ pub const fn null<T>() -> *const T { 0 as *const T }
 pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
 
 /// Swaps the values at two mutable locations of the same type, without
-/// deinitializing either. They may overlap, unlike `mem::swap` which is
-/// otherwise equivalent.
+/// deinitializing either.
+///
+/// The values pointed at by `x` and `y` may overlap, unlike `mem::swap` which
+/// is otherwise equivalent. If the values do overlap, then the overlapping
+/// region of memory from `x` will be used. This is demonstrated in the
+/// examples section below.
 ///
 /// # Safety
 ///
@@ -100,6 +104,40 @@ pub const fn null_mut<T>() -> *mut T { 0 as *mut T }
 /// as arguments.
 ///
 /// Ensure that these pointers are valid before calling `swap`.
+///
+/// # Examples
+///
+/// Swapping two non-overlapping regions:
+///
+/// ```
+/// use std::ptr;
+///
+/// let mut array = [0, 1, 2, 3];
+///
+/// let x = array[0..].as_mut_ptr() as *mut [u32; 2];
+/// let y = array[2..].as_mut_ptr() as *mut [u32; 2];
+///
+/// unsafe {
+///     ptr::swap(x, y);
+///     assert_eq!([2, 3, 0, 1], array);
+/// }
+/// ```
+///
+/// Swapping two overlapping regions:
+///
+/// ```
+/// use std::ptr;
+///
+/// let mut array = [0, 1, 2, 3];
+///
+/// let x = array[0..].as_mut_ptr() as *mut [u32; 3];
+/// let y = array[1..].as_mut_ptr() as *mut [u32; 3];
+///
+/// unsafe {
+///     ptr::swap(x, y);
+///     assert_eq!([1, 0, 1, 2], array);
+/// }
+/// ```
 #[inline]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index db5bffced10..959935242dc 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -153,12 +153,12 @@
 //! }
 //! ```
 //!
-//! # The `?` syntax
+//! # The question mark operator, `?`
 //!
 //! When writing code that calls many functions that return the
-//! [`Result`] type, the error handling can be tedious. The [`?`]
-//! syntax hides some of the boilerplate of propagating errors up the
-//! call stack.
+//! [`Result`] type, the error handling can be tedious. The question mark
+//! operator, [`?`], hides some of the boilerplate of propagating errors
+//! up the call stack.
 //!
 //! It replaces this:
 //!