about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
AgeCommit message (Collapse)AuthorLines
2023-03-13Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31bors-3/+21
Remove `box_syntax` r? `@Nilstrieb` This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected. It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute. As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new` Closes #49733
2023-03-12Add recovery for use of removed `box` syntaxclubby789-0/+28
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-10/+0
2023-03-11Gate const closures even when they appear in macrosMichael Goulet-1/+1
2023-03-04Rollup merge of #108715 - chenyukang:yukang/cleanup-parser-delims, ↵Matthias Krüger-13/+0
r=compiler-errors Remove unclosed_delims from parser After landing https://github.com/rust-lang/rust/pull/108297 we could remove `unclosed_delims` from the parser now.
2023-03-03Remove unclosed_delims from parseryukang-13/+0
2023-03-03check if snippet is `)`Takayuki Maeda-2/+7
2023-03-01recover from for-else and while-elsey21-0/+22
2023-03-01Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkinMatthias Krüger-0/+12
fix #108495, postfix decrement and prefix decrement has no warning Fixes #108495
2023-02-28micro fmt changesMaybe Waffle-1/+1
2023-02-27handle only postfix decrementnx2k3-24/+4
2023-02-27check double negationnx2k3-3/+10
2023-02-26fix some commentsnx2k3-3/+3
2023-02-26fix #108495, postfix decrement and prefix decrement has no warningnx2k3-4/+29
2023-02-24Replace parse_[sth]_expr with parse_expr_[sth] function namesest31-118/+118
This resolves an inconsistency in naming style for functions on the parser, between functions parsing specific kinds of items and those for expressions, favoring the parse_item_[sth] style used by functions for items. There are multiple advantages of that style: * functions of both categories are collected in the same place in the rustdoc output. * it helps with autocompletion, as you can narrow down your search for a function to those about expressions. * it mirrors rust's path syntax where less specific things come first, then it gets more specific, i.e. std::collections::hash_map::Entry The disadvantage is that it doesn't "read like a sentence" any more, but I think the advantages weigh more greatly. This change was mostly application of this command: sed -i -E 's/(fn |\.)parse_([[:alnum:]_]+)_expr/\1parse_expr_\2/' compiler/rustc_parse/src/parser/*.rs Plus very minor fixes outside of rustc_parse, and an invocation of x fmt.
2023-02-21Use `ThinVec` in a few more AST types.Nicholas Nethercote-2/+2
2023-02-21Use `ThinVec` in `ast::ExprKind::Match`.Nicholas Nethercote-1/+1
2023-02-21Use `ThinVec` in `ast::Block`.Nicholas Nethercote-2/+2
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-5/+6
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2023-02-21Use `ThinVec` in `ast::Generics` and related types.Nicholas Nethercote-1/+1
2023-02-06Migrate `rustc_parse` to derive diagnosticsclubby789-1/+2
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