Skip to content

Commit 28964b4

Browse files
authored
Rollup merge of #71220 - cuviper:std_or_patterns, r=Mark-Simulacrum
Dogfood or_patterns in the standard library We can start using `or_patterns` in the standard library as a step toward stabilization. cc #54883 @Centril
2 parents b2e4d48 + 2edd123 commit 28964b4

File tree

10 files changed

+14
-16
lines changed

10 files changed

+14
-16
lines changed

src/liballoc/collections/btree/map.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2058,12 +2058,7 @@ where
20582058
(Excluded(s), Excluded(e)) if s == e => {
20592059
panic!("range start and end are equal and excluded in BTreeMap")
20602060
}
2061-
(Included(s), Included(e))
2062-
| (Included(s), Excluded(e))
2063-
| (Excluded(s), Included(e))
2064-
| (Excluded(s), Excluded(e))
2065-
if s > e =>
2066-
{
2061+
(Included(s) | Excluded(s), Included(e) | Excluded(e)) if s > e => {
20672062
panic!("range start is greater than range end in BTreeMap")
20682063
}
20692064
_ => {}

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
#![feature(new_uninit)]
104104
#![feature(nll)]
105105
#![feature(optin_builtin_traits)]
106+
#![feature(or_patterns)]
106107
#![feature(pattern)]
107108
#![feature(ptr_internals)]
108109
#![feature(ptr_offset_from)]

src/libcore/cmp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
858858
#[must_use]
859859
#[stable(feature = "rust1", since = "1.0.0")]
860860
fn le(&self, other: &Rhs) -> bool {
861-
matches!(self.partial_cmp(other), Some(Less) | Some(Equal))
861+
matches!(self.partial_cmp(other), Some(Less | Equal))
862862
}
863863

864864
/// 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> {
895895
#[must_use]
896896
#[stable(feature = "rust1", since = "1.0.0")]
897897
fn ge(&self, other: &Rhs) -> bool {
898-
matches!(self.partial_cmp(other), Some(Greater) | Some(Equal))
898+
matches!(self.partial_cmp(other), Some(Greater | Equal))
899899
}
900900
}
901901

src/libcore/iter/traits/iterator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3109,7 +3109,7 @@ pub trait Iterator {
31093109
Self::Item: PartialOrd<I::Item>,
31103110
Self: Sized,
31113111
{
3112-
matches!(self.partial_cmp(other), Some(Ordering::Less) | Some(Ordering::Equal))
3112+
matches!(self.partial_cmp(other), Some(Ordering::Less | Ordering::Equal))
31133113
}
31143114

31153115
/// Determines if the elements of this `Iterator` are lexicographically
@@ -3149,7 +3149,7 @@ pub trait Iterator {
31493149
Self::Item: PartialOrd<I::Item>,
31503150
Self: Sized,
31513151
{
3152-
matches!(self.partial_cmp(other), Some(Ordering::Greater) | Some(Ordering::Equal))
3152+
matches!(self.partial_cmp(other), Some(Ordering::Greater | Ordering::Equal))
31533153
}
31543154

31553155
/// Checks if the elements of this iterator are sorted.

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
#![feature(exhaustive_patterns)]
106106
#![feature(no_core)]
107107
#![feature(optin_builtin_traits)]
108+
#![feature(or_patterns)]
108109
#![feature(prelude_import)]
109110
#![feature(repr_simd, platform_intrinsics)]
110111
#![feature(rustc_attrs)]

src/libcore/num/dec2flt/parse.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn parse_decimal(s: &str) -> ParseResult<'_> {
5454

5555
match s.first() {
5656
None => Valid(Decimal::new(integral, b"", 0)),
57-
Some(&b'e') | Some(&b'E') => {
57+
Some(&b'e' | &b'E') => {
5858
if integral.is_empty() {
5959
return Invalid; // No digits before 'e'
6060
}
@@ -70,7 +70,7 @@ pub fn parse_decimal(s: &str) -> ParseResult<'_> {
7070

7171
match s.first() {
7272
None => Valid(Decimal::new(integral, fractional, 0)),
73-
Some(&b'e') | Some(&b'E') => parse_exp(integral, fractional, &s[1..]),
73+
Some(&b'e' | &b'E') => parse_exp(integral, fractional, &s[1..]),
7474
_ => Invalid, // Trailing junk after fractional part
7575
}
7676
}

src/libcore/num/flt2dec/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,14 @@ fn determine_sign(sign: Sign, decoded: &FullDecoded, negative: bool) -> &'static
422422
"+"
423423
}
424424
}
425-
(_, Sign::Minus) | (_, Sign::MinusRaw) => {
425+
(_, Sign::Minus | Sign::MinusRaw) => {
426426
if negative {
427427
"-"
428428
} else {
429429
""
430430
}
431431
}
432-
(_, Sign::MinusPlus) | (_, Sign::MinusPlusRaw) => {
432+
(_, Sign::MinusPlus | Sign::MinusPlusRaw) => {
433433
if negative {
434434
"-"
435435
} else {

src/libstd/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
#![feature(never_type)]
286286
#![feature(nll)]
287287
#![feature(optin_builtin_traits)]
288+
#![feature(or_patterns)]
288289
#![feature(panic_info_message)]
289290
#![feature(panic_internals)]
290291
#![feature(panic_unwind)]

src/libstd/sync/mpsc/oneshot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<T> Packet<T> {
260260
let state = match self.state.load(Ordering::SeqCst) {
261261
// Each of these states means that no further activity will happen
262262
// with regard to abortion selection
263-
s @ EMPTY | s @ DATA | s @ DISCONNECTED => s,
263+
s @ (EMPTY | DATA | DISCONNECTED) => s,
264264

265265
// If we've got a blocked thread, then use an atomic to gain ownership
266266
// of it (may fail)

src/libstd/sync/mpsc/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<T> Packet<T> {
205205
// Messages which actually popped from the queue shouldn't count as
206206
// a steal, so offset the decrement here (we already have our
207207
// "steal" factored into the channel count above).
208-
data @ Ok(..) | data @ Err(Upgraded(..)) => unsafe {
208+
data @ (Ok(..) | Err(Upgraded(..))) => unsafe {
209209
*self.queue.consumer_addition().steals.get() -= 1;
210210
data
211211
},

0 commit comments

Comments
 (0)