about summary refs log tree commit diff
path: root/compiler/rustc_parse
AgeCommit message (Collapse)AuthorLines
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>
2022-05-30Optimize the diagnostic generation for `extern unsafe`SparrowLii-26/+15
2022-05-24Minor improvement on else-no-if diagnosticMichael Goulet-8/+1
2022-05-24Rollup merge of #97298 - compiler-errors:if-else-stmt-braces, r=davidtwcoDylan DPC-5/+57
Parse expression after `else` as a condition if followed by `{` Fixes #49361. Two things: 1. This wording needs help. I can never find a natural/intuitive phrasing when I write diagnostics :sweat_smile: 2. Do we even want to show the "wrap in braces" case? I would assume most of the time the "add an `if`" case is the right one.
2022-05-24Auto merge of #97121 - pvdrz:do-subdiagnostics-later, r=davidtwcobors-9/+7
Avoid double binding of subdiagnostics inside `#[derive(SessionDiagnostic)]` r? `@davidtwco`
2022-05-23Parse expression after `else` as a condition if followed by `{`Michael Goulet-5/+57
2022-05-23Rollup merge of #97254 - jhpratt:remove-crate-vis, r=cjgillotDylan DPC-37/+8
Remove feature: `crate` visibility modifier FCP completed in #53120.
2022-05-22rustc_parse: Move AST -> TokenStream conversion logic to `rustc_ast`Vadim Petrochenkov-111/+6
2022-05-21Merge crate and restricted visibilitiesJacob Pratt-18/+6
2022-05-21Remove feature: `crate` visibility modifierJacob Pratt-22/+5
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-17/+16
2022-05-20Introduce BareFnTy::decl_span and fix generics span.Camille GILLOT-1/+3
2022-05-19Move condition out of `maybe_recover_unexpected_comma`.Nicholas Nethercote-6/+9
2022-05-19Move condition out of `maybe_recover_colon_colon_in_pat_typo`.Nicholas Nethercote-6/+7
2022-05-19Move condition out of `maybe_report_ambiguous_plus` and ↵Nicholas Nethercote-16/+9
`maybe_recover_from_bad_type_plus`.
2022-05-19Move condition out of `maybe_recover_from_question_mark`.Nicholas Nethercote-11/+6
2022-05-19Move condition out of `maybe_recover_from_bad_qpath`.Nicholas Nethercote-14/+13
2022-05-17generate code for `subdiagnostic` fields in the second `match`Christian Poveda-9/+7
2022-05-16keep bounds where they wereChristian Poveda-2/+1
2022-05-16migrate `maybe_recover_from_bad_type_plus` diagnosticChristian Poveda-25/+48
2022-05-11ast: Introduce some traits to get AST node properties genericallyVadim Petrochenkov-15/+33
And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
2022-05-11Rollup merge of #96543 - nnethercote:rm-make_token_stream-hacks, r=Aaron1011Yuki Okushi-40/+1
Remove hacks in `make_token_stream`. `make_tokenstream` has three commented hacks, and a comment at the top referring to #67062. These hacks have no observable effect, at least as judged by running the test suite. The hacks were added in #82608, with an explanation [here](https://github.com/rust-lang/rust/pull/82608#issuecomment-812877329). It appears that one of the following is true: (a) they never did anything useful, (b) they do something useful but we have no test coverage for them, or (c) something has changed in the meantime that means they are no longer necessary. This commit removes the hacks and the comments, in the hope that (b) is not true. r? `@Aaron1011`
2022-05-11Remove some unnecessary invisible delimiter checks.Nicholas Nethercote-2/+1
These seem to have no useful effect... they don't seem useful from a code inspection point of view, and they affect anything in the test suite.
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-19/+20
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-04Auto merge of #96546 - nnethercote:overhaul-MacArgs, r=petrochenkovbors-17/+35
Overhaul `MacArgs` Motivation: - Clarify some code that I found hard to understand. - Eliminate one use of three places where `TokenKind::Interpolated` values are created. r? `@petrochenkov`