about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2020-04-16 12:44:57 -0700
committerJosh Stone <jistone@redhat.com>2020-04-16 12:44:57 -0700
commit2edd123a233fff2fbccd17299e0c14d2203e1acc (patch)
tree0a17e3a35ef2901f28cc637693889a057f77910f
parent7fb5187d0423f4cd0441526571b8cd61927123c9 (diff)
downloadrust-2edd123a233fff2fbccd17299e0c14d2203e1acc.tar.gz
rust-2edd123a233fff2fbccd17299e0c14d2203e1acc.zip
Dogfood or_patterns in the standard library
-rw-r--r--src/liballoc/collections/btree/map.rs7
-rw-r--r--src/liballoc/lib.rs1
-rw-r--r--src/libcore/cmp.rs4
-rw-r--r--src/libcore/iter/traits/iterator.rs4
-rw-r--r--src/libcore/lib.rs1
-rw-r--r--src/libcore/num/dec2flt/parse.rs4
-rw-r--r--src/libcore/num/flt2dec/mod.rs4
-rw-r--r--src/libstd/lib.rs1
-rw-r--r--src/libstd/sync/mpsc/oneshot.rs2
-rw-r--r--src/libstd/sync/mpsc/stream.rs2
10 files changed, 14 insertions, 16 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs
index 3fc1b5e16b3..38196b2d4b4 100644
--- a/src/liballoc/collections/btree/map.rs
+++ b/src/liballoc/collections/btree/map.rs
@@ -2058,12 +2058,7 @@ where
         (Excluded(s), Excluded(e)) if s == e => {
             panic!("range start and end are equal and excluded in BTreeMap")
         }
-        (Included(s), Included(e))
-        | (Included(s), Excluded(e))
-        | (Excluded(s), Included(e))
-        | (Excluded(s), Excluded(e))
-            if s > e =>
-        {
+        (Included(s) | Excluded(s), Included(e) | Excluded(e)) if s > e => {
             panic!("range start is greater than range end in BTreeMap")
         }
         _ => {}
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index 121c1cde548..a2071844d5d 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -103,6 +103,7 @@
 #![feature(new_uninit)]
 #![feature(nll)]
 #![feature(optin_builtin_traits)]
+#![feature(or_patterns)]
 #![feature(pattern)]
 #![feature(ptr_internals)]
 #![feature(ptr_offset_from)]
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index 8c542136a7f..335969b3ef0 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -858,7 +858,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
     #[must_use]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn le(&self, other: &Rhs) -> bool {
-        matches!(self.partial_cmp(other), Some(Less) | Some(Equal))
+        matches!(self.partial_cmp(other), Some(Less | Equal))
     }
 
     /// This method tests greater than (for `self` and `other`) and is used by the `>` operator.
@@ -895,7 +895,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
     #[must_use]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn ge(&self, other: &Rhs) -> bool {
-        matches!(self.partial_cmp(other), Some(Greater) | Some(Equal))
+        matches!(self.partial_cmp(other), Some(Greater | Equal))
     }
 }
 
diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs
index c8829817e19..34ca79154b6 100644
--- a/src/libcore/iter/traits/iterator.rs
+++ b/src/libcore/iter/traits/iterator.rs
@@ -3109,7 +3109,7 @@ pub trait Iterator {
         Self::Item: PartialOrd<I::Item>,
         Self: Sized,
     {
-        matches!(self.partial_cmp(other), Some(Ordering::Less) | Some(Ordering::Equal))
+        matches!(self.partial_cmp(other), Some(Ordering::Less | Ordering::Equal))
     }
 
     /// Determines if the elements of this `Iterator` are lexicographically
@@ -3149,7 +3149,7 @@ pub trait Iterator {
         Self::Item: PartialOrd<I::Item>,
         Self: Sized,
     {
-        matches!(self.partial_cmp(other), Some(Ordering::Greater) | Some(Ordering::Equal))
+        matches!(self.partial_cmp(other), Some(Ordering::Greater | Ordering::Equal))
     }
 
     /// Checks if the elements of this iterator are sorted.
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index a04b7162c92..1c7bce3fac5 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -105,6 +105,7 @@
 #![feature(exhaustive_patterns)]
 #![feature(no_core)]
 #![feature(optin_builtin_traits)]
+#![feature(or_patterns)]
 #![feature(prelude_import)]
 #![feature(repr_simd, platform_intrinsics)]
 #![feature(rustc_attrs)]
diff --git a/src/libcore/num/dec2flt/parse.rs b/src/libcore/num/dec2flt/parse.rs
index 93b08bce853..2766843155a 100644
--- a/src/libcore/num/dec2flt/parse.rs
+++ b/src/libcore/num/dec2flt/parse.rs
@@ -54,7 +54,7 @@ pub fn parse_decimal(s: &str) -> ParseResult<'_> {
 
     match s.first() {
         None => Valid(Decimal::new(integral, b"", 0)),
-        Some(&b'e') | Some(&b'E') => {
+        Some(&b'e' | &b'E') => {
             if integral.is_empty() {
                 return Invalid; // No digits before 'e'
             }
@@ -70,7 +70,7 @@ pub fn parse_decimal(s: &str) -> ParseResult<'_> {
 
             match s.first() {
                 None => Valid(Decimal::new(integral, fractional, 0)),
-                Some(&b'e') | Some(&b'E') => parse_exp(integral, fractional, &s[1..]),
+                Some(&b'e' | &b'E') => parse_exp(integral, fractional, &s[1..]),
                 _ => Invalid, // Trailing junk after fractional part
             }
         }
diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs
index f5cd26a1852..9adea94e87d 100644
--- a/src/libcore/num/flt2dec/mod.rs
+++ b/src/libcore/num/flt2dec/mod.rs
@@ -422,14 +422,14 @@ fn determine_sign(sign: Sign, decoded: &FullDecoded, negative: bool) -> &'static
                 "+"
             }
         }
-        (_, Sign::Minus) | (_, Sign::MinusRaw) => {
+        (_, Sign::Minus | Sign::MinusRaw) => {
             if negative {
                 "-"
             } else {
                 ""
             }
         }
-        (_, Sign::MinusPlus) | (_, Sign::MinusPlusRaw) => {
+        (_, Sign::MinusPlus | Sign::MinusPlusRaw) => {
             if negative {
                 "-"
             } else {
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index a9a519f0a3a..59d845c619b 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -285,6 +285,7 @@
 #![feature(never_type)]
 #![feature(nll)]
 #![feature(optin_builtin_traits)]
+#![feature(or_patterns)]
 #![feature(panic_info_message)]
 #![feature(panic_internals)]
 #![feature(panic_unwind)]
diff --git a/src/libstd/sync/mpsc/oneshot.rs b/src/libstd/sync/mpsc/oneshot.rs
index 5b41525e06a..75f5621fa12 100644
--- a/src/libstd/sync/mpsc/oneshot.rs
+++ b/src/libstd/sync/mpsc/oneshot.rs
@@ -260,7 +260,7 @@ impl<T> Packet<T> {
         let state = match self.state.load(Ordering::SeqCst) {
             // Each of these states means that no further activity will happen
             // with regard to abortion selection
-            s @ EMPTY | s @ DATA | s @ DISCONNECTED => s,
+            s @ (EMPTY | DATA | DISCONNECTED) => s,
 
             // If we've got a blocked thread, then use an atomic to gain ownership
             // of it (may fail)
diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs
index f33493ee0c9..26b4faebd86 100644
--- a/src/libstd/sync/mpsc/stream.rs
+++ b/src/libstd/sync/mpsc/stream.rs
@@ -205,7 +205,7 @@ impl<T> Packet<T> {
             // Messages which actually popped from the queue shouldn't count as
             // a steal, so offset the decrement here (we already have our
             // "steal" factored into the channel count above).
-            data @ Ok(..) | data @ Err(Upgraded(..)) => unsafe {
+            data @ (Ok(..) | Err(Upgraded(..))) => unsafe {
                 *self.queue.consumer_addition().steals.get() -= 1;
                 data
             },