about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
AgeCommit message (Collapse)AuthorLines
2023-01-08Do not emit structured suggestion for turbofish with wrong spanEsteban Küber-2/+10
Fix #79161.
2023-01-06Tiny formatting fixEsteban Küber-6/+7
2022-12-30Auto merge of #106268 - kraktus:patch-2, r=Nilstriebbors-1/+1
fix comment for `TokenCursor::desugar` the hashes of the text were forgotten.
2022-12-29Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgrbors-3/+94
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-29fix comment for `TokenCursor::desugar`kraktus-1/+1
the hashes of the text were forgotten.
2022-12-29Rollup merge of #106242 - estebank:diff-markers, r=jyn514Matthias Krüger-5/+120
Detect diff markers in the parser Partly address #32059.
2022-12-29Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, ↵Matthias Krüger-2/+2
r=compiler-errors Rename `Rptr` to `Ref` in AST and HIR The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-29Provide a better error for `Fn` traits with lifetime paramsYutaro Ohno-3/+94
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-28Add support for diff3 formatEsteban Küber-0/+7
2022-12-28Tweak wordingEsteban Küber-6/+17
2022-12-28Account for ADT bodies and struct expressionsEsteban Küber-2/+30
2022-12-28Detect diff markers in the parserEsteban Küber-3/+72
Partly address #32059.
2022-12-28Rollup merge of #105570 - Nilstrieb:actual-best-failure, r=compiler-errorsMatthias Krüger-0/+4
Properly calculate best failure in macro matching Previously, we used spans. This was not good. Sometimes, the span of the token that failed to match may come from a position later in the file which has been transcribed into a token stream way earlier in the file. If precisely this token fails to match, we think that it was the best match because its span is so high, even though other arms might have gotten further in the token stream. We now try to properly use the location in the token stream. This needs a little cleanup as the `best_failure` field is getting out of hand but it should be mostly good to go. I hope I didn't violate too many abstraction boundaries..
2022-12-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-2/+2
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-28Rollup merge of #106176 - compiler-errors:fn-kw-as-fn-trait, r=estebankMatthias Krüger-3/+53
Recover `fn` keyword as `Fn` trait in bounds `impl fn()` -> `impl Fn()` Fixes #82515
2022-12-27Rollup merge of #106066 - JohnTitor:rm-bindings-after-at-fixme, ↵Matthias Krüger-12/+6
r=compiler-errors Always suggest as `MachineApplicable` in `recover_intersection_pat` This resolves one FIXME in `recover_intersection_pat` by always applying `MachineApplicable` when suggesting, as `bindings_after_at` is now stable. This also separates a test to apply `// run-rustfix`. Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-12-27Recover `fn` keyword as `Fn` trait in boundsMichael Goulet-3/+53
2022-12-26Auto merge of #103020 - lyming2007:issue-102598-fix, r=jackh726bors-1/+19
error parsing lifetime following by Sized and message + between them Fixes #102598
2022-12-27Rollup merge of #106151 - TaKO8Ki:remove-unused-imports, r=jackh726fee1-dead-2/+0
Remove unused imports
2022-12-26remove unused importsTakayuki Maeda-2/+0
2022-12-25Auto merge of #105701 - RedDocMD:bug-105634, r=cjgillotbors-3/+7
Allow .. to be parsed as let initializer .. and ..= are valid expressions, however when used in a let statement it is not parsed. Fixes #105634
2022-12-23Always suggest as `MachineApplicable` in `recover_intersection_pat`Yuki Okushi-12/+6
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-12-19Rollup merge of #105864 - matthiaskrgr:compl, r=NilstriebDylan DPC-2/+1
clippy::complexity fixes filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool r? `@compiler-errors`
2022-12-19clippy::complexity fixesMatthias Krüger-2/+1
filter_next needless_question_mark bind_instead_of_map manual_find derivable_impls map_identity redundant_slicing skip_while_next unnecessary_unwrap needless_bool
2022-12-18avoid .into() conversion to identical typesMatthias Krüger-6/+2
2022-12-16Little fixesDeep Majumder-3/+3
2022-12-14Allow .. to be parsed as let initializerDeep Majumder-3/+7
.. and ..= are valid expressions, however when used in a let statement it is not parsed.
2022-12-14Rollup merge of #105502 - chenyukang:yukang/fix-105366-impl, r=estebankMatthias Krüger-2/+26
Suggest impl in the scenario of typo with fn Fixes #105366
2022-12-14Auto merge of #104875 - chenyukang:yukang/fix-104867-inc, r=estebankbors-43/+26
Properly handle postfix inc/dec in standalone and subexpr scenarios Fixes #104867 r? `@estebank`
2022-12-13error parsing lifetime following by Sized and message + between themYiming Lei-1/+19
detect the pattern at the general site parse_impl_ty() this will fix #102598
2022-12-12Properly calculate best failure in macro matchingNilstrieb-0/+4
Previously, we used spans. This was not good. Sometimes, the span of the token that failed to match may come from a position later in the file which has been transcribed into a token stream way earlier in the file. If precisely this token fails to match, we think that it was the best match because its span is so high, even though other arms might have gotten further in the token stream. We now try to properly use the location in the token stream.
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-31/+51
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
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-3/+0
2022-12-10fix #105366, suggest impl in the scenario of typo with fnyukang-2/+26
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/+8
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-05Rollup merge of #105223 - lukas-code:(ExprWithBlock), r=petrochenkovMatthias Krüger-14/+5
suggest parenthesis around ExprWithBlock BinOp ExprWithBlock fix https://github.com/rust-lang/rust/issues/105179 fix https://github.com/rust-lang/rust/issues/102171
2022-12-05Parameterise `Parser::{recover_unclosed_char,handle_missing_lit}`.Nicholas Nethercote-30/+49
These two methods both produce a `MetaItemLit`, and then some of the call sites convert the `MetaItemLit` to a `token::Lit` with `as_token_lit`. This commit parameterises these two methods with a `mk_lit_char` closure, which can be used to produce either `MetaItemLit` or `token::Lit` directly as necessary.
2022-12-04Rollup merge of #105141 - ohno418:fix-ice-on-invalid-var-decl-in-macro-call, ↵Matthias Krüger-19/+24
r=compiler-errors Fix ICE on invalid variable declarations in macro calls This fixes ICE that happens with invalid variable declarations in macro calls like: ```rust macro_rules! m { ($s:stmt) => {} } m! { var x } m! { auto x } m! { mut x } ``` Found this is because of not collecting tokens on recovery, so I changed to force collect them. Fixes https://github.com/rust-lang/rust/issues/103529.
2022-12-03more commentsLukas Markeffsky-3/+4
2022-12-03suggest parenthesis around ExprWithBlock BinOp ExprWithBlockLukas Markeffsky-12/+2
2022-12-03Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillotMatthias Krüger-3/+7
Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
2022-12-03parser: refactoring on recovery from invalid variable declarationsYutaro Ohno-16/+21
Previously, the `recover_local_after_let` function was called from the body of the `recover_stmt_local` function. Unifying these two functions make it more simple and more readable.
2022-12-03parser: fix ICE with invalid variable declaration in macro callYutaro Ohno-4/+4
Fix ICE on parsing an invalid variable declaration as a statement like: ``` macro_rules! m { ($s:stmt) => {} } m! { var x } ```
2022-12-01While parsing enum variant, the error message always disappearYiming Lei-1/+8
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-02Remove `token::Lit` from `ast::MetaItemLit`.Nicholas Nethercote-6/+7
`token::Lit` contains a `kind` field that indicates what kind of literal it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has its own `kind` field. This means that `ast::MetaItemLit` encodes the literal kind in two different ways. This commit changes `ast::MetaItemLit` so it no longer wraps `token::Lit`. It now contains the `symbol` and `suffix` fields from `token::Lit`, but not the `kind` field, eliminating the redundancy.
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-29Avoid unnecessary `MetaItem`/`Attribute` conversions.Nicholas Nethercote-17/+26
`check_builtin_attribute` calls `parse_meta` to convert an `Attribute` to a `MetaItem`, which it then checks. However, many callers of `check_builtin_attribute` start with a `MetaItem`, and then convert it to an `Attribute` by calling `cx.attribute(meta_item)`. This `MetaItem` to `Attribute` to `MetaItem` conversion is silly. This commit adds a new function `check_builtin_meta_item`, which can be called instead from these call sites. `check_builtin_attribute` also now calls it. The commit also renames `check_meta` as `check_attr` to better match its arguments.
2022-11-28Keep track of the start of the argument block of a closureSarthak Singh-3/+7