Files
rust/src/libsyntax
Zack M. Davis 1f04597c3c in which parentheses are suggested for should-have-been-tuple-patterns
Programmers used to working in some other languages (such as Python or
Go) might expect to be able to destructure values with comma-separated
identifiers but no parentheses on the left side of an assignment.

Previously, the first name in such code would get parsed as a
single-indentifier pattern—recognizing, for example, the
`let a` in `let a, b = (1, 2);`—whereupon we would have a fatal syntax
error on seeing an unexpected comma rather than the expected semicolon
(all the way nearer to the end of `parse_full_stmt`).

Instead, let's look for that comma when parsing the pattern, and if we
see it, momentarily make-believe that we're parsing the remaining
elements in a tuple pattern, so that we can suggest wrapping it all in
parentheses. We need to do this in a separate wrapper method called on
the top-level pattern (or `|`-patterns) in a `let` statement, `for`
loop, `if`- or `while let` expression, or match arm rather than within
`parse_pat` itself, because `parse_pat` gets called recursively to parse
the sub-patterns within a tuple pattern.

Resolves #48492.
2018-03-08 11:30:34 -08:00
..
2018-03-05 11:05:01 +01:00
2018-03-02 10:48:52 +01:00
2018-03-02 10:48:52 +01:00
2018-03-06 19:58:02 -05:00
2018-03-02 10:48:52 +01:00
2018-02-17 17:38:49 +01:00
2018-03-06 19:58:02 -05:00
2018-03-02 10:48:52 +01:00
2018-03-02 10:48:52 +01:00
2018-02-22 18:26:01 -05:00
2018-03-02 10:48:52 +01:00

NB: This crate is part of the Rust compiler. For an overview of the compiler as a whole, see the README.md file found in librustc.

The syntax crate contains those things concerned purely with syntax that is, the AST ("abstract syntax tree"), parser, pretty-printer, lexer, macro expander, and utilities for traversing ASTs.