Skip to content

Commit

Permalink
Auto merge of #68034 - Centril:rollup-3d9pq14, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jan 9, 2020
2 parents caa231d + b24de8f commit adc6572
Show file tree
Hide file tree
Showing 123 changed files with 1,666 additions and 535 deletions.
20 changes: 4 additions & 16 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
fn lt(&self, other: &Rhs) -> bool {
match self.partial_cmp(other) {
Some(Less) => true,
_ => false,
}
matches!(self.partial_cmp(other), Some(Less))
}

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

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

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

Expand Down
10 changes: 2 additions & 8 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2968,10 +2968,7 @@ pub trait Iterator {
Self::Item: PartialOrd<I::Item>,
Self: Sized,
{
match self.partial_cmp(other) {
Some(Ordering::Less) | Some(Ordering::Equal) => true,
_ => false,
}
matches!(self.partial_cmp(other), Some(Ordering::Less) | Some(Ordering::Equal))
}

/// Determines if the elements of this `Iterator` are lexicographically
Expand Down Expand Up @@ -3011,10 +3008,7 @@ pub trait Iterator {
Self::Item: PartialOrd<I::Item>,
Self: Sized,
{
match self.partial_cmp(other) {
Some(Ordering::Greater) | Some(Ordering::Equal) => true,
_ => false,
}
matches!(self.partial_cmp(other), Some(Ordering::Greater) | Some(Ordering::Equal))
}

/// Checks if the elements of this iterator are sorted.
Expand Down
53 changes: 13 additions & 40 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ $EndFeature, "
```"),
#[stable(feature = "no_panic_abs", since = "1.13.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[allow(unused_attributes)]
#[allow_internal_unstable(const_if_match)]
#[inline]
pub const fn wrapping_abs(self) -> Self {
Expand Down Expand Up @@ -1709,6 +1710,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
#[inline]
#[stable(feature = "wrapping", since = "1.7.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[allow(unused_attributes)]
#[allow_internal_unstable(const_if_match)]
pub const fn overflowing_neg(self) -> (Self, bool) {
if self == Self::min_value() {
Expand Down Expand Up @@ -1997,6 +1999,7 @@ $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
#[allow(unused_attributes)]
#[allow_internal_unstable(const_if_match)]
#[inline]
#[rustc_inherit_overflow_checks]
Expand Down Expand Up @@ -4283,10 +4286,7 @@ impl u8 {
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[inline]
pub fn is_ascii_alphabetic(&self) -> bool {
match *self {
b'A'..=b'Z' | b'a'..=b'z' => true,
_ => false,
}
matches!(*self, b'A'..=b'Z' | b'a'..=b'z')
}

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

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

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

/// Checks if the value is an ASCII decimal digit:
Expand Down Expand Up @@ -4426,10 +4417,7 @@ impl u8 {
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[inline]
pub fn is_ascii_digit(&self) -> bool {
match *self {
b'0'..=b'9' => true,
_ => false,
}
matches!(*self, b'0'..=b'9')
}

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

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

/// Checks if the value is an ASCII graphic character:
Expand Down Expand Up @@ -4538,10 +4520,7 @@ impl u8 {
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[inline]
pub fn is_ascii_graphic(&self) -> bool {
match *self {
b'!'..=b'~' => true,
_ => false,
}
matches!(*self, b'!'..=b'~')
}

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

/// Checks if the value is an ASCII control character:
Expand Down Expand Up @@ -4627,10 +4603,7 @@ impl u8 {
#[stable(feature = "ascii_ctype_on_intrinsics", since = "1.24.0")]
#[inline]
pub fn is_ascii_control(&self) -> bool {
match *self {
b'\0'..=b'\x1F' | b'\x7F' => true,
_ => false,
}
matches!(*self, b'\0'..=b'\x1F' | b'\x7F')
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ impl<T> Option<T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_some(&self) -> bool {
match *self {
Some(_) => true,
None => false,
}
matches!(*self, Some(_))
}

/// Returns `true` if the option is a [`None`] value.
Expand Down
5 changes: 1 addition & 4 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,7 @@ impl<T, E> Result<T, E> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub const fn is_ok(&self) -> bool {
match *self {
Ok(_) => true,
Err(_) => false,
}
matches!(*self, Ok(_))
}

/// Returns `true` if the result is [`Err`].
Expand Down
10 changes: 2 additions & 8 deletions src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ pub trait Pattern<'a>: Sized {
/// Checks whether the pattern matches at the front of the haystack
#[inline]
fn is_prefix_of(self, haystack: &'a str) -> bool {
match self.into_searcher(haystack).next() {
SearchStep::Match(0, _) => true,
_ => false,
}
matches!(self.into_searcher(haystack).next(), SearchStep::Match(0, _))
}

/// Checks whether the pattern matches at the back of the haystack
Expand All @@ -58,10 +55,7 @@ pub trait Pattern<'a>: Sized {
where
Self::Searcher: ReverseSearcher<'a>,
{
match self.into_searcher(haystack).next_back() {
SearchStep::Match(_, j) if haystack.len() == j => true,
_ => false,
}
matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j)
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/libcore/task/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ impl<T> Poll<T> {
#[inline]
#[stable(feature = "futures_api", since = "1.36.0")]
pub fn is_ready(&self) -> bool {
match *self {
Poll::Ready(_) => true,
Poll::Pending => false,
}
matches!(*self, Poll::Ready(_))
}

/// Returns `true` if this is `Poll::Pending`
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/hir/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! conflicts between multiple such attributes attached to the same
//! item.

use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
use crate::hir::map::Map;
use crate::lint::builtin::UNUSED_ATTRIBUTES;
use crate::ty::query::Providers;
use crate::ty::TyCtxt;
Expand All @@ -13,6 +13,7 @@ use errors::struct_span_err;
use rustc_error_codes::*;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::DUMMY_HIR_ID;
use rustc_hir::{self, HirId, Item, ItemKind, TraitItem, TraitItemKind};
use rustc_span::symbol::sym;
Expand Down Expand Up @@ -519,7 +520,9 @@ impl CheckAttrVisitor<'tcx> {
}

impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
type Map = Map<'tcx>;

fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir())
}

Expand Down
Loading

0 comments on commit adc6572

Please sign in to comment.