about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
AgeCommit message (Collapse)AuthorLines
2022-04-27Avoid producing `NoDelim` values in `MacArgs::delim()`.Nicholas Nethercote-16/+20
2022-04-27Avoid producing `NoDelim` values in `TokenCursorFrame`.Nicholas Nethercote-22/+15
2022-04-26move `AmbigousPlus` outsideChristian Poveda-9/+10
2022-04-26avoid `format!`Christian Poveda-2/+2
2022-04-25remove old codeChristian Poveda-9/+0
2022-04-25migrate ambiguous plus diagnosticChristian Poveda-9/+23
2022-04-23Better handle too many `#` recovery in raw strEsteban Küber-9/+34
Point at all the unnecessary trailing `#`. Better handle interaction with outer attributes when `;` is missing. Fix #95030.
2022-04-21Introduced `Cursor::next_with_spacing_ref`.Nicholas Nethercote-5/+5
This lets us clone just the parts within a `TokenTree` that need cloning, rather than the entire thing. This is a surprisingly large performance win, up to 4% on `async-std-1.10.0`.
2022-04-21Produce `CloseDelim` and pop the stack at the same time.Nicholas Nethercote-27/+34
This makes `CloseDelim` handling more like `OpenDelim` handling, which produces `OpenDelim` and pushes the stack at the same time. It requires some adjustment to `parse_token_tree` now that we don't remain within the frame after getting the `CloseDelim`.
2022-04-21Avoid some tuple destructuring.Nicholas Nethercote-5/+7
Surprisingly, this is a non-trivial performance win.
2022-04-20Remove `Eof` sanity check in `Parser::inlined_bump_with`.Nicholas Nethercote-6/+0
A Google search of the error message fails to return any relevant resuts, suggesting this has never occurred in practice. And removeing it reduces instruction counts by up to 2% on some benchmarks.
2022-04-20Inline `Parser::nonterminal_may_begin_with`.Nicholas Nethercote-2/+4
2022-04-20Inline `Parser::parse_nonterminal`.Nicholas Nethercote-1/+3
2022-04-20Only record `fallback_span` when necessary.Nicholas Nethercote-1/+1
2022-04-20Remove the loop from `Parser::bump()`.Nicholas Nethercote-29/+34
The loop is there to handle a `NoDelim` open/close token. This commit changes `TokenCursor::inlined_next` so it never returns such a token. This is a performance win because the conditional test in `bump()` is removed. If the parser needs changing in the future to handle `NoDelim` tokens, then `inlined_next()` can easily be changed to return them.
2022-04-20Remove `TokenCursorFrame::open_delim`.Nicholas Nethercote-20/+5
Because it's now always true.
2022-04-20Use `true` for `open_delim`/`close_delim` in one spot.Nicholas Nethercote-2/+2
The `DelimToken` here is `NoDelim`, which means the returned delim tokens will just be ignored by `Parser::bump()`. This commit changes things so the delim tokens won't be returned.
2022-04-20Add a size assertion for `Parser`.Nicholas Nethercote-0/+5
2022-04-20Move desugaring code into its own function.Nicholas Nethercote-67/+60
It's not hot, so shouldn't be within the always inlined part.
2022-04-19Handle `Delimited` opening immediately.Nicholas Nethercote-1/+3
Instead of letting the next iteration of the loop handle it.
2022-04-19Add {open,close}_delim arguments to `TokenCursorFrame::new()`.Nicholas Nethercote-12/+13
This will facilitate the change in the next commit. `boolean` arguments aren't great, but the function is only used in three places within this one file.
2022-04-19Rearrange `TokenCursor::inlined_next()`.Nicholas Nethercote-17/+20
In particular, avoid wrapping a token within `TokenTree::Token` and then immediately matching it and returning the token within. Just return the token immediately.
2022-04-19Merge `TokenCursor::{next,next_desugared}`.Nicholas Nethercote-85/+71
And likewise for the inlined variants. I did this for simplicity, but interesting it was a performance win as well.
2022-04-19Inline and remove `Parser::next_tok()`.Nicholas Nethercote-32/+26
It has a single call site.
2022-04-19Inline and remove `TokenTree::{open_tt,close_tt}`.Nicholas Nethercote-2/+2
They both have a single call site.
2022-04-17Rollup merge of #95346 - Aaron1011:stablize-const-extern-fn, r=pnkfelixDylan DPC-0/+3
Stablize `const_extern_fn` for "Rust" and "C" All other ABIs are left unstable for now. cc #64926
2022-04-16Rollup merge of #94985 - dtolnay:constattr, r=pnkfelixDylan DPC-2/+2
Parse inner attributes on inline const block According to https://github.com/rust-lang/rust/pull/84414#issuecomment-826150936, inner attributes are intended to be supported *"in all containers for statements (or some subset of statements)"*. This PR adds inner attribute parsing and pretty-printing for inline const blocks (https://github.com/rust-lang/rust/issues/76001), which contain statements just like an unsafe block or a loop body. ```rust let _ = const { #![allow(...)] let x = (); x }; ```
2022-04-16Rollup merge of #95859 - rainy-me:unterminated-nested-block-comment, ↵Dylan DPC-10/+50
r=petrochenkov Improve diagnostics for unterminated nested block comment close #95283 (This is my first time try to messing around with rust compiler and might get a lot of things wrong... :bow: )
2022-04-14refactor: change to use peekablerainy-me-20/+17
2022-04-13couple of clippy::complexity fixesMatthias Krüger-3/+3
2022-04-14improve diagnostics for unterminated nested block commentrainy-me-10/+53
2022-04-12use `to_string` instead of `format!`Takayuki Maeda-1/+1
2022-04-10better error for binder on associated type boundMichael Goulet-12/+36
2022-04-07Auto merge of #95715 - nnethercote:shrink-Nonterminal, r=davidtwcobors-8/+8
Shrink `Nonterminal` Small consistency and performance improvements. r? `@petrochenkov`
2022-04-07Shrink `Nonterminal`.Nicholas Nethercote-8/+8
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`. This slightly reduces cumulative and peak allocation amounts, most notably on `deep-vector`.
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