summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/item.rs
AgeCommit message (Collapse)AuthorLines
2023-02-24Replace parse_[sth]_expr with parse_expr_[sth] function namesest31-2/+2
This resolves an inconsistency in naming style for functions on the parser, between functions parsing specific kinds of items and those for expressions, favoring the parse_item_[sth] style used by functions for items. There are multiple advantages of that style: * functions of both categories are collected in the same place in the rustdoc output. * it helps with autocompletion, as you can narrow down your search for a function to those about expressions. * it mirrors rust's path syntax where less specific things come first, then it gets more specific, i.e. std::collections::hash_map::Entry The disadvantage is that it doesn't "read like a sentence" any more, but I think the advantages weigh more greatly. This change was mostly application of this command: sed -i -E 's/(fn |\.)parse_([[:alnum:]_]+)_expr/\1parse_expr_\2/' compiler/rustc_parse/src/parser/*.rs Plus very minor fixes outside of rustc_parse, and an invocation of x fmt.
2023-02-21Use `ThinVec` in a few more AST types.Nicholas Nethercote-2/+2
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-7/+7
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2023-02-21Use `ThinVec` in `ast::Impl` and related types.Nicholas Nethercote-3/+3
2023-02-19Reduce limit on `macro_rules!` diagnosticJacob Pratt-1/+1
2023-02-19Make public API, docs algorithm-agnosticJacob Pratt-2/+3
2023-02-06Migrate `rustc_parse` to derive diagnosticsclubby789-62/+62
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-1/+1
2023-02-01Make "use latest edition" subdiagnostic translatableXiretza-3/+3
2023-02-01rustc_parse: revert conversion of "non-item in item list" diagnosticXiretza-18/+25
#[derive(Subdiagnostic)] does not allow multiple subdiagnostics on one variant, as in NonItemInItemListSub::Other.
2023-02-01rustc_parse: migrate more to diagnostic structsXiretza-260/+153
2023-02-01Fix condition for "missing `struct`" diagnostic on tuple structsXiretza-1/+1
The check previously matched this, and suggested adding a missing `struct`: pub Foo(...): It was probably intended to match this instead (semicolon instead of colon): pub Foo(...);
2023-02-01Use AddToDiagnostic for "use latest edition" helpXiretza-5/+10
2023-02-01rustc_parse: avoid creating unnecessary intermediate stringsXiretza-1/+2
2023-01-12Auto merge of #106537 - ↵bors-3/+11
fmease:recover-where-clause-before-tuple-struct-body, r=estebank Recover from where clauses placed before tuple struct bodies Open to any suggestions regarding the phrasing of the diagnostic. Fixes #100790. `@rustbot` label A-diagnostics r? diagnostics
2023-01-11parser: recover from where clauses placed before tuple struct bodiesLeón Orell Valerian Liehr-3/+11
2023-01-11Detect struct literal needing parenthesesEsteban Küber-1/+2
Fix #82051.
2022-12-29Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params) - #105899 (`./x doc library --open` opens `std`) - #106190 (Account for multiple multiline spans with empty padding) - #106202 (Trim more paths in obligation types) - #106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing) - #106236 (docs/test: add docs and a UI test for `E0514` and `E0519`) - #106259 (Update Clippy) - #106260 (Fix index out of bounds issues in rustdoc) - #106263 (Formatter should not try to format non-Rust files) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-29Provide a better error for `Fn` traits with lifetime paramsYutaro Ohno-1/+1
Currently, given `Fn`-family traits with lifetime params like `Fn<'a>(&'a str) -> bool`, many unhelpful errors show up. These are a bit confusing. This commit allows these situations to suggest simply using higher-ranked trait bounds like `for<'a> Fn(&'a str) -> bool`.
2022-12-28Tweak wordingEsteban Küber-1/+1
2022-12-28Account for ADT bodies and struct expressionsEsteban Küber-2/+29
2022-12-28Detect diff markers in the parserEsteban Küber-2/+9
Partly address #32059.
2022-12-26Auto merge of #103020 - lyming2007:issue-102598-fix, r=jackh726bors-1/+0
error parsing lifetime following by Sized and message + between them Fixes #102598
2022-12-26remove unused importsTakayuki Maeda-1/+0
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