about summary refs log tree commit diff
path: root/compiler/rustc_parse
AgeCommit message (Collapse)AuthorLines
2023-04-04Replace another lock with an append-only vecOli Scherer-1/+1
2023-04-04Replace a lock with an atomicOli Scherer-2/+7
2023-03-28Add `(..)` syntax for RTNMichael Goulet-8/+43
2023-03-28RTNMichael Goulet-1/+5
2023-03-27Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errorsGuillaume Gomez-1/+1
Remove the `NodeId` of `ast::ExprKind::Async` This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416. In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`. It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-22Rollup merge of #109203 - Ezrashaw:refactor-ident-parsing, r=NilstriebMatthias Krüger-65/+129
refactor/feat: refactor identifier parsing a bit \+ error recovery for `expected_ident_found` Prior art: #108854
2023-03-21Refactor `handle_missing_lit`.Nicholas Nethercote-14/+8
2023-03-20feat: implement error recovery in `expected_ident_found`Ezra Shaw-36/+79
2023-03-19Remove the `NodeId` of `ast::ExprKind::Async`Arpad Borsos-1/+1
2023-03-19refactor: improve "ident starts with number" errorEzra Shaw-16/+29
2023-03-19refactor: refactor identifier parsing somewhatEzra Shaw-23/+31
2023-03-13Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31bors-3/+37
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-12Rollup merge of #109029 - compiler-errors:parse-gating, r=jackh726Matthias Krüger-4/+10
Gate usages of `dyn*` and const closures in macros We silently accepted `dyn*` and const closures in macros as long as they didn't expand to anything containing these experimental features, unlike other gated features such as `for<'a>` binders on closures, etc. Let's not do that, to make sure nobody begins relying on this.
2023-03-12Add recovery for use of removed `box` syntaxclubby789-0/+28
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-10/+16
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11Gate const closures even when they appear in macrosMichael Goulet-4/+8
2023-03-11Gate all usages of dyn*, even in macrosMichael Goulet-0/+2
2023-03-10Rollup merge of #108900 - bvanjoi:issue-108275, r=petrochenkovMatthias Krüger-1/+1
fix(lexer): print whitespace warning for \x0c - close https://github.com/rust-lang/rust/issues/108275 - discussion: https://github.com/rust-lang/rust/pull/108403
2023-03-09fix(lexer): not skipped whitespace warning for '\x0c'bohan-1/+1
2023-03-09Rollup merge of #108854 - Ezrashaw:improve-int-idents, r=oli-obkMatthias Krüger-36/+41
feat/refactor: improve errors in case of ident with number at start Improve parser code when we parse a integer (or float) literal but expect an identifier. We emit an error message saying that identifiers can't begin with numbers. This PR just improves that code and expands it to all identifiers. Note that I haven't implemented error recovery (this didn't exist before anyway), I might do that in a follow up PR.
2023-03-09feat/refactor: improve errors in case of ident with number at startEzra Shaw-36/+41
2023-03-07Simplify `sort_by` callsMaybe Waffle-1/+1
2023-03-04Rollup merge of #108715 - chenyukang:yukang/cleanup-parser-delims, ↵Matthias Krüger-158/+12
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-04Rollup merge of #108298 - TaKO8Ki:fix-104440, r=cjgillotDylan DPC-2/+7
Fix ICE: check if snippet is `)` Fixes #107705
2023-03-03Remove unclosed_delims from parseryukang-158/+12
2023-03-03Match unmatched backticks in comments in compiler/est31-3/+3
2023-03-03check if snippet is `)`Takayuki Maeda-2/+7
2023-03-01recover from for-else and while-elsey21-0/+37
2023-03-01Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgrbors-2/+26
Rollup of 10 pull requests Successful merges: - #108376 (compiler/rustc_session: fix sysroot detection logic) - #108400 (add llvm cgu instructions stats to perf) - #108496 (fix #108495, postfix decrement and prefix decrement has no warning) - #108505 (Further unify validity intrinsics) - #108520 (Small cleanup to `one_bound_for_assoc_type`) - #108560 (Some `infer/mod.rs` cleanups) - #108563 (Make mailmap more correct) - #108564 (Fix `x clean` with specific paths) - #108571 (Add contains_key to SortedIndexMultiMap) - #108578 (Update Fuchsia platform team members) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-01Rollup merge of #108496 - nx2k3:issue-108495-dec, r=WaffleLapkinMatthias Krüger-2/+26
fix #108495, postfix decrement and prefix decrement has no warning Fixes #108495
2023-03-01Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petrochenkovMatthias Krüger-56/+60
Exit when there are unmatched delims to avoid noisy diagnostics From https://github.com/rust-lang/rust/pull/104012#issuecomment-1311764832 r? ``@petrochenkov``
2023-02-28micro fmt changesMaybe Waffle-1/+2
2023-02-28refactor parse_token_trees to not return unmatched_delimsyukang-30/+29
2023-02-28no need to return unmatched_delims from tokentreesyukang-10/+6
2023-02-28rename unmatched_braces to unmatched_delimsyukang-26/+27
2023-02-28remove duplicated diagnostic for unclosed delimiteryukang-8/+9
2023-02-28Exit when there are unmatched delims to avoid noisy diagnosticsyukang-3/+10
2023-02-27handle only postfix decrementnx2k3-34/+4
2023-02-27check double negationnx2k3-3/+10
2023-02-27Rollup merge of #108477 - y21:replace-semi-with-comma-sugg, r=compiler-errorsMatthias Krüger-1/+1
Make `match` arm comma suggestion more clear Fixes #108472
2023-02-26fix some commentsnx2k3-7/+5
2023-02-26fix #108495, postfix decrement and prefix decrement has no warningnx2k3-7/+55
2023-02-26Rollup merge of #108418 - est31:parser_function_names, r=NilstriebMatthias Krüger-130/+130
Replace parse_[sth]_expr with parse_expr_[sth] function names This resolves an inconsistency in naming style for functions on the parser, where: * functions parsing specific kinds of items are named `parse_item_[sth]` and * functions parsing specific kinds of *expressions* are named `parse_[sth]_expr` favoring the 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](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/parser/struct.Parser.html). * 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-26generalize help messagey21-1/+1
2023-02-24Replace parse_[sth]_expr with parse_expr_[sth] function namesest31-130/+130
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-23parser: provide better errors on closures with braces missingYutaro Ohno-1/+5
We currently provide wrong suggestions and unhelpful errors on closure bodies with braces missing. For example, given the following code: ``` fn main() { let _x = Box::new(|x|x+1;); } ``` the current output is like this: ``` error: expected expression, found `)` --> ./main.rs:2:30 | 2 | let _x = Box::new(|x|x+1;); | ^ expected expression error: closure bodies that contain statements must be surrounded by braces --> ./main.rs:2:25 | 2 | let _x = Box::new(|x|x+1;); | ^ 3 | } | ^ | ... help: try adding braces | 2 ~ let _x = Box::new(|x| {x+1;); 3 ~ }} ... error: expected `;`, found `}` --> ./main.rs:2:32 | 2 | let _x = Box::new(|x|x+1;); | ^ help: add `;` here 3 | } | - unexpected token error: aborting due to 3 previous errors ``` This commit allows outputting correct suggestions and errors. The above code would output like this: ``` error: closure bodies that contain statements must be surrounded by braces --> ./main.rs:2:25 | 2 | let _x = Box::new(|x|x+1;); | ^ ^ | note: statement found outside of a block --> ./main.rs:2:29 | 2 | let _x = Box::new(|x|x+1;); | ---^ this `;` turns the preceding closure into a statement | | | this expression is a statement because of the trailing semicolon note: the closure body may be incorrectly delimited --> ./main.rs:2:23 | 2 | let _x = Box::new(|x|x+1;); | ^^^^^^ - ...but likely you meant the closure to end here | | | this is the parsed closure... help: try adding braces | 2 | let _x = Box::new(|x| {x+1;}); | + + error: aborting due to previous error ```
2023-02-22errors: generate typed identifiers in each crateDavid Wood-99/+853
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-21Use `ThinVec` in a few more AST types.Nicholas Nethercote-4/+4
2023-02-21Use `ThinVec` in `ast::ExprKind::Match`.Nicholas Nethercote-1/+1