about summary refs log tree commit diff
path: root/compiler/rustc_parse
AgeCommit message (Collapse)AuthorLines
2022-09-30Rollup merge of #102350 - TaKO8Ki:incomplete-fn-in-struct-definition, ↵Matthias Krüger-11/+17
r=fee1-dead Improve errors for incomplete functions in struct definitions Given the following code: ```rust fn main() {} struct Foo { fn } ``` [playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=29139f870511f6918324be5ddc26c345) The current output is: ``` Compiling playground v0.0.1 (/playground) error: functions are not allowed in struct definitions --> src/main.rs:4:5 | 4 | fn | ^^ | = help: unlike in C++, Java, and C#, functions are declared in `impl` blocks = help: see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information error: could not compile `playground` due to previous error ``` In this case, rustc should suggest escaping `fn` to use it as an identifier.
2022-09-30Remove expr_parentheses_needed from ParseSessMichael Goulet-3/+5
2022-09-29Remove from compiler/ cratesreez12g-1/+0
2022-09-29improve E0585 helpRageking8-2/+2
2022-09-28Auto merge of #101619 - Xiretza:rustc_parse-session-diagnostics, r=davidtwcobors-1253/+1749
Migrate more of rustc_parse to SessionDiagnostic Still far from complete, but I thought I'd add a checkpoint here because rebasing was starting to get annoying.
2022-09-28Auto merge of #102302 - nnethercote:more-lexer-improvements, r=matkladbors-398/+386
More lexer improvements A follow-up to #99884. r? `@matklad`
2022-09-28Address review comments.Nicholas Nethercote-8/+8
2022-09-27Rollup merge of #102284 - compiler-errors:missing-type-in-raw-ptr, r=davidtwcoMatthias Krüger-4/+7
Structured suggestion for missing `mut`/`const` in raw pointer Fixes #102261
2022-09-27Implement IntoDiagnosticArg for rustc_ast::token::Token(Kind)Xiretza-56/+51
2022-09-27Don't unnecessarily stringify paths in diagnosticsXiretza-12/+13
2022-09-27Document use of Symbol::to_string()Xiretza-0/+2
2022-09-27Migrate even more diagnostics in rustc_parse to diagnostic structsXiretza-213/+342
2022-09-27Migrate "struct literal body without path" error to diagnostic structXiretza-16/+29
2022-09-27Migrate "expected semicolon" diagnostics to diagnostic structsXiretza-16/+72
2022-09-27Migrate "expected identifier" diagnostics to diagnostic structsXiretza-43/+154
2022-09-27Rework "inner attribute not permitted" errorsXiretza-58/+58
2022-09-27Remove error condition in parse_attributeXiretza-25/+12
This function is only ever called when the `#` has already been consumed, no need to produce an error message here.
2022-09-27Migrate more rustc_parse diagnostics to diagnostic structsXiretza-155/+156
2022-09-27Move rustc_parse diagnostic structs to separate moduleXiretza-811/+819
2022-09-27Migrate "invalid literal suffix" diagnostic to diagnostic structsXiretza-47/+56
2022-09-27Migrate more diagnostics in rustc_parse to diagnostic structsXiretza-218/+402
2022-09-28improve errors for incomplete functions in struct definitionsTakayuki Maeda-11/+17
2022-09-27Structured suggestion for missing mut/const in pointerMichael Goulet-4/+7
2022-09-27Rename some variables.Nicholas Nethercote-10/+10
These make the delimiter processing clearer.
2022-09-27add a label to struct/enum/union ident nameTakayuki Maeda-10/+26
2022-09-27create a new local varTakayuki Maeda-5/+3
2022-09-27Minor improvements.Nicholas Nethercote-3/+5
Add some comments, and mark one path as unreachable.
2022-09-26Rollup merge of #102286 - compiler-errors:recover-semi-in-block-item, ↵Matthias Krüger-7/+30
r=davidtwco Recover some items that expect braces and don't take semicolons Fixes #102262
2022-09-26remove cfg(bootstrap)Pietro Albini-1/+0
2022-09-26Auto merge of #102297 - fee1-dead-contrib:rollup-2np0cre, r=fee1-deadbors-0/+17
Rollup of 5 pull requests Successful merges: - #102143 (Recover from struct nested in struct) - #102178 (bootstrap: the backtrace feature is stable, no need to allow it any more) - #102197 (Stabilize const `BTree{Map,Set}::new`) - #102267 (Don't set RUSTC in the bootstrap build script) - #102270 (Remove benches from `rustc_middle`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-09-26Inline and remove `cook_lexer_token`.Nicholas Nethercote-171/+174
This is a small performance win, alas.
2022-09-26Add `rustc_lexer::TokenKind::Eof`.Nicholas Nethercote-8/+2
For alignment with `rust_ast::TokenKind::Eof`. Plus it's a bit faster, due to less `Option` manipulation in `StringReader::next_token`.
2022-09-26Use less DRY in `cook_lexer_token`.Nicholas Nethercote-19/+19
This is a case where a small amount of repetition results in code that is faster and easier to read.
2022-09-26Make `rustc_lexer::cursor::Cursor` public.Nicholas Nethercote-10/+13
`Cursor` is currently hidden, and the main tokenization path uses `rustc_lexer::first_token` which involves constructing a new `Cursor` for every single token, which is weird. Also, `first_token` also can't handle empty input, so callers have to check for that first. This commit makes `Cursor` public, so `StringReader` can contain a `Cursor`, which results in a simpler structure. The commit also changes `StringReader::advance_token` so it returns an `Option<Token>`, simplifying the the empty input case.
2022-09-26[ui] Rearrange `StringReader`/`TokenTreesReader` creation.Nicholas Nethercote-20/+20
`TokenTreesReader` wraps a `StringReader`, but the `into_token_trees` function obscures this. This commit moves to a more straightforward control flow.
2022-09-26Remove `ast::Token::take`.Nicholas Nethercote-2/+1
Instead of replacing `TokenTreesReader::token` in two steps, we can just do it in one, which is both simpler and faster.
2022-09-26Remove `TokenTreesReader::bump`.Nicholas Nethercote-17/+9
It's an unnecessary layer that obfuscates when I am looking for optimizations.
2022-09-26Clarify spacing computation.Nicholas Nethercote-13/+20
The spacing computation is done in two parts. In the first part `next_token` and `bump` use `Spacing::Alone` to mean "preceded by whitespace" and `Spacing::Joint` to mean the opposite. In the second part `parse_token_tree_other` then adjusts the `spacing` value to mean the usual thing (i.e. "is the following token joinable punctuation?"). This shift in meaning is very confusing and it took me some time to understand what was going on. This commit changes the first part to use a bool, and adds some comments, which makes things much clearer.
2022-09-26Move `#!` checking.Nicholas Nethercote-9/+8
Currently does the "is this a `#!` at the start of the file?" check for every single token(!) This commit moves it so it only happens once.
2022-09-25Recover some items that expect braces and don't take semicolonsMichael Goulet-7/+30
2022-09-26Remove unnecessary `spacing` assignment.Nicholas Nethercote-1/+0
It has no useful effect.
2022-09-26Rearrange `TokenTreesReader::parse_token_tree`.Nicholas Nethercote-178/+168
`parse_token_tree` is basically a match with four arms: `Eof`, `OpenDelim`, `CloseDelim`, and "other". It has two call sites, and at each call site one of the arms is unreachable. It's also not inlined. This commit removes `parse_token_tree` by splitting it into four functions and inlining them. This avoids some repeated conditional tests and also some non-inlined function calls on the hot path.
2022-09-22recover from struct nested in structRageking8-0/+17
2022-09-22Add missing code="" attributes to suggestion subdiagnosticsXiretza-4/+4
2022-09-21FIX - adopt new Diagnostic naming in newly migrated modulesJhonny Bill Mena-2/+2
FIX - ambiguous Diagnostic link in docs UPDATE - rename diagnostic_items to IntoDiagnostic and AddToDiagnostic [Gardening] FIX - formatting via `x fmt` FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way DELETE - unneeded allow attributes in Handler method FIX - broken test FIX - Rebase conflict UPDATE - rename residual _SessionDiagnostic and fix LintDiag link
2022-09-21UPDATE - rename SessionSubdiagnostic macro to SubdiagnosticJhonny Bill Mena-7/+7
Also renames: - sym::AddSubdiagnostic to sym:: Subdiagnostic - rustc_diagnostic_item = "AddSubdiagnostic" to rustc_diagnostic_item = "Subdiagnostic"
2022-09-21UPDATE - rename DiagnosticHandler macro to DiagnosticJhonny Bill Mena-42/+42
2022-09-21UPDATE - rename DiagnosticHandler trait to IntoDiagnosticJhonny Bill Mena-43/+43
2022-09-21UPDATE - move SessionDiagnostic from rustc_session to rustc_errorsJhonny Bill Mena-1/+1
2022-09-21Auto merge of #101846 - chenyukang:fix-101793, r=davidtwcobors-5/+41
Fix the wording of help msg for bitwise not Fixes #101793