about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
AgeCommit message (Collapse)AuthorLines
2023-11-15Re-format code with new rustfmtMark Rousskov-10/+12
2023-11-15discard invalid spans in external blocksbohan-2/+4
2023-11-14Fix some typoscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-11-14Detect more `=>` typosEsteban Küber-9/+10
Handle and recover `match expr { pat >= { arm } }`.
2023-11-14Recover `dyn` and `impl` after `for<...>`Michael Goulet-3/+57
2023-11-13Auto merge of #117770 - sjwang05:issue-117766, r=estebank,TaKO8Kibors-20/+61
Catch stray `{` in let-chains Fixes #117766
2023-11-12Fix `is_keyword_ahead` visibilitysjwang05-1/+1
Co-authored-by: Takayuki Maeda <takoyaki0316@gmail.com>
2023-11-11Move unclosed delim errors to separate functionsjwang05-53/+58
2023-11-10Correctly handle while-let-chainssjwang05-2/+2
2023-11-09Catch an edge casesjwang05-1/+5
2023-11-09Catch stray { in let-chainssjwang05-1/+33
2023-11-09Suggest fix for ; within let-chainssjwang05-4/+20
2023-11-08Rollup merge of #117282 - clubby789:recover-wrong-function-header, r=TaKO8KiGuillaume Gomez-3/+37
Recover from incorrectly ordered/duplicated function keywords Fixes #115714
2023-11-07Auto merge of #117297 - clubby789:fn-trait-missing-paren, r=TaKO8Kibors-0/+40
Give a better diagnostic for missing parens in Fn* bounds Fixes #108109 It would be nice to try and recover here, but I'm not sure it's worth the effort, especially as the bounds on the recovered function would be incorrect.
2023-11-04fmtDinu Blanovschi-3/+1
2023-11-04feat(hir): Store the `Span` of the `move` keywordDinu Blanovschi-1/+4
2023-11-03Auto merge of #117507 - nnethercote:rustc_span, r=Nilstriebbors-10/+10
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-10/+10
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-11-01Rollup merge of #117298 - clubby789:fn-missing-params, r=petrochenkovMatthias Krüger-0/+18
Recover from missing param list in function definitions Addresses the other issue mentioned in #108109
2023-11-01Auto merge of #117289 - estebank:issue-72298, r=cjgillotbors-1/+33
Account for `ref` and `mut` in the wrong place for pattern ident renaming If the user writes `S { ref field: name }` instead of `S { field: ref name }`, we suggest the correct code. Fix #72298.
2023-11-01Give a better diagnostic for missing parens in Fn* boundsclubby789-0/+40
2023-11-01Recover from missing param list in function definitionsclubby789-0/+18
2023-11-01Stabilize C string literalsJohn Millikin-3/+0
2023-10-31Rollup merge of #116712 - estebank:issue-116252, r=petrochenkovMatthias Krüger-27/+63
When encountering unclosed delimiters during lexing, check for diff markers Fix #116252.
2023-10-30Talk about `gen fn` in diagnostics about `gen fn`Oli Scherer-3/+3
2023-10-30When encountering unclosed delimiters during parsing, check for diff markersEsteban Küber-27/+63
Fix #116252.
2023-10-30Account for `ref` and `mut` in the wrong place for pattern ident renamingEsteban Küber-1/+33
If the user writes `S { ref field: name }` instead of `S { field: ref name }`, we suggest the correct code. Fix #72298.
2023-10-29Auto merge of #116889 - MU001999:master, r=petrochenkovbors-0/+2
Eat close paren if capture_cfg to avoid unbalanced parens Fixes #116781
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-13/+51
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-28restore snapshot when parse_param_generalMu001999-0/+2
2023-10-27Recover from incorrectly ordered/duplicated function keywordsclubby789-3/+37
2023-10-27Rollup merge of #117212 - clubby789:fix-ternary-recover, r=compiler-errorsMatthias Krüger-13/+13
Properly restore snapshot when failing to recover parsing ternary If the recovery parsed an expression, then failed to eat a `:`, it would return `false` without restoring the snapshot. Fix this by always restoring the snapshot when returning `false`. Draft for now because I'd like to try and improve this recovery further. Fixes #117208
2023-10-27Handle `move` generatorsOli Scherer-11/+8
2023-10-27Feature gate `gen` blocks, even in 2024 editionOli Scherer-1/+2
2023-10-27Add gen blocks to ast and do some broken ast loweringOli Scherer-18/+14
2023-10-26Recover ternary expression as errorclubby789-9/+11
2023-10-26Properly restore snapshot when failing to recover parsing ternaryclubby789-4/+2
2023-10-26Reserve `gen` keyword for `gen {}` blocks and `gen fn` in 2024 editionOli Scherer-2/+46
2023-10-25Avoid unbounded O(n^2) when parsing nested type argsEsteban Küber-6/+25
When encountering code like `f::<f::<f::<f::<f::<f::<f::<f::<...` with unmatched closing angle brackets, add a linear check that avoids the exponential behavior of the parse recovery mechanism. Fix #117080.
2023-10-20s/generator/coroutine/Oli Scherer-1/+1
2023-10-20Move where doc comment meant as comment checkEsteban Küber-18/+21
The new place makes more sense and covers more cases beyond individual statements. ``` error: expected one of `.`, `;`, `?`, `else`, or an operator, found doc comment `//!foo --> $DIR/doc-comment-in-stmt.rs:25:22 | LL | let y = x.max(1) //!foo | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected one of `.`, `;`, `?`, `else`, or an operator | help: add a space before `!` to write a regular comment | LL | let y = x.max(1) // !foo | + ``` Fix #65329.
2023-10-15Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstriebbors-136/+164
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-13Auto merge of #116645 - estebank:issue-116608, r=oli-obkbors-3/+74
Detect ruby-style closure in parser When parsing a closure without a body that is surrounded by a block, suggest moving the opening brace after the closure head. Fix #116608.
2023-10-13Format all the let chains in compilerMichael Goulet-136/+164
2023-10-12Detect ruby-style closure in parserEsteban Küber-3/+74
When parsing a closure without a body that is surrounded by a block, suggest moving the opening brace after the closure head. Fix #116608.
2023-10-12Reorder an expression to improve readability.Nicholas Nethercote-12/+7
2023-10-12Rename `Token::is_op` as `Token::is_punct`.Nicholas Nethercote-3/+6
For consistency with `proc_macro::Punct`.
2023-10-06Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkinJubilee-19/+85
Detect missing `=>` after match guard during parsing ``` error: expected one of `,`, `:`, or `}`, found `.` --> $DIR/missing-fat-arrow.rs:25:14 | LL | Some(a) if a.value == b { | - while parsing this struct LL | a.value = 1; | -^ expected one of `,`, `:`, or `}` | | | while parsing this struct field | help: try naming a field | LL | a: a.value = 1; | ++ help: you might have meant to start a match arm after the match guard | LL | Some(a) if a.value == b => { | ++ ``` Fix #78585.
2023-10-04Point to where missing return type should goMichael Goulet-1/+1
2023-10-04review commentsEsteban Küber-3/+2