about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
AgeCommit message (Collapse)AuthorLines
2023-08-02Add test for enum with fieldsCatherine Flores-6/+1
2023-08-03Remove `MacDelimiter`.Nicholas Nethercote-14/+12
It's the same as `Delimiter`, minus the `Invisible` variant. I'm generally in favour of using types to make impossible states unrepresentable, but this one feels very low-value, and the conversions between the two types are annoying and confusing. Look at the change in `src/tools/rustfmt/src/expr.rs` for an example: the old code converted from `MacDelimiter` to `Delimiter` and back again, for no good reason. This suggests the author was confused about the types.
2023-08-03Keep the suggestion for wrong arbitrary self typesMu001999-54/+85
2023-08-02Avoid an unnecessary local variable.Nicholas Nethercote-2/+1
2023-08-02Move `TokenCursor::break_last_token` into `Parser`.Nicholas Nethercote-39/+25
Similar to the last commit, it's more of a `Parser`-level concern than a `TokenCursor`-level concern. And the struct size reductions are nice. After this change, `TokenCursor` is as minimal as possible (two fields and two methods) which is nice.
2023-08-02Move `TokenCursor::num_next_calls` into `Parser` and rename it.Nicholas Nethercote-18/+14
It's more of a `Parser`-level concern than a `TokenCursor`-level concern. Also, `num_bump_calls` is a more accurate name, because it's incremented in `Parser::bump`.
2023-08-02Inline and remove `parse_all_token_trees`.Nicholas Nethercote-10/+1
It has a single call site.
2023-08-02`parse_all_token_trees` cannot fail.Nicholas Nethercote-2/+2
2023-08-01Auto merge of #114273 - nnethercote:move-doc-comment-desugaring, r=petrochenkovbors-80/+15
Move doc comment desugaring out of `TokenCursor`. It's awkward that `TokenCursor` sometimes desugars doc comments on the fly, but usually doesn't. r? `@petrochenkov`
2023-08-01Suggests turbofish in patternsMu001999-1/+24
2023-07-31Remove `desugar_doc_comments` arg from `Parser::new()`.Nicholas Nethercote-8/+3
It's only true at one call site; do the desugaring there instead.
2023-07-31Move doc comment desugaring out of `TokenCursor`.Nicholas Nethercote-73/+13
`TokenCursor` currently does doc comment desugaring on the fly, if the `desugar_doc_comment` field is set. This requires also modifying the token stream on the fly with `replace_prev_and_rewind`. This commit moves the doc comment desugaring out of `TokenCursor`, by introducing a new `TokenStream::desugar_doc_comment` method. This separation of desugaring and iterating makes the code nicer.
2023-07-31parser: more friendly hints for handling `async move` in the 2015 editionbohan-4/+18
2023-07-31Fix a typo in a comment.Nicholas Nethercote-3/+3
2023-07-31Remove an unnecessary `return` keyword.Nicholas Nethercote-1/+1
2023-07-30Rollup merge of #114256 - Urgau:fix-issue-114180, r=WaffleLapkinMatthias Krüger-1/+1
Fix invalid suggestion for mismatched types in closure arguments This PR fixes the invalid suggestion for mismatched types in closure arguments. The invalid suggestion came from a wrongly created span in the parser for closure arguments that don't have a type specified. Specifically, the span in this case was the last token span, but in the case of tuples, the span represented the last parenthesis instead of the whole tuple, which is fixed by taking the more accurate span of the pattern. There is one unfortunate downside of this fix, it worsens even more the diagnostic for mismatched types in closure args without an explicit type. This happens because there is no correct span for implied inferred type. I tried also fixing this but it's a rabbit hole. Fixes https://github.com/rust-lang/rust/issues/114180
2023-07-30Fix invalid suggestion for mismatched types in closure argumentsUrgau-1/+1
The invalid suggestion came from a wrongly created span in `rustc_parse' for closure arguments that didn't have a type specified. Specifically, the span in this case was the last token span, but in the case of tuples, the span represented the last parenthesis instead of the whole tuple, which is fixed by taking the more accurate span of the pattern.
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-39/+32
2023-07-29Auto merge of #114028 - Centri3:ternary-operator, r=compiler-errorsbors-2/+53
Gracefully handle ternary operator Fixes #112578 ~~May not be the best way to do this as it doesn't check for a single `:`, so it could perhaps appear even when the actual issue is just a missing semicolon. May not be the biggest deal, though?~~ Nevermind, got it working properly now ^^
2023-07-28Parse generic const itemsLeón Orell Valerian Liehr-20/+159
2023-07-27Rollup merge of #114081 - nnethercote:desugar_doc_comments-cleanups, ↵Matthias Krüger-21/+27
r=petrochenkov `desugar_doc_comments` cleanups r? `@petrochenkov`
2023-07-26Add a comment to `TokenCursor::desugar_doc_comments`.Nicholas Nethercote-0/+3
Useful information that took me some time to discern.
2023-07-26Remove `desugar_doc_comments` arguments from `TokenCursor::{inlined_,}next`.Nicholas Nethercote-19/+24
Because it's now always `self.desugar_doc_comments`.
2023-07-26Tweak `Parser::look_ahead`.Nicholas Nethercote-1/+1
It doesn't really matter what the `desugar_doc_comments` argument is here, because in practice we never look ahead through doc comments. Changing it to `cursor.desugar_doc_comments` will allow some follow-up simplifications.
2023-07-26Remove `Parser::desugar_doc_comments`.Nicholas Nethercote-3/+1
It's currently stored twice: once in `Parser`, once in the `TokenStream` within `Parser`. We only need the latter.
2023-07-25Only early return if recoveredCatherine Flores-15/+20
2023-07-25Remove unnecessary `maybe_ternary_lo` fieldCatherine Flores-18/+5
2023-07-25Gracefully handle missing ternary operatorCatherine Flores-4/+63
2023-07-25Auto merge of #113476 - fee1-dead-contrib:c-str-lit, r=petrochenkovbors-9/+32
Reimplement C-str literals This reverts #113334, cc `@fmease.` While converting lexer tokens to ast Tokens in `rustc_parse`, we check the edition of the span of the token. If the edition < 2021, we split the token into two, one being the identifier and other being the str literal.
2023-07-25extract common codeDeadbeef-11/+10
2023-07-24Recover from some macrosCatherine Flores-16/+36
2023-07-24Rollup merge of #113994 - nyurik:parser-fmt-ref, r=davidtwcoMatthias Krüger-8/+8
Optimize format usage Per #112156, using `&` in `format!` may cause a small perf delay, so I tried to clean up one module at a time format usage. This PR includes a few removals of the ref in format (they do compile locally without the ref), as well as a few format inlining for consistency.
2023-07-24Specify macro is invalid in certain contextsCatherine-26/+55
2023-07-24Optimize format usageYuri Astrakhan-8/+8
Per #112156, using `&` in `format!` may cause a small perf delay, so I tried to clean up one module at a time format usage. This PR includes a few removals of the ref in format (they do compile locally without the ref), as well as a few format inlining for consistency.
2023-07-23fix some clippy::style findingsMatthias Krüger-1/+1
comparison_to_empty iter_nth_zero for_kv_map manual_next_back redundant_pattern
2023-07-23fix couple of clippy findings:Matthias Krüger-1/+1
filter_map_identity iter_kv_map needless_question_mark redundant_at_rest_pattern filter_next derivable_impls
2023-07-23reimplement C string literalsDeadbeef-1/+25
2023-07-22Support interpolated block for try and asyncMichael Goulet-4/+10
2023-07-20Don't translate compiler-internal bug messagesOli Scherer-34/+17
2023-07-19Rollup merge of #113803 - compiler-errors:const-interp-block, r=fee1-deadDylan DPC-1/+2
Fix inline_const with interpolated block Interpolation already worked when we had a `const $block` that wasn't a statement expr: ``` fn foo() { let _ = const $block; } ``` But it was failing when the const block was in statement expr position: ``` fn foo() { const $block; } ``` ... because of a bug in a check for const items. This fixes that. --- cc https://github.com/rust-lang/rust/pull/112953#issuecomment-1631354481, though I don't think this requires an FCP since it's already supported in exprs and seems to me to be fully a parser bug.
2023-07-19Make it clearer that edition functions are >=, not ==Michael Goulet-6/+6
2023-07-19Fix inline_const with interpolated blockMichael Goulet-1/+2
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-3/+6
2023-07-05Fix the issue of wrong diagnosis for extern pub fnyukang-1/+5
2023-07-04Detect extra space in keyword for better hintyukang-0/+16
2023-06-27Auto merge of #113105 - matthiaskrgr:rollup-rci0uym, r=matthiaskrgrbors-15/+12
Rollup of 8 pull requests Successful merges: - #112207 (Add trustzone and virtualization target features for aarch32.) - #112454 (Make compiletest aware of targets without dynamic linking) - #112628 (Allow comparing `Box`es with different allocators) - #112692 (Provide more context for `rustc +nightly -Zunstable-options` on stable) - #112972 (Make `UnwindAction::Continue` explicit in MIR dump) - #113020 (Add tests impl via obj unless denied) - #113084 (Simplify some conditions) - #113103 (Normalize types when applying uninhabited predicate.) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-27Rollup merge of #112978 - compiler-errors:bad-block-sugg, r=davidtwcoMatthias Krüger-0/+15
Add suggestion for bad block fragment error Makes it a bit clearer how to fix this parser restriction
2023-06-27Rollup merge of #112518 - chenyukang:yukang-fix-112458, r=davidtwcoMatthias Krüger-2/+8
Detect actual span for getting unexpected token from parsing macros Fixes #112458
2023-06-27Simplify some conditionsMaybe Waffle-15/+12
2023-06-23Add suggestion for bad block fragment errorMichael Goulet-0/+15