about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-11-12 19:28:04 +0000
committerbors <bors@rust-lang.org>2021-11-12 19:28:04 +0000
commite90c5fbbc5df5c81267747daeb937d4e955ce6ad (patch)
tree8d5dfc3ab54f45746b74fe9a33d9a86d6d7c526f /library/core/src
parent220ed09b26177ca4b6ab525f403d251024389a41 (diff)
parent5e7c0313976d670bbe6accdaa27347ed23aed58b (diff)
downloadrust-e90c5fbbc5df5c81267747daeb937d4e955ce6ad.tar.gz
rust-e90c5fbbc5df5c81267747daeb937d4e955ce6ad.zip
Auto merge of #90836 - matthiaskrgr:rollup-ou6yrlw, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90589 (rustc_llvm: update PassWrapper for recent LLVM)
 - #90644 (Extend the const swap feature)
 - #90704 (Unix ExitStatus comments and a tiny docs fix)
 - #90761 (Shorten Span of unused macro lints)
 - #90795 (Add more comments to explain the code to generate the search index)
 - #90798 (Document `unreachable!` custom panic message)
 - #90826 (rustc_feature: Convert `BuiltinAttribute` from tuple to a struct)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/macros/mod.rs7
-rw-r--r--library/core/src/ptr/mut_ptr.rs3
-rw-r--r--library/core/src/slice/mod.rs6
3 files changed, 11 insertions, 5 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 5b3e988caa5..993ae723229 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -554,7 +554,10 @@ macro_rules! writeln {
 ///
 /// # Panics
 ///
-/// This will always [`panic!`].
+/// This will always [`panic!`] because `unreachable!` is just a shorthand for `panic!` with a
+/// fixed, specific message.
+///
+/// Like `panic!`, this macro has a second form for displaying custom values.
 ///
 /// # Examples
 ///
@@ -581,7 +584,7 @@ macro_rules! writeln {
 ///         if 3*i < i { panic!("u32 overflow"); }
 ///         if x < 3*i { return i-1; }
 ///     }
-///     unreachable!();
+///     unreachable!("The loop should always return");
 /// }
 /// ```
 #[macro_export]
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index adc64cb2bd3..5d5527dc8b4 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -1092,8 +1092,9 @@ impl<T: ?Sized> *mut T {
     ///
     /// [`ptr::swap`]: crate::ptr::swap()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
+    #[rustc_const_unstable(feature = "const_swap", issue = "83163")]
     #[inline(always)]
-    pub unsafe fn swap(self, with: *mut T)
+    pub const unsafe fn swap(self, with: *mut T)
     where
         T: Sized,
     {
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs
index 65ed72cb0cd..d876d944e7f 100644
--- a/library/core/src/slice/mod.rs
+++ b/library/core/src/slice/mod.rs
@@ -558,8 +558,9 @@ impl<T> [T] {
     /// assert!(v == ["a", "b", "e", "d", "c"]);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[rustc_const_unstable(feature = "const_swap", issue = "83163")]
     #[inline]
-    pub fn swap(&mut self, a: usize, b: usize) {
+    pub const fn swap(&mut self, a: usize, b: usize) {
         let _ = &self[a];
         let _ = &self[b];
 
@@ -595,7 +596,8 @@ impl<T> [T] {
     /// [`swap`]: slice::swap
     /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
     #[unstable(feature = "slice_swap_unchecked", issue = "88539")]
-    pub unsafe fn swap_unchecked(&mut self, a: usize, b: usize) {
+    #[rustc_const_unstable(feature = "const_swap", issue = "83163")]
+    pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) {
         #[cfg(debug_assertions)]
         {
             let _ = &self[a];