about summary refs log tree commit diff
path: root/tests/ui/or-patterns
AgeCommit message (Collapse)AuthorLines
2025-08-30Avoid unnecessary suggestion in or-patternEsteban Küber-34/+5
2025-08-30Suggest constant on unused binding in a patternEsteban Küber-18/+40
``` error: unused variable: `Batery` --> $DIR/binding-typo-2.rs:110:9 | LL | Batery => {} | ^^^^^^ | help: if this is intentional, prefix it with an underscore | LL | _Batery => {} | + help: you might have meant to pattern match on the similarly named constant `Battery` | LL | Battery => {} | + ```
2025-08-30On unused binding in pattern, suggest unit struct/variant with similar nameEsteban Küber-70/+189
When encountering a typo in a pattern that gets interpreted as an unused binding, look for unit struct/variant of the same type as the binding: ``` error: unused variable: `Non` --> $DIR/binding-typo-2.rs:36:9 | LL | Non => {} | ^^^ | help: if this is intentional, prefix it with an underscore | LL | _Non => {} | + help: you might have meant to pattern match on the similarly named variant `None` | LL - Non => {} LL + std::prelude::v1::None => {} | ```
2025-08-30On binding not present in all patterns, look at consts and unit ↵Esteban Küber-3/+250
structs/variants for suggestions When encountering an or-pattern with a binding not available in all patterns, look for consts and unit struct/variants that have similar names as the binding to detect typos. ``` error[E0408]: variable `Ban` is not bound in all patterns --> $DIR/binding-typo.rs:22:9 | LL | (Foo, _) | (Ban, Foo) => {} | ^^^^^^^^ --- variable not in all patterns | | | pattern doesn't bind `Ban` | help: you might have meant to use the similarly named unit variant `Bar` | LL - (Foo, _) | (Ban, Foo) => {} LL + (Foo, _) | (Bar, Foo) => {} | ``` For items that are not in the immedate scope, suggest the full path for them: ``` error[E0408]: variable `Non` is not bound in all patterns --> $DIR/binding-typo-2.rs:51:16 | LL | (Non | Some(_))=> {} | --- ^^^^^^^ pattern doesn't bind `Non` | | | variable not in all patterns | help: you might have meant to use the similarly named unit variant `None` | LL - (Non | Some(_))=> {} LL + (core::option::Option::None | Some(_))=> {} | ```
2025-08-29Add test for typo in or-pattern bindingEsteban Küber-0/+82
2025-08-25On binding not present in all patterns, suggest potential typoEsteban Küber-0/+111
``` error[E0408]: variable `Ban` is not bound in all patterns --> f12.rs:9:9 | 9 | (Foo,Bar)|(Ban,Foo) => {} | ^^^^^^^^^ --- variable not in all patterns | | | pattern doesn't bind `Ban` | help: you might have meant to use the similarly named previously used binding `Bar` | 9 - (Foo,Bar)|(Ban,Foo) => {} 9 + (Foo,Bar)|(Bar,Foo) => {} | ```
2025-08-23Rollup merge of #145234 - dianne:1-tuple-witnesses, r=jackh726Samuel Tardieu-8/+8
match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little) Constructor patterns of type `(T,)` are written `(pat,)`, not `(pat)`. However, exhaustiveness/usefulness diagnostics would print them as `(pat)` when e.g. providing a witness of non-exhaustiveness and suggesting adding arms to make matches exhaustive; this would result in an error when applied. rust-analyzer already prints the trailing comma, so it doesn't need changing. This also includes some cleanup in the second commit, with justification in the commit message.
2025-08-10show a trailing comma on singleton tuple constructors in witness patsdianne-8/+8
2025-08-04Include whitespace in "remove `|`" suggestion and make it hiddenEsteban Küber-110/+48
2025-05-09Error message for top-level or-patterns suggesting a solutionKornel-24/+24
2025-04-21Rollup merge of #140029 - reddevilmidzy:move-test, r=jieyouxuChris Denton-0/+25
Relocate tests in `tests/ui` Part of #133895 Moved tests from a top-level directory into a more appropriate subdirectory. If there is anything else that could be improved, please let me know! r? jieyouxu
2025-04-21Cleaned up 5 tests in `tests/ui`reddevilmidzy-0/+25
2025-04-17Auto merge of #139949 - matthiaskrgr:rollup-pxc5tsx, r=matthiaskrgrbors-7/+7
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-17Rollup merge of #138632 - clubby789:stabilize-cfg-boolean-lit, ↵Matthias Krüger-7/+7
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-1/+0
Type ascription syntax was removed in 2023.
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-2/+2
2025-04-03Use `cfg(false)` in UI testsclubby789-7/+7
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-26/+39
``` 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; | ```
2024-12-12Filter empty lines, comments and delimiters from previous to last multiline ↵Esteban Küber-1/+0
span rendering
2024-11-23Update tests for new TRPL chapter orderChris Krycho-1/+1
2024-10-28Tweak more warnings.Nicholas Nethercote-4/+4
Much like the previous commit. I think the removal of "the token" in each message is fine here. There are many more error messages that mention tokens without saying "the token" than those that do say it.
2024-08-19Reword the "unreachable pattern" explanationsNadrieril-68/+68
2024-07-24Improve "covered_by_many" errorNadrieril-7/+51
2024-07-24Explain why a given pattern is considered unreachableNadrieril-63/+168
2024-07-12Make parse error suggestions verbose and fix spansEsteban Küber-40/+249
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-16Add testsNadrieril-16/+47
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-37/+37
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-28/+62
2024-01-18Consistently warn unreachable subpatternsNadrieril-4/+18
2024-01-18Add testsNadrieril-1/+43
2024-01-13Bless testsGeorge-lewis-0/+1
Update tests
2023-12-07recurse into refs when comparing tys for diagnosticsjyn-2/+2
2023-11-26Auto merge of #117611 - Nadrieril:linear-pass-take-4, r=cjgillotbors-27/+66
Rewrite exhaustiveness in one pass This is at least my 4th attempt at this in as many years x) Previous attempts were all too complicated or too slow. But we're finally here! The previous version of the exhaustiveness algorithm computed reachability for each arm then exhaustiveness of the whole match. Since each of these steps does roughly the same things, this rewrites the algorithm to do them all in one go. I also think this makes things much simpler. I also rewrote the documentation of the algorithm in depth. Hopefully it's up-to-date and easier to follow now. Plz comment if anything's unclear. r? `@oli-obk` I think you're one of the rare other people to understand the exhaustiveness algorithm? cc `@varkor` I know you're not active anymore, but if you feel like having a look you might enjoy this :D Fixes https://github.com/rust-lang/rust/issues/79307
2023-11-24Show number in error message even for one errorNilstrieb-4/+4
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-22Add some testsNadrieril-27/+66
2023-10-30Correctly handle nested or-patterns in column-wise analysesNadrieril-0/+6
2023-10-12Detect ruby-style closure in parserEsteban Küber-1/+7
When parsing a closure without a body that is surrounded by a block, suggest moving the opening brace after the closure head. Fix #116608.
2023-10-02Replace `HashMap` with `IndexMap` in pattern binding resolveNilstrieb-42/+42
It will be iterated over, so we should avoid using `HashMap`.
2023-08-18Bless test changesGary Guo-34/+34
2023-05-21Rename `drop_ref` lint to `dropping_references`Urgau-1/+1
2023-05-21Rename `drop_copy` lint to `dropping_copy_types`Urgau-1/+1
2023-05-10Adjust tests for new drop and forget lintsUrgau-0/+2
2023-05-01Rip it outNilstrieb-22/+16
My type ascription Oh rip it out Ah If you think we live too much then You can sacrifice diagnostics Don't mix your garbage Into my syntax So many weird hacks keep diagnostics alive Yet I don't even step outside So many bad diagnostics keep tyasc alive Yet tyasc doesn't even bother to survive!
2023-04-27Provide RHS type hint when reporting operator errorMichael Goulet-2/+2
2023-04-03Perform match checking on THIR.Camille GILLOT-6/+6
2023-01-30Modify primary span label for E0308Esteban Küber-5/+5
The previous output was unintuitive to users.
2023-01-11Migrate pattern matchingmejrs-1/+1
2023-01-11Move /src/test to /testsAlbert Larsan-0/+2978