about summary refs log tree commit diff
path: root/src/test/ui/parser
AgeCommit message (Collapse)AuthorLines
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
2020-02-16Add test for issue-62894Yuki Okushi-0/+54
2020-02-15ast: normalize `ForeignItemKind::Ty` & `AssocItemKind::TyAlias`.Mazdak Farrokhzad-4/+99
2020-02-14Suggest a comma if a struct initializer field fails to parseAaron Hill-2/+3
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-13parser: misc small item related improvements & cleanups.Mazdak Farrokhzad-84/+88
2020-02-13parser: unify item list parsing.Mazdak Farrokhzad-14/+25
as a consequence, `trait X { #![attr] }` becomes legal.
2020-02-13macro_legacy_warnings -> errorMazdak Farrokhzad-0/+21
2020-02-13parser: add test for 'extern crate async'Mazdak Farrokhzad-0/+12
2020-02-13ast_validation: tweak diagnostic outputMazdak Farrokhzad-20/+20
2020-02-13parser: fuse free `fn` parsing together.Mazdak Farrokhzad-33/+79
2020-02-13parser_fn_front_matter: allow `const .. extern`Mazdak Farrokhzad-45/+50
2020-02-13IsAsync -> enum Async { Yes { span: Span, .. }, No }Mazdak Farrokhzad-4/+12
use new span for better diagnostics.
2020-02-12Rollup merge of #68981 - estebank:silence, r=davidtwcoDylan DPC-6/+6
Account for type params on method without parentheses Account for those type parameters in the structured suggestion when forgetting to call method: ``` error[E0615]: attempted to take value of method `collect` on type `std::vec::IntoIter<_>` --> $DIR/method-missing-parentheses.rs:2:32 | LL | let _ = vec![].into_iter().collect::<usize>; | ^^^^^^^--------- | | | help: use parentheses to call the method: `collect::<usize>()` ```
2020-02-11Auto merge of #68929 - matprec:consistent-issue-references, r=Dylan-DPCbors-4/+4
Make issue references consistent Fixes https://github.com/rust-lang/rust/issues/62976 cc https://github.com/rust-lang/rust/pull/63008 r? @varkor because you reviewed the original pr
2020-02-10review comment: wordingEsteban Küber-6/+6
2020-02-10Rollup merge of #69014 - dwrensha:fix-68890, r=CentrilDylan DPC-0/+24
change an instance of span_bug() to struct_span_err() to avoid ICE After #67148, the `span_bug()` in `parse_ty_tuple_or_parens()` is reachable because `parse_paren_comma_seq()` can return an `Ok()` even in cases where it encounters an error. This pull request prevents an ICE in such cases by replacing the `span_bug()` with `struct_span_error()`. Fixes #68890.
2020-02-09[parser] change an instance of span_bug() to struct_span_err() to avoid ICEDavid Renshaw-0/+24
2020-02-10parser: Keep current and previous tokens preciselyVadim Petrochenkov-2/+2
including their unnormalized forms. Add more documentation for them.
2020-02-09--bless --compare-mode=nllMatthias Prechtl-4/+4
2020-02-06rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros.Eduard-Mihai Burtescu-0/+22
2020-02-06Rollup merge of #68845 - dwrensha:fix-68783, r=estebankDylan DPC-0/+0
stop using BytePos for computing spans in librustc_parse/parser/mod.rs Computing spans using logic such as `self.token.span.lo() + BytePos(1)` can cause internal compiler errors like #68730 when non-ascii characters are given as input. #68735 partially addressed this problem, but only for one case. Moreover, its usage of `next_point()` does not actually align with what `bump_with()` expects. For example, given the token `>>=`, we should pass the span consisting of the final two characters `>=`, but `next_point()` advances the span beyond the end of the `=`. This pull request instead computes the start of the new span by doing `start_point(self.token.span).hi()`. This matches `self.token.span.lo() + BytePos(1)` in the common case where the characters are ascii, and it gracefully handles multibyte characters. Fixes #68783.
2020-02-05ast_validation: fix visiting bug.Mazdak Farrokhzad-0/+21
2020-02-04stop using BytePos for computing spans in librustc_parse/parser/mod.rsDavid Renshaw-0/+0
2020-02-05parser: merge `fn` grammars wrt. bodies & headersMazdak Farrokhzad-20/+387
also refactor `FnKind` and `visit_assoc_item` visitors
2020-02-03Auto merge of #68735 - JohnTitor:fix-ice-0202, r=estebankbors-0/+0
Use `next_point` to avoid ICE Fixes #68730 r? @estebank (I think you're familiar with that)
2020-02-02Rollup merge of #68764 - Centril:self-semantic, r=petrochenkovMazdak Farrokhzad-4/+365
parser: syntactically allow `self` in all `fn` contexts Part of https://github.com/rust-lang/rust/pull/68728. `self` parameters are now *syntactically* allowed as the first parameter irrespective of item context (and in function pointers). Instead, semantic validation (`ast_validation`) is used. r? @petrochenkov
2020-02-02parser: address review comments re. `self`.Mazdak Farrokhzad-76/+87
2020-02-02parser: move restrictions re. `self` to `ast_validation`.Mazdak Farrokhzad-0/+350
2020-02-02Rollup merge of #68681 - bobrippling:fix-matched-angle-brackets, r=CentrilYuki Okushi-0/+46
Suggest path separator for single-colon typos This commit adds guidance for when a user means to type a path, but ends up typing a single colon, such as `<<Impl as T>:Ty>`. This change seemed pertinent as the current error message is particularly misleading, emitting `error: unmatched angle bracket`, despite the angle bracket being matched later on, leaving the user to track down the typo'd colon.