about summary refs log tree commit diff
path: root/src/librustc_parse/parser
AgeCommit message (Collapse)AuthorLines
2020-02-28Suggest constraining type parametersEsteban Küber-2/+4
2020-02-28Rollup merge of #69547 - matthiaskrgr:more_misc, r=Mark-SimulacrumMazdak Farrokhzad-1/+1
remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls.
2020-02-28Rollup merge of #69541 - dotdash:format, r=Mark-SimulacrumMazdak Farrokhzad-9/+6
Remove unneeded calls to format!()
2020-02-28Rollup merge of #69481 - matthiaskrgr:single_char, r=ecstatic-morseMazdak Farrokhzad-1/+1
use char instead of &str for single char patterns
2020-02-28Rollup merge of #69384 - petrochenkov:nounnorm, r=CentrilMazdak Farrokhzad-69/+59
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-28use is_empty() instead of len() == x to determine if structs are empty.Matthias Krüger-1/+1
2020-02-28remove redundant clones, references to operands, explicit boolean ↵Matthias Krüger-1/+1
comparisons and filter(x).next() calls.
2020-02-28Rollup merge of #69529 - matthiaskrgr:clippy_identity_conversion, ↵Dylan DPC-5/+4
r=Mark-Simulacrum don't use .into() to convert types into identical types. This removes redundant `.into()` calls. example: `let s: String = format!("hello").into();`
2020-02-27don't use .into() to convert types into identical types.Matthias Krüger-5/+4
example: let s: String = format!("hello").into();
2020-02-27Remove unneeded calls to format!()Björn Steinbrink-9/+6
2020-02-27use char instead of &str for single char patternsMatthias Krüger-1/+1
2020-02-27use find(x) instead of filter(x).next()Matthias Krüger-6/+2
2020-02-26Rollup merge of #69447 - Centril:minor-stmt-refactor, r=estebankDylan DPC-94/+87
Minor refactoring of statement parsing Extracted out of https://github.com/rust-lang/rust/pull/69445. r? @estebank
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
2020-02-25parse: address nitpickMazdak Farrokhzad-3/+2
2020-02-25parse: move condition into guardMazdak Farrokhzad-28/+28
2020-02-24parse: simplify `parse_stmt_without_recovery`.Mazdak Farrokhzad-36/+29
2020-02-24parse: extract `parse_stmt_item` & `parse_stmt_path_start`.Mazdak Farrokhzad-32/+33
2020-02-24syntax: Remove `Nt(Impl,Trait,Foreign)Item`Vadim Petrochenkov-8/+0
2020-02-24don't explicitly compare against true or falseMatthias Krüger-2/+2
2020-02-24parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`Vadim Petrochenkov-65/+56
2020-02-24Add some missing support for `NtIdent`Vadim Petrochenkov-4/+3
2020-02-24parse: tweak diagnostic wordingsMazdak Farrokhzad-5/+5
2020-02-24parse: tweak `parse_item_` for more reuse.Mazdak Farrokhzad-19/+9
2020-02-24parse/ast: move `Defaultness` into variants.Mazdak Farrokhzad-32/+32
2020-02-24parse: `NtItem` -> `parse_item_common`.Mazdak Farrokhzad-8/+9
2020-02-24parser: tweak item kind wordingMazdak Farrokhzad-11/+9
2020-02-24parser: tweak unmatched wordingMazdak Farrokhzad-5/+6
2020-02-24parser: refactor away at_endMazdak Farrokhzad-9/+3
2020-02-24parse: move token hack into `parse_item_common`.Mazdak Farrokhzad-55/+31
2020-02-24parse: use `parse_item_common` in `parse_assoc_item_`.Mazdak Farrokhzad-144/+72
2020-02-24parse: use `parse_item_common` in `parse_foreign_item`.Mazdak Farrokhzad-28/+53
2020-02-24parse: recover `default` on free items.Mazdak Farrokhzad-13/+46
2020-02-24parse: extract `error_on_unmatched_vis`.Mazdak Farrokhzad-10/+16
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-70/+43
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-39/+22
They are always set synchronously with normalized tokens now
2020-02-17parser: Set previous and unnormalized tokens in couple more placesVadim Petrochenkov-7/+8
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