about summary refs log tree commit diff
path: root/src/librustc_parse/parser/item.rs
AgeCommit message (Collapse)AuthorLines
2020-07-01Rollup merge of #73803 - Aaron1011:feature/angle-field-recovery, r=matthewjasperManish Goregaokar-1/+28
Recover extra trailing angle brackets in struct definition This commit applies the existing 'extra angle bracket recovery' logic when parsing fields in struct definitions. This allows us to continue parsing the struct's fields, avoiding spurious 'missing field' errors in code that tries to use the struct.
2020-07-01Remove `token::FlattenGroup`Vadim Petrochenkov-1/+1
2020-06-27Recover extra trailing angle brackets in struct definitionAaron Hill-1/+28
This commit applies the existing 'extra angle bracket recovery' logic when parsing fields in struct definitions. This allows us to continue parsing the struct's fields, avoiding spurious 'missing field' errors in code that tries to use the struct.
2020-06-26proc_macro: Stop flattening groups with dummy spansVadim Petrochenkov-1/+1
2020-05-25Only capture tokens for items with outer attributesAaron Hill-5/+16
Suggested by @petrochenkov in https://github.com/rust-lang/rust/issues/43081#issuecomment-633389225
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-4/+4
2020-05-05Detect errors caused by `async` block in 2015 editionEsteban Küber-1/+1
2020-04-22Rollup merge of #71256 - cuviper:must_use_replace, r=estebankDylan DPC-1/+1
Lint must_use on mem::replace This adds a hint on `mem::replace`, "if you don't need the old value, you can just assign the new value directly". This is in similar spirit to the `must_use` on `ManuallyDrop::take`.
2020-04-18remove build warningsTshepang Lekhonkhobe-2/+2
Code blocks that are not annotated are assumed to be Rust
2020-04-17Fix unused results from mem::replaceJosh Stone-1/+1
2020-04-02Rollup merge of #70421 - Centril:recover-const-async-fn-ptr, r=estebankMazdak Farrokhzad-2/+2
parse: recover on `const fn()` / `async fn()` Recover on `const fn()` and `async fn()` function pointers, suggesting to remove the qualifier. For example: ``` error: an `fn` pointer type cannot be `async` --> $DIR/recover-const-async-fn-ptr.rs:6:11 | LL | type T3 = async fn(); | -----^^^^^ | | | `async` because of this | help: remove the `async` qualifier ``` r? @estebank
2020-03-26error_bad_item_kind: add help textMazdak Farrokhzad-2/+4
2020-03-26parse: recover on `const fn()` / `async fn()`.Mazdak Farrokhzad-2/+2
2020-03-25Rename `def_span` to `guess_head_span`Esteban Küber-1/+1
2020-03-22Rollup merge of #70209 - Centril:recover-quant-closure, r=petrochenkovDylan DPC-1/+1
parser: recover on `for<'a> |...| body` closures When encountering `for` and `<` is 1 token ahead, interpret this as an explicitly quantified generic closure and recover, rather than attempting to parse a `for` loop. This provides both improved diagnostics as well as an insurance policy for the ability to use this as the syntax for generic closures in the future. As requested by r? @eddyb
2020-03-21recover on `for<'a> |...| body` closures.Mazdak Farrokhzad-1/+1
2020-03-21Rollup merge of #70187 - matthiaskrgr:cl2ppy, r=Mark-SimulacrumMazdak Farrokhzad-4/+4
more clippy fixes * remove redundant returns (clippy::needless_return) * remove redundant import (clippy::single_component_path_imports) * remove redundant format!() call (clippy::useless_format) * don't use ok() before calling expect() (clippy::ok_expect)
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-4/+4
2020-03-20can_begin_literal_maybe_minus: `true` on `"-"? lit` NTs.Mazdak Farrokhzad-1/+1
2020-03-18fix rebase falloutMazdak Farrokhzad-7/+4
2020-03-18tweak outline module parsing spansMazdak Farrokhzad-1/+1
2020-03-18parse: module parsing -> item.rsMazdak Farrokhzad-5/+64
2020-03-16Other `legacy` -> `macro_rules`Vadim Petrochenkov-1/+1
2020-03-16ast/hir: `MacroDef::legacy` -> `MacroDef::macro_rules`Vadim Petrochenkov-2/+2
2020-03-15Rollup merge of #69589 - petrochenkov:maccall, r=CentrilMazdak Farrokhzad-11/+7
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-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-11/+7
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-20/+24
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-2/+1
2020-03-10use check_path moreMazdak Farrokhzad-1/+1
2020-03-10parse: recover on `fn foo() = expr;`Mazdak Farrokhzad-1/+16
2020-03-10parse: simplify parse_fn_bodyMazdak Farrokhzad-17/+7
2020-03-09Address review commentsVadim Petrochenkov-1/+1
2020-03-09Use `Token::uninterpolate` in couple more places matching on `(Nt)Ident`Vadim Petrochenkov-0/+2
2020-03-09rustc_ast: Introduce `Token::uninterpolate`Vadim Petrochenkov-2/+2
2020-03-09rustc_ast: Introduce `Token::uninterpolated_span`Vadim Petrochenkov-1/+1
2020-03-09rustc_parse: Use `Token::ident` where possibleVadim Petrochenkov-11/+8
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-04Tweak output for invalid negative impl AST errorsEsteban Küber-1/+1
2020-03-01ast: Implement `TryFrom<ItemKind>` for associated and foreign itemsVadim Petrochenkov-20/+20
2020-03-01Rollup merge of #69579 - petrochenkov:noprevspan, r=CentrilYuki Okushi-29/+32
parser: Remove `Parser::prev_span` Follow-up to https://github.com/rust-lang/rust/pull/69384. r? @Centril
2020-03-01Auto merge of #69592 - petrochenkov:nosyntax, r=Centrilbors-9/+13
Rename `libsyntax` to `librustc_ast` This was the last rustc crate that wasn't following the `rustc_*` naming convention. Follow-up to https://github.com/rust-lang/rust/pull/67763.
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-9/+13
2020-02-29rustc_parse: Tweak the function parameter name checkVadim Petrochenkov-3/+4
2020-02-29parser: Remove `Parser::prev_span`Vadim Petrochenkov-1/+1
2020-02-29parser: `prev_span` -> `prev_token.span`Vadim Petrochenkov-28/+31
2020-02-28Rollup merge of #69384 - petrochenkov:nounnorm, r=CentrilMazdak Farrokhzad-8/+6
parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token` So, after https://github.com/rust-lang/rust/pull/69006, its follow-ups and an attempt to remove `Parser::prev_span` I came to the conclusion that the unnormalized token and its span is what you want in most cases, so it should be default. Normalization only makes difference in few cases where we are checking against `token::Ident` or `token::Lifetime` specifically. This PR uses `normalized_token` for those cases. Using normalization explicitly means that people writing code should remember about `NtIdent` and `NtLifetime` in general. (That is alleviated by the fact that `token.ident()` and `fn parse_ident_*` are already written.) Remembering about `NtIdent`, was, however, already the case, kind of, because the implicit normalization was performed only for the current/previous token, but not for things like `look_ahead`. As a result, most of token classification methods in `token.rs` already take `NtIdent` into account (this PR fixes a few pre-existing minor mistakes though). The next step is removing `normalized(_prev)_token` entirely and replacing it with `token.ident()` (mostly) and `token.normalize()` (occasionally). I want to make it a separate PR for that and run it though perf. `normalized_token` filled on every bump has both a potential to avoid repeated normalization, and to do unnecessary work in advance (it probably doesn't matter anyway, the normalization is very cheap). r? @Centril
2020-02-26Rollup merge of #69423 - petrochenkov:nont, r=CentrilDylan DPC-8/+0
syntax: Remove `Nt(Impl,Trait,Foreign)Item` Follow-up to https://github.com/rust-lang/rust/pull/69366. r? @Centril