about summary refs log tree commit diff
path: root/tests/ui/parser/issues
AgeCommit message (Collapse)AuthorLines
2025-10-02Rollup merge of #147004 - estebank:ascription-in-pat, r=fee1-deadMatthias Krüger-17/+6
Tweak handling of "struct like start" where a struct isn't supported This improves the case where someone tries to write a `match` expr where the patterns have type ascription syntax. Makes them less verbose, by giving up on the first encounter in the block, and makes them more accurate by only treating them as a struct literal if successfully parsed as such. Before, encountering something like `match a { b:` would confuse the parser and think everything after `match` *must* be a struct, and if it wasn't it would generate a cascade of unnecessary diagnostics.
2025-09-26Ignore more failing ui tests for GCC backendGuillaume Gomez-1/+2
2025-09-24Tweak handling of "struct like start" where a struct isn't supportedEsteban Küber-17/+6
This improves the case where someone tries to write a `match` expr where the patterns have type ascription syntax. Makes them less verbose, by giving up on the first encounter in the block, and makes them more accurate by only treating them as a struct literal if successfuly parsed as such.
2025-08-18Rename and move tuple index suffix regression testJieyou Xu-44/+0
To make it more obvious what it's testing. This is its own commit to make git blame easier.
2025-08-05Added checks for attribute in type caseKivooeo-9/+4
2025-07-18Rollup merge of #138554 - xizheyin:issue-138401, r=chenyukangMatthias Krüger-45/+41
Distinguish delim kind to decide whether to emit unexpected closing delimiter Fixes #138401
2025-07-18Deduplicate `unmatched_delims` in `rustc_parse` to reduce confusionxizheyin-59/+29
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-16Rollup merge of #143921 - oli-obk:const-index, r=fee1-deadSamuel Tardieu-26/+15
Constify `Index` traits tracking issue: rust-lang/rust#143775 the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate. r? ```````@fee1-dead```````
2025-07-15constify `Index` trait and its slice implsOli Scherer-26/+15
2025-07-15Recover and suggest use `;` to construct array typexizheyin-0/+39
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-07Add ui test unnessary-error-issue-138401.rsxizheyin-0/+26
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-26Rewrite `macro_rules!` parser to not use the MBE engine itselfJosh Triplett-3/+3
The `macro_rules!` parser was written to match the series of rules using the macros-by-example (MBE) engine and a hand-written equivalent of the left-hand side of a MBE macro. This was complex to read, difficult to extend, and produced confusing error messages. Because it was using the MBE engine, any parse failure would be reported as if some macro was being applied to the `macro_rules!` invocation itself; for instance, errors would talk about "macro invocation", "macro arguments", and "macro call", when they were actually about the macro *definition*. And in practice, the `macro_rules!` parser only used the MBE engine to extract the left-hand side and right-hand side of each rule as a token tree, and then parsed the rest using a separate parser. Rewrite it to parse the series of rules using a simple loop, instead. This makes it more extensible in the future, and improves error messages. For instance, omitting a semicolon between rules will result in "expected `;`" and "unexpected token", rather than the confusing "no rules expected this token in macro call". This work was greatly aided by pair programming with Vincenzo Palazzo and Eric Holk.
2025-06-20Rollup merge of #142485 - mu001999-contrib:dead-code/adt-pattern, r=petrochenkovTrevor Gross-1/+3
Marks ADT live if it appears in pattern Marks ADT live if it appears in pattern, it implies the construction of the ADT. 1. Then we can detect unused private ADTs impl `Default`, without special logics for `Default` and other std traits. 2. We can also remove `rustc_trivial_field_reads` on `Default`, and the logic in `should_ignore_item` (introduced by rust-lang/rust#126302). Fixes rust-lang/rust#120770 Extracted from rust-lang/rust#128637. r? `@petrochenkov`
2025-06-14Marks ADT live if it appears in patternMu001999-1/+3
2025-06-11stabilize gaiBoxy-4/+10
2025-06-03Add missing 2015 edition directivesLukas Wirth-1/+3
These tests specifically test 2015 edition behavior, so ensure that they can only be run with this edition
2025-05-07Rollup merge of #140671 - xizheyin:issue-140169, r=petrochenkovGuillaume Gomez-40/+4
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-40/+4
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2025-05-04Auto merge of #140616 - petrochenkov:noannempty, r=jieyouxubors-2/+0
compiletest: Do not require annotations on empty labels and suggestions Unlike other empty diagnostics, empty labels (only underlining spans) and empty suggestions (suggestions to remove something) are quite usual and do not require any special attention and annotations. This effectively reverts a part of https://github.com/rust-lang/rust/pull/139485. r? `@jieyouxu`
2025-05-03compiletest: Do not require annotations on empty labels and suggestionsVadim Petrochenkov-2/+0
2025-05-03Just suggest positional arg and adjust issue0139104 ui testxizheyin-29/+84
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-25Check if format argument is identifier to avoid error err-emitxizheyin-43/+19
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-25Add ui test parser/issues/invalid-parse-format-issue-139104.rsxizheyin-0/+74
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-22Rollup merge of #139921 - Kivooeo:master, r=WaffleLapkinChris Denton-3/+3
improve diagnostic for raw pointer field access with -> This PR enhances the error messages emitted by the Rust compiler when users attempt to use the `->` operator for field access on raw pointers or when dereferencing is needed. The changes aim to provide clearer guidance, by suggesting the correct use of the `.` operator and explicit dereferencing. **Before:** ``` help: `xs` is a raw pointer; try dereferencing it | LL | (*xs)->count += 1; | ++ + ``` **Now:** ``` help: use `.` on a dereferenced raw pointer instead | LL - xs->count += 1; LL + (*xs).count += 1; | ``` I added extra clarification in the message. Since this error occurs in the parser, we can't be certain that the type is a raw pointer. That's why the message includes only a small note in brackets. (In contrast, the message above is emitted in HIR, where we *can* check whether it's a raw pointer.) **Before:** ``` --> main.rs:11:11 | 11 | xs->count += 1; | ^^ | = help: the . operator will dereference the value if needed ``` **After:** ``` --> main.rs:11:11 | 11 | xs->count += 1; | ^^ | = help: the `.` operator will automatically dereference the value, except if the value is a raw pointer ```
2025-04-22improve diagnostic for raw pointer field access using `->`Kivooeo-3/+3
2025-04-18Remove let_chains feature gate from even more testsest31-2/+2
2025-04-17Rollup merge of #139967 - jieyouxu:auxiliary, r=wesleywiserMatthias Krüger-3/+2
Introduce and use specialized `//@ ignore-auxiliary` for test support files instead of using `//@ ignore-test` ### Summary Add a semantically meaningful directive for ignoring test *auxiliary* files. This is for auxiliary files that *participate* in actual tests but should not be built by `compiletest` (i.e. these files are involved through `mod xxx;` or `include!()` or `#[path = "xxx"]`, etc.). ### Motivation A specialized directive like `//@ ignore-auxiliary` makes it way easier to audit disabled tests via `//@ ignore-test`. - These support files cannot use the canonical `auxiliary/` dir because they participate in module resolution or are included, or their relative paths can be important for test intention otherwise. Follow-up to: - #139705 - #139783 - #139740 See also discussions in: - [#t-compiler > Directive name for non-test aux files?](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Directive.20name.20for.20non-test.20aux.20files.3F/with/512773817) - [#t-compiler > Handling disabled &#96;//@ ignore-test&#96; tests](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Handling.20disabled.20.60.2F.2F.40.20ignore-test.60.20tests/with/512005974) - [#t-compiler/meetings > &#91;steering&#93; 2025-04-11 Dealing with disabled tests](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bsteering.5D.202025-04-11.20Dealing.20with.20disabled.20tests/with/511717981) ### Remarks on remaining unconditionally disabled tests under `tests/` After this PR, against commit 79a272c6402, only **14** remaining test files are disabled through `//@ ignore-test`: <details> <summary>Remaining `//@ ignore-test` files under `tests/`</summary> ``` tests/debuginfo/drop-locations.rs 4://@ ignore-test (broken, see #128971) tests/rustdoc/macro-document-private-duplicate.rs 1://@ ignore-test (fails spuriously, see issue #89228) tests/rustdoc/inline_cross/assoc-const-equality.rs 3://@ ignore-test (FIXME: #125092) tests/ui/match/issue-27021.rs 7://@ ignore-test (#54987) tests/ui/match/issue-26996.rs 7://@ ignore-test (#54987) tests/ui/issues/issue-49298.rs 9://@ ignore-test (#54987) tests/ui/issues/issue-59756.rs 2://@ ignore-test (rustfix needs multiple suggestions) tests/ui/precondition-checks/write.rs 5://@ ignore-test (unimplemented) tests/ui/precondition-checks/read.rs 5://@ ignore-test (unimplemented) tests/ui/precondition-checks/write_bytes.rs 5://@ ignore-test (unimplemented) tests/ui/explicit-tail-calls/drop-order.rs 2://@ ignore-test: tail calls are not implemented in rustc_codegen_ssa yet, so this causes 🧊 tests/ui/panics/panic-short-backtrace-windows-x86_64.rs 3://@ ignore-test (#92000) tests/ui/json/json-bom-plus-crlf-multifile-aux.rs 3://@ ignore-test Not a test. Used by other tests tests/ui/traits/next-solver/object-soundness-requires-generalization.rs 2://@ ignore-test (see #114196) ``` </details> Of these, most are either **unimplemented**, or **spurious**, or **known-broken**. The outstanding one is `tests/ui/json/json-bom-plus-crlf-multifile-aux.rs` which I did not want to touch in *this* PR -- that aux file has load-bearing BOM and carriage returns and byte offset matters. I think those test files that require special encoding / BOM probably are better off as `run-make` tests. See #139968 for that aux file. ### Review advice - Best reviewed commit-by-commit. - The directive name diverged from the most voted `//@ auxiliary` because I think that's easy to confuse with `//@ aux-{crate,dir}`. r? compiler
2025-04-17tests: use `//@ ignore-auxiliary` with backlinked primary test fileJieyou Xu-3/+2
2025-04-17Auto merge of #139949 - matthiaskrgr:rollup-pxc5tsx, r=matthiaskrgrbors-2/+2
Rollup of 8 pull requests Successful merges: - #138632 (Stabilize `cfg_boolean_literals`) - #139416 (unstable book; document `macro_metavar_expr_concat`) - #139782 (Consistent with treating Ctor Call as Struct in liveness analysis) - #139885 (document RUSTC_BOOTSTRAP, RUSTC_OVERRIDE_VERSION_STRING, and -Z allow-features in the unstable book) - #139904 (Explicitly annotate edition for `unpretty=expanded` and `unpretty=hir` tests) - #139932 (transmutability: Refactor tests for simplicity) - #139944 (Move eager translation to a method on Diag) - #139948 (git: ignore `60600a6fa403216bfd66e04f948b1822f6450af7` for blame purposes) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-17Auto merge of #139940 - matthiaskrgr:rollup-rd4d3fn, r=matthiaskrgrbors-3/+3
Rollup of 9 pull requests Successful merges: - #135340 (Add `explicit_extern_abis` Feature and Enforce Explicit ABIs) - #139440 (rustc_target: RISC-V: feature addition batch 2) - #139667 (cfi: Remove #[no_sanitize(cfi)] for extern weak functions) - #139828 (Don't require rigid alias's trait to hold) - #139854 (Improve parse errors for stray lifetimes in type position) - #139889 (Clean UI tests 3 of n) - #139894 (Fix `opt-dist` CLI flag and make it work without LLD) - #139900 (stepping into impls for normalization is unproductive) - #139915 (replace some #[rustc_intrinsic] usage with use of the libcore declarations) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-17Rollup merge of #138632 - clubby789:stabilize-cfg-boolean-lit, ↵Matthias Krüger-2/+2
r=davidtwco,Urgau,traviscross Stabilize `cfg_boolean_literals` Closes #131204 `@rustbot` labels +T-lang +I-lang-nominated This will end up conflicting with the test in #138293 so whichever doesn't land first will need updating -- # Stabilization Report ## General design ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized? [RFC 3695](https://github.com/rust-lang/rfcs/pull/3695), none. ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con. None ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those? None ## Has a call-for-testing period been conducted? If so, what feedback was received? Yes; only positive feedback was received. ## Implementation quality ### Summarize the major parts of the implementation and provide links into the code (or to PRs) Implemented in [#131034](https://github.com/rust-lang/rust/pull/131034). ### Summarize existing test coverage of this feature - [Basic usage, including `#[cfg()]`, `cfg!()` and `#[cfg_attr()]`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/true-false.rs) - [`--cfg=true/false` on the command line being accessible via `r#true/r#false`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/raw-true-false.rs) - [Interaction with the unstable `#[doc(cfg(..))]` feature](https://github.com/rust-lang/rust/tree/6d71251/tests/rustdoc-ui/cfg-boolean-literal.rs) - [Denying `--check-cfg=cfg(true/false)`](https://github.com/rust-lang/rust/tree/6d71251/tests/ui/check-cfg/invalid-arguments.rs) - Ensuring `--cfg false` on the command line doesn't change the meaning of `cfg(false)`: `tests/ui/cfg/cmdline-false.rs` - Ensuring both `cfg(true)` and `cfg(false)` on the same item result in it being disabled: `tests/ui/cfg/both-true-false.rs` ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking? The above mentioned issue; it should not block as it interacts with another unstable feature. ### What FIXMEs are still in the code for that feature and why is it ok to leave them there? None ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization - `@clubby789` (RFC) - `@Urgau` (Implementation in rustc) ### Which tools need to be adjusted to support this feature. Has this work been done? `rustdoc`'s unstable`#[doc(cfg(..)]` has been updated to respect it. `cargo` has been updated with a forward compatibility lint to enable supporting it in cargo once stabilized. ## Type system and execution rules ### What updates are needed to the reference/specification? (link to PRs when they exist) A few lines to be added to the reference for configuration predicates, specified in the RFC.
2025-04-16Remove old diagnostic notes for type ascription syntaxZalathar-18/+0
Type ascription syntax was removed in 2023.
2025-04-15Improve diagnostic for E0178 (bad `+` in type)León Orell Valerian Liehr-3/+3
Namely, use a more sensical primary span. Don't pretty-print AST nodes for the diagnostic message. Why: * It's lossy (e.g., it doesn't replicate trailing `+`s in trait objects. * It's prone to leak error nodes (printed as `(/*ERROR*/)`) since the LHS can easily represent recovered code (e.g., `fn(i32?) + T`).
2025-04-09Auto merge of #139555 - petrochenkov:errkind-ann, r=jieyouxubors-5/+5
UI tests: add missing diagnostic kinds where possible The subset of https://github.com/rust-lang/rust/pull/139427 that only adds diagnostic kinds to line annotations, without changing any other things in annotations or compiletest. After this only non-viral `NOTE`s and `HELP`s should be missing. r? `@jieyouxu`
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-5/+5
2025-04-07compiletest: Avoid ignoring empty diagnostics in one more placeVadim Petrochenkov-0/+2
This catches some silly notes emitted by rustc, which should ideally be fixed
2025-04-03Use `cfg(false)` in UI testsclubby789-2/+2
2025-04-03compiletest: Require `//~` annotations even if `error-pattern` is specifiedVadim Petrochenkov-18/+21
2025-04-01Auto merge of #138492 - lcnr:rm-inline_const_pat, r=oli-obkbors-4/+0
remove `feature(inline_const_pat)` Summarizing https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/remove.20feature.28inline_const_pat.29.20and.20shared.20borrowck. With https://github.com/rust-lang/types-team/issues/129 we will start to borrowck items together with their typeck parent. This is necessary to correctly support opaque types, blocking the new solver and TAIT/ATPIT stabilization with the old one. This means that we cannot really support `inline_const_pat` as they are implemented right now: - we want to typeck inline consts together with their parent body to allow inference to flow both ways and to allow the const to refer to local regions of its parent.This means we also need to borrowck the inline const together with its parent as that's necessary to properly support opaque types - we want the inline const pattern to participate in exhaustiveness checking - to participate in exhaustiveness checking we need to evaluate it, which requires borrowck, which now relies on borrowck of the typeck root, which ends up checking exhaustiveness again. **This is a query cycle**. There are 4 possible ways to handle this: - stop typechecking inline const patterns together with their parent - causes inline const patterns to be different than inline const exprs - prevents bidirectional inference, we need to either fail to compile `if let const { 1 } = 1u32` or `if let const { 1u32 } = 1` - region inference for inline consts will be harder, it feels non-trivial to support inline consts referencing local regions from the parent fn - inline consts no longer participate in exhaustiveness checking. Treat them like `pat if pat == const { .. }` instead. We then only evaluate them after borrowck - difference between `const { 1 }` and `const FOO: usize = 1; match x { FOO => () }`. This is confusing - do they carry their weight if they are now just equivalent to using an if-guard - delay exhaustiveness checking until after borrowck - should be possible in theory, but is a quite involved change and may have some unexpected challenges - remove this feature for now I believe we should either delay exhaustiveness checking or remove the feature entirely. As moving exhaustiveness checking to after borrow checking is quite complex I think the right course of action is to fully remove the feature for now and to add it again once/if we've got that implementation figured out. `const { .. }`-expressions remain stable. These seem to have been the main motivation for https://github.com/rust-lang/rfcs/issues/2920. r? types cc `@rust-lang/types` `@rust-lang/lang` #76001
2025-03-29compiletest: Support matching diagnostics on lines belowVadim Petrochenkov-38/+34
2025-03-26Rollup merge of #138898 - fmease:decrustify-parser-post-ty-ascr, ↵Stuart Cook-78/+0
r=compiler-errors Mostly parser: Eliminate code that's been dead / semi-dead since the removal of type ascription syntax **Disclaimer**: This PR is intended to mostly clean up code as opposed to bringing about behavioral changes. Therefore it doesn't aim to address any of the 'FIXME: remove after a month [dated: 2023-05-02]: "type ascription syntax has been removed, see issue [#]101728"'. --- By commit: 1. Removes truly dead code: * Since 1.71 (#109128) `let _ = { f: x };` is a syntax error as opposed to a semantic error which allows the parse-time diagnostic (suggestion) "*struct literal body without path // you might have forgotten […]*" to kick in. * The analysis-time diagnostic (suggestion) from <=1.70 "*cannot find value \`f\` in this scope // you might have forgotten […]*" is therefore no longer reachable. 2. Updates `is_certainly_not_a_block` to be in line with the current grammar: * The seq. `{ ident:` is definitely not the start of a block. Before the removal of ty ascr, `{ ident: ty_start` would begin a block expr. * This shouldn't make more code compile IINM, it should *ultimately* only affect diagnostics. * For example, `if T { f: () } {}` will now be interpreted as an `if` with struct lit `T { f: () }` as its *condition* (which is banned in the parser anyway) as opposed to just `T` (with the *consequent* being `f : ()` which is also invalid (since 1.71)). The diagnostics are almost the same because we have two separate parse recovery procedures + diagnostics: `StructLiteralNeedingParens` (*invalid struct lit*) before and `StructLiteralNotAllowedHere` (*struct lits aren't allowed here*) now, as you can see from the diff. * (As an aside, even before this PR, fn `maybe_suggest_struct_literal` should've just used the much older & clearer `StructLiteralNotAllowedHere`) * NB: This does sadly regress the compiler output for `tests/ui/parser/type-ascription-in-pattern.rs` but that can be fixed in follow-up PRs. It's not super important IMO and a natural consequence. 3. Removes code that's become dead due to the prior commit. * Basically reverts #106620 + #112475 (without regressing rustc's output!). * Now the older & more robust parse recovery procedure (cc `StructLiteralNotAllowedHere`) takes care of the cases the removed code used to handle. * This automatically fixes the suggestions for \[[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=7e2030163b11ee96d17adc3325b01780)\]: * `if Ty::<i32> { f: K }.m() {}`: `if Ty::<i32> { SomeStruct { f: K } }.m() {}` (broken) → ` if (Ty::<i32> { f: K }).m() {}` * `if <T as Trait>::Out { f: K::<> }.m() {}`: `if <T as Trait>(::Out { f: K::<> }).m() {}` (broken) → `if (<T as Trait>::Out { f: K::<> }).m() {}` 4. Merge and simplify UI tests pertaining to this issue, so it's easier to add more regression tests like for the two cases mentioned above. 5. Merge UI tests and add the two regression tests. Best reviewed commit by commit (on request I'll partially squash after approval).
2025-03-25compiletest: Support matching on diagnostics without a spanVadim Petrochenkov-0/+3
2025-03-25Incorporate issue-111692.rs into the larger test file and add more test casesLeón Orell Valerian Liehr-80/+0
Note that issue-111692.rs was incorrectly named: It's a regression test for issue [#]112278, not for [#]111692. That's been addressed, too.
2025-03-25Brace-ident-colon can certainly no longer start a blockLeón Orell Valerian Liehr-19/+21
thanks to the removal of type ascription.
2025-03-21remove `feature(inline_const_pat)`lcnr-4/+0
2025-03-01Implment `#[cfg]` and `#[cfg_attr]` in `where` clausesFrank King-1/+1
2025-02-28Remove `NtPat`.Nicholas Nethercote-3/+3
The one notable test change is `tests/ui/macros/trace_faulty_macros.rs`. This commit removes the complicated `Interpolated` handling in `expected_expression_found` that results in a longer error message. But I think the new, shorter message is actually an improvement. The original complaint was in #71039, when the error message started with "error: expected expression, found `1 + 1`". That was confusing because `1 + 1` is an expression. Other than that, the reporter said "the whole error message is not too bad if you ignore the first line". Subsequently, extra complexity and wording was added to the error message. But I don't think the extra wording actually helps all that much. In particular, it still says of the `1+1` that "this is expected to be expression". This repeats the problem from the original complaint! This commit removes the extra complexity, reverting to a simpler error message. This is primarily because the traversal is a pain without `Interpolated` tokens. Nonetheless, I think the error message is *improved*. It now starts with "expected expression, found `pat` metavariable", which is much clearer and the real problem. It also doesn't say anything specific about `1+1`, which is good, because the `1+1` isn't really relevant to the error -- it's the `$e:pat` that's important.
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-8/+8
2025-02-14Consider add-prefix replacements tooMichael Goulet-15/+10
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-18/+12