about summary refs log tree commit diff
path: root/compiler/rustc_parse/messages.ftl
AgeCommit message (Collapse)AuthorLines
2023-12-08Auto merge of #118420 - compiler-errors:async-gen, r=eholkbors-2/+0
Introduce support for `async gen` blocks I'm delighted to demonstrate that `async gen` block are not very difficult to support. They're simply coroutines that yield `Poll<Option<T>>` and return `()`. **This PR is WIP and in draft mode for now** -- I'm mostly putting it up to show folks that it's possible. This PR needs a lang-team experiment associated with it or possible an RFC, since I don't think it falls under the jurisdiction of the `gen` RFC that was recently authored by oli (https://github.com/rust-lang/rfcs/pull/3513, https://github.com/rust-lang/rust/issues/117078). ### Technical note on the pre-generator-transform yield type: The reason that the underlying coroutines yield `Poll<Option<T>>` and not `Poll<T>` (which would make more sense, IMO, for the pre-transformed coroutine), is because the `TransformVisitor` that is used to turn coroutines into built-in state machine functions would have to destructure and reconstruct the latter into the former, which requires at least inserting a new basic block (for a `switchInt` terminator, to match on the `Poll` discriminant). This does mean that the desugaring (at the `rustc_ast_lowering` level) of `async gen` blocks is a bit more involved. However, since we already need to intercept both `.await` and `yield` operators, I don't consider it much of a technical burden. r? `@ghost`
2023-12-08Support async gen fnMichael Goulet-2/+0
2023-12-08Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errorsbors-2/+0
never_patterns: Parse match arms with no body Never patterns are meant to signal unreachable cases, and thus don't take bodies: ```rust let ptr: *const Option<!> = ...; match *ptr { None => { foo(); } Some(!), } ``` This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser). ~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit r? `@compiler-errors`
2023-12-04Make async gen fn an errorEric Holk-0/+2
2023-12-03Detect attempts to expand a macro to a match arm againNadrieril-2/+0
Because a macro invocation can expand to a never pattern, we can't rule out a `arm!(),` arm at parse time. Instead we detect that case at expansion time, if the macro tries to output a pattern followed by `=>`.
2023-11-29Account for `(pat if expr) => {}`Esteban Küber-0/+3
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix #100825.
2023-11-29Rollup merge of #118191 - estebank:let-chain-typo, r=compiler-errorsMatthias Krüger-0/+4
Suggest `let` or `==` on typo'd let-chain When encountering a bare assignment in a let-chain, suggest turning the assignment into a `let` expression or an equality check. ``` error: expected expression, found `let` statement --> $DIR/bad-if-let-suggestion.rs:5:8 | LL | if let x = 1 && i = 2 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions help: you might have meant to continue the let-chain | LL | if let x = 1 && let i = 2 {} | +++ help: you might have meant to compare for equality | LL | if let x = 1 && i == 2 {} | + ```
2023-11-28Suggest `let` or `==` on typo'd let-chainEsteban Küber-0/+4
When encountering a bare assignment in a let-chain, suggest turning the assignment into a `let` expression or an equality check. ``` error: expected expression, found `let` statement --> $DIR/bad-if-let-suggestion.rs:5:8 | LL | if let x = 1 && i = 2 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions help: you might have meant to continue the let-chain | LL | if let x = 1 && let i = 2 {} | +++ help: you might have meant to compare for equality | LL | if let x = 1 && i == 2 {} | + ```
2023-11-27Suggest swapping the order of `ref` and `box`Hirochika Matsumoto-0/+3
2023-11-14Recover `dyn` and `impl` after `for<...>`Michael Goulet-0/+3
2023-11-07Auto merge of #117297 - clubby789:fn-trait-missing-paren, r=TaKO8Kibors-0/+3
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-01Rollup merge of #117298 - clubby789:fn-missing-params, r=petrochenkovMatthias Krüger-0/+3
Recover from missing param list in function definitions Addresses the other issue mentioned in #108109
2023-11-01Give a better diagnostic for missing parens in Fn* boundsclubby789-0/+3
2023-11-01Recover from missing param list in function definitionsclubby789-0/+3
2023-10-30Talk about `gen fn` in diagnostics about `gen fn`Oli Scherer-2/+2
2023-10-26Reserve `gen` keyword for `gen {}` blocks and `gen fn` in 2024 editionOli Scherer-0/+3
2023-10-06Rollup merge of #116400 - estebank:issue-78585, r=WaffleLapkinJubilee-0/+4
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-03Move some tests aroundEsteban Küber-4/+4
2023-10-03Detect missing `=>` after match guard during parsingEsteban Küber-0/+4
``` 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-03Rollup merge of #115863 - chenyukang:yukang-add-message-tidy-check, r=davidtwcoMatthias Krüger-30/+0
Add check_unused_messages in tidy From https://github.com/rust-lang/rust/pull/115728#issuecomment-1715490553 The check is not 100% accurate, I guess it's enough for now.
2023-09-28Tweak wording of missing angle backets in qualified pathEsteban Küber-1/+1
2023-09-20Cleanup unused messages in ftl filesyukang-30/+0
2023-09-13Address review commentsMatthew Jasper-0/+1
- Add doc comment to new type - Restore "only supported directly in conditions of `if` and `while` expressions" note - Rename variant with clearer name
2023-09-11Move let expression checking to parsingMatthew Jasper-0/+2
There was an incomplete version of the check in parsing and a second version in AST validation. This meant that some, but not all, invalid uses were allowed inside macros/disabled cfgs. It also means that later passes have a hard time knowing when the let expression is in a valid location, sometimes causing ICEs. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress later errors and MIR construction for invalid let expressions.
2023-08-16Fix bad suggestion when wrong parentheses around a dyn traityukang-2/+2
2023-08-04Rollup merge of #113999 - Centri3:macro-arm-expand, r=wesleywiserMatthias Krüger-0/+6
Specify macro is invalid in certain contexts Adds a note when a macro is used where it really shouldn't be. Closes #113766
2023-08-03Rollup merge of #114300 - MU001999:fix/turbofish-pat, r=estebankMatthias Krüger-0/+2
Suggests turbofish in patterns Fixes #114112 r? ```@estebank```
2023-08-01Suggests turbofish in patternsMu001999-0/+2
2023-07-31parser: more friendly hints for handling `async move` in the 2015 editionbohan-0/+2
2023-07-29Auto merge of #114028 - Centri3:ternary-operator, r=compiler-errorsbors-0/+4
Gracefully handle ternary operator Fixes #112578 ~~May not be the best way to do this as it doesn't check for a single `:`, so it could perhaps appear even when the actual issue is just a missing semicolon. May not be the biggest deal, though?~~ Nevermind, got it working properly now ^^
2023-07-28Parse generic const itemsLeón Orell Valerian Liehr-0/+8
2023-07-25Gracefully handle missing ternary operatorCatherine Flores-0/+4
2023-07-24Specify macro is invalid in certain contextsCatherine-0/+6
2023-06-23Add suggestion for bad block fragment errorMichael Goulet-0/+1
2023-06-10reword the message to suggest surrounding with parenthesesyukang-1/+1
2023-05-25Ensure Fluent messages are in alphabetical orderclubby789-594/+594
2023-05-13improve error for `impl<..> impl Trait for Type`y21-0/+5
2023-05-09Rollup merge of #111120 - chenyukang:yukang-suggest-let, r=NilstriebDylan DPC-0/+1
Suggest let for possible binding with ty Origin from https://github.com/rust-lang/rust/pull/109128#discussion_r1179866137 r? `@Nilstrieb`
2023-05-09move sugg to derive session diagnosticyukang-0/+1
2023-05-05Add parsing for builtin # in expression and item contextest31-0/+4
2023-05-02Implement negative boundsMichael Goulet-8/+2
2023-05-01soften the wording for removing type ascriptionyukang-1/+2
2023-05-01Rip it outNilstrieb-0/+8
My type ascription Oh rip it out Ah If you think we live too much then You can sacrifice diagnostics Don't mix your garbage Into my syntax So many weird hacks keep diagnostics alive Yet I don't even step outside So many bad diagnostics keep tyasc alive Yet tyasc doesn't even bother to survive!
2023-04-27Migrate trivially translatable `rustc_parse` diagnosticsclubby789-0/+72
2023-04-25Fix static string lintsclubby789-0/+30
2023-04-10Remove `..` from return type notationMichael Goulet-0/+4
2023-03-28Add `(..)` syntax for RTNMichael Goulet-0/+4
2023-03-19refactor: refactor identifier parsing somewhatEzra Shaw-1/+1
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-0/+3
2023-03-11Simplify message pathsest31-0/+733
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