about summary refs log tree commit diff
path: root/compiler/rustc_parse
AgeCommit message (Collapse)AuthorLines
2025-06-12Rollup merge of #142261 - folkertdev:unstable-attr-correct-edition, ↵Matthias Krüger-1/+6
r=compiler-errors use correct edition when warning for unsafe attributes fixes https://github.com/rust-lang/rust/issues/142182 If an attribute is re-emitted by a macro, the incorrect edition was used to emit warnings for unsafe attributes. This logic was introduced in https://github.com/rust-lang/rust/pull/139718 cc `@compiler-errors` `@ehuss`
2025-06-11Add expectation for `{` when parsing lone coroutine qualifiersLukas Wirth-13/+19
2025-06-09use correct edition when warning for unsafe attributesFolkert de Vries-1/+6
If an attribute is re-emitted by a macro, the incorrect edition was used to emit warnings for unsafe attributes
2025-06-08Remove all unused feature gates from the compilerbjorn3-1/+0
2025-06-06Rollup merge of #141603 - nnethercote:reduce-P, r=fee1-deadGuillaume Gomez-13/+11
Reduce `ast::ptr::P` to a typedef of `Box` As per the MCP at https://github.com/rust-lang/compiler-team/issues/878. r? `@fee1-dead`
2025-06-04Ensure stack in `Parser::parse_ty`Josh Stone-8/+12
This solve a stack overflow found on Fedora s390x when building `tests/ui/associated-consts/issue-93775.rs`.
2025-06-04Rollup merge of #141570 - chenyukang:yukang-fix-eq_unspanned, r=workingjubileeMatthias Krüger-2/+6
Fix incorrect eq_unspanned in TokenStream Fixes rust-lang/rust#141522 r? ``@workingjubilee`` should we remove this function? since it's used in several places, i'd prefer to keep it.
2025-06-03Rollup merge of #141945 - nnethercote:rm-Path-is_ident, r=compiler-errorsMatthias Krüger-1/+1
Remove `Path::is_ident`. It checks that a path has a single segment that matches the given symbol, and that there are zero generic arguments. It has a single use. We also have `impl PartialEq<Symbol> for Path` which does exactly the same thing *except* it doesn't check for zero generic arguments, which seems like an oversight. It has numerous uses. This commit removes `Path::is_ident`, adds a test for zero generic arguments to `PartialEq<Symbol> for Path`, and changes the single use of `is_ident` to instead use `==`. r? `@wesleywiser`
2025-06-03Add `iter` macroOli Scherer-1/+1
This adds an `iter!` macro that can be used to create movable generators. This also adds a yield_expr feature so the `yield` keyword can be used within iter! macro bodies. This was needed because several unstable features each need `yield` expressions, so this allows us to stabilize them separately from any individual feature. Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de> Co-authored-by: Jieyou Xu <jieyouxu@outlook.com> Co-authored-by: Travis Cross <tc@traviscross.com>
2025-06-03Remove `Path::is_ident`.Nicholas Nethercote-1/+1
It checks that a path has a single segment that matches the given symbol, and that there are zero generic arguments. It has a single use. We also have `impl PartialEq<Symbol> for Path` which does exactly the same thing *except* it doesn't check for zero generic arguments, which seems like an oversight. It has numerous uses. This commit removes `Path::is_ident`, adds a test for zero generic arguments to `PartialEq<Symbol> for Path`, and changes the single use of `is_ident` to instead use `==`.
2025-05-30Rollup merge of #141077 - chenyukang:yukang-fix-140991-comma, r=wesleywiserJubilee-18/+36
Fix the issue of typo of comma in arm parsing Fixes #140991 I also checked is it a '/', since it's near from ',' from keyboard.
2025-05-30Rollup merge of #141004 - matthewjasper:unicode-before-expansion, r=davidtwcoMatthias Krüger-2/+87
Report text_direction_codepoint_in_literal when parsing The lint is now reported in code that gets removed/modified/duplicated by macro expansion, and spans are more accurate so we don't get ICEs from trying to split a span in the middle of a character. This removes support for lint level attributes for `text_direction_codepoint_in_literal` except at the crate level, I don't think that there's an easy way around this when the lint can be reported on code that's removed by `cfg` or that is only in the input of a macro. Fixes #140281
2025-05-29Rollup merge of #141675 - nnethercote:ItemKind-field-order, r=fee1-deadJacob Pratt-3/+3
Reorder `ast::ItemKind::{Struct,Enum,Union}` fields. So they match the order of the parts in the source code, e.g.: ``` struct Foo<T, U> { t: T, u: U } <-><----> <------------> / | \ ident generics variant_data ``` r? `@fee1-dead`
2025-05-28Rollup merge of #141670 - chenyukang:yukang-fix-ice-from-contracts, ↵Trevor Gross-7/+6
r=nnethercote Fix ICE in tokenstream with contracts from parser recovery Fixes rust-lang/rust#140683 After two times of parsing error, the `recover_stmt_` constructs an error ast, then when we expand macors, the invalid tokenstream triggered ICE because of mismatched delims. Expected `{` and get other tokens is an obvious error message, too much effort on recovery may introduce noise. r? ```@nnethercote```
2025-05-28Reorder `ast::ItemKind::{Struct,Enum,Union}` fields.Nicholas Nethercote-3/+3
So they match the order of the parts in the source code, e.g.: ``` struct Foo<T, U> { t: T, u: U } <-><----> <------------> / | \ ident generics variant_data ```
2025-05-28Fix ICE in tokenstream with contracts from parser recoveryyukang-7/+6
2025-05-27Report text_direction_codepoint_in_literal when parsingMatthew Jasper-2/+87
- The lint is now reported in code that gets removed/modified/duplicated by macro expansion. - Spans are more accurate - Fixes #140281
2025-05-27move asm parsing code into `rustc_parse`Folkert de Vries-0/+480
2025-05-27Reduce `P<T>` to a typedef of `Box<T>`.Nicholas Nethercote-12/+10
Keep the `P` constructor function for now, to minimize immediate churn. All the `into_inner` calls are removed, which is nice.
2025-05-27Remove the one use of `P<[T]>`.Nicholas Nethercote-1/+1
A `Vec` is fine, the additional word (vector vs. boxed slice) doesn't matter here.
2025-05-26remove eq_unspanned from TokenStreamyukang-2/+6
2025-05-16Fix the issue of typo of comma in arm parsingyukang-18/+36
2025-05-16Rollup merge of #141003 - clubby789:ternary-improve, r=compiler-errorsMatthias Krüger-12/+52
Improve ternary operator recovery This - Improves the span of the error to not point at the next token - Where possible, we use the span of the condition to further improve the span of the error to include the cond, and suggest a maybe-incorrect fix Currently this works on free expressions, not let statements; some more refactoring would be needed to pass the span down, which I'm not sure is worth doing. ### Old ![image](https://github.com/user-attachments/assets/5688cefc-e4ef-4135-a5ba-340ce05ae6f3) ### New ![image](https://github.com/user-attachments/assets/154f5380-e0c8-42c7-9bf8-0adb3d0433fa)
2025-05-14Improve ternary operator recoveryJamie-12/+52
2025-05-12update cfg(bootstrap)Pietro Albini-1/+0
2025-05-09Error message for top-level or-patterns suggesting a solutionKornel-2/+2
2025-05-09Remove `Ident::empty`.Nicholas Nethercote-1/+1
All uses have been removed. And it's nonsensical: an identifier by definition has at least one char. The commits adds an is-non-empty assertion to `Ident::new` to enforce this, and converts some `Ident` constructions to use `Ident::new`. Adding the assertion requires making `Ident::new` and `Ident::with_dummy_span` non-const, which is no great loss. The commit amends a couple of places that do path splitting to ensure no empty identifiers are created.
2025-05-07Rollup merge of #140671 - xizheyin:issue-140169, r=petrochenkovGuillaume Gomez-6/+72
Parser: Recover error from named params while parse_path Fixes #140169 I added test to the first commit and the second added the code and changes to test. r? `@petrochenkov`
2025-05-07Use `parse_param_general` when parsing `(T, U)->R` in `parse_path_segment`xizheyin-6/+72
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2025-05-06Rollup merge of #140035 - fee1-dead-contrib:push-oszwkkvmpkks, ↵Stuart Cook-7/+167
r=jieyouxu,wesleywiser Implement RFC 3503: frontmatters Tracking issue: #136889 Supercedes #137193. This implements [RFC 3503](https://github.com/rust-lang/rfcs/blob/master/text/3503-frontmatter.md). This might break rust-analyzer. Will look into how to fix that. Suggestions welcome for how to improve diagnostics.
2025-05-05Implement RFC 3503: frontmattersDeadbeef-7/+167
Supercedes #137193
2025-05-04Make attribute safety validation logic more obviousJieyou Xu-14/+47
2025-05-03Report the `unsafe_attr_outside_unsafe` lint at the closest nodeUrgau-5/+11
2025-04-30Rollup merge of #140494 - ehuss:document-restrictions, r=traviscross,SparrowLiiMatthias Krüger-0/+49
Parser: Document restrictions I had trouble easily understanding what these various flags do. This is my attempt to try to explain what these do.
2025-04-30ast: Remove token visiting from AST visitorVadim Petrochenkov-75/+0
It's no longer necessary after the removal of nonterminal tokens in #124141.
2025-04-29Parser: Document restrictionsEric Huss-0/+49
I had trouble easily understanding what these various flags do. This is my attempt to try to explain what these do.
2025-04-30Use `ThinVec` to shrink `LazyAttrTokenStreamInner`.Nicholas Nethercote-2/+3
2025-04-30Simplify `LazyAttrTokenStream`.Nicholas Nethercote-18/+7
This commit does the following. - Changes it from `Lrc<Box<dyn ToAttrTokenStream>>` to `Lrc<LazyAttrTokenStreamInner>`. - Reworks `LazyAttrTokenStreamImpl` as `LazyAttrTokenStreamInner`, which is a two-variant enum. - Removes the `ToAttrTokenStream` trait and the two impls of it. The recursion limit must be increased in some crates otherwise rustdoc aborts.
2025-04-29Move various token stream things from `rustc_parse` to `rustc_ast`.Nicholas Nethercote-338/+12
Specifically: `TokenCursor`, `TokenTreeCursor`, `LazyAttrTokenStreamImpl`, `FlatToken`, `make_attr_token_stream`, `ParserRange`, `NodeRange`. `ParserReplacement`, and `NodeReplacement`. These are all related to token streams, rather than actual parsing. This will facilitate the simplifications in the next commit.
2025-04-26Rollup merge of #140272 - Kivooeo:new-fix-four, r=est31Matthias Krüger-4/+17
Improve error message for `||` (or) in let chains **Description** This PR improves the error message when using `||` in an if let chain expression, addressing #140263. **Changes** 1. Creates a dedicated error message specifically for `||` usage in let chains 2. Points the primary span directly at the `||` operator 3. Removes confusing secondary notes about "let statements" and unsupported contexts 5. Adds UI tests verifying the new error message and valid cases **Before** ```rust error: expected expression, found let statement --> src/main.rs:2:8 | 2 | if let true = true || false {} | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of if and while expressions note: || operators are not supported in let chain expressions --> src/main.rs:2:24 | 2 | if let true = true || false {} | ``` **After** ```rust error: `||` operators are not supported in let chain conditions --> src/main.rs:2:24 | 2 | if let true = true || false {} | ^^ ``` **Implementation details** 1. Added new `OrInLetChain` diagnostic in errors.rs 2. Modified `CondChecker` in expr.rs to prioritize the `||` error 3. Updated fluent message definitions to use clearer wording **Related issue** Fixes #140263 cc ```@ehuss``` (issue author)
2025-04-25resolved conflictKivooeo-4/+17
2025-04-25Rollup merge of #140202 - est31:let_chains_feature_compiler, r=lcnrMatthias Krüger-1/+1
Make #![feature(let_chains)] bootstrap conditional in compiler/ Let chains have been stabilized recently in #132833, so we can remove the gating from our uses in the compiler (as the compiler uses edition 2024).
2025-04-24Rollup merge of #140228 - fmease:revert-overzealous-colon-recovery, r=jieyouxuMatthias Krüger-13/+18
Revert overzealous parse recovery for single colons in paths Basically manually reverts #136808, cc ``@chenyukang`` ``@estebank.`` Reopens #129273. Fixes [after beta backport] #140227.
2025-04-24Revert overzealous parse recovery for single colonsLeón Orell Valerian Liehr-13/+18
2025-04-23Auto merge of #140180 - ChrisDenton:rollup-5pvs08u, r=ChrisDentonbors-52/+64
Rollup of 7 pull requests Successful merges: - #140142 (Some more graphviz tweaks) - #140146 (Update `compiler_builtins` to 0.1.156) - #140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.) - #140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic) - #140163 (Validate extension in `PathBuf::add_extension`) - #140173 (Ping Mara when touching format_args!() internals.) - #140175 (`rc""` more clear error message) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-23Make #![feature(let_chains)] bootstrap conditional in compiler/est31-1/+1
2025-04-23Rollup merge of #140175 - Kivooeo:new-fix-one, r=compiler-errorsChris Denton-2/+10
`rc""` more clear error message here is small fix that provides better error message when user is trying to use `rc""` the same way it was made for `rb""` example of it's work ```rust | 2 | rc"\n"; | ^^ unknown prefix | = note: prefixed identifiers and literals are reserved since Rust 2021 help: use `cr` for a raw C-string | 2 - rc"\n"; 2 + cr"\n"; | ``` **related issue** fixes #140170 cc `@cyrgani` (issue author)
2025-04-23Rollup merge of #140147 - xizheyin:issue-138401-1, r=compiler-errorsChris Denton-50/+54
Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`. Clean code prepared for resolving #138401. To avoid having too many extraneous changes in one PR, I cleaned up some of the naming and method placement in lexer in this PR. 1. For the make_unclosed_delims_error function defined in mod.rs is only used in lexer, so moved into lexer, which enhances encapsulation. 2. For open_braces in TokenTreeDiagInfo the naming is not canonical, as Brace refers to `{...} ` and this variable can store all kinds of different Delimiters. so I named it open_delimiters. r? `@chenyukang`
2025-04-23rc and cr more clear error messageKivooeo-2/+10
2025-04-22Rollup merge of #140144 - nnethercote:fix-140098, r=petrochenkovChris Denton-13/+13
Handle another negated literal in `eat_token_lit`. Extends the change from #139653, which was on expressions, to literals. Fixes #140098. r? ``@petrochenkov``