Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #63563

Closed
wants to merge 46 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3b229f1
check that ptr is valid already when doing Deref, not only when doing…
RalfJung Jul 27, 2019
5800bec
discourage use of ref_to_mplace
RalfJung Jul 28, 2019
3677c5b
the alignment checks on access can no longer fail now
RalfJung Jul 28, 2019
e4c39e1
better name for check_in_alloc
RalfJung Jul 28, 2019
388d99d
fix tests
RalfJung Jul 28, 2019
74fbdb6
move 'get me the access-checked version of an mplace' into separate f…
RalfJung Jul 28, 2019
647c0e0
'Ref' can now be sure it gets a 'Pointer'
RalfJung Jul 28, 2019
a4af9d1
parse_pat_with_range_pat: remove unnecessary assignments.
Centril Aug 12, 2019
90793c0
extract parse_pat_deref
Centril Aug 12, 2019
c69b3ed
extract parse_pat_tuple_or_parens
Centril Aug 12, 2019
3b65133
extract recover_pat_ident_mut_first
Centril Aug 12, 2019
231da7e
extract ban_pat_range_if_ambiguous
Centril Aug 12, 2019
e32bd69
extract parse_pat_mac_invoc
Centril Aug 12, 2019
e6f980f
extract parse_pat_range_starting_with_path
Centril Aug 12, 2019
49740b7
extract parse_pat_range_starting_with_lit
Centril Aug 12, 2019
37f37a5
parser/pat: minor misc cleanup
Centril Aug 12, 2019
ddf734d
extract fatal_unexpected_non_pat
Centril Aug 12, 2019
c8fc4c1
extract parse_pat_{tuple_}struct + recover_one_fewer_dotdot
Centril Aug 12, 2019
71415ef
Parse excess semicolons as empty stmts for linting
nathanwhit Jul 25, 2019
2f6cb5f
Add lint for excess trailing semicolons
nathanwhit Jul 30, 2019
76a1345
Update tests for excess semicolon lint
nathanwhit Jul 30, 2019
c037597
Remove redundant `ty` fields from `mir::Constant` and `hair::pattern:…
eddyb Aug 12, 2019
2882bee
rustc_mir: add sanity asserts for the types of `ty::Const`s.
eddyb Aug 12, 2019
22127b1
rustc_mir: use the right type for associated const literals.
eddyb Aug 12, 2019
d30f481
Fix indentation nit in src/librustc/mir/mod.rs.
eddyb Aug 12, 2019
13fd466
Point at the right enclosing scope when using `await` in non-async fn
estebank Aug 13, 2019
e9b3a01
Bump to 1.39
Mark-Simulacrum Aug 11, 2019
376636e
syntax: Remove `DummyResult::expn_only`
petrochenkov Aug 13, 2019
25d507f
review comment: move test
estebank Aug 13, 2019
0d29142
expand: `expand_fragment` -> `fully_expand_fragment`
petrochenkov Aug 13, 2019
d416ebe
expand: Unimplement `MutVisitor` on `MacroExpander`
petrochenkov Aug 13, 2019
9348af8
Add NodeId for Arm, Field and FieldPat
c410-f3r Aug 14, 2019
2601c86
Handle cfg(bootstrap) throughout
Mark-Simulacrum Aug 11, 2019
6575a96
Disable --cfg bootstrap in libcore
Mark-Simulacrum Aug 12, 2019
f7ff36d
Update error-format to match new Cargo flags for pipelining
alexcrichton Aug 12, 2019
264640c
move test that shouldn't be in test/run-pass/
Centril Aug 14, 2019
96f51b5
Rollup merge of #62984 - nathanwhit:extra_semi_lint, r=varkor
Centril Aug 14, 2019
34dea10
Rollup merge of #63075 - RalfJung:deref-checks, r=oli-obk
Centril Aug 14, 2019
b2a39d5
Rollup merge of #63490 - Centril:cleanup-pat-parser, r=petrochenkov
Centril Aug 14, 2019
6a11bf7
Rollup merge of #63495 - eddyb:mir-constant-ty, r=oli-obk
Centril Aug 14, 2019
a93e9ff
Rollup merge of #63509 - estebank:async-span, r=Centril
Centril Aug 14, 2019
f475eb7
Rollup merge of #63528 - petrochenkov:anyany, r=estebank
Centril Aug 14, 2019
2a62053
Rollup merge of #63534 - Mark-Simulacrum:stage0-bump, r=Centril
Centril Aug 14, 2019
8e66f1a
Rollup merge of #63537 - petrochenkov:novisit, r=alexcrichton
Centril Aug 14, 2019
e030478
Rollup merge of #63542 - c410-f3r:node_ids, r=petrochenkov
Centril Aug 14, 2019
a1f564b
Rollup merge of #63560 - Centril:mv-generator-test, r=petrochenkov
Centril Aug 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
extract parse_pat_tuple_or_parens
  • Loading branch information
Centril committed Aug 12, 2019
commit c69b3ede8a98b45633736f7a84757fe7f3b5a392
26 changes: 14 additions & 12 deletions src/libsyntax/parse/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,7 @@ impl<'a> Parser<'a> {
let lo = self.token.span;
let pat = match self.token.kind {
token::BinOp(token::And) | token::AndAnd => self.parse_pat_deref(expected)?,
token::OpenDelim(token::Paren) => {
// Parse a tuple or parenthesis pattern.
let (fields, trailing_comma) = self.parse_paren_comma_seq(|p| p.parse_pat(None))?;

// Here, `(pat,)` is a tuple pattern.
// For backward compatibility, `(..)` is a tuple pattern as well.
if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) {
PatKind::Paren(fields.into_iter().nth(0).unwrap())
} else {
PatKind::Tuple(fields)
}
}
token::OpenDelim(token::Paren) => self.parse_pat_tuple_or_parens()?,
token::OpenDelim(token::Bracket) => {
// Parse `[pat, pat,...]` as a slice pattern.
PatKind::Slice(self.parse_delim_comma_seq(token::Bracket, |p| p.parse_pat(None))?.0)
Expand Down Expand Up @@ -336,6 +325,19 @@ impl<'a> Parser<'a> {
Ok(PatKind::Ref(subpat, mutbl))
}

/// Parse a tuple or parenthesis pattern.
fn parse_pat_tuple_or_parens(&mut self) -> PResult<'a, PatKind> {
let (fields, trailing_comma) = self.parse_paren_comma_seq(|p| p.parse_pat(None))?;

// Here, `(pat,)` is a tuple pattern.
// For backward compatibility, `(..)` is a tuple pattern as well.
Ok(if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) {
PatKind::Paren(fields.into_iter().nth(0).unwrap())
} else {
PatKind::Tuple(fields)
})
}

// Helper function to decide whether to parse as ident binding
// or to try to do something more complex like range patterns.
fn parse_as_ident(&mut self) -> bool {
Expand Down