about summary refs log tree commit diff
path: root/src/librustc_parse
AgeCommit message (Collapse)AuthorLines
2020-03-16ast/hir: `MacroDef::legacy` -> `MacroDef::macro_rules`Vadim Petrochenkov-2/+2
2020-03-15Rollup merge of #69589 - petrochenkov:maccall, r=CentrilMazdak Farrokhzad-32/+24
ast: `Mac`/`Macro` -> `MacCall` It's now obvious that these refer to macro calls rather than to macro definitions. It's also a single name instead of two different names in different places. `rustc_expand` usually calls macro calls in a wide sense (including attributes and derives) "macro invocations", but structures and variants renamed in this PR are only relevant to fn-like macros, so it's simpler and clearer to just call them calls. cc https://github.com/rust-lang/rust/pull/63586#discussion_r314232513 r? @eddyb
2020-03-14Rollup merge of #69809 - matthiaskrgr:lifetimes, r=eddybYuki Okushi-3/+3
remove lifetimes that can be elided (clippy::needless_lifetimes)
2020-03-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-32/+24
2020-03-12remove lifetimes that can be elided (clippy::needless_lifetimes)Matthias Krüger-3/+3
2020-03-12Rollup merge of #69722 - estebank:negative-impl-span-ast, r=CentrilMazdak Farrokhzad-7/+11
Tweak output for invalid negative impl AST errors Use more accurate spans for negative `impl` errors. r? @Centril
2020-03-11Rollup merge of #69760 - Centril:parse-expr-improve, r=estebankMazdak Farrokhzad-240/+282
Improve expression & attribute parsing This PR includes misc improvements to expression and attribute parsing. 1. Some code simplifications 2. Better recovery for various block forms, e.g. `loop statements }` (missing `{` after `loop`). (See e.g., `block-no-opening-brace.rs` among others for examples.) 3. Added recovery for e.g., `unsafe $b` where `$b` refers to a `block` macro fragment. (See `bad-interpolated-block.rs` for examples.) 4. ^--- These are done so that code sharing in block parsing is increased. 5. Added recovery for e.g., `'label: loop { ... }` (See `labeled-no-colon-expr.rs`.) 6. Added recovery for e.g., `&'lifetime expr` (See `regions-out-of-scope-slice.rs`.) 7. Added recovery for e.g., `fn foo() = expr;` (See `fn-body-eq-expr-semi.rs`.) 8. Simplified attribute parsing code & slightly improved diagnostics. 9. Added recovery for e.g., `Box<('a) + Trait>`. 10. Added recovery for e.g, `if true #[attr] {} else #[attr] {} else #[attr] if true {}`. r? @estebank
2020-03-10parse: Tweak the function parameter edition checkVadim Petrochenkov-3/+1
Move anon-params tests to ui/anon-params.
2020-03-10parse_if_expr: recover on attributesMazdak Farrokhzad-8/+39
2020-03-10trait-object-lifetime-parens: improve recovery.Mazdak Farrokhzad-6/+11
2020-03-10use check_path moreMazdak Farrokhzad-8/+5
2020-03-10simplify & improve parse_ty_tuple_or_parensMazdak Farrokhzad-19/+18
2020-03-10error_block_no_opening_brace: handle closures betterMazdak Farrokhzad-9/+7
2020-03-10parser: add note for `'label expr`.Mazdak Farrokhzad-0/+1
2020-03-10parser/attr: adjust indentation.Mazdak Farrokhzad-7/+5
2020-03-10parse_labeled_expr: add a suggestion on missing colon.Mazdak Farrokhzad-3/+13
2020-03-10parse_block_tail: reduce visibilityMazdak Farrokhzad-5/+1
2020-03-10unify/improve/simplify attribute parsingMazdak Farrokhzad-132/+102
2020-03-10parse: recover on `fn foo() = expr;`Mazdak Farrokhzad-1/+16
2020-03-10parse: simplify parse_fn_bodyMazdak Farrokhzad-17/+7
2020-03-10parse: recover on `&'lt $expr` / `'lt $expr`.Mazdak Farrokhzad-4/+31
2020-03-10more reuse in block parsing & improve diagnostics.Mazdak Farrokhzad-13/+20
2020-03-10simplify parse_inner_attributesMazdak Farrokhzad-6/+2
2020-03-10use error_block_no_opening_brace moreMazdak Farrokhzad-1/+5
2020-03-10parse_labeled_expr: simplifyMazdak Farrokhzad-15/+13
2020-03-09Rollup merge of #69801 - petrochenkov:nonorm, r=CentrilMazdak Farrokhzad-106/+77
rustc_parse: Remove `Parser::normalized(_prev)_token` Perform the "normalization" (renamed to "uninterpolation") on the fly when necessary. The final part of https://github.com/rust-lang/rust/pull/69579 https://github.com/rust-lang/rust/pull/69384 https://github.com/rust-lang/rust/pull/69376 https://github.com/rust-lang/rust/pull/69211 https://github.com/rust-lang/rust/pull/69034 https://github.com/rust-lang/rust/pull/69006. r? @Centril
2020-03-09Rollup merge of #69201 - Aaron1011:feature/permit-if-attr, r=CentrilMazdak Farrokhzad-9/+0
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-09Address review commentsVadim Petrochenkov-8/+7
2020-03-09Use `Token::uninterpolate` in couple more places matching on `(Nt)Ident`Vadim Petrochenkov-3/+4
2020-03-09rustc_parse: Remove `Parser::normalized(_prev)_token`Vadim Petrochenkov-40/+7
2020-03-09rustc_ast: Introduce `Token::uninterpolate`Vadim Petrochenkov-4/+4
2020-03-09rustc_ast: Introduce `Token::uninterpolated_span`Vadim Petrochenkov-12/+15
2020-03-09rustc_parse: Use `Token::ident` where possibleVadim Petrochenkov-47/+48
2020-03-07Rollup merge of #69773 - matthiaskrgr:typos, r=petrochenkovMazdak Farrokhzad-4/+4
fix various typos
2020-03-07Rollup merge of #69708 - estebank:tiny, r=petrochenkovMazdak Farrokhzad-1/+6
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-07Make error message clearer about creating new moduleKornel-25/+10
2020-03-07Rollup merge of #69656 - matthiaskrgr:iter_nth_zero, r=oli-obkMazdak Farrokhzad-3/+3
Use .next() instead of .nth(0) on iterators.
2020-03-07Rollup merge of #68985 - daboross:fix-35813, r=CentrilMazdak Farrokhzad-5/+58
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-06fix various typosMatthias Krüger-4/+4
2020-03-06Auto merge of #69586 - petrochenkov:unmerge, r=Centrilbors-20/+20
ast: Unmerge structures for associated items and foreign items Follow-up to https://github.com/rust-lang/rust/pull/69194. r? @Centril
2020-03-05review commentsEsteban Küber-7/+11
2020-03-05Rollup merge of #69736 - matthiaskrgr:even_more_clippy, r=Dylan-DPCDylan DPC-1/+1
even more clippy cleanups * Don't pass &mut where immutable reference (&) is sufficient (clippy::unnecessary_mut_passed) * Use more efficient &&str to String conversion (clippy::inefficient_to_string) * Don't always eval arguments inside .expect(), use unwrap_or_else and closure. (clippy::expect_fun_call) * Use righthand '&' instead of lefthand "ref". (clippy::toplevel_ref_arg) * Use simple 'for i in x' loops instead of 'while let Some(i) = x.next()' loops on iterators. (clippy::while_let_on_iterator) * Const items have by default a static lifetime, there's no need to annotate it. (clippy::redundant_static_lifetimes) * Remove redundant patterns when matching ( x @ _ to x) (clippy::redundant_pattern)
2020-03-05Const items have by default a static lifetime, there's no need to annotate ↵Matthias Krüger-1/+1
it. (clippy::redundant_static_lifetimes)
2020-03-04Tweak output for invalid negative impl AST errorsEsteban Küber-1/+1
2020-03-04Permit attributes on 'if' expressionsAaron Hill-9/+0
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-04Use .map() to modify data inside Options instead of using .and_then(|x| ↵Matthias Krüger-1/+1
Some(y)) (clippy::option_and_then_some)
2020-03-04On mismatched delimiters, only point at empty blocks that are in the same lineEsteban Küber-1/+6
2020-03-03Use .next() instead of .nth(0) on iterators.Matthias Krüger-3/+3
2020-03-01encode `;` stmt w/o expr as `StmtKind::Empty`Mazdak Farrokhzad-20/+7
2020-03-01ast: Implement `TryFrom<ItemKind>` for associated and foreign itemsVadim Petrochenkov-20/+20