about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
AgeCommit message (Collapse)AuthorLines
2023-02-05Recover from missing expression in for loopObei Sideg-0/+15
2023-02-05rustc_parse: remove huge error importsest31-98/+88
2023-02-03Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obkMichael Goulet-1/+1
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-1/+1
Improve `TokenCursor`. Some small improvements, for things that were bugging me. Best reviewed one commit at a time. r? ``@petrochenkov``
2023-02-03Remove `TokenCursorFrame`.Nicholas Nethercote-1/+1
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-02Improve diagnostic for missing space in range patternclubby789-0/+8
2023-02-01Make "use latest edition" subdiagnostic translatableXiretza-11/+12
2023-02-01Convert rustc_parse::parser::pat::Expected to enumXiretza-2/+2
This is required in order to support translatable diagnostics.
2023-02-01rustc_parse: migrate more to diagnostic structsXiretza-14/+14
2023-02-01Use AddToDiagnostic for "use latest edition" helpXiretza-3/+3
2023-02-01fix parser mistaking const closures for const itemDeadbeef-1/+1
2023-02-01Rollup merge of #107487 - edward-shen:edward-shen/107213-round-2, r=estebankMatthias Krüger-1/+1
Make the "extra if in let...else block" hint a suggestion Changes the hint to a suggestion, suggested in #107213. r? ```@estebank```
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-1/+1
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-28Check for missing space between fat arrow and range patternclubby789-1/+1
2023-01-23Add suggestion to remove if in let...else blockEdward Shen-13/+20
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-20Rollup merge of #106783 - WaffleLapkin:break-my-ident, r=wesleywiserMatthias Krüger-7/+54
Recover labels written as identifiers This adds recovery for `break label expr` and `continue label`, as well as a test for `break label`.
2023-01-14Rollup merge of #106849 - WaffleLapkin:unvec, r=NilstriebMatthias Krüger-3/+2
Allocate one less vec while parsing arrays Probably does not matter, but imo a little bit nicer.
2023-01-14Allocate one less vec in `parser/expr.rs`Maybe Waffle-3/+2
2023-01-14Improve comments in `parser/expr.rs`Maybe Waffle-9/+13
2023-01-14Make `LhsExpr::AlreadyParsed` a named structMaybe Waffle-4/+4
2023-01-13Recover labels written as identifiersMaybe Waffle-5/+52
2023-01-12Remove an `unwrap()` from parser that can be written as if-let-chainMaybe Waffle-2/+2
2023-01-12parse const closuresDeadbeef-1/+7
2023-01-11Detect struct literal needing parenthesesEsteban Küber-1/+1
Fix #82051.
2023-01-06Tiny formatting fixEsteban Küber-6/+7
2022-12-28Account for ADT bodies and struct expressionsEsteban Küber-0/+1
2022-12-25Auto merge of #105701 - RedDocMD:bug-105634, r=cjgillotbors-3/+7
Allow .. to be parsed as let initializer .. and ..= are valid expressions, however when used in a let statement it is not parsed. Fixes #105634
2022-12-16Little fixesDeep Majumder-3/+3
2022-12-14Allow .. to be parsed as let initializerDeep Majumder-3/+7
.. and ..= are valid expressions, however when used in a let statement it is not parsed.
2022-12-14Auto merge of #104875 - chenyukang:yukang/fix-104867-inc, r=estebankbors-6/+9
Properly handle postfix inc/dec in standalone and subexpr scenarios Fixes #104867 r? `@estebank`
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-22/+38
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
2022-12-05Rollup merge of #105223 - lukas-code:(ExprWithBlock), r=petrochenkovMatthias Krüger-14/+5
suggest parenthesis around ExprWithBlock BinOp ExprWithBlock fix https://github.com/rust-lang/rust/issues/105179 fix https://github.com/rust-lang/rust/issues/102171
2022-12-05Parameterise `Parser::{recover_unclosed_char,handle_missing_lit}`.Nicholas Nethercote-21/+36
These two methods both produce a `MetaItemLit`, and then some of the call sites convert the `MetaItemLit` to a `token::Lit` with `as_token_lit`. This commit parameterises these two methods with a `mk_lit_char` closure, which can be used to produce either `MetaItemLit` or `token::Lit` directly as necessary.
2022-12-03more commentsLukas Markeffsky-3/+4
2022-12-03suggest parenthesis around ExprWithBlock BinOp ExprWithBlockLukas Markeffsky-12/+2
2022-12-03Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillotMatthias Krüger-3/+7
Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
2022-12-02Remove `token::Lit` from `ast::MetaItemLit`.Nicholas Nethercote-5/+6
`token::Lit` contains a `kind` field that indicates what kind of literal it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has its own `kind` field. This means that `ast::MetaItemLit` encodes the literal kind in two different ways. This commit changes `ast::MetaItemLit` so it no longer wraps `token::Lit`. It now contains the `symbol` and `suffix` fields from `token::Lit`, but not the `kind` field, eliminating the redundancy.
2022-11-28Keep track of the start of the argument block of a closureSarthak Singh-3/+7
2022-11-28Rename `ast::Lit` as `ast::MetaItemLit`.Nicholas Nethercote-12/+15
2022-11-26add start_stmt to handle postfix incrementyukang-14/+9
2022-11-25fix #104867, Properly handle postfix inc/dec in standalone and subexpr scenariosyukang-1/+9
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-2/+3
2022-11-22`rustc_parse`: remove `ref` patternsMaybe Waffle-4/+4
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-1/+1
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-19Cleanup macro matching recoveryNilstrieb-5/+0
The retry has been implemented already.
2022-11-18Auto merge of #104573 - matthiaskrgr:rollup-k36ybtp, r=matthiaskrgrbors-2/+13
Rollup of 8 pull requests Successful merges: - #101162 (Migrate rustc_resolve to use SessionDiagnostic, part # 1) - #103386 (Don't allow `CoerceUnsized` into `dyn*` (except for trait upcasting)) - #103405 (Detect incorrect chaining of if and if let conditions and recover) - #103594 (Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets) - #104006 (Add variant_name function to `LangItem`) - #104494 (Migrate GUI test to use functions) - #104516 (rustdoc: clean up sidebar width CSS) - #104550 (fix a typo) Failed merges: - #104554 (Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less) r? `@ghost` `@rustbot` modify labels: rollup
2022-11-18Rollup merge of #103405 - chenyukang:yukang/fix-103381-and-if, r=compiler-errorsMatthias Krüger-2/+13
Detect incorrect chaining of if and if let conditions and recover Fixes #103381
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-17/+25
patterns.