diff options
| author | Josh Stone <jistone@redhat.com> | 2020-04-16 17:38:52 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2020-04-19 07:33:58 -0700 |
| commit | 7b005c5fcb743e97b3cafee951b19fe7e51753c8 (patch) | |
| tree | d5957a313d6f45c65b344b9c1bf6cf0247fd4409 /src/librustc_parse/parser | |
| parent | 36b1a9296cde2b773771710e9bbd608fd2eca35f (diff) | |
| download | rust-7b005c5fcb743e97b3cafee951b19fe7e51753c8.tar.gz rust-7b005c5fcb743e97b3cafee951b19fe7e51753c8.zip | |
Dogfood more or_patterns in the compiler
Diffstat (limited to 'src/librustc_parse/parser')
| -rw-r--r-- | src/librustc_parse/parser/diagnostics.rs | 14 | ||||
| -rw-r--r-- | src/librustc_parse/parser/pat.rs | 2 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs index da6d863f239..fe129f2c3a8 100644 --- a/src/librustc_parse/parser/diagnostics.rs +++ b/src/librustc_parse/parser/diagnostics.rs @@ -508,11 +508,11 @@ impl<'a> Parser<'a> { // `x == y == z` (BinOpKind::Eq, AssocOp::Equal) | // `x < y < z` and friends. - (BinOpKind::Lt, AssocOp::Less) | (BinOpKind::Lt, AssocOp::LessEqual) | - (BinOpKind::Le, AssocOp::LessEqual) | (BinOpKind::Le, AssocOp::Less) | + (BinOpKind::Lt, AssocOp::Less | AssocOp::LessEqual) | + (BinOpKind::Le, AssocOp::LessEqual | AssocOp::Less) | // `x > y > z` and friends. - (BinOpKind::Gt, AssocOp::Greater) | (BinOpKind::Gt, AssocOp::GreaterEqual) | - (BinOpKind::Ge, AssocOp::GreaterEqual) | (BinOpKind::Ge, AssocOp::Greater) => { + (BinOpKind::Gt, AssocOp::Greater | AssocOp::GreaterEqual) | + (BinOpKind::Ge, AssocOp::GreaterEqual | AssocOp::Greater) => { let expr_to_str = |e: &Expr| { self.span_to_snippet(e.span) .unwrap_or_else(|_| pprust::expr_to_string(&e)) @@ -526,8 +526,7 @@ impl<'a> Parser<'a> { false // Keep the current parse behavior, where the AST is `(x < y) < z`. } // `x == y < z` - (BinOpKind::Eq, AssocOp::Less) | (BinOpKind::Eq, AssocOp::LessEqual) | - (BinOpKind::Eq, AssocOp::Greater) | (BinOpKind::Eq, AssocOp::GreaterEqual) => { + (BinOpKind::Eq, AssocOp::Less | AssocOp::LessEqual | AssocOp::Greater | AssocOp::GreaterEqual) => { // Consume `z`/outer-op-rhs. let snapshot = self.clone(); match self.parse_expr() { @@ -545,8 +544,7 @@ impl<'a> Parser<'a> { } } // `x > y == z` - (BinOpKind::Lt, AssocOp::Equal) | (BinOpKind::Le, AssocOp::Equal) | - (BinOpKind::Gt, AssocOp::Equal) | (BinOpKind::Ge, AssocOp::Equal) => { + (BinOpKind::Lt | BinOpKind::Le | BinOpKind::Gt | BinOpKind::Ge, AssocOp::Equal) => { let snapshot = self.clone(); // At this point it is always valid to enclose the lhs in parentheses, no // further checks are necessary. diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index 983aa43916f..d588373425d 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -162,7 +162,7 @@ impl<'a> Parser<'a> { _ => false, }); match (is_end_ahead, &self.token.kind) { - (true, token::BinOp(token::Or)) | (true, token::OrOr) => { + (true, token::BinOp(token::Or) | token::OrOr) => { self.ban_illegal_vert(lo, "trailing", "not allowed in an or-pattern"); self.bump(); true |
