Skip to content

Commit adc6572

Browse files
committed
Auto merge of #68034 - Centril:rollup-3d9pq14, r=Centril
Rollup of 12 pull requests Successful merges: - #67630 (Treat extern statics just like statics in the "const pointer to static" representation) - #67747 (Explain that associated types and consts can't be accessed directly on the trait's path) - #67884 (Fix incremental builds of core by allowing unused attribute.) - #67966 (Use matches macro in libcore and libstd) - #67979 (Move `intravisit` => `rustc_hir` + misc cleanup) - #67986 (Display more informative ICE) - #67990 (slice patterns: harden match-based borrowck tests) - #68005 (Improve E0184 explanation) - #68009 (Spell check librustc_error_codes) - #68023 (Fix issue #68008) - #68024 (Remove `-Z continue-parse-after-error`) - #68026 (Small improvements in lexical_region_resolve) Failed merges: r? @ghost
2 parents caa231d + b24de8f commit adc6572

File tree

123 files changed

+1666
-535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1666
-535
lines changed

src/libcore/cmp.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -821,10 +821,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
821821
#[must_use]
822822
#[stable(feature = "rust1", since = "1.0.0")]
823823
fn lt(&self, other: &Rhs) -> bool {
824-
match self.partial_cmp(other) {
825-
Some(Less) => true,
826-
_ => false,
827-
}
824+
matches!(self.partial_cmp(other), Some(Less))
828825
}
829826

830827
/// This method tests less than or equal to (for `self` and `other`) and is used by the `<=`
@@ -843,10 +840,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
843840
#[must_use]
844841
#[stable(feature = "rust1", since = "1.0.0")]
845842
fn le(&self, other: &Rhs) -> bool {
846-
match self.partial_cmp(other) {
847-
Some(Less) | Some(Equal) => true,
848-
_ => false,
849-
}
843+
matches!(self.partial_cmp(other), Some(Less) | Some(Equal))
850844
}
851845

852846
/// This method tests greater than (for `self` and `other`) and is used by the `>` operator.
@@ -864,10 +858,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
864858
#[must_use]
865859
#[stable(feature = "rust1", since = "1.0.0")]
866860
fn gt(&self, other: &Rhs) -> bool {
867-
match self.partial_cmp(other) {
868-
Some(Greater) => true,
869-
_ => false,
870-
}
861+
matches!(self.partial_cmp(other), Some(Greater))
871862
}
872863

873864
/// This method tests greater than or equal to (for `self` and `other`) and is used by the `>=`
@@ -886,10 +877,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
886877
#[must_use]
887878
#[stable(feature = "rust1", since = "1.0.0")]
888879
fn ge(&self, other: &Rhs) -> bool {
889-
match self.partial_cmp(other) {
890-
Some(Greater) | Some(Equal) => true,
891-
_ => false,
892-
}
880+
matches!(self.partial_cmp(other), Some(Greater) | Some(Equal))
893881
}
894882
}
895883

src/libcore/iter/traits/iterator.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -2968,10 +2968,7 @@ pub trait Iterator {
29682968
Self::Item: PartialOrd<I::Item>,
29692969
Self: Sized,
29702970
{
2971-
match self.partial_cmp(other) {
2972-
Some(Ordering::Less) | Some(Ordering::Equal) => true,
2973-
_ => false,
2974-
}
2971+
matches!(self.partial_cmp(other), Some(Ordering::Less) | Some(Ordering::Equal))
29752972
}
29762973

29772974
/// Determines if the elements of this `Iterator` are lexicographically
@@ -3011,10 +3008,7 @@ pub trait Iterator {
30113008
Self::Item: PartialOrd<I::Item>,
30123009
Self: Sized,
30133010
{
3014-
match self.partial_cmp(other) {
3015-
Some(Ordering::Greater) | Some(Ordering::Equal) => true,
3016-
_ => false,
3017-
}
3011+
matches!(self.partial_cmp(other), Some(Ordering::Greater) | Some(Ordering::Equal))
30183012
}
30193013

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

src/libcore/num/mod.rs

+13-40
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@ $EndFeature, "
14161416
```"),
14171417
#[stable(feature = "no_panic_abs", since = "1.13.0")]
14181418
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
1419+
#[allow(unused_attributes)]
14191420
#[allow_internal_unstable(const_if_match)]
14201421
#[inline]
14211422
pub const fn wrapping_abs(self) -> Self {
@@ -1709,6 +1710,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
17091710
#[inline]
17101711
#[stable(feature = "wrapping", since = "1.7.0")]
17111712
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
1713+
#[allow(unused_attributes)]
17121714
#[allow_internal_unstable(const_if_match)]
17131715
pub const fn overflowing_neg(self) -> (Self, bool) {
17141716
if self == Self::min_value() {
@@ -1997,6 +1999,7 @@ $EndFeature, "
19971999
```"),
19982000
#[stable(feature = "rust1", since = "1.0.0")]
19992001
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
2002+
#[allow(unused_attributes)]
20002003
#[allow_internal_unstable(const_if_match)]
20012004
#[inline]
20022005
#[rustc_inherit_overflow_checks]
@@ -4283,10 +4286,7 @@ impl u8 {
42834286
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
42844287
#[inline]
42854288
pub fn is_ascii_alphabetic(&self) -> bool {
4286-
match *self {
4287-
b'A'..=b'Z' | b'a'..=b'z' => true,
4288-
_ => false,
4289-
}
4289+
matches!(*self, b'A'..=b'Z' | b'a'..=b'z')
42904290
}
42914291

42924292
/// Checks if the value is an ASCII uppercase character:
@@ -4318,10 +4318,7 @@ impl u8 {
43184318
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
43194319
#[inline]
43204320
pub fn is_ascii_uppercase(&self) -> bool {
4321-
match *self {
4322-
b'A'..=b'Z' => true,
4323-
_ => false,
4324-
}
4321+
matches!(*self, b'A'..=b'Z')
43254322
}
43264323

43274324
/// Checks if the value is an ASCII lowercase character:
@@ -4353,10 +4350,7 @@ impl u8 {
43534350
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
43544351
#[inline]
43554352
pub fn is_ascii_lowercase(&self) -> bool {
4356-
match *self {
4357-
b'a'..=b'z' => true,
4358-
_ => false,
4359-
}
4353+
matches!(*self, b'a'..=b'z')
43604354
}
43614355

43624356
/// Checks if the value is an ASCII alphanumeric character:
@@ -4391,10 +4385,7 @@ impl u8 {
43914385
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
43924386
#[inline]
43934387
pub fn is_ascii_alphanumeric(&self) -> bool {
4394-
match *self {
4395-
b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z' => true,
4396-
_ => false,
4397-
}
4388+
matches!(*self, b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z')
43984389
}
43994390

44004391
/// Checks if the value is an ASCII decimal digit:
@@ -4426,10 +4417,7 @@ impl u8 {
44264417
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
44274418
#[inline]
44284419
pub fn is_ascii_digit(&self) -> bool {
4429-
match *self {
4430-
b'0'..=b'9' => true,
4431-
_ => false,
4432-
}
4420+
matches!(*self, b'0'..=b'9')
44334421
}
44344422

44354423
/// Checks if the value is an ASCII hexadecimal digit:
@@ -4464,10 +4452,7 @@ impl u8 {
44644452
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
44654453
#[inline]
44664454
pub fn is_ascii_hexdigit(&self) -> bool {
4467-
match *self {
4468-
b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f' => true,
4469-
_ => false,
4470-
}
4455+
matches!(*self, b'0'..=b'9' | b'A'..=b'F' | b'a'..=b'f')
44714456
}
44724457

44734458
/// Checks if the value is an ASCII punctuation character:
@@ -4503,10 +4488,7 @@ impl u8 {
45034488
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
45044489
#[inline]
45054490
pub fn is_ascii_punctuation(&self) -> bool {
4506-
match *self {
4507-
b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~' => true,
4508-
_ => false,
4509-
}
4491+
matches!(*self, b'!'..=b'/' | b':'..=b'@' | b'['..=b'`' | b'{'..=b'~')
45104492
}
45114493

45124494
/// Checks if the value is an ASCII graphic character:
@@ -4538,10 +4520,7 @@ impl u8 {
45384520
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
45394521
#[inline]
45404522
pub fn is_ascii_graphic(&self) -> bool {
4541-
match *self {
4542-
b'!'..=b'~' => true,
4543-
_ => false,
4544-
}
4523+
matches!(*self, b'!'..=b'~')
45454524
}
45464525

45474526
/// Checks if the value is an ASCII whitespace character:
@@ -4590,10 +4569,7 @@ impl u8 {
45904569
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
45914570
#[inline]
45924571
pub fn is_ascii_whitespace(&self) -> bool {
4593-
match *self {
4594-
b'\t' | b'\n' | b'\x0C' | b'\r' | b' ' => true,
4595-
_ => false,
4596-
}
4572+
matches!(*self, b'\t' | b'\n' | b'\x0C' | b'\r' | b' ')
45974573
}
45984574

45994575
/// Checks if the value is an ASCII control character:
@@ -4627,10 +4603,7 @@ impl u8 {
46274603
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
46284604
#[inline]
46294605
pub fn is_ascii_control(&self) -> bool {
4630-
match *self {
4631-
b'\0'..=b'\x1F' | b'\x7F' => true,
4632-
_ => false,
4633-
}
4606+
matches!(*self, b'\0'..=b'\x1F' | b'\x7F')
46344607
}
46354608
}
46364609

src/libcore/option.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ impl<T> Option<T> {
187187
#[inline]
188188
#[stable(feature = "rust1", since = "1.0.0")]
189189
pub fn is_some(&self) -> bool {
190-
match *self {
191-
Some(_) => true,
192-
None => false,
193-
}
190+
matches!(*self, Some(_))
194191
}
195192

196193
/// Returns `true` if the option is a [`None`] value.

src/libcore/result.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,7 @@ impl<T, E> Result<T, E> {
282282
#[inline]
283283
#[stable(feature = "rust1", since = "1.0.0")]
284284
pub const fn is_ok(&self) -> bool {
285-
match *self {
286-
Ok(_) => true,
287-
Err(_) => false,
288-
}
285+
matches!(*self, Ok(_))
289286
}
290287

291288
/// Returns `true` if the result is [`Err`].

src/libcore/str/pattern.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ pub trait Pattern<'a>: Sized {
4646
/// Checks whether the pattern matches at the front of the haystack
4747
#[inline]
4848
fn is_prefix_of(self, haystack: &'a str) -> bool {
49-
match self.into_searcher(haystack).next() {
50-
SearchStep::Match(0, _) => true,
51-
_ => false,
52-
}
49+
matches!(self.into_searcher(haystack).next(), SearchStep::Match(0, _))
5350
}
5451

5552
/// Checks whether the pattern matches at the back of the haystack
@@ -58,10 +55,7 @@ pub trait Pattern<'a>: Sized {
5855
where
5956
Self::Searcher: ReverseSearcher<'a>,
6057
{
61-
match self.into_searcher(haystack).next_back() {
62-
SearchStep::Match(_, j) if haystack.len() == j => true,
63-
_ => false,
64-
}
58+
matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j)
6559
}
6660
}
6761

src/libcore/task/poll.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ impl<T> Poll<T> {
3939
#[inline]
4040
#[stable(feature = "futures_api", since = "1.36.0")]
4141
pub fn is_ready(&self) -> bool {
42-
match *self {
43-
Poll::Ready(_) => true,
44-
Poll::Pending => false,
45-
}
42+
matches!(*self, Poll::Ready(_))
4643
}
4744

4845
/// Returns `true` if this is `Poll::Pending`

src/librustc/hir/check_attr.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! conflicts between multiple such attributes attached to the same
55
//! item.
66
7-
use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
7+
use crate::hir::map::Map;
88
use crate::lint::builtin::UNUSED_ATTRIBUTES;
99
use crate::ty::query::Providers;
1010
use crate::ty::TyCtxt;
@@ -13,6 +13,7 @@ use errors::struct_span_err;
1313
use rustc_error_codes::*;
1414
use rustc_hir as hir;
1515
use rustc_hir::def_id::DefId;
16+
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
1617
use rustc_hir::DUMMY_HIR_ID;
1718
use rustc_hir::{self, HirId, Item, ItemKind, TraitItem, TraitItemKind};
1819
use rustc_span::symbol::sym;
@@ -519,7 +520,9 @@ impl CheckAttrVisitor<'tcx> {
519520
}
520521

521522
impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
522-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
523+
type Map = Map<'tcx>;
524+
525+
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
523526
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
524527
}
525528

0 commit comments

Comments
 (0)