about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/item.rs
AgeCommit message (Collapse)AuthorLines
2022-12-14Rollup merge of #105502 - chenyukang:yukang/fix-105366-impl, r=estebankMatthias Krüger-2/+18
Suggest impl in the scenario of typo with fn Fixes #105366
2022-12-13error parsing lifetime following by Sized and message + between themYiming Lei-1/+0
detect the pattern at the general site parse_impl_ty() this will fix #102598
2022-12-11Rollup merge of #105369 - chenyukang:yukang/fix-105226, r=TaKO8KiMatthias Krüger-3/+9
Detect spurious ; before assoc fn body Fixes #105226 r? ``@TaKO8Ki``
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-12-10fix #105366, suggest impl in the scenario of typo with fnyukang-2/+18
2022-12-07fix #105226, Detect spurious ; before assoc fn bodyyukang-3/+9
2022-12-06Rollup merge of #105098 - lyming2007:issue-103869-fix, r=eholkMatthias Krüger-1/+4
propagate the error from parsing enum variant to the parser and emit out While parsing enum variant, the error message always disappear Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case https://github.com/rust-lang/rust/issues/103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix https://github.com/rust-lang/rust/issues/103869
2022-12-01While parsing enum variant, the error message always disappearYiming Lei-1/+4
Because the error message that emit out is from main error of parser The information of enum variant disappears while parsing enum variant with error We only check the syntax of expecting token, i.e, in case #103869 It will error it without telling the message that this error is from pasring enum variant. Propagate the sub-error from parsing enum variant to the main error of parser by chaining it with map_err Check the sub-error before emitting the main error of parser and attach it. Fix #103869
2022-12-01rustc_ast_lowering: Stop lowering imports into multiple itemsVadim Petrochenkov-1/+1
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-11-23Auto merge of #104410 - WaffleLapkin:unregress, r=estebankbors-9/+21
Fix perf regression by correctly matching keywords This should (hopefully) fix regression from #99918 r? `@estebank`
2022-11-22`rustc_parse`: remove `ref` patternsMaybe Waffle-4/+4
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-12/+9
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-17Use `ThinVec` in `ast::Path`.Nicholas Nethercote-3/+4
2022-11-16Fix perf regression by correctly matching keywordsMaybe Waffle-9/+21
2022-11-11Auto merge of #99918 - WaffleLapkin:fnFnfun, r=estebankbors-31/+60
Recover wrong-cased keywords that start items (_this pr was inspired by [this tweet](https://twitter.com/Azumanga/status/1552982326409367561)_) r? `@estebank` We've talked a bit about this recovery, but I just wanted to make sure that this is the right approach :) For now I've only added the case insensitive recovery to `use`s, since most other items like `impl` blocks, modules, functions can start with multiple keywords which complicates the matter.
2022-11-08Parser: Recover from using colon as path separator in importsBruno A. Muciño-0/+17
2022-10-18Fix the bug of next_point in spanyukang-1/+1
2022-10-11Fix let removal suggestion in structMichael Goulet-6/+11
2022-10-10`let` is not allowed in struct field definitionsgimbles-1/+17
Co-authored-by: jyn514 <jyn514@gmail.com> Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-10-01Replace some `bool` params with an enumMaybe Waffle-29/+34
2022-10-01Recover wrong cased keywords starting functionsMaybe Waffle-37/+42
2022-10-01recover wrong-cased `use`s (`Use`, `USE`, etc)Maybe Waffle-3/+22
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-29improve E0585 helpRageking8-2/+2
2022-09-27Migrate more rustc_parse diagnostics to diagnostic structsXiretza-12/+10
2022-09-27Move rustc_parse diagnostic structs to separate moduleXiretza-1/+3
2022-09-28improve errors for incomplete functions in struct definitionsTakayuki Maeda-11/+17
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-26Rollup merge of #102286 - compiler-errors:recover-semi-in-block-item, ↵Matthias Krüger-7/+22
r=davidtwco Recover some items that expect braces and don't take semicolons Fixes #102262
2022-09-25Recover some items that expect braces and don't take semicolonsMichael Goulet-7/+22
2022-09-22recover from struct nested in structRageking8-0/+17
2022-09-16tweak suggestionyukang-1/+1
2022-09-15fix #101797: Suggest associated const for incorrect use of let in traitsyukang-4/+15
2022-09-06Rollup merge of #101457 - ChayimFriedman2:struct-field-semi, r=fee1-deadGuillaume Gomez-0/+11
Recover from using `;` as separator between fields Partially fixes #101440 (only for record structs). Doing that for tuple structs is harder as their parsing passes through a bunch of helper functions. I don't know how to do that. But [their error message is better anyway](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cc6ee8bb2593596c0cea89d49e79bcb4) and suggests using a comma, even if it doesn't suggest replacing the semicolon with it.
2022-09-05Recover from using `;` as separator between fieldsChayim Refael Friedman-0/+11
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-2/+2
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-1/+0
by module
2022-08-22Use `AttrVec` in more places.Nicholas Nethercote-32/+25
In some places we use `Vec<Attribute>` and some places we use `ThinVec<Attribute>` (a.k.a. `AttrVec`). This results in various points where we have to convert between `Vec` and `ThinVec`. This commit changes the places that use `Vec<Attribute>` to use `AttrVec`. A lot of this is mechanical and boring, but there are some interesting parts: - It adds a few new methods to `ThinVec`. - It implements `MapInPlace` for `ThinVec`, and introduces a macro to avoid the repetition of this trait for `Vec`, `SmallVec`, and `ThinVec`. Overall, it makes the code a little nicer, and has little effect on performance. But it is a precursor to removing `rustc_data_structures::thin_vec::ThinVec` and replacing it with `thin_vec::ThinVec`, which is implemented more efficiently.
2022-08-17Box the `MacCall` in various types.Nicholas Nethercote-1/+1
2022-08-15Rollup merge of #100458 - compiler-errors:fn-argument-span, r=estebankMatthias Krüger-1/+1
Adjust span of fn argument declaration Span of a fn argument declaration goes from: ``` fn foo(i : i32 , ...) ^^^^^^^^ ``` to: ``` fn foo(i : i32 , ...) ^^^^^^^ ``` That is, we don't include the extra spacing up to the trailing comma, which I think is more correct. cc https://github.com/rust-lang/rust/pull/99646#discussion_r944568074 r? ``@estebank`` --- The two tests that had dramatic changes in their rendering I think actually are improved, though they are kinda poor spans both before and after the changes. :shrug: Thoughts?
2022-08-15Rollup merge of #100566 - TaKO8Ki:use-create-snapshot-for-diagnostic, r=cjgillotMatthias Krüger-2/+2
Use `create_snapshot_for_diagnostic` instead of `clone` for `Parser` follow-up to #98020
2022-08-15use `create_snapshot_for_diagnostic` instead of `clone` for `Parser`Takayuki Maeda-2/+2
2022-08-14Rollup merge of #100115 - obeis:issue-99910, r=cjgillotDylan DPC-0/+10
Suggest removing `let` if `const let` or `let const` is used Closes #99910
2022-08-13Rollup merge of #100446 - ↵Michael Goulet-4/+34
TaKO8Ki:suggest-removing-semicolon-after-impl-trait-items, r=compiler-errors Suggest removing a semicolon after impl/trait items fixes #99822
2022-08-13Rollup merge of #100475 - chenyukang:fix-100461, r=fee1-deadMichael Goulet-2/+6
Give a helpful diagnostic when the next struct field has an attribute Fixes #100461
2022-08-13use `span_suggestion` instead of `span_suggestion_verbose`Takayuki Maeda-1/+1
2022-08-13give a helpful diagnostic even when the next struct field has an attributeyukang-2/+6
2022-08-12Adjust span of fn argumentsMichael Goulet-1/+1
2022-08-12suggest removing a semicolon after impl/trait itemsTakayuki Maeda-4/+34