about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2019-08-26Rollup merge of #63693 - Centril:polish-parse-or-pats, r=estebankMazdak Farrokhzad-109/+210
Fully implement or-pattern parsing Builds upon the initial parsing in https://github.com/rust-lang/rust/pull/61708 to fully implement or-pattern (`p | q`) parsing as specified in [the grammar section of RFC 2535](https://github.com/rust-lang/rfcs/blob/master/text/2535-or-patterns.md#grammar). Noteworthy: - We allow or-patterns in `[p | q, ...]`. - We allow or-patterns in `let` statements and `for` expressions including with leading `|`. - We improve recovery for `p || q` (+ tests for that in `multiple-pattern-typo.rs`). - We improve recovery for `| p | q` in inner patterns (tests in `or-patterns-syntactic-fail.rs`). - We rigorously test or-pattern parsing (in `or-patterns-syntactic-{pass,fail}.rs`). - We harden the feature gating tests. - We do **_not_** change `ast.rs`. That is, `ExprKind::Let.0` and `Arm.pats` still accept `Vec<P<Pat>>`. I was starting work on that but it would be cleaner to do this in a separate PR so this one has a narrower scope. cc @dlrobertson cc the tracking issue https://github.com/rust-lang/rust/issues/54883. r? @estebank
2019-08-27resolve: Block expansion of a derive container until all its derives are ↵Vadim Petrochenkov-54/+86
resolved Also mark derive helpers as known as a part of the derive container's expansion instead of expansion of the derives themselves which may happen too late.
2019-08-26parser: fix span for leading vert.Mazdak Farrokhzad-1/+2
2019-08-25Refactor feature gate checking codePascal Hertleif-18/+22
Tries to clarify the filtering of active features and make the code more expressive.
2019-08-25pprust: Do not print spaces before some tokensVadim Petrochenkov-1/+13
2019-08-25Introduce and use `Feature` type for feature gatesPascal Hertleif-23/+98
This replaces the ad-hoc tuples used in the different feature gate files and unifies their content into a common type, leading to more readable matches and other good stuff that comes from having named fields. It also contains the description of each feature as extracted from the doc comment.
2019-08-25parser: TopLevel -> RecoverComma.Mazdak Farrokhzad-10/+10
2019-08-25parser: gracefully handle `fn foo(A | B: type)`.Mazdak Farrokhzad-11/+41
2019-08-25Rollup merge of #63854 - c410-f3r:attrs-visit, r=petrochenkovMazdak Farrokhzad-81/+116
Modifies how Arg, Arm, Field, FieldPattern and Variant are visited Part of the necessary work to accomplish #63468.
2019-08-25parser: 'while parsing this or-pattern...'Mazdak Farrokhzad-1/+4
2019-08-25parser: simplify parse_pat_with_or_{inner}Mazdak Farrokhzad-17/+10
2019-08-24parser: reword || recovery.Mazdak Farrokhzad-1/+1
2019-08-24parser: extract recover_inner_leading_vert.Mazdak Farrokhzad-4/+7
2019-08-24parse_top_pat: silence leading vert gating sometimes.Mazdak Farrokhzad-3/+15
2019-08-24parser: bool -> TopLevel.Mazdak Farrokhzad-5/+9
2019-08-24parser: bool -> GateOr.Mazdak Farrokhzad-10/+16
2019-08-24parser: better recovery for || in inner pats.Mazdak Farrokhzad-4/+23
2019-08-24parser: drive-by: simplify `parse_arg_general`.Mazdak Farrokhzad-6/+3
2019-08-24parser: `let` stmts & `for` exprs: allow or-patterns.Mazdak Farrokhzad-8/+2
2019-08-24parser: document `parse_pat`.Mazdak Farrokhzad-0/+4
2019-08-24parser: `parse_pats` -> `parse_top_pat{_unpack}`.Mazdak Farrokhzad-16/+24
2019-08-24parser: document `ban_unexpected_or_or`.Mazdak Farrokhzad-0/+1
2019-08-24parser: move `maybe_recover_unexpected_comma` to a more appropriate place.Mazdak Farrokhzad-50/+49
2019-08-24parser: use `eat_or_separator` for leading vert.Mazdak Farrokhzad-2/+2
2019-08-24parser: improve `parse_pat_with_or` docs.Mazdak Farrokhzad-1/+2
2019-08-24parser: extract `eat_or_separator`.Mazdak Farrokhzad-30/+28
2019-08-24parser: integrate `maybe_recover_unexpected_comma` in `parse_pat_with_or`.Mazdak Farrokhzad-9/+17
2019-08-24parser: extract `maybe_recover_unexpected_comma`.Mazdak Farrokhzad-31/+36
2019-08-24parser: simplify `parse_pat_with_or`.Mazdak Farrokhzad-1/+1
2019-08-24parser: improve or-patterns recovery.Mazdak Farrokhzad-4/+11
2019-08-24parser: refactor `parse_pat_with_or` + use it in [p0, p1, ..] pats.Mazdak Farrokhzad-8/+15
2019-08-24parser: type alias `type Expected = Option<&'static str>;`.Mazdak Farrokhzad-8/+7
2019-08-24parser: extract `ban_unexpected_or_or`.Mazdak Farrokhzad-11/+13
2019-08-24Modifies how Arg, Arm, Field, FieldPattern and Variant are visitedCaio-81/+116
Part of the necessary work to accomplish #63468.
2019-08-24Use doc comments for feature gate descriptionsPascal Hertleif-261/+284
This is just in preparation for future usage of these texts.
2019-08-24Auto merge of #63823 - petrochenkov:noapply2, r=matthewjasperbors-78/+71
Audit uses of `apply_mark` in built-in macros + Remove default macro transparencies Every use of `apply_mark` in a built-in or procedural macro is supposed to look like this ```rust location.with_ctxt(SyntaxContext::root().apply_mark(ecx.current_expansion.id)) ``` where `SyntaxContext::root()` means that the built-in/procedural macro is defined directly, rather than expanded from some other macro. However, few people understood what `apply_mark` does, so we had a lot of copy-pasted uses of it looking e.g. like ```rust span = span.apply_mark(ecx.current_expansion.id); ``` , which doesn't really make sense for procedural macros, but at the same time is not too harmful, if the macros use the traditional `macro_rules` hygiene. So, to fight this, we stop using `apply_mark` directly in built-in macro implementations, and follow the example of regular proc macros instead and use analogues of `Span::def_site()` and `Span::call_site()`, which are much more intuitive and less error-prone. - `ecx.with_def_site_ctxt(span)` takes the `span`'s location and combines it with a def-site context. - `ecx.with_call_site_ctxt(span)` takes the `span`'s location and combines it with a call-site context. Even if called multiple times (which sometimes happens due to some historical messiness of the built-in macro code) these functions will produce the same result, unlike `apply_mark` which will grow the mark chain further in this case. --- After `apply_mark`s in built-in macros are eliminated, the remaining `apply_mark`s are very few in number, so we can start passing the previously implicit `Transparency` argument to them explicitly, thus eliminating the need in `default_transparency` fields in hygiene structures and `#[rustc_macro_transparency]` annotations on built-in macros. So, the task of making built-in macros opaque can now be formulated as "eliminate `with_legacy_ctxt` in favor of `with_def_site_ctxt`" rather than "replace `#[rustc_macro_transparency = "semitransparent"]` with `#[rustc_macro_transparency = "opaque"]`". r? @matthewjasper
2019-08-23syntax: move `feature_gate.rs`.Mazdak Farrokhzad-0/+0
2019-08-23syntax: extract `check.rs`.Mazdak Farrokhzad-953/+960
2019-08-23builtin_attrs.rs: retain FIXMEs.Mazdak Farrokhzad-2/+6
2019-08-23builtin_attrs.rs: organize!Mazdak Farrokhzad-241/+259
2019-08-23builtin_attrs.rs: cleanup with `(un)gated!`.Mazdak Farrokhzad-288/+229
2019-08-23builtin_attrs.rs: refactor `rustc_attrs` entries.Mazdak Farrokhzad-233/+109
2019-08-23builtin_attrs.rs: simplify `cfg_fn`.Mazdak Farrokhzad-8/+7
2019-08-23syntax: extract `builin_attrs.rs`.Mazdak Farrokhzad-715/+732
2019-08-23syntax: extract `active.rs` feature gates.Mazdak Farrokhzad-517/+525
2019-08-23syntax: extract `removed.rs` feature gates.Mazdak Farrokhzad-77/+85
2019-08-23syntax: extract `accepted.rs` feature gates.Mazdak Farrokhzad-231/+239
2019-08-23Remove default macro transparenciesVadim Petrochenkov-21/+0
All transparancies are passed explicitly now. Also remove `#[rustc_macro_transparency]` annotations from built-in macros, they are no longer used. `#[rustc_macro_transparency]` only makes sense for declarative macros now.
2019-08-23hygiene: Require passing transparency explicitly to `apply_mark`Vadim Petrochenkov-41/+47
2019-08-23Audit uses of `apply_mark` in built-in macrosVadim Petrochenkov-17/+25
Replace them with equivalents of `Span::{def_site,call_site}` from proc macro API. The new API is much less error prone and doesn't rely on macros having default transparency.