about summary refs log tree commit diff
path: root/tests/ui/parser/recover
AgeCommit message (Collapse)AuthorLines
2025-08-26fix: Add col separator before secondary messages with no sourceScott Schafer-0/+1
2025-08-22Recover param: Ty = EXPRMichael Goulet-0/+19
2025-08-19bless tests with new lint messagesKarol Zwolak-1/+1
2025-08-06Rollup merge of #144195 - Kivooeo:bad-attr, r=fmease,compiler-errorsGuillaume Gomez-7/+11
Parser: Recover from attributes applied to types and generic args r? compiler Add clearer error messages for invalid attribute usage in types or generic types fixes rust-lang/rust#135017 fixes rust-lang/rust#144132
2025-08-05Added checks for attribute in type caseKivooeo-7/+11
2025-07-31Extend `is_case_difference` to handle digit-letter confusablesxizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-16future-incompat lints: don't link to the nightly edition-guide versiondianne-10/+10
2025-07-15Recover and suggest use `;` to construct array typexizheyin-38/+52
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-14Add test array-type-no-semi.rsxizheyin-0/+74
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-20Recover from semicolon field separatorCameron Steffen-9/+9
2025-06-13Rework how the disallowed qualifier lints are generatedJonathan Brouwer-110/+55
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-13Add failing testsJonathan Brouwer-2/+88
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-46/+48
2025-04-17Auto merge of #139949 - matthiaskrgr:rollup-pxc5tsx, r=matthiaskrgrbors-3/+3
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-0/+37
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-3/+3
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-17Rollup merge of #139854 - fmease:modern-diag-for-lt-in-ty, r=davidtwcoMatthias Krüger-0/+37
Improve parse errors for stray lifetimes in type position While technically & syntactically speaking lifetimes do begin[^1] types in type contexts (this essentially excludes generic argument lists) and require a following `+` to form a complete type (`'a +` denotes a bare trait object type), the likelihood that a user meant to write a lifetime-prefixed bare trait object type in *modern* editions (Rust ≥2021) when placing a lifetime into a type context is incredibly low (they would need to add at least three tokens to turn it into a *semantically* well-formed TOT: `'a` → `dyn 'a + Trait`). Therefore let's *lie* in modern editions (just like in PR https://github.com/rust-lang/rust/pull/131239, a precedent if you will) by stating "*expected type, found lifetime*" in such cases which is a lot more a approachable, digestible and friendly compared to "*lifetime in trait object type must be followed by `+`*" (as added in PR https://github.com/rust-lang/rust/pull/69760). I've also added recovery for "ampersand-less" reference types (e.g., `'a ()`, `'a mut Ty`) in modern editions because it was trivial to do and I think it's not unlikely to occur in practice. Fixes #133413. [^1]: For example, in the context of decl macros, this implies that a lone `'a` always matches syntax fragment `ty` ("even if" there's a later macro matcher expecting syntax fragment `lifetime`). Rephrased, lifetimes (in type contexts) *commit* to the type parser.
2025-04-16Remove old diagnostic notes for type ascription syntaxZalathar-1/+0
Type ascription syntax was removed in 2023.
2025-04-15Improve parse errors for lifetimes in type positionLeón Orell Valerian Liehr-0/+37
2025-04-14Rollup merge of #139392 - compiler-errors:raw-expr, r=oli-obkMatthias Krüger-0/+140
Detect and provide suggestion for `&raw EXPR` When emitting an error in the parser, and we detect that the previous token was `raw` and we *could* have consumed `const`/`mut`, suggest that this may have been a mistyped raw ref expr. To do this, we add `const`/`mut` to the expected token set when parsing `&raw` as an expression (which does not affect the "good path" of parsing, for the record). This is kind of a rudimentary error improvement, since it doesn't actually attempt to recover anything, leading to some other knock-on errors b/c we still treat `&raw` as the expression that was parsed... but at least we add the suggestion! I don't think the parser grammar means we can faithfully recover `&raw EXPR` early, i.e. during `parse_expr_borrow`. Fixes #133231
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-2/+2
2025-04-04Detect and provide suggestion for `&raw EXPR`Michael Goulet-0/+140
2025-04-03Use `cfg(false)` in UI testsclubby789-3/+3
2025-03-21remove `feature(inline_const_pat)`lcnr-176/+0
2025-03-06Use closure parse codeSantiago Pastorino-3/+3
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-1/+1
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-3/+2
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-98/+147
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-01-27Trim extra whitespace in fn ptr suggestion spanTyrone Wu-16/+16
Trim extra whitespace when suggesting removal of invalid qualifiers when parsing function pointer type. Fixes: #133083 Signed-off-by: Tyrone Wu <wudevelops@gmail.com>
2025-01-07Update tests.Mara Bos-32/+32
2024-12-21Detect missing `.` in method chain in let bindings and statementsEsteban Küber-0/+102
On parse errors where an ident is found where one wasn't expected, see if the next elements might have been meant as method call or field access. ``` error: expected one of `.`, `;`, `?`, `else`, or an operator, found `map` --> $DIR/missing-dot-on-statement-expression.rs:7:29 | LL | let _ = [1, 2, 3].iter()map(|x| x); | ^^^ expected one of `.`, `;`, `?`, `else`, or an operator | help: you might have meant to write a method call | LL | let _ = [1, 2, 3].iter().map(|x| x); | + ```
2024-11-24parse guard patternsNadrieril-15/+15
Co-authored-by: Max Niederman <max@maxniederman.com>
2024-11-23Update tests for new TRPL chapter orderChris Krycho-60/+60
2024-11-16Increase accuracy of `if` condition misparse suggestionEsteban Küber-0/+293
Look at the expression that was parsed when trying to recover from a bad `if` condition to determine what was likely intended by the user beyond "maybe this was meant to be an `else` body". ``` error: expected `{`, found `map` --> $DIR/missing-dot-on-if-condition-expression-fixable.rs:4:30 | LL | for _ in [1, 2, 3].iter()map(|x| x) {} | ^^^ expected `{` | help: you might have meant to write a method call | LL | for _ in [1, 2, 3].iter().map(|x| x) {} | + ```
2024-10-06On function and method calls in patterns, link to the bookEsteban Küber-51/+109
``` error: expected a pattern, found an expression --> f889.rs:3:13 | 3 | let (x, y.drop()) = (1, 2); //~ ERROR | ^^^^^^^^ not a pattern | = note: arbitrary expressions are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> error[E0532]: expected a pattern, found a function call --> f889.rs:2:13 | 2 | let (x, drop(y)) = (1, 2); //~ ERROR | ^^^^ not a tuple struct or tuple variant | = note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch18-00-patterns.html> ``` Fix #97200.
2024-09-18Add suggestions for expressions in patternsLieselotte-53/+764
2024-09-18Recover more expressions in patternsLieselotte-0/+803
2024-08-28Suggest the struct variant pattern syntax on usage of unit variant pattern ↵tunawasabi-0/+5
for a struct variant
2024-08-03Revert "Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix"Michael Goulet-9/+7
This reverts commit 13314df21b0bb0cdd02c6760581d1b9f1052fa7e, reversing changes made to 6e534c73c35f569492ed5fb5f349075d58ed8b7e.
2024-07-18Fix ICE in suggestion caused by `⩵` being recovered as `==`Esteban Küber-0/+27
The second suggestion shown here would previously incorrectly assume that the span corresponding to `⩵` was 2 bytes wide composed by 2 1 byte wide chars, so a span pointing at `==` could point only at one of the `=` to remove it. Instead, we now replace the whole thing (as we should have the whole time): ``` error: unknown start of token: \u{2a75} --> $DIR/unicode-double-equals-recovery.rs:1:16 | LL | const A: usize ⩵ 2; | ^ | help: Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not | LL | const A: usize == 2; | ~~ error: unexpected `==` --> $DIR/unicode-double-equals-recovery.rs:1:16 | LL | const A: usize ⩵ 2; | ^ | help: try using `=` instead | LL | const A: usize = 2; | ~ ```
2024-07-12Make `;` suggestions inlineEsteban Küber-72/+12
2024-07-12Make parse error suggestions verbose and fix spansEsteban Küber-68/+362
Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts.
2024-06-20Fix `...` in multline code-skips in suggestionsEsteban Küber-1/+1
When we have long code skips, we write `...` in the line number gutter. For suggestions, we were "centering" the `...` with the line, but that was consistent with what we do in every other case.
2024-06-07Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelixMatthias Krüger-7/+9
Detect pub structs never constructed and unused associated constants <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Lints never constructed public structs. If we don't provide public methods to construct public structs with private fields, and don't construct them in the local crate. They would be never constructed. So that we can detect such public structs. --- Update: Also lints unused associated constants in traits.
2024-06-05Detect pub structs never constructed and unused associated constants in traitsr0cky-7/+9
2024-06-01Simplify IntVarValue/FloatVarValueMichael Goulet-9/+0
2024-05-09Make sure we consume a generic arg when checking mistyped turbofishMichael Goulet-0/+20
2024-05-02Stabilize exclusive_rangeRoss Smyth-71/+70
2024-04-12Suppress erroneous suggestionAlan Egerton-36/+0
The suggestion to use `let else` with an uninitialized refutable `let` statement was erroneous: `let else` cannot be used with deferred initialization.
2024-03-23Suggest assoc ty bound on lifetime in eq constraintLeón Orell Valerian Liehr-7/+12