about summary refs log tree commit diff
path: root/compiler/rustc_parse
AgeCommit message (Collapse)AuthorLines
2022-07-12Parse closure bindersMaybe Waffle-26/+22
This is first step in implementing RFC 3216. - Parse `for<'a>` before closures in ast - Error in lowering - Add `closure_lifetime_binder` feature
2022-07-12Rollup merge of #98633 - c410-f3r:yet-another-let-chain, r=estebankDylan DPC-8/+24
Fix last `let_chains` blocker In order to forbid things like `let x = (let y = 1);` or `if let a = 1 && { let x = let y = 1; } {}`, the parser **HAS** to know the context of `let`. This context thing is not a surprise in the parser because you can see **a lot** of ad hoc fixes mixing parsing logic with validation logic creating code that looks more like spaghetti with tomato sauce. To make things even greater, a new ad hoc fix was added to only allow `let`s in a valid `let_chains` context by checking the previously processed token. This was the only solution I could think of and believe me, I thought about it for a long time 👍 In the long term, it should be preferable to segregate different responsibilities or create a more robust and cleaner parser framework. cc https://github.com/rust-lang/rust/pull/94927 cc https://github.com/rust-lang/rust/issues/53667
2022-07-08Fix last let_chains blockerCaio-8/+24
2022-07-08Auto merge of #98638 - bjorn3:less_string_interning, r=tmiaskobors-2/+1
Use less string interning This removes string interning in a couple of places where doing so won't result in perf improvements. I also switched one place to use pre-interned symbols.
2022-07-07diagnostics: suggest naming a field after failing to parseMichael Howell-0/+13
2022-07-07diagnostics: mention the `:` token when struct fields fail to parseMichael Howell-0/+5
2022-07-07Auto merge of #98827 - aDotInTheVoid:suggest-extern-block, r=nagisabors-1/+10
Suggest using block for `extern "abi" fn` with no body `@rustbot` modify labels: +A-diagnostics
2022-07-03Auto merge of #98673 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrumbors-2/+2
Bump bootstrap compiler r? `@Mark-Simulacrum`
2022-07-02ast: Add span to `Extern`Nixon Enraght-Moony-1/+10
2022-07-01update cfg(bootstrap)sPietro Albini-2/+2
2022-06-29Rollup merge of #98668 - TaKO8Ki:avoid-many-&str-to-string-conversions, ↵Matthias Krüger-7/+4
r=Dylan-DPC Avoid some `&str` to `String` conversions with `MultiSpan::push_span_label` This patch removes some`&str` to `String` conversions with `MultiSpan::push_span_label`.
2022-06-29avoid many `&str` to `String` conversions with `MultiSpan::push_span_label`Takayuki Maeda-7/+4
2022-06-28Use pre-interned symbols in import recoverybjorn3-2/+1
2022-06-27various: add `rustc_lint_diagnostics` to diag fnsDavid Wood-0/+3
The `rustc_lint_diagnostics` attribute is used by the diagnostic translation/struct migration lints to identify calls where non-translatable diagnostics or diagnostics outwith impls are being created. Any function used in creating a diagnostic should be annotated with this attribute so this commit adds the attribute to many more functions. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-26Rollup merge of #98428 - davidtwco:translation-derive-typed-identifiers, ↵Matthias Krüger-12/+12
r=oli-obk macros: use typed identifiers in diag and subdiag derive Using typed identifiers instead of strings with the Fluent identifiers in the diagnostic and subdiagnostic derives - this enables the diagnostic derive to benefit from the compile-time validation that comes with typed identifiers, namely that use of a non-existent Fluent identifier will not compile. r? `````@oli-obk`````
2022-06-25[rustc_parse] Forbid lets in certain placesCaio-4/+32
2022-06-24macros: use typed identifiers in subdiag deriveDavid Wood-3/+3
As in the diagnostic derive, using typed identifiers in the subdiagnostic derive improves the diagnostics of using the subdiagnostic derive as Fluent messages will be confirmed to exist at compile-time. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-24macros: use typed identifiers in diag deriveDavid Wood-9/+9
Using typed identifiers instead of strings with the Fluent identifier enables the diagnostic derive to benefit from the compile-time validation that comes with typed identifiers - use of a non-existent Fluent identifier will not compile. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-20Rollup merge of #98183 - dtolnay:emptybound, r=lcnrYuki Okushi-1/+4
Fix pretty printing of empty bound lists in where-clause Repro: ```rust macro_rules! assert_item_stringify { ($item:item $expected:literal) => { assert_eq!(stringify!($item), $expected); }; } fn main() { assert_item_stringify! { fn f<'a, T>() where 'a:, T: {} "fn f<'a, T>() where 'a:, T: {}" } } ``` Previously this assertion would fail because rustc renders the where-clause as `where 'a, T` which is invalid syntax. This PR makes the above assertion pass. This bug also affects `-Zunpretty=expanded`. The intention is for that to emit syntactically valid code, but the buggy output is not valid Rust syntax. ```console $ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded #![feature(prelude_import)] #![no_std] #[prelude_import] use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; fn f<'a, T>() where 'a, T {} ``` ```console $ rustc <(echo "fn f<'a, T>() where 'a:, T: {}") -Zunpretty=expanded | rustc - error: expected `:`, found `,` --> <anon>:7:23 | 7 | fn f<'a, T>() where 'a, T {} | ^ expected `:` ```
2022-06-17remove the rest of unnecessary `to_string`Takayuki Maeda-4/+4
2022-06-16Fix pretty printing of empty type bound lists in where-clauseDavid Tolnay-1/+4
2022-06-16Do not suggest adding semicolon/changing delimiters for macros in item ↵Chayim Refael Friedman-21/+25
position that originates in macros
2022-06-13Improve parsing errors and suggestions for bad if statementsMichael Goulet-43/+82
2022-06-14Rollup merge of #95211 - terrarier2111:improve-parser, r=compiler-errorsYuki Okushi-9/+88
Improve parser diagnostics This pr fixes https://github.com/rust-lang/rust/issues/93867 and contains a couple of diagnostics related changes to the parser. Here is a short list with some of the changes: - don't suggest the same thing that is the current token - suggest removing the current token if the following token is one of the suggestions (maybe incorrect) - tell the user to put a type or lifetime after where if there is none (as a warning) - reduce the amount of tokens suggested (via the new eat_noexpect and check_noexpect methods) If any of these changes are undesirable, i can remove them, thanks!
2022-06-13remove unnecessary `to_string` and `String::new` for `tool_only_span_suggestion`Takayuki Maeda-1/+1
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-127/+96
2022-06-12Improves parser diagnostics, fixes #93867threadexception-9/+88
2022-06-12use `create_snapshot_for_diagnostic` instead of `clone`Takayuki Maeda-2/+2
2022-06-08Rollup merge of #97857 - ChayimFriedman2:box-identifier-help, r=compiler-errorsMichael Goulet-4/+57
Suggest escaping `box` as identifier Fixes #97810.
2022-06-08Suggest escaping `box` as identifierChayim Refael Friedman-4/+57
2022-06-08Rollup merge of #97823 - compiler-errors:missing-comma-match-arm, r=estebankDylan DPC-13/+38
Recover missing comma after match arm If we're missing a comma after a match arm expression, try parsing another pattern and a following `=>`. If we find both of those, then recover by suggesting to insert a `,`. Fixes #80112
2022-06-07recover `import` instead of `use` in itemMichael Goulet-20/+49
2022-06-07Recover missing comma after match armMichael Goulet-13/+38
2022-06-06Add spaces before and after expr in add {} suggestionWaffle Maybe-2/+2
Co-authored-by: Michael Goulet <michael@errs.io>
2022-06-05Suggest removing label in `'label: non_block_expr`Maybe Waffle-3/+14
2022-06-05Do not suggest adding labeled block if there are no labeled breaksMaybe Waffle-0/+23
2022-06-05Suggest adding `{}` for `'label: non_block_expr`Maybe Waffle-2/+28
2022-06-02Rollup merge of #97587 - pvdrz:maybe-recover-from-bad-qpath-stage-2, r=davidtwcoDylan DPC-44/+77
Migrate more diagnostics to use the `#[derive(SessionDiagnostic)]` r? ``@davidtwco``
2022-06-02Rollup merge of #97166 - nnethercote:move-conditions-out, r=estebankYuki Okushi-50/+41
Move conditions out of recover/report functions. `Parser` has six recover/report functions that are passed a boolean, and nothing is done if the boolean has a particular value. This PR moves the tests outside the functions. This has the following effects. - The number of lines of code goes down. - Some `use` items become shorter. - Avoids the strangeness whereby 11 out of 12 calls to `maybe_recover_from_bad_qpath` pass `true` as the second argument. - Makes it clear at the call site that only one of `maybe_recover_from_bad_type_plus` and `maybe_report_ambiguous_plus` will be run. r? `@estebank`
2022-06-01rename `sp` to `span`Christian Poveda-2/+2
2022-05-31migrate `check_for_for_in_in_typo` diagnosticChristian Poveda-8/+13
2022-05-31merge diagnostics about incorrect uses of `.await`Christian Poveda-3/+3
2022-05-31migrate `error_on_incorrect_await` diagnosticChristian Poveda-9/+22
2022-05-31use `suggestion_short` for incorrect semicolon diagnosticChristian Poveda-1/+1
2022-05-31migrate `recover_from_await_method_call` diagnosticChristian Poveda-8/+10
2022-05-31migrate `maybe_consume_incorrect_semicolon` diagnosticChristian Poveda-9/+18
2022-05-31migrate `maybe_recover_from_bad_qpath_stage_2` diagnosticChristian Poveda-9/+13
2022-05-31Auto merge of #97566 - compiler-errors:rollup-qfxw4j8, r=compiler-errorsbors-26/+15
Rollup of 6 pull requests Successful merges: - #89685 (refactor: VecDeques Iter fields to private) - #97172 (Optimize the diagnostic generation for `extern unsafe`) - #97395 (Miri call ABI check: ensure type size+align stay the same) - #97431 (don't do `Sized` and other return type checks on RPIT's real type) - #97555 (Source code page: line number click adds `NaN`) - #97558 (Fix typos in comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-05-30Rollup merge of #97172 - SparrowLii:unsafe_extern, r=compiler-errorsMichael Goulet-26/+15
Optimize the diagnostic generation for `extern unsafe` This PR does the following about diagnostic generation when parsing foreign mod: 1. Fixes the FIXME about avoiding depending on the error message text. 2. Continue parsing when `unsafe` is followed by `{` (just like `unsafe extern {...}`). 3. Add test case.
2022-05-30errors: simplify referring to fluent attributesDavid Wood-7/+4
To render the message of a Fluent attribute, the identifier of the Fluent message must be known. `DiagnosticMessage::FluentIdentifier` contains both the message's identifier and optionally the identifier of an attribute. Generated constants for each attribute would therefore need to be named uniquely (amongst all error messages) or be able to refer to only the attribute identifier which will be combined with a message identifier later. In this commit, the latter strategy is implemented as part of the `Diagnostic` type's functions for adding subdiagnostics of various kinds. Signed-off-by: David Wood <david.wood@huawei.com>