summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/pat.rs
AgeCommit message (Collapse)AuthorLines
2021-03-19stabilize or_patternsmark-54/+19
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-4/+4
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-03-05use pat<no_top_alt> for patterns in let bindingsmark-62/+122
2021-02-23Rollup merge of #81235 - reese:rw-tuple-diagnostics, r=estebankDylan DPC-1/+1
Improve suggestion for tuple struct pattern matching errors. Closes #80174 This change allows numbers to be parsed as field names when pattern matching on structs, which allows us to provide better error messages when tuple structs are matched using a struct pattern. r? ``@estebank``
2021-02-15Simplify pattern grammar by allowing nested leading vertmark-81/+102
Along the way, we also implement a handful of diagnostics improvements and fixes, particularly with respect to the special handling of `||` in place of `|` and when there are leading verts in function params, which don't allow top-level or-patterns anyway.
2021-02-13Require passing an `AttrWrapper` to `collect_tokens_trailing_token`Aaron Hill-11/+19
This is a pure refactoring split out from #80689. It represents the most invasive part of that PR, requiring changes in every caller of `parse_outer_attributes` In order to eagerly expand `#[cfg]` attributes while preserving the original `TokenStream`, we need to know the range of tokens that corresponds to every attribute target. This is accomplished by making `parse_outer_attributes` return an opaque `AttrWrapper` struct. An `AttrWrapper` must be converted to a plain `AttrVec` by passing it to `collect_tokens_trailing_token`. This makes it difficult to accidentally construct an AST node with attributes without calling `collect_tokens_trailing_token`, since AST nodes store an `AttrVec`, not an `AttrWrapper`. As a result, we now call `collect_tokens_trailing_token` for attribute targets which only support inert attributes, such as generic arguments and struct fields. Currently, the constructed `LazyTokenStream` is simply discarded. Future PRs will record the token range corresponding to the attribute target, allowing those tokens to be removed from an enclosing `collect_tokens_trailing_token` call if necessary.
2021-01-29Fix typo in pat.rsIkko Ashimine-1/+1
parentesized -> parenthesized
2021-01-20Improve suggestion for tuple struct pattern matching errors.Reese Williams-1/+1
Currently, when a user uses a struct pattern to pattern match on a tuple struct, the errors we emit generally suggest adding fields using their field names, which are numbers. However, numbers are not valid identifiers, so the suggestions, which use the shorthand notation, are not valid syntax. This commit changes those errors to suggest using the actual tuple struct pattern syntax instead, which is a more actionable suggestion.
2020-12-30Implement edition-based macro pat featuremark-7/+0
2020-12-19implement edition-specific :pat behavior for 2015/18mark-3/+14
2020-11-29Fixes #79357 unstable or-pat suggestionsunknown-11/+22
2020-11-03rustc_ast: `visit_mac` -> `visit_mac_call`Vadim Petrochenkov-1/+1
2020-11-03rustc_ast: Do not panic by default when visiting macro callsVadim Petrochenkov-4/+0
2020-10-30Add back missing commentsJoshua Nelson-2/+3
2020-10-30Fix even more clippy warningsJoshua Nelson-9/+8
2020-10-22Make inline const work for half open rangesSantiago Pastorino-4/+4
2020-10-22Make inline const work in range patternsSantiago Pastorino-6/+15
2020-10-22Rename parse_const_expr to parse_const_blockSantiago Pastorino-1/+1
2020-10-16Parse inline const patternsSantiago Pastorino-0/+3
2020-10-02Fix span for incorrect pattern field and add labelEsteban Küber-1/+2
2020-08-30mv compiler to compiler/mark-0/+1012