summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
AgeCommit message (Collapse)AuthorLines
2022-04-30Add `do yeet` expressions to allow experimentation in nightlyScott McMurray-0/+21
Using an obviously-placeholder syntax. An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point. But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-29errors: `span_suggestion` takes `impl ToString`David Wood-3/+3
Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-44/+46
2022-04-27Avoid producing `NoDelim` values in `TokenCursorFrame`.Nicholas Nethercote-1/+2
2022-04-07Shrink `Nonterminal`.Nicholas Nethercote-1/+1
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`. This slightly reduces cumulative and peak allocation amounts, most notably on `deep-vector`.
2022-04-05errors: implement fallback diagnostic translationDavid Wood-2/+2
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-03Auto merge of #88672 - camelid:inc-parser-sugg, r=davidtwcobors-0/+24
Suggest `i += 1` when we see `i++` or `++i` Closes #83502 (for `i++` and `++i`; `--i` should be covered by #82987, and `i--` is tricky to handle). This is a continuation of #83536. r? `@estebank`
2022-04-01Rollup merge of #95293 - compiler-errors:braces, r=davidtwcoMatthias Krüger-11/+7
suggest wrapping single-expr blocks in square brackets Suggests a fix in cases like: ```diff - const A: [i32; 1] = { 1 }; + const A: [i32; 1] = [ 1 ]; ^ ^ ``` Also edit the message for the same suggestion in the parser (e.g. `{ 1, 2 }`). Fixes #95289
2022-03-30Addressed comments by @compiler-errors and @bjorn3Yuri Astrakhan-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-1/+1
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-24suggest wrapping single-expr blocks in square bracketsMichael Goulet-11/+7
2022-03-23Add heuristic to avoid treating `x + +2` as incrementNoah Lev-0/+1
2022-03-23Improve function namesNoah Lev-2/+2
2022-03-23Emit both subexp and standalone sugg for postfixNoah Lev-3/+1
This solves the TODO.
2022-03-23Refactor, handle fields better, add field testsNoah Lev-8/+8
2022-03-23Move increment checks to improve errorsNoah Lev-0/+25
2022-03-18suggest removing type ascription in bad positionMichael Goulet-6/+35
2022-03-18use `self.create_snapshot_for_diagnostic` instead of `self.clone()`Takayuki Maeda-5/+6
2022-03-17Rollup merge of #94731 - TaKO8Ki:const-generic-expr-recovery, ↵Dylan DPC-11/+11
r=davidtwco,oli-obk Suggest adding `{ .. }` around a const function call with arguments closes #91020
2022-03-15use `format_args_capture` in some parts of rustc_parseTakayuki Maeda-18/+18
2022-03-10replace `self.clone()` with `self.create_snapshot_for_diagnostic()`Takayuki Maeda-11/+11
2022-03-07diagnostics: only talk about `Cargo.toml` if running under CargoMichael Howell-3/+1
Fixes #94646
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-3/+3
2022-02-28Tweak diagnosticsEsteban Kuber-10/+46
* Recover from invalid `'label: ` before block. * Make suggestion to enclose statements in a block multipart. * Point at `match`, `while`, `loop` and `unsafe` keywords when failing to parse their expression. * Do not suggest `{ ; }`. * Do not suggest `|` when very unlikely to be what was wanted (in `let` statements).
2022-02-25Rollup merge of #94344 - notriddle:notriddle/suggest-parens-more, r=oli-obkMatthias Krüger-2/+16
diagnostic: suggest parens when users want logical ops, but get closures Fixes #93536
2022-02-24diagnostic: suggest parens when users want logical ops, but get closuresMichael Howell-2/+16
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-4/+7
2022-02-23rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.Eduard-Mihai Burtescu-9/+10
2022-02-23rustc_errors: remove `struct_dummy`.Eduard-Mihai Burtescu-3/+5
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-2/+2
2022-02-19Adopt let else in more placesest31-3/+2
2022-02-12Rollup merge of #93595 - compiler-errors:ice-on-lifetime-arg, r=jackh726Matthias Krüger-3/+3
fix ICE when parsing lifetime as function argument I don't really like this, but we basically need to emit an error instead of just delaying an bug, because there are too many places in the AST that aren't covered by my previous PRs... cc: https://github.com/rust-lang/rust/issues/93282#issuecomment-1028052945
2022-02-03clippy::perf fixesMatthias Krüger-3/+3
single_char_pattern and to_string_in_format_args
2022-02-02fix ICE when parsing lifetime as function argumentMichael Goulet-3/+3
2022-01-31Write UI tests, tweak message5225225-3/+2
2022-01-27Suggest making base prefix lowercase if parsing fails5225225-0/+26
2022-01-25delay the bug once again, generalize turbofish suggestionMichael Goulet-4/+3
2022-01-25Remove delayed bug when encountering label in bad turbofishMichael Goulet-2/+3
2022-01-22Fix let_chains and if_let_guard feature flagsCaio-3/+17
2022-01-17Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, ↵Matthias Krüger-1/+7
r=nagisa Fix suggesting turbofish with lifetime arguments Now we suggest turbofish correctly given exprs like `foo<'_>`. Also fix suggestion when we have `let x = foo<bar, baz>;` which was broken.
2022-01-13Fix suggesting turbofish with lifetime argumentsMichael Goulet-1/+7
2022-01-14Parse `Ty?` as `Option<Ty>` and provide structured suggestionEsteban Kuber-2/+2
Swift has specific syntax that desugars to `Option<T>` similar to our `?` operator, which means that people might try to use it in Rust. Parse it and gracefully recover.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-4/+6
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-2/+2
2021-12-14Stabilize `destructuring_assignment`Jacob Pratt-2/+0
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-2/+4
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-14Rollup merge of #91597 - r00ster91:lessthangreaterthan, r=oli-obkMatthias Krüger-1/+33
Recover on invalid operators `<>` and `<=>` Thanks to #89871 for showing me how to do this. Next, I think it'd be nice to recover on `<=>` too, like #89871 intended, if this even works.
2021-12-14Recover on invalid operators <> and <=>r00ster91-1/+33
2021-12-08Do not attempt to suggest help for overly malformed struct/function callthreadexception-20/+27
2021-12-01Improve diagnostic for missing half of binary operator in `if` conditionFabian Wolff-10/+41