about summary refs log tree commit diff
path: root/src/librustc_parse
AgeCommit message (Collapse)AuthorLines
2020-02-24ast: add `Defaultness` to `Item`, making `AssocItem` an alias.Mazdak Farrokhzad-3/+4
2020-02-24`parse_defaultness`: avoid hardcoded list of keywords.Mazdak Farrokhzad-26/+13
2020-02-24add `Span` to `ast::Defaultness::Default`.Mazdak Farrokhzad-1/+1
2020-02-23Rollup merge of #69376 - petrochenkov:bumpwith, r=CentrilDylan DPC-127/+51
parser: Cleanup `Parser::bump_with` and its uses Follow-up to https://github.com/rust-lang/rust/pull/69006. r? @Centril
2020-02-23Rollup merge of #69375 - Menschenkindlein:master, r=Dylan-DPCDylan DPC-2/+2
Rename CodeMap to SourceMap follow up See https://github.com/rust-lang/rust/issues/51574
2020-02-22Use multipart suggestionDavid Ross-13/+9
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-22parser: Cleanup `Parser::bump_with` and its usesVadim Petrochenkov-127/+51
2020-02-22Rename CodeMap to SourceMap follow upMaxim Zholobak-2/+2
2020-02-22parse: allow `type Foo: Ord` syntactically.Mazdak Farrokhzad-20/+12
2020-02-18Rollup merge of #69236 - Centril:mut-parens-at-recovery, r=estebankMazdak Farrokhzad-16/+13
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 #69211 - petrochenkov:prevtok, r=CentrilMazdak Farrokhzad-73/+47
parser: Simplify treatment of macro variables in `Parser::bump` Follow-up to https://github.com/rust-lang/rust/pull/69006. Token normalization for `$ident` and `$lifetime` is merged directly into `bump`. Special "unknown macro variable" diagnostic for unexpected `$`s is removed as preventing legal code from compiling (as a result `bump` also doesn't call itself recursively anymore and can't make `prev_token` inconsistent). r? @Centril
2020-02-18Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkovMazdak Farrokhzad-117/+91
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-17parser: Remove `Option`s from unnormalized tokensVadim Petrochenkov-43/+26
They are always set synchronously with normalized tokens now
2020-02-17parser: Set previous and unnormalized tokens in couple more placesVadim Petrochenkov-7/+9
2020-02-17parser: Do not call `bump` recursivelyVadim Petrochenkov-43/+32
Token normalization is merged directly into `bump`. Special "unknown macro variable" diagnostic for unexpected `$`s is removed as preventing legal code from compiling.
2020-02-17parse: recover `mut (x @ y)` as `(mut x @ mut y)`.Mazdak Farrokhzad-16/+13
2020-02-17Auto merge of #69129 - Centril:macro-legacy-errors, r=petrochenkovbors-53/+9
Transition macro_legacy_warnings into a hard error Fixes https://github.com/rust-lang/rust/issues/67098. r? @petrochenkov
2020-02-17Rollup merge of #69186 - petrochenkov:kwrules, r=CentrilYuki Okushi-2/+2
[tiny] parser: `macro_rules` is a weak keyword r? @Centril
2020-02-17Rename `FunctionRetTy` to `FnRetTy`Yuki Okushi-10/+6
2020-02-15Remove extra debug print in unreachable!David Ross-2/+1
2020-02-15Keep better fix suggestion if type ascription is likely unintendedDavid Ross-9/+15
2020-02-15Type ascription outputs a Type, not CastDavid Ross-1/+3
Previously this just errored out on all usages of type ascription, which isn't helpful.
2020-02-15Refactor out error case & apply suggestions.David Ross-20/+42
This is almost entirely refactoring and message changing, with the single behavioral change of panicking for unexpected output.
2020-02-15Parse & reject postfix operators after castsDavid Ross-2/+39
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-1/+26
2020-02-15Record proc macro harness order for use during metadata deserializationAaron Hill-0/+2
Fixes #68690 When we generate the proc macro harness, we now explicitly recorder the order in which we generate entries. We then use this ordering data to deserialize the correct proc-macro-data from the crate metadata.
2020-02-15fuse extern & associated item parsing up to defaultnessMazdak Farrokhzad-77/+39
2020-02-15parse extern constsMazdak Farrokhzad-21/+6
2020-02-15parse associated statics.Mazdak Farrokhzad-10/+8
2020-02-15ast/parser: fuse `static` & `const` grammars in all contexts.Mazdak Farrokhzad-16/+21
2020-02-15ast: make `= <expr>;` optional in free statics/consts.Mazdak Farrokhzad-11/+8
2020-02-15ast: normalize `ForeignItemKind::Ty` & `AssocItemKind::TyAlias`.Mazdak Farrokhzad-5/+7
2020-02-15ast: move Generics into AssocItemKindsMazdak Farrokhzad-8/+8
2020-02-15parser: `macro_rules` is a weak keywordVadim Petrochenkov-2/+2
2020-02-14Suggest a comma if a struct initializer field fails to parseAaron Hill-1/+7
Currently, we emit a "try adding a comma" suggestion if a comma is missing in a struct definition. However, we emit no such suggestion if a comma is missing in a struct initializer. This commit adds a "try adding a comma" suggestion when we don't find a comma during the parsing of a struct initializer field. The change to `src/test/ui/parser/removed-syntax-with-1.stderr` isn't great, but I don't see a good way of avoiding it.
2020-02-13Rollup merge of #69057 - Centril:clean-expand, r=petrochenkovDylan DPC-55/+34
expand: misc cleanups and simplifications Some work I did while trying to understand expand for the purposes of https://github.com/rust-lang/rust/issues/64197. r? @petrochenkov
2020-02-13parser: inline parse_assoc_macro_invocMazdak Farrokhzad-20/+10
2020-02-13parser: misc small item related improvements & cleanups.Mazdak Farrokhzad-150/+131
2020-02-13parser: extract `recover_const_mut`.Mazdak Farrokhzad-13/+17
2020-02-13parser: fuse `trait` parsing & layer with `is_path_start_item`Mazdak Farrokhzad-35/+27
2020-02-13parser: make `eat_macro_def` redundant.Mazdak Farrokhzad-33/+12
2020-02-13parser: remove `Option<Vec<Attribute>>` in `ItemInfo`.Mazdak Farrokhzad-59/+50
2020-02-13parser_item_mod: avoid cloning outer attributesMazdak Farrokhzad-23/+16
2020-02-13parser: introduce `parse_item_kind` as central `ItemInfo` logic.Mazdak Farrokhzad-192/+156
this also extracts macro item parsers.
2020-02-13parser: extract `recover_missing_kw_before_item`Mazdak Farrokhzad-84/+90
2020-02-13parser: unify item list parsing.Mazdak Farrokhzad-56/+46
as a consequence, `trait X { #![attr] }` becomes legal.
2020-02-13parser: extract common foreign item code for each kindMazdak Farrokhzad-67/+21
2020-02-13macro_legacy_warnings -> errorMazdak Farrokhzad-53/+9
2020-02-13simplify config::featuresMazdak Farrokhzad-19/+18
2020-02-13StripUnconfigured::in_cfg: simplify with slice patternsMazdak Farrokhzad-36/+16