Commit Graph

20 Commits

Author SHA1 Message Date
Vadim Petrochenkov b25d3ba781 ast/hir: Rename field-related structures
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-16 11:41:24 +03:00
mark e64138c534 use pat<no_top_alt> for patterns in let bindings 2021-03-05 10:10:04 -06:00
Dylan DPC 8e51bd4315
Rollup merge of #81235 - reese:rw-tuple-diagnostics, r=estebank
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-23 02:51:44 +01:00
mark aee1e59e6f Simplify pattern grammar by allowing nested leading vert
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-15 12:07:54 -06:00
Aaron Hill 0b411f56e1
Require passing an `AttrWrapper` to `collect_tokens_trailing_token`
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-02-13 12:07:15 -05:00
Ikko Ashimine 718398ccaf
Fix typo in pat.rs
parentesized -> parenthesized
2021-01-29 23:30:55 +09:00
Reese Williams 8a83c8f64f Improve suggestion for tuple struct pattern matching errors.
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.
2021-01-20 23:06:19 -05:00
mark 40bf3c0f09 Implement edition-based macro pat feature 2020-12-30 09:57:49 -06:00
mark 1a7d00a529 implement edition-specific :pat behavior for 2015/18 2020-12-19 07:13:36 -06:00
unknown de3a0bdf05 Fixes #79357 unstable or-pat suggestions 2020-11-29 15:31:45 -03:00
Vadim Petrochenkov 90fafc8c8f rustc_ast: `visit_mac` -> `visit_mac_call` 2020-11-03 23:39:51 +03:00
Vadim Petrochenkov 3237b3886c rustc_ast: Do not panic by default when visiting macro calls 2020-11-03 20:38:20 +03:00
Joshua Nelson 5339bd1ebe Add back missing comments 2020-10-30 10:13:41 -04:00
Joshua Nelson 57c6ed0c07 Fix even more clippy warnings 2020-10-30 10:13:39 -04:00
Santiago Pastorino 83abed9df6
Make inline const work for half open ranges 2020-10-22 13:22:12 -03:00
Santiago Pastorino f8842b9bac
Make inline const work in range patterns 2020-10-22 13:21:18 -03:00
Santiago Pastorino 954b5a81b4
Rename parse_const_expr to parse_const_block 2020-10-22 13:21:18 -03:00
Santiago Pastorino 59d07c3ae5
Parse inline const patterns 2020-10-16 15:15:34 -03:00
Esteban Küber 7d5a6203ec Fix span for incorrect pattern field and add label 2020-10-02 00:44:16 -07:00
mark 9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00