about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
AgeCommit message (Collapse)AuthorLines
2023-02-05Recover from missing expression in for loopObei Sideg-0/+27
2023-02-05rustc_parse: remove huge error importsest31-121/+111
2023-02-04Recover from default value for a lifetime in generic parameters.Lenko Donchev-1/+24
2023-02-03Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obkMichael Goulet-6/+17
Replace `ConstFnMutClosure` with const closures Also fixes a parser bug. cc `@oli-obk` for compiler changes
2023-02-03Rollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkovDylan DPC-66/+61
Improve `TokenCursor`. Some small improvements, for things that were bugging me. Best reviewed one commit at a time. r? ``@petrochenkov``
2023-02-03Rollup merge of #107602 - estebank:anon-enum-access, r=compiler-errorsMatthias Krüger-12/+39
Parse and recover from type ascription in patterns Reintroduce part of #106960, which was reverted in #107478. r? `@compiler-errors`
2023-02-03Rename `Cursor`/`CursorRef` as `TokenTreeCursor`/`RefTokenTreeCursor`.Nicholas Nethercote-5/+8
This makes it clear they return token trees, and makes for a nice comparison against `TokenCursor` which returns tokens.
2023-02-03Remove `TokenCursorFrame`.Nicholas Nethercote-42/+34
The motivation here is to eliminate the `Option<(Delimiter, DelimSpan)>`, which is `None` for the outermost token stream and `Some` for all other token streams. We are already treating the innermost frame specially -- this is the `frame` vs `stack` distinction in `TokenCursor`. We can push that further so that `frame` only contains the cursor, and `stack` elements contain the delimiters for their children. When we are in the outermost token stream `stack` is empty, so there are no stored delimiters, which is what we want because the outermost token stream *has* no delimiters. This change also shrinks `TokenCursor`, which shrinks `Parser` and `LazyAttrTokenStreamImpl`, which is nice.
2023-02-03Make clear that `TokenTree::Token` shouldn't contain a delimiter.Nicholas Nethercote-1/+7
2023-02-03Improve doc comment desugaring.Nicholas Nethercote-27/+21
Sometimes the parser needs to desugar a doc comment into `#[doc = r"foo"]`. Currently it does this in a hacky way: by pushing a "fake" new frame (one without a delimiter) onto the `TokenCursor` stack. This commit changes things so that the token stream itself is modified in place. The nice thing about this is that it means `TokenCursorFrame::delim_sp` is now only `None` for the outermost frame.
2023-02-02Parse and recover from type ascription in patternsEsteban Küber-12/+39
2023-02-02Rollup merge of #107559 - WaffleLapkin:is_it_2015¿, r=davidtwcoMatthias Krüger-2/+2
Rename `rust_2015` → `is_rust_2015` r? ```@compiler-errors``` https://github.com/rust-lang/rust/pull/107508#discussion_r1092300088
2023-02-02Rollup merge of #107493 - clubby789:range-fat-arrow-followup, r=estebankMatthias Krüger-7/+12
Improve diagnostic for missing space in range pattern Improves the diagnostic in #107425 by turning it into a note explaining the parsing issue. r? `@compiler-errors`
2023-02-02Rollup merge of #106919 - compiler-errors:underscore-typo-in-field-pat, ↵Matthias Krüger-8/+15
r=jackh726 Recover `_` as `..` in field pattern
2023-02-02Improve diagnostic for missing space in range patternclubby789-7/+12
2023-02-02Use `rust_2018` instead of `!is_rust_2015`Maybe Waffle-1/+1
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-2/+2
2023-02-02Recover _ as .. in field patternMichael Goulet-8/+15
2023-02-02Revert "Teach parser to understand fake anonymous enum syntax" and related ↵Michael Goulet-103/+17
commits Revert "review comment: Remove AST AnonTy" This reverts commit 020cca8d36cb678e3ddc2ead41364be314d19e93. Revert "Ensure macros are not affected" This reverts commit 12d18e403139eeeeb339e8611b2bed4910864edb. Revert "Emit fewer errors on patterns with possible type ascription" This reverts commit c847a01a3b1f620c4fdb98c75805033e768975d1. Revert "Teach parser to understand fake anonymous enum syntax" This reverts commit 2d824206655bfb26cb5eed43490ee396542b153e.
2023-02-01Make "use latest edition" subdiagnostic translatableXiretza-17/+38
2023-02-01rustc_parse: revert conversion of "non-item in item list" diagnosticXiretza-50/+25
#[derive(Subdiagnostic)] does not allow multiple subdiagnostics on one variant, as in NonItemInItemListSub::Other.
2023-02-01migrate parser::ty to diagnostic structsXiretza-85/+141
2023-02-01Convert rustc_parse::parser::pat::Expected to enumXiretza-20/+36
This is required in order to support translatable diagnostics.
2023-02-01rustc_parse: migrate more to diagnostic structsXiretza-480/+817
2023-02-01Fix condition for "missing `struct`" diagnostic on tuple structsXiretza-1/+1
The check previously matched this, and suggested adding a missing `struct`: pub Foo(...): It was probably intended to match this instead (semicolon instead of colon): pub Foo(...);
2023-02-01Use AddToDiagnostic for "use latest edition" helpXiretza-8/+13
2023-02-01rustc_parse: avoid creating unnecessary intermediate stringsXiretza-1/+2
2023-02-01fix formatting + test syntaxSpanishPear-1/+1
2023-02-01fix parser mistaking const closures for const itemDeadbeef-6/+17
2023-02-01Rollup merge of #107487 - edward-shen:edward-shen/107213-round-2, r=estebankMatthias Krüger-2/+2
Make the "extra if in let...else block" hint a suggestion Changes the hint to a suggestion, suggested in #107213. r? ```@estebank```
2023-01-31Rollup merge of #107467 - WaffleLapkin:uneq, r=oli-obkGuillaume Gomez-22/+22
Improve enum checks Some light refactoring.
2023-01-31move to multipart spansSpanishPear-5/+6
2023-01-31Auto merge of #105650 - cassaundra:float-literal-suggestion, r=pnkfelixbors-1/+10
Fix invalid float literal suggestions when recovering an integer Only suggest adding a zero to integers with a preceding dot when the change will result in a valid floating point literal. For example, `.0x0` should not be turned into `0.0x0`. r? nnethercote
2023-01-30Make the "extra if in let...else block" hint a suggestionEdward Shen-2/+2
2023-01-30Fix invalid float literal suggestions when recovering an integerCassaundra Smith-1/+10
Only suggest adding a zero to integers with a preceding dot when the change will result in a valid floating point literal. For example, `.0x0` should not be turned into `0.0x0`.
2023-01-30Replace enum `==`s with `match`es where it makes senseMaybe Waffle-22/+22
2023-01-29Insert whitespace to avoid ident concatenation in suggestionRyo Yoshida-1/+1
2023-01-28Migrate some range parsing diagnosticsclubby789-19/+50
2023-01-28Check for missing space between fat arrow and range patternclubby789-14/+32
2023-01-28Rollup merge of #104012 - chenyukang:yukang/fix-103882-deli-indentation, ↵Matthias Krüger-87/+162
r=petrochenkov Improve unexpected close and mismatch delimiter hint in TokenTreesReader Fixes #103882 Fixes #68987 Fixes #69259 The inner indentation mismatching will be covered by outer block, the new added function `report_error_prone_delim_block` will find out the error prone candidates for reporting.
2023-01-28Rollup merge of #107190 - fmease:fix-81698, r=compiler-errorsMatthias Krüger-14/+56
Recover from more const arguments that are not wrapped in curly braces Recover from some array, borrow, tuple & arithmetic expressions in const argument positions that lack curly braces and provide a suggestion to fix the issue continuing where #92884 left off. Examples of such expressions: `[]`, `[0]`, `[1, 2]`, `[0; 0xff]`, `&9`, `("", 0)` and `(1 + 2) * 3` (we previously did not recover from them). I am not entirely happy with my current solution because the code that recovers from `[0]` (coinciding with a malformed slice type) and `[0; 0]` (coinciding with a malformed array type) is quite fragile as the aforementioned snippets are actually successfully parsed as types by `parse_ty` since it itself already recovers from them (returning `[⟨error⟩]` and `[⟨error⟩; 0]` respectively) meaning I have to manually look for `TyKind::Err`s and construct a separate diagnostic for the suggestion to attach to (thereby emitting two diagnostics in total). Fixes #81698. `@rustbot` label A-diagnostics r? diagnostics
2023-01-27recover more unbraced const argsLeón Orell Valerian Liehr-14/+56
2023-01-27Improve unexpected close and mismatch delimiter hint in TokenTreesReaderyukang-87/+162
2023-01-26Rollup merge of #106960 - estebank:parse-anon-enums, r=cjgillotMatthias Krüger-18/+104
Teach parser to understand fake anonymous enum syntax Parse `Ty | OtherTy` in function argument and return types. Parse type ascription in top level patterns. Minimally address #100741.
2023-01-23Add suggestion to remove if in let...else blockEdward Shen-14/+30
Adds an additional hint to failures where we encounter an else keyword while we're parsing an if-let block. This is likely that the user has accidentally mixed if-let and let...else together.
2023-01-23review comment: Remove AST AnonTyEsteban Küber-1/+1
2023-01-22revert to previous spanSpanishPear-3/+4
2023-01-22Attempt to address review comments via github web...Shrey Sudhir-3/+2
2023-01-22Apply automatic suggestions from code reviewShrey Sudhir-3/+3
Co-authored-by: Takayuki Maeda <takoyaki0316@gmail.com>
2023-01-22--wip-- [skip ci]SpanishPear-2/+55
--wip-- [skip ci] get the generic text and put it int he suggestion, but suggestion not working on derive subdiagnostic refactor away from derives and use span_suggestion() instead. Show's the correct(?) generic contents, but overwrites the fn name :( x fmt drop commented code and s/todo/fixme get the correct diagnostic for functions, at least x fmt remove some debugs remove format remove debugs remove useless change remove useless change remove legacy approach correct lookahead + error message contains the ident name fmt refactor code tests add tests remoev debug remove comment