summary refs log tree commit diff
path: root/src/test/ui/parser
AgeCommit message (Collapse)AuthorLines
2020-04-03parse_and_disallow_postfix_after_cast: account for `ExprKind::Err`.Mazdak Farrokhzad-0/+11
2020-03-21can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.Mazdak Farrokhzad-1/+37
2020-03-09Rollup merge of #69201 - Aaron1011:feature/permit-if-attr, r=CentrilMazdak Farrokhzad-111/+37
Permit attributes on 'if' expressions Previously, attributes on 'if' expressions (e.g. `#[attr] if true {}`) were disallowed during parsing. This made it impossible for macros to perform any custom handling of such attributes (e.g. stripping them away), since a compilation error would be emitted before they ever had a chance to run. This PR permits attributes on 'if' expressions ('if-attrs' from here on). Both built-in attributes (e.g. `#[allow]`, `#[cfg]`) and proc-macro attributes are supported. We still do *not* accept attributes on 'other parts' of an if-else chain. That is, the following code snippet still fails to parse: ```rust if true {} #[attr] else if false {} else #[attr] if false {} #[attr] else {} ``` Closes https://github.com/rust-lang/rust/issues/68618
2020-03-07Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkovMazdak Farrokhzad-7/+7
fix various typos
2020-03-07Rollup merge of #69708 - estebank:tiny, r=petrochenkovMazdak Farrokhzad-8/+2
On mismatched delimiters, only point at empty blocks that are in the same line We point at empty blocks when we have mismatched braces to detect cases where editors auto insert `}` after writing `{`. Gate this to only the case where the entire span is in the same line so we never point at explicitly empty blocks.
2020-03-07Rollup merge of #68985 - daboross:fix-35813, r=CentrilMazdak Farrokhzad-0/+563
Parse & reject postfix operators after casts This adds an explicit error messages for when parsing `x as Type[0]` or similar expressions. Our add an extra parse case for parsing any postfix operator (dot, indexing, method calls, await) that triggers directly after parsing `as` expressions. My friend and I worked on this together, but they're still deciding on a github username and thus I'm submitting this for both of us. It will immediately error out, but will also provide the rest of the parser with a useful parse tree to deal with. There's one decision we made in how this produces the parse tree. In the situation `&x as T[0]`, one could imagine this parsing as either `&((x as T)[0])` or `((&x) as T)[0]`. We chose the latter for ease of implementation, and as it seemed the most intuitive. Feedback welcome! This is our first change to the parser section, and it might be completely horrible. Fixes #35813.
2020-03-06bless testsMatthias Krüger-7/+7
2020-03-04Update stderrAaron Hill-59/+35
2020-03-04Move if-attr tests to their own directoryAaron Hill-162/+0
2020-03-04Add run-pass test suggested by @joshtriplettAaron Hill-0/+15
2020-03-04Remove recovery testAaron Hill-30/+0
2020-03-04Test trying to cfg-remove an `if` expressionAaron Hill-0/+13
2020-03-04Test that stmt_expr_attrs properly gates if-attrsAaron Hill-0/+18
2020-03-04Test #[allow(unused)] on `if` expressionAaron Hill-0/+12
2020-03-04Permit attributes on 'if' expressionsAaron Hill-25/+109
Previously, attributes on 'if' expressions (e.g. #[attr] if true {}) were disallowed during parsing. This made it impossible for macros to perform any custom handling of such attributes (e.g. stripping them away), since a compilation error would be emitted before they ever had a chance to run. This PR permits attributes on 'if' expressions ('if-attrs' from here on). Both built-in attributes (e.g. `#[allow]`, `#[cfg]`) are supported. We still do *not* accept attributes on 'other parts' of an if-else chain. That is, the following code snippet still fails to parse: ```rust if true {} #[attr] else if false {} else #[attr] if false {} #[attr] else {} ```
2020-03-04On mismatched delimiters, only point at empty blocks that are in the same lineEsteban Küber-8/+2
2020-03-01encode `;` stmt w/o expr as `StmtKind::Empty`Mazdak Farrokhzad-17/+7
2020-02-28Update UI testsGuillaume Gomez-3/+6
2020-02-27Auto merge of #68434 - varkor:astconv-mismatch-error, r=nikomatsakisbors-8/+14
Move generic arg/param validation to `create_substs_for_generic_args` to resolve various const generics issues This changes some diagnostics, but I think they're around as helpful as the previous ones, and occur infrequently regardless. Fixes https://github.com/rust-lang/rust/issues/68257. Fixes https://github.com/rust-lang/rust/issues/68398. r? @eddyb
2020-02-24parse: test bad variants wrt. issue 48137.Mazdak Farrokhzad-0/+97
2020-02-24parse: tweak diagnostic wordingsMazdak Farrokhzad-96/+96
2020-02-24parse/ast: move `Defaultness` into variants.Mazdak Farrokhzad-182/+448
2020-02-24parse: `NtItem` -> `parse_item_common`.Mazdak Farrokhzad-0/+34
2020-02-24parser: tweak item kind wordingMazdak Farrokhzad-80/+80
2020-02-24parser: tweak unmatched wordingMazdak Farrokhzad-24/+36
2020-02-24parse: harden `default` test.Mazdak Farrokhzad-56/+96
2020-02-24parse: use `parse_item_common` in `parse_assoc_item_`.Mazdak Farrokhzad-86/+479
2020-02-24parse: use `parse_item_common` in `parse_foreign_item`.Mazdak Farrokhzad-31/+327
2020-02-24parse: recover `default` on free items.Mazdak Farrokhzad-5/+180
2020-02-24add `Span` to `ast::Defaultness::Default`.Mazdak Farrokhzad-8/+24
2020-02-22Use multipart suggestionDavid Ross-53/+229
This is a modified version of estebank's suggestion, with a bit of extra cleanup now that we don't need the different cases for if we can turn a span into a string or not.
2020-02-22Add more double cast + method call testsDavid Ross-22/+105
2020-02-22Add note regarding argument orderingvarkor-0/+4
2020-02-22Move generic arg / param validation to `create_substs_for_generic_args`varkor-8/+10
2020-02-22parse: allow `type Foo: Ord` syntactically.Mazdak Farrokhzad-3/+103
2020-02-18Rollup merge of #69236 - Centril:mut-parens-at-recovery, r=estebankMazdak Farrokhzad-11/+21
parse: recover `mut (x @ y)` as `(mut x @ mut y)`. Follow up to https://github.com/rust-lang/rust/pull/68992#discussion_r376829749 and https://github.com/rust-lang/rust/pull/63945. Specifically, when given `let mut (x @ y)` we recover with `let (mut x @ mut y)` as the suggestion: ```rust error: `mut` must be attached to each individual binding --> $DIR/mut-patterns.rs:12:9 | LL | let mut (x @ y) = 0; | ^^^^^^^^^^^ help: add `mut` to each binding: `(mut x @ mut y)` | = note: `mut` may be followed by `variable` and `variable @ pattern` ``` r? @matthewjasper @estebank
2020-02-18Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkovMazdak Farrokhzad-100/+680
parse: fuse associated and extern items up to defaultness Language changes: - The grammar of extern `type` aliases is unified with associated ones, and becomes: ```rust TypeItem = "type" ident generics {":" bounds}? where_clause {"=" type}? ";" ; ``` Semantic restrictions (`ast_validation`) are added to forbid any parameters in `generics`, any bounds in `bounds`, and any predicates in `where_clause`, as well as the presence of a type expression (`= u8`). (Work still remains to fuse this with free `type` aliases, but this can be done later.) - The grammar of constants and static items (free, associated, and extern) now permits the absence of an expression, and becomes: ```rust GlobalItem = {"const" {ident | "_"} | "static" "mut"? ident} {"=" expr}? ";" ; ``` - A semantic restriction is added to enforce the presence of the expression (the body). - A semantic restriction is added to reject `const _` in associated contexts. Together, these changes allow us to fuse the grammar of associated items and extern items up to `default`ness which is the main goal of the PR. ----------------------- We are now very close to fully fusing the entirely of item parsing and their ASTs. To progress further, we must make a decision: should we parse e.g. `default use foo::bar;` and whatnot? Accepting that is likely easiest from a parsing perspective, as it does not require using look-ahead, but it is perhaps not too onerous to only accept it for `fn`s (and all their various qualifiers), `const`s, `static`s, and `type`s. r? @petrochenkov
2020-02-18Rollup merge of #69192 - JohnTitor:add-tests, r=CentrilDylan DPC-0/+54
Add more regression tests Closes #39618 Closes #51798 Closes #62894 Closes #63952 Closes #68653 r? @Centril
2020-02-17parse: recover `mut (x @ y)` as `(mut x @ mut y)`.Mazdak Farrokhzad-11/+21
2020-02-17Auto merge of #69129 - Centril:macro-legacy-errors, r=petrochenkovbors-0/+21
Transition macro_legacy_warnings into a hard error Fixes https://github.com/rust-lang/rust/issues/67098. r? @petrochenkov
2020-02-15Fix test stderr after rebasing on master.David Ross-2/+2
2020-02-15Remove trailing whitespaceDavid Ross-3/+3
2020-02-15Add more error cases to issue 35813 testsDavid Ross-58/+225
2020-02-15Parse & reject postfix operators after castsDavid Ross-0/+137
This adds parsing for expressions like 'x as Ty[0]' which will immediately error out, but still give the rest of the parser a valid parse tree to continue.
2020-02-15reject assoc statics & extern consts during parsingMazdak Farrokhzad-67/+154
2020-02-15fuse extern & associated item parsing up to defaultnessMazdak Farrokhzad-21/+25
2020-02-15parse extern constsMazdak Farrokhzad-14/+46
2020-02-15parse associated statics.Mazdak Farrokhzad-15/+197
2020-02-15ast/parser: fuse `static` & `const` grammars in all contexts.Mazdak Farrokhzad-46/+122
2020-02-15ast: make `= <expr>;` optional in free statics/consts.Mazdak Farrokhzad-0/+104