Skip to content

Commit ad48d52

Browse files
committed
Auto merge of #71231 - cuviper:rustc_or_patterns, r=Mark-Simulacrum
Dogfood more or_patterns in the compiler Another step toward the stabilization of `or_patterns`... cc #54883 @Centril r? @Mark-Simulacrum
2 parents 1b7dec9 + 7b005c5 commit ad48d52

File tree

125 files changed

+759
-688
lines changed

Some content is hidden

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

125 files changed

+759
-688
lines changed

src/libfmt_macros/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
test(attr(deny(warnings)))
1111
)]
1212
#![feature(nll)]
13+
#![feature(or_patterns)]
1314
#![feature(rustc_private)]
1415
#![feature(unicode_internals)]
1516
#![feature(bool_to_option)]
@@ -482,7 +483,7 @@ impl<'a> Parser<'a> {
482483
// fill character
483484
if let Some(&(_, c)) = self.cur.peek() {
484485
match self.cur.clone().nth(1) {
485-
Some((_, '>')) | Some((_, '<')) | Some((_, '^')) => {
486+
Some((_, '>' | '<' | '^')) => {
486487
spec.fill = Some(c);
487488
self.cur.next();
488489
}

src/librustc_apfloat/ieee.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ impl<S: Semantics> Float for IeeeFloat<S> {
744744
Status::OK
745745
}
746746

747-
(Category::Zero, _) | (_, Category::NaN) | (_, Category::Infinity) => {
747+
(Category::Zero, _) | (_, Category::NaN | Category::Infinity) => {
748748
self = rhs;
749749
Status::OK
750750
}
@@ -954,7 +954,7 @@ impl<S: Semantics> Float for IeeeFloat<S> {
954954
Status::INVALID_OP.and(Self::NAN)
955955
}
956956

957-
(Category::Infinity, _) | (Category::Zero, _) => Status::OK.and(self),
957+
(Category::Infinity | Category::Zero, _) => Status::OK.and(self),
958958

959959
(Category::Normal, Category::Infinity) => {
960960
self.category = Category::Zero;
@@ -989,8 +989,7 @@ impl<S: Semantics> Float for IeeeFloat<S> {
989989
fn c_fmod(mut self, rhs: Self) -> StatusAnd<Self> {
990990
match (self.category, rhs.category) {
991991
(Category::NaN, _)
992-
| (Category::Zero, Category::Infinity)
993-
| (Category::Zero, Category::Normal)
992+
| (Category::Zero, Category::Infinity | Category::Normal)
994993
| (Category::Normal, Category::Infinity) => Status::OK.and(self),
995994

996995
(_, Category::NaN) => {

src/librustc_apfloat/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#![no_std]
3535
#![forbid(unsafe_code)]
3636
#![feature(nll)]
37+
#![feature(or_patterns)]
3738

3839
#[macro_use]
3940
extern crate alloc;

src/librustc_apfloat/ppc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ where
186186
Status::OK.and(self)
187187
}
188188

189-
(Category::Zero, _) | (_, Category::NaN) | (_, Category::Infinity) => {
190-
Status::OK.and(rhs)
191-
}
189+
(Category::Zero, _) | (_, Category::NaN | Category::Infinity) => Status::OK.and(rhs),
192190

193191
(Category::Normal, Category::Normal) => {
194192
let mut status = Status::OK;
@@ -288,9 +286,9 @@ where
288286
Status::OK.and(Self::NAN)
289287
}
290288

291-
(Category::Zero, _) | (Category::Infinity, _) => Status::OK.and(self),
289+
(Category::Zero | Category::Infinity, _) => Status::OK.and(self),
292290

293-
(_, Category::Zero) | (_, Category::Infinity) => Status::OK.and(rhs),
291+
(_, Category::Zero | Category::Infinity) => Status::OK.and(rhs),
294292

295293
(Category::Normal, Category::Normal) => {
296294
let mut status = Status::OK;

src/librustc_ast/ast.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,8 +1569,7 @@ impl LitKind {
15691569
pub fn is_suffixed(&self) -> bool {
15701570
match *self {
15711571
// suffixed variants
1572-
LitKind::Int(_, LitIntType::Signed(..))
1573-
| LitKind::Int(_, LitIntType::Unsigned(..))
1572+
LitKind::Int(_, LitIntType::Signed(..) | LitIntType::Unsigned(..))
15741573
| LitKind::Float(_, LitFloatType::Suffixed(..)) => true,
15751574
// unsuffixed variants
15761575
LitKind::Str(..)

src/librustc_ast/attr/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,10 @@ impl MetaItem {
442442
{
443443
// FIXME: Share code with `parse_path`.
444444
let path = match tokens.next().map(TokenTree::uninterpolate) {
445-
Some(TokenTree::Token(Token { kind: kind @ token::Ident(..), span }))
446-
| Some(TokenTree::Token(Token { kind: kind @ token::ModSep, span })) => 'arm: {
445+
Some(TokenTree::Token(Token {
446+
kind: kind @ (token::Ident(..) | token::ModSep),
447+
span,
448+
})) => 'arm: {
447449
let mut segments = if let token::Ident(name, _) = kind {
448450
if let Some(TokenTree::Token(Token { kind: token::ModSep, .. })) = tokens.peek()
449451
{

src/librustc_ast/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(crate_visibility_modifier)]
1515
#![feature(label_break_value)]
1616
#![feature(nll)]
17+
#![feature(or_patterns)]
1718
#![feature(try_trait)]
1819
#![feature(unicode_internals)]
1920
#![recursion_limit = "256"]

src/librustc_ast/util/comments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ pub fn gather_comments(sm: &SourceMap, path: FileName, src: String) -> Vec<Comme
226226
rustc_lexer::TokenKind::BlockComment { terminated: _ } => {
227227
if !is_block_doc_comment(token_text) {
228228
let code_to_the_right = match text[pos + token.len..].chars().next() {
229-
Some('\r') | Some('\n') => false,
229+
Some('\r' | '\n') => false,
230230
_ => true,
231231
};
232232
let style = match (code_to_the_left, code_to_the_right) {
233-
(true, true) | (false, true) => Mixed,
233+
(_, true) => Mixed,
234234
(false, false) => Isolated,
235235
(true, false) => Trailing,
236236
};

src/librustc_ast_lowering/lib.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,16 +1239,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12391239
let bounds =
12401240
this.arena.alloc_from_iter(bounds.iter().filter_map(
12411241
|bound| match *bound {
1242-
GenericBound::Trait(ref ty, TraitBoundModifier::None)
1243-
| GenericBound::Trait(ref ty, TraitBoundModifier::MaybeConst) => {
1244-
Some(this.lower_poly_trait_ref(ty, itctx.reborrow()))
1245-
}
1242+
GenericBound::Trait(
1243+
ref ty,
1244+
TraitBoundModifier::None | TraitBoundModifier::MaybeConst,
1245+
) => Some(this.lower_poly_trait_ref(ty, itctx.reborrow())),
12461246
// `?const ?Bound` will cause an error during AST validation
12471247
// anyways, so treat it like `?Bound` as compilation proceeds.
1248-
GenericBound::Trait(_, TraitBoundModifier::Maybe)
1249-
| GenericBound::Trait(_, TraitBoundModifier::MaybeConstMaybe) => {
1250-
None
1251-
}
1248+
GenericBound::Trait(
1249+
_,
1250+
TraitBoundModifier::Maybe | TraitBoundModifier::MaybeConstMaybe,
1251+
) => None,
12521252
GenericBound::Outlives(ref lifetime) => {
12531253
if lifetime_bound.is_none() {
12541254
lifetime_bound = Some(this.lower_lifetime(lifetime));
@@ -1740,8 +1740,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
17401740
c_variadic,
17411741
implicit_self: decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| {
17421742
let is_mutable_pat = match arg.pat.kind {
1743-
PatKind::Ident(BindingMode::ByValue(mt), _, _)
1744-
| PatKind::Ident(BindingMode::ByRef(mt), _, _) => mt == Mutability::Mut,
1743+
PatKind::Ident(BindingMode::ByValue(mt) | BindingMode::ByRef(mt), _, _) => {
1744+
mt == Mutability::Mut
1745+
}
17451746
_ => false,
17461747
};
17471748

@@ -2468,7 +2469,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24682469
hir::QPath::Resolved(None, path) => {
24692470
// Turn trait object paths into `TyKind::TraitObject` instead.
24702471
match path.res {
2471-
Res::Def(DefKind::Trait, _) | Res::Def(DefKind::TraitAlias, _) => {
2472+
Res::Def(DefKind::Trait | DefKind::TraitAlias, _) => {
24722473
let principal = hir::PolyTraitRef {
24732474
bound_generic_params: &[],
24742475
trait_ref: hir::TraitRef { path, hir_ref_id: hir_id },

src/librustc_ast_lowering/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
194194
) -> hir::PatKind<'hir> {
195195
match self.resolver.get_partial_res(p.id).map(|d| d.base_res()) {
196196
// `None` can occur in body-less function signatures
197-
res @ None | res @ Some(Res::Local(_)) => {
197+
res @ (None | Some(Res::Local(_))) => {
198198
let canonical_id = match res {
199199
Some(Res::Local(id)) => id,
200200
_ => p.id,

0 commit comments

Comments
 (0)