about summary refs log tree commit diff
path: root/src/test/ui/pattern/usefulness
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-6440/+0
2022-12-13Avoid rendering empty annotationsOli Scherer-8/+14
2022-12-13Don't emit empty notesOli Scherer-11/+1
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-31/+13
available
2022-11-21Simplify testOli Scherer-3/+1
Co-authored-by: lcnr <rust@lcnr.de>
2022-11-21Fix an ICE that I just made worseOli Scherer-0/+28
2022-11-20Change to Ty::is_inhabited_fromCameron Steffen-1/+1
2022-10-01bless ui testsMaybe Waffle-4/+4
2022-09-15Remove the let_else feature gate from the testsuiteest31-14/+12
Result of running: rg -l "feature.let_else" src/test/ | xargs sed -s -i "s#^...feature.let_else..\$##" Plus manual tidy fixes.
2022-09-15Remove feature gate from let else suggestionest31-2/+2
The let else suggestion added by 0d92752b8aac53e033541d04fc7d9677d8bca227 does not need a feature gate any more.
2022-09-03Include enum path in variant suggestionMichael Goulet-180/+180
2022-07-01Shorten def_span for more items.Camille GILLOT-98/+50
2022-06-19Be more hygenic with spansMichael Goulet-56/+38
2022-06-19Only omit trailing comma if block doesn't come from macro expansionMichael Goulet-1/+1
2022-04-27Make [e]println macros eagerly drop temporaries (for backport)David Tolnay-1/+1
2022-03-16Rollup merge of #94868 - dtolnay:noblock, r=Dylan-DPCDylan DPC-1/+1
Format core and std macro rules, removing needless surrounding blocks Many of the asserting and printing macros in `core` and `std` are written with prehistoric-looking formatting, like this: https://github.com/rust-lang/rust/blob/335ffbfa547df94ac236f5c56130cecf99c8d82b/library/std/src/macros.rs#L96-L101 In modern Rust style this would conventionally be written as follows instead, always using braces and a trailing semicolon on the macro arms: https://github.com/rust-lang/rust/blob/af53809c874e0afb7be966df4d3cfcaa05277c53/library/std/src/macros.rs#L98-L105 Getting rid of the unneeded braces inside the expansion reduces extraneous indentation in macro-expanded code. For example: ```rust println!("repro {}", true); ``` ```rust // before: { ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); }; ``` ```rust // after: ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); ```
2022-03-12Fix rebase conflicts with stderr filesDevin Ragotzy-53/+160
2022-03-12Only filter doc(hidden) fields/variants when not crate localDevin Ragotzy-9/+65
2022-03-12Update output for doc hidden usefulness ui test outputDevin Ragotzy-62/+64
2022-03-12Add struct to doc hidden usefulness ui testsDevin Ragotzy-11/+35
2022-03-12Add struct to stability ui tests in usefulnessDevin Ragotzy-15/+60
2022-03-11Format core and std macro rules, removing needless surrounding blocksDavid Tolnay-1/+1
2022-03-08Do not suggest `let_else` if no bindings would be introducedEsteban Kuber-16/+0
2022-03-08Suggest `if let`/`let_else` for refutable pat in `let`Esteban Kuber-14/+38
2022-03-08Change wording of suggestion to add missing `match` armEsteban Kuber-146/+146
2022-03-08Point at uncovered variants in enum definition in `note` instead of a ↵Esteban Kuber-523/+654
`span_label` This makes the order of the output always consistent: 1. Place of the `match` missing arms 2. The `enum` definition span 3. The structured suggestion to add a fallthrough arm
2022-03-08When finding a match expr with multiple arms that requires more, suggest itEsteban Kuber-47/+235
Given ```rust match Some(42) { Some(0) => {} Some(1) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} Some(1) => {} None | Some(_) => todo!(), } ```
2022-03-08When finding a match expr with a single arm that requires more, suggest itEsteban Kuber-76/+377
Given ```rust match Some(42) { Some(0) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} None | Some(_) => todo!(), } ```
2022-03-08When encountering a match expr with no arms, suggest itEsteban Kuber-146/+181
Given ```rust match Some(42) {} ``` suggest ```rust match Some(42) { None | Some(_) => todo!(), } ```
2022-03-03Cleanup feature gates.Camille GILLOT-13/+12
2021-11-23Fix stack overflow in `usefulness.rs`Badel2-0/+14
2021-10-12Filter unstable and doc hidden variants in usefulness checkingDevin Ragotzy-0/+185
Add test cases for unstable variants Add test cases for doc hidden variants Move is_doc_hidden to method on TyCtxt Add unstable variants test to reachable-patterns ui test Rename reachable-patterns -> omitted-patterns
2021-10-01Rollup merge of #89441 - Nadrieril:fix-89393, r=tmandryManish Goregaokar-22/+56
Normalize after substituting via `field.ty()` Back in https://github.com/rust-lang/rust/issues/72476 I hadn't understood where the problem was coming from, and only worked around the issue. What happens is that calling `field.ty()` on a field of a generic struct substitutes the appropriate generics but doesn't normalize the resulting type. As a consumer of types I'm surprised that one would substitute without normalizing, feels like a footgun, so I added a comment. Fixes https://github.com/rust-lang/rust/issues/89393.
2021-10-01Normalize after substituting via `field.ty()`Nadrieril-22/+56
2021-09-29Auto merge of #88950 - Nadrieril:deconstruct-pat, r=oli-obkbors-16/+95
Add an intermediate representation to exhaustiveness checking The exhaustiveness checking algorithm keeps deconstructing patterns into a `Constructor` and some `Fields`, but does so a bit all over the place. This PR introduces a new representation for patterns that already has that information, so we only compute it once at the start. I find this makes code easier to follow. In particular `DeconstructedPat::specialize` is a lot simpler than what happened before, and more closely matches the description of the algorithm. I'm also hoping this could help for the project of librarifying exhaustiveness for rust_analyzer since it decouples the algorithm from `rustc_middle::Pat`.
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-9/+9
2021-09-26Replace `Pat` with a new intermediate representationNadrieril-14/+48
2021-09-26Rework `Fields` internals.Nadrieril-2/+2
Now `Fields` is just a `Vec` of patterns, with some extra info on the side to reconstruct patterns when needed. This emphasizes that this extra info is not central to the algorithm.
2021-09-22Add testsNadrieril-0/+45
2021-08-30Handle irrufutable or unreachable let-elseCameron Steffen-12/+21
2021-08-16Don't mark `if_let_guard` as an incomplete featureLéo Lanteri Thauvin-5/+4
2021-08-15Introduce hir::ExprKind::Let - Take 2Caio-7/+5
2021-08-11Modify structured suggestion outputEsteban Küber-3/+3
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-3/+3
2021-04-03Remove redundant `ignore-tidy-linelength` annotationsSimon Jakobi-4/+2
This is step 2 towards fixing #77548. In the codegen and codegen-units test suites, the `//` comment markers were kept in order not to affect any source locations. This is because these tests cannot be automatically `--bless`ed.
2021-02-18Add explanations and suggestions to `irrefutable_let_patterns` lintCamelid-4/+26
2021-02-17replace if-let and while-let with `if let` and `while let`Takayuki Maeda-4/+4
2021-02-13Add match pattern diagnostics regression testBram van den Heuvel-0/+29
2021-02-07Auto merge of #80632 - Nadrieril:fix-80501, r=varkorbors-0/+27
Identify unreachable subpatterns more reliably In https://github.com/rust-lang/rust/pull/80104 I used `Span`s to identify unreachable sub-patterns in the presence of or-patterns during exhaustiveness checking. In https://github.com/rust-lang/rust/issues/80501 it was revealed that `Span`s are complicated and that this was not a good idea. Instead, this PR identifies subpatterns logically: as a path in the tree of subpatterns of a given pattern. I made a struct that captures a set of such subpatterns. This is a bit complex, but thankfully self-contained; the rest of the code does not need to know anything about it. Fixes https://github.com/rust-lang/rust/issues/80501. I think I managed to keep the perf neutral. r? `@varkor`
2021-02-06path trimming: ignore type aliasesDan Aloni-1/+1