about summary refs log tree commit diff
path: root/compiler/rustc_parse
AgeCommit message (Collapse)AuthorLines
2022-04-06Stop flagging certain inner attrs as outer onesLeón Orell Valerian Liehr-11/+15
2022-04-05errors: implement fallback diagnostic translationDavid Wood-17/+25
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-5/+5
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: introduce `DiagnosticMessage`David Wood-1/+2
Introduce a `DiagnosticMessage` type that will enable diagnostic messages to be simple strings or Fluent identifiers. `DiagnosticMessage` is now used in the implementation of the standard `DiagnosticBuilder` APIs. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-03Auto merge of #88672 - camelid:inc-parser-sugg, r=davidtwcobors-1/+237
Suggest `i += 1` when we see `i++` or `++i` Closes #83502 (for `i++` and `++i`; `--i` should be covered by #82987, and `i--` is tricky to handle). This is a continuation of #83536. r? `@estebank`
2022-04-02Auto merge of #95590 - GuillaumeGomez:multi-line-attr-handling-doctest, ↵bors-0/+4
r=notriddle Fix multiline attributes handling in doctests Fixes #55713. I needed to have access to the `unclosed_delims` field in order to check that the attribute was completely parsed and didn't have missing parts, so I created a getter for it. r? `@notriddle`
2022-04-02Fix doctest multi-line mod attributes handlingGuillaume Gomez-0/+4
2022-04-01Rollup merge of #95293 - compiler-errors:braces, r=davidtwcoMatthias Krüger-11/+7
suggest wrapping single-expr blocks in square brackets Suggests a fix in cases like: ```diff - const A: [i32; 1] = { 1 }; + const A: [i32; 1] = [ 1 ]; ^ ^ ``` Also edit the message for the same suggestion in the parser (e.g. `{ 1, 2 }`). Fixes #95289
2022-03-31Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errorsDylan DPC-3/+3
Spellchecking compiler comments This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-31Rollup merge of #95251 - GrishaVar:hashes-u16-to-u8, r=dtolnayDylan DPC-3/+1
Reduce max hash in raw strings from u16 to u8 [Relevant discussion](https://rust-lang.zulipchat.com/#narrow/stream/237824-t-lang.2Fdoc/topic/Max.20raw.20string.20delimiters)
2022-03-30Addressed comments by @compiler-errors and @bjorn3Yuri Astrakhan-1/+1
2022-03-30Spellchecking compiler commentsYuri Astrakhan-3/+3
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30Update error message & remove outdated test commentGrisha Vartanyan-3/+1
2022-03-30Rollup merge of #95461 - nyurik:spelling, r=lcnrDylan DPC-5/+5
Spellchecking some comments This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30Spellchecking some commentsYuri Astrakhan-5/+5
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-28Rollup merge of #95318 - rust-lang:notriddle/issue-95208, r=wesleywiserDylan DPC-0/+29
diagnostics: correct generic bounds with doubled colon Fixes #95208
2022-03-28Rollup merge of #95301 - nnethercote:rm-NtTT, r=petrochenkovDylan DPC-14/+24
Remove `Nonterminal::NtTT`. It's only needed for macro expansion, not as a general element in the AST. This commit removes it, adds `NtOrTt` for the parser and macro expansion cases, and renames the variants in `NamedMatch` to better match the new type. r? `@petrochenkov`
2022-03-27Make fatal DiagnosticBuilder yield neverMichael Goulet-12/+20
2022-03-28Remove `Nonterminal::NtTT`.Nicholas Nethercote-14/+24
It's only needed for macro expansion, not as a general element in the AST. This commit removes it, adds `NtOrTt` for the parser and macro expansion cases, and renames the variants in `NamedMatch` to better match the new type.
2022-03-27Fix from rebaseNoah Lev-5/+5
I changed the test functions to be `pub` rather than called from a `main` function too, for easier future modification of tests.
2022-03-27Auto merge of #94495 - estebank:missing-closing-gt, r=jackh726bors-1/+34
Provide suggestion for missing `>` in a type parameter list When encountering an inproperly terminated type parameter list, provide a suggestion to close it after the last non-constraint type parameter that was successfully parsed. Fix #94058.
2022-03-27Handle `,` to `;` substitution in arg paramsEsteban Kuber-0/+17
2022-03-27Provide suggestion for missing `>` in a type parameter listEsteban Kuber-1/+17
When encountering an inproperly terminated type parameter list, provide a suggestion to close it after the last non-constraint type parameter that was successfully parsed. Fix #94058.
2022-03-26Stablize `const_extern_fn` for "Rust" and "C"Aaron Hill-0/+3
All other ABIs are left unstable for now. cc #64926
2022-03-26Auto merge of #95149 - cjgillot:once-diag, r=estebankbors-4/+4
Remove `Session::one_time_diagnostic` This is untracked mutable state, which modified the behaviour of queries. It was used for 2 things: some full-blown errors, but mostly for lint declaration notes ("the lint level is defined here" notes). It is replaced by the diagnostic deduplication infra which already exists in the diagnostic emitter. A new diagnostic level `OnceNote` is introduced specifically for lint notes, to deduplicate subdiagnostics. As a drive-by, diagnostic emission takes a `&mut` to allow dropping the `SubDiagnostic`s.
2022-03-25diagnostics: correct generic bounds with doubled colonMichael Howell-0/+29
Fixes #95208
2022-03-24suggest wrapping single-expr blocks in square bracketsMichael Goulet-11/+7
2022-03-23Fix rustfix panic on testNoah Lev-1/+1
`run-rustfix` applies all suggestions regardless of their Applicability. There's a flag, `rustfix-only-machine-applicable`, that does what it says, but then the produced `.fixed` file would have invalid code from the suggestions that weren't applied. So, I moved the cases of postfix increment, in which case multiple suggestions are given, to the `-notfixed` test, which does not run rustfix. I also changed the Applicability to Unspecified since MaybeIncorrect requires that the code be valid, even if it's incorrect.
2022-03-23Use `multipart_suggestions`Noah Lev-48/+54
This records that the suggestions are mutually-exclusive (i.e., only one should be applied).
2022-03-23Change temporary variable name if it would conflictNoah Lev-7/+4
2022-03-23Make `standalone` an enumNoah Lev-13/+25
2022-03-23Add heuristic to avoid treating `x + +2` as incrementNoah Lev-0/+1
2022-03-23Improve function namesNoah Lev-4/+4
2022-03-23Improve handling of `tmp` variable name conflictsNoah Lev-2/+6
2022-03-23Emit both subexp and standalone sugg for postfixNoah Lev-31/+55
This solves the TODO.
2022-03-23Emit structured suggestions for field accesses tooNoah Lev-22/+11
2022-03-23Refactor, handle fields better, add field testsNoah Lev-18/+18
2022-03-23Reduce rightward driftNoah Lev-31/+30
2022-03-23Remove error recovery todosNoah Lev-15/+9
2022-03-23Move increment checks to improve errorsNoah Lev-43/+210
2022-03-23Suggest `i += 1` when we see `i++` or `++i`Camelid-0/+43
2022-03-23Rollup merge of #95212 - ↵Dylan DPC-2/+2
TaKO8Ki:replace-this-clone-with-this-create-snapshot-for-diagnostic, r=Dylan-DPC Replace `this.clone()` with `this.create_snapshot_for_diagnostic()` Use [`create_snapshot_for_diagnostic`](https://github.com/rust-lang/rust/blob/cd119057160cedea245aa2679add56723f3dc784/compiler/rustc_parse/src/parser/diagnostics.rs#L214-L223) I implemented in https://github.com/rust-lang/rust/pull/94731 instead of `this.clone()` to avoid duplicate errors about unclosed delims being emitted when the `Parser` is dropped.
2022-03-22Auto merge of #95215 - Dylan-DPC:rollup-l9f9t7l, r=Dylan-DPCbors-4/+8
Rollup of 5 pull requests Successful merges: - #95188 ([`macro-metavar-expr`] Fix generated tokens hygiene) - #95196 (rename LocalState::Uninitialized to Unallocated) - #95197 (Suggest constraining param for unary ops when missing trait impl) - #95200 (Cancel a not emitted error after parsing const generic args) - #95207 (update Termination trait docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-23replace `this.clone()` with `this.create_snapshot_for_diagnostic()`Takayuki Maeda-2/+2
2022-03-22Auto merge of #94693 - nnethercote:parser-inlining, r=petrochenkovbors-12/+33
Inline some parser functions Some crates that do a lot of complex declarative macro expansion spend a lot of time parsing (and reparsing) tokens. These commits inline some functions for some minor speed wins. r? `@ghost`
2022-03-22cancel a not emitted error after parsing const generic argsTakayuki Maeda-4/+8
2022-03-22Split `TokenCursor::{next,next_desugared}` into inlined and non-inlined halves.Nicholas Nethercote-10/+24
2022-03-22Split `Parser::bump_with` into inlined and non-inlined halves.Nicholas Nethercote-2/+9
The call site within `Parser::bump` is hot. Also add an inline annotation to `Parser::next_tok`. It was already being inlined by the compiler; this just makes sure that continues.
2022-03-21Auto merge of #95104 - compiler-errors:remove-ascription, r=davidtwcobors-6/+35
suggest removing type ascription in bad parsing position Not sure how to test this with the non-nightly suggestion. Didn't add a new UI test because it already manifests in an existing UI test. Fixes #95014
2022-03-20Rollup merge of #95135 - ↵Matthias Krüger-1/+1
TaKO8Ki:fix-not-emitted-unmatched-angle-bracket-error, r=Dylan-DPC Fix a not emitted unmatched angle bracket error closes #95128