about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/diagnostics.rs
AgeCommit message (Collapse)AuthorLines
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-11/+11
2022-02-28Rollup merge of #94445 - c410-f3r:more-let-chains, r=cjgillotMatthias Krüger-39/+39
4 - Make more use of `let_chains` Continuation of #94376. cc #53667
2022-02-28Tweak diagnosticsEsteban Kuber-14/+39
* 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-284 - Make more use of `let_chains`Caio-39/+39
Continuation of #94376. cc #53667
2022-02-25Suggest {} around more bad const generic exprsMichael Goulet-16/+23
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-10/+22
2022-02-23rustc_errors: take `self` by value in `DiagnosticBuilder::cancel`.Eduard-Mihai Burtescu-21/+18
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-6/+6
2022-02-03compiler: clippy::complexity fixesMatthias Krüger-4/+4
useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-01-27Improve suggestion for escaping reserved keywordsNoah Lev-4/+4
2022-01-25delay the bug once again, generalize turbofish suggestionMichael Goulet-18/+12
2022-01-25Remove delayed bug when encountering label in bad turbofishMichael Goulet-1/+1
2022-01-17Rollup merge of #92876 - compiler-errors:fix-turbofish-lifetime-suggestion, ↵Matthias Krüger-16/+23
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-16Rollup merge of #92746 - estebank:question-mark-in-type, r=davidtwcoMatthias Krüger-1/+29
Parse `Ty?` as `Option<Ty>` and provide structured suggestion 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.
2022-01-13Fix suggesting turbofish with lifetime argumentsMichael Goulet-16/+23
2022-01-14Parse `Ty?` as `Option<Ty>` and provide structured suggestionEsteban Kuber-1/+29
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.
2022-01-09eplace usages of vec![].into_iter with [].into_iterLucas Kent-2/+2
2021-12-14fix clippy::single_char_pattern perf findingsMatthias Krüger-1/+1
2021-12-09Remove redundant [..]sest31-3/+3
2021-12-04Do not add `;` to expected tokens list when it's wrongMichael Howell-1/+2
There's a few spots where semicolons are checked for to do error recovery, and should not be suggested (or checked for other stuff). Fixes #87647
2021-11-29review comments: clean upEsteban Kuber-2/+180
2021-11-25Auto merge of #85346 - estebank:issue-84946, r=nagisa,varkorbors-6/+73
Account for incorrect `impl Foo<const N: ty> {}` syntax Fix #84946
2021-11-24Tweak span and add more testsEsteban Kuber-5/+2
2021-11-24Account for incorrect `impl Foo<const N: ty> {}` syntaxEsteban Küber-6/+76
Fix #84946
2021-11-22fix(doctest): detect extern crate items in statement doctestsMichael Howell-1/+1
This partially reverts #91026, because rustdoc needs to detect the extern statements, even when they appear inside implicit `main()`. It does not entirely revert it, so the old bug is still fixed, by duplicating some of the logic from `parse_mod` instead of trying to use it directly. Fixes #91134
2021-10-17Some "parenthesis" and "parentheses" fixesr00ster91-2/+2
2021-09-24Auto merge of #88835 - FabianWolff:issue-88770, r=petrochenkovbors-2/+2
Fix error recovery in format macro parsing Fixes #88770. Basically, the assumption in the following comment is incorrect: https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/compiler/rustc_builtin_macros/src/format.rs#L167-L172 This is only true in the first iteration of the loop, when [`p.clear_expected_tokens()`](https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/compiler/rustc_builtin_macros/src/format.rs#L164) is called. In subsequent iterations, `p.expected_tokens` won't be empty, so `p.expect()` won't actually call `unexpected_try_recover()`: https://github.com/rust-lang/rust/blob/b69fe57261086e70aea9d5b58819a1794bf7c121/compiler/rustc_parse/src/parser/mod.rs#L487-L498 Instead, it will call `expect_one_of()`, which _can_ recover and return `Ok()`. This PR handles this case to fix the ICE in #88770.
2021-09-17Rollup merge of #87566 - JohnTitor:find-eqeq-on-assoc-type-bounds, r=estebankGuillaume Gomez-1/+13
Recover invalid assoc type bounds using `==` Fix #87493 r? `@estebank`
2021-09-17Apply review commentsYuki Okushi-2/+2
2021-09-17Recover invalid assoc type bounds using `==`Yuki Okushi-1/+13
2021-09-17Use `multipart_suggestion`Yuki Okushi-19/+13
2021-09-17Emit clearer diagnostics for parens around `for` loop headsYuki Okushi-2/+3
2021-09-13Auto merge of #87915 - estebank:fancy-spans, r=oli-obkbors-39/+46
Use smaller spans for some structured suggestions Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts
2021-09-10Fix error recovery in format macro parsingFabian Wolff-2/+2
2021-09-04Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiserbors-3/+8
Detect bare blocks with type ascription that were meant to be a `struct` literal Address part of #34255. Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.
2021-09-03Detect bare blocks with type ascription that were meant to be a `struct` literalEsteban Kuber-3/+8
Address part of #34255. Potential improvement: silence the other knock down errors in `issue-34255-1.rs`.
2021-08-27Point at unclosed delimiters as part of the primary MultiSpanEsteban Kuber-1/+11
Both the place where the parser encounters a needed closed delimiter and the unclosed opening delimiter are important, so they should get the same level of highlighting in the output.
2021-08-12Use smaller spans for some structured suggestionsEsteban Kuber-39/+46
Use more accurate suggestion spans for * argument parse error * fully qualified path * missing code block type * numeric casts * E0212
2021-07-30Use multispan suggestions more oftenEsteban Küber-1/+1
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-24fix code to suggest `;` on parse errorElliot Bobrow-57/+57
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-1/+1
position.
2021-05-08Rename `Parser::span_fatal_err` -> `Parser::span_err`Joshua Nelson-5/+1
The name was misleading, it wasn't actually a fatal error.
2021-04-12don't bump in check_mistyped_turbofish_with_multiple_type_paramsb-naber-15/+17
2021-03-17Emit more pretty diagnostics for qualified pathsYuki Okushi-14/+21
2021-03-17Fix bad diagnostics for anon params with qualified pathsYuki Okushi-10/+20
2021-03-17Fix bad diagnostics for anon params with refYuki Okushi-31/+54
2021-02-27Fix turbofish recovery with multiple generic argsÖmer Sinan Ağacan-1/+1
check_mistyped_turbofish_with_multiple_type_params was previously expecting type arguments between angle brackets, which is not right, as we can also see const expressions. We now use generic argument parser instead of type parser. Test with one, two, and three generic arguments added to check consistentcy between 1. check_no_chained_comparison: Called after parsing a nested binop application like `x < A > ...` where angle brackets are interpreted as binary operators and `A` is an expression. 2. check_mistyped_turbofish_with_multiple_type_params: called by `parse_full_stmt` when we expect to see a semicolon after parsing an expression but don't see it. (In `T2<1, 2>::C;`, the expression is `T2 < 1`)
2021-02-25fix reviewklensy-1/+1
2021-02-24replaced some map_or with map_or_elseklensy-1/+1
2021-02-15Simplify pattern grammar by allowing nested leading vertmark-1/+1
Along the way, we also implement a handful of diagnostics improvements and fixes, particularly with respect to the special handling of `||` in place of `|` and when there are leading verts in function params, which don't allow top-level or-patterns anyway.