summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/diagnostics.rs
AgeCommit message (Collapse)AuthorLines
2023-03-01Auto merge of #108587 - matthiaskrgr:rollup-rw6po59, r=matthiaskrgrbors-2/+14
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/+14
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-3/+3
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-0/+1
2023-02-28refactor parse_token_trees to not return unmatched_delimsyukang-2/+2
2023-02-28rename unmatched_braces to unmatched_delimsyukang-4/+4
2023-02-27handle only postfix decrementnx2k3-10/+0
2023-02-26fix some commentsnx2k3-4/+2
2023-02-26fix #108495, postfix decrement and prefix decrement has no warningnx2k3-3/+26
2023-02-24Replace parse_[sth]_expr with parse_expr_[sth] function namesest31-2/+2
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-22errors: generate typed identifiers in each crateDavid Wood-3/+3
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 `ast::AngleBracketedArgs`.Nicholas Nethercote-1/+1
2023-02-21Use `ThinVec` in `ast::Block`.Nicholas Nethercote-1/+1
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-1/+1
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2023-02-14Rollup merge of #103478 - SpanishPear:spanishpear/issue_103366_fix, r=TaKO8KiMatthias Krüger-2/+56
Suggest fix for misplaced generic params on fn item #103366 fixes #103366 This still has some work to go, but works for 2/3 of the initial base cases described in #1033366 simple fn: ``` error: expected identifier, found `<` --> shreys/test_1.rs:1:3 | 1 | fn<T> id(x: T) -> T { x } | ^ expected identifier | help: help: place the generic parameter list after the function name: | 1 | fn id<T>(x: T) -> T { x } | ~~~~ ``` Complicated bounds ``` error: expected identifier, found `<` --> spanishpear/test_2.rs:1:3 | 1 | fn<'a, B: 'a + std::ops::Add<Output = u32>> f(_x: B) { } | ^ expected identifier | help: help: place the generic parameter list after the function name: | 1 | fn f<'a, B: 'a + std::ops::Add<Output = u32>>(_x: B) { } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Opening a draft PR for comments on approach, particularly I have the following questions: - [x] Is it okay to be using `err.span_suggestion` over struct derives? I struggled to get the initial implementation (particularly the correct suggestion message) on struct derives, although I think given what I've learned since starting, I could attempt re-doing it with that approach. - [x] in the case where the snippet cannot be obtained from a span, is the `help` but no suggestion okay? I think yes (also, when does this case occur?) - [x] are there any red flags for the generalisation of this work for relevant item kinds (i.e. `struct`, `enum`, `trait`, and `union`). My basic testing indicates it does work for those types except the help tip is currently hardcoded to `after the function name` - which should change dependent on the item. - [x] I am planning to not show the suggestion if there is already a `<` after the item identifier, (i.e. if there are already generics, as after a function name per the original issue). Any major objections? - [x] Is the style of error okay? I wasn't sure if there was a way to make it display nicer, or if thats handled by span_suggestion These aren't blocking questions, and I will keep working on: - check if there is a `<` after the ident (and if so, not showing the suggestion) - generalize the help message - figuring out how to write/run/etc ui tests (including reading the docs for them) - logic cleanups
2023-02-02Parse and recover from type ascription in patternsEsteban Küber-12/+39
2023-02-02Revert "Teach parser to understand fake anonymous enum syntax" and related ↵Michael Goulet-39/+13
commits Revert "review comment: Remove AST AnonTy" This reverts commit 020cca8d36cb678e3ddc2ead41364be314d19e93. Revert "Ensure macros are not affected" This reverts commit 12d18e403139eeeeb339e8611b2bed4910864edb. Revert "Emit fewer errors on patterns with possible type ascription" This reverts commit c847a01a3b1f620c4fdb98c75805033e768975d1. Revert "Teach parser to understand fake anonymous enum syntax" This reverts commit 2d824206655bfb26cb5eed43490ee396542b153e.
2023-02-01Convert rustc_parse::parser::pat::Expected to enumXiretza-2/+2
This is required in order to support translatable diagnostics.
2023-02-01fix formatting + test syntaxSpanishPear-1/+1
2023-01-31move to multipart spansSpanishPear-5/+6
2023-01-28Rollup merge of #107190 - fmease:fix-81698, r=compiler-errorsMatthias Krüger-0/+22
Recover from more const arguments that are not wrapped in curly braces Recover from some array, borrow, tuple & arithmetic expressions in const argument positions that lack curly braces and provide a suggestion to fix the issue continuing where #92884 left off. Examples of such expressions: `[]`, `[0]`, `[1, 2]`, `[0; 0xff]`, `&9`, `("", 0)` and `(1 + 2) * 3` (we previously did not recover from them). I am not entirely happy with my current solution because the code that recovers from `[0]` (coinciding with a malformed slice type) and `[0; 0]` (coinciding with a malformed array type) is quite fragile as the aforementioned snippets are actually successfully parsed as types by `parse_ty` since it itself already recovers from them (returning `[⟨error⟩]` and `[⟨error⟩; 0]` respectively) meaning I have to manually look for `TyKind::Err`s and construct a separate diagnostic for the suggestion to attach to (thereby emitting two diagnostics in total). Fixes #81698. `@rustbot` label A-diagnostics r? diagnostics
2023-01-27recover more unbraced const argsLeón Orell Valerian Liehr-0/+22
2023-01-22revert to previous spanSpanishPear-3/+4
2023-01-22Attempt to address review comments via github web...Shrey Sudhir-3/+2
2023-01-22Apply automatic suggestions from code reviewShrey Sudhir-3/+3
Co-authored-by: Takayuki Maeda <takoyaki0316@gmail.com>
2023-01-22--wip-- [skip ci]SpanishPear-2/+55
--wip-- [skip ci] get the generic text and put it int he suggestion, but suggestion not working on derive subdiagnostic refactor away from derives and use span_suggestion() instead. Show's the correct(?) generic contents, but overwrites the fn name :( x fmt drop commented code and s/todo/fixme get the correct diagnostic for functions, at least x fmt remove some debugs remove format remove debugs remove useless change remove useless change remove legacy approach correct lookahead + error message contains the ident name fmt refactor code tests add tests remoev debug remove comment
2023-01-17Emit fewer errors on patterns with possible type ascriptionEsteban Küber-0/+2
2023-01-17Teach parser to understand fake anonymous enum syntaxEsteban Küber-13/+37
Parse `-> Ty | OtherTy`. Parse type ascription in top level patterns.
2023-01-11Detect struct literal needing parenthesesEsteban Küber-11/+26
Fix #82051.
2023-01-08Do not emit structured suggestion for turbofish with wrong spanEsteban Küber-2/+10
Fix #79161.
2022-12-29Rollup merge of #106242 - estebank:diff-markers, r=jyn514Matthias Krüger-1/+71
Detect diff markers in the parser Partly address #32059.
2022-12-28Add support for diff3 formatEsteban Küber-0/+7
2022-12-28Tweak wordingEsteban Küber-4/+15
2022-12-28Detect diff markers in the parserEsteban Küber-1/+53
Partly address #32059.
2022-12-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-1/+1
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-26remove unused importsTakayuki Maeda-1/+0
2022-12-14Auto merge of #104875 - chenyukang:yukang/fix-104867-inc, r=estebankbors-35/+15
Properly handle postfix inc/dec in standalone and subexpr scenarios Fixes #104867 r? `@estebank`
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-3/+3
2022-11-26will not suggest for postfix operator when can not handle precedences wellyukang-1/+5
2022-11-26add start_stmt to handle postfix incrementyukang-14/+15
2022-11-25fix #104867, Properly handle postfix inc/dec in standalone and subexpr scenariosyukang-41/+16
2022-11-24Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiserbors-1/+1
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-22`rustc_parse`: remove `ref` patternsMaybe Waffle-5/+5
2022-11-21Match crate and slug namesmejrs-1/+1
2022-11-19Rollup merge of #104566 - matthiaskrgr:clippy_perf_nov18, r=oli-obkDylan DPC-2/+2
couple of clippy::perf fixes
2022-11-18couple of clippy::perf fixesMatthias Krüger-2/+2
2022-11-17Use `ThinVec` in `ast::Path`.Nicholas Nethercote-8/+11
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-5/+5
patterns.
2022-11-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-1/+1
2022-11-11Rollup merge of #103468 - chenyukang:yukang/fix-103435-extra-parentheses, ↵Manish Goregaokar-5/+19
r=estebank Fix unused lint and parser caring about spaces to won't produce invalid code Fixes #103435