about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
AgeCommit message (Collapse)AuthorLines
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`
2022-05-05Overhaul `MacArgs::Eq`.Nicholas Nethercote-17/+35
The value in `MacArgs::Eq` is currently represented as a `Token`. Because of `TokenKind::Interpolated`, `Token` can be either a token or an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a literal or macro call AST fragment, and then is later lowered to a literal token. But this is very non-obvious. `Token` is a much more general type than what is needed. This commit restricts things, by introducing a new type `MacArgsEqKind` that is either an AST expression (pre-lowering) or an AST literal (post-lowering). The downside is that the code is a bit more verbose in a few places. The benefit is that makes it much clearer what the possibilities are (though also shorter in some other places). Also, it removes one use of `TokenKind::Interpolated`, taking us a step closer to removing that variant, which will let us make `Token` impl `Copy` and remove many "handle Interpolated" code paths in the parser. Things to note: - Error messages have improved. Messages like this: ``` unexpected token: `"bug" + "found"` ``` now say "unexpected expression", which makes more sense. Although arbitrary expressions can exist within tokens thanks to `TokenKind::Interpolated`, that's not obvious to anyone who doesn't know compiler internals. - In `parse_mac_args_common`, we no longer need to collect tokens for the value expression.
2022-05-02fix most compiler/ doctestsElliot Roberts-19/+20
2022-05-02Fix invalid keyword order for function declarationsKen Matsui-2/+2
2022-04-30Add `do yeet` expressions to allow experimentation in nightlyScott McMurray-0/+21
Using an obviously-placeholder syntax. An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point. But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-30Save colon span to suggest bounds.Camille GILLOT-4/+9
2022-04-29Remove hacks in `make_token_stream`.Nicholas Nethercote-38/+0
`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.
2022-04-29errors: `span_suggestion` takes `impl ToString`David Wood-13/+13
Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-28Rollup merge of #96433 - petrochenkov:delim, r=nnethercoteDylan DPC-240/+245
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter` Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming. After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`. It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is. cc https://github.com/rust-lang/rust/pull/96421 r? ``@nnethercote``
2022-04-28Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwcoDylan DPC-9/+12
Migrate ambiguous plus diagnostic to the new derive macro r? ````@davidtwco```` ````@jyn514````
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-240/+245
2022-04-28Rollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnrDylan DPC-3/+1
replace let else with `?` r? `@oli-obk`
2022-04-28Rollup merge of #96421 - nnethercote:less-NoDelim, r=petrochenkovDylan DPC-50/+50
Less `NoDelim` Currently there are several places where `NoDelim` (which really means "implicit delimiter" or "invisible delimiter") is used to mean "no delimiter". The name `NoDelim` is a bit misleading, and may be a cause. This PR changes these places, e.g. by changing a `DelimToken` to `Option<DelimToken>` and then using `None` to mean "no delimiter". As a result, the *only* place where `NoDelim` values are now produced is within: - `Delimiter::to_internal()`, when converting from `Delimiter::None`. - `FlattenNonterminals::process_token()`, when converting `TokenKind::Interpolated`. r? ````@petrochenkov````
2022-04-27rename `sum_with_parens`Christian Poveda-6/+3
2022-04-27tut tut tutEllen-3/+1
2022-04-27Avoid producing `NoDelim` values in `FrameData`.Nicholas Nethercote-12/+15