about summary refs log tree commit diff
path: root/src/test/ui/pattern/usefulness
AgeCommit message (Collapse)AuthorLines
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
2021-01-24Identify subpatterns by the path to them instead of spansNadrieril-21/+3
2021-01-24Add testsNadrieril-0/+45
2021-01-12Add tests for uninhabited typesNadrieril-212/+351
2021-01-12Deduplicate some tests using revisionsNadrieril-227/+74
2021-01-03Add notes to stderr of non-exhaustive-reference testDaniel Noom-2/+6
2021-01-03Add note to non-exhaustive match on reference to emptyDaniel Noom-0/+24
Rust prints "type `&A` is non-empty" even is A is empty. This is the intended behavior, but can be confusing. This commit adds a note to non-exhaustive pattern errors if they are a reference to something uninhabited. I did not add tests to check that the note is not shown for non-references or inhabited references, because this is already done in other tests. Maybe the added test is superfluous, because `always-inhabited-union-ref` already checks for this case. This does not handle &&Void or &&&void etc. I could add those as special cases as well and ignore people who need quadruple references. Fixes #78123
2020-12-22Add some testsNadrieril-28/+71
2020-12-22Auto merge of #78242 - Nadrieril:rename-overlapping_endpoints-lint, r=varkorbors-86/+103
Rename `overlapping_patterns` lint As discussed in https://github.com/rust-lang/rust/issues/65477. I also tweaked a few things along the way. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2020-12-19Tweak diagnosticsNadrieril-8/+8
2020-12-18Keep all witnesses of non-exhaustivenessNadrieril-12/+14
2020-12-18Add testsNadrieril-14/+47
2020-11-29`overlapping_range_endpoints` does not belong in the `unused` lint groupNadrieril-37/+39
2020-11-29Improve error messageNadrieril-17/+32
2020-11-29Be consistent about linting singletonsNadrieril-19/+3
2020-11-29Rename the `overlapping_patterns` lint to `overlapping_range_endpoints`Nadrieril-33/+33
2020-11-29Add testsNadrieril-3/+19
2020-11-28Correctly detect `usize`/`isize` range overlapsNadrieril-2/+8
2020-11-21Improve integer range testsNadrieril-663/+892
2020-11-19Regroup many usefulness-related test in the same folderNadrieril-0/+751
2020-11-18Auto merge of #78995 - Nadrieril:clean-empty-match, r=varkorbors-55/+162
Handle empty matches cleanly in exhaustiveness checking This removes the special-casing of empty matches that was done in `check_match`. This fixes most of https://github.com/rust-lang/rust/issues/55123. Somewhat unrelatedly, I also made `_match.rs` more self-contained, because I think it's cleaner. r? `@varkor` `@rustbot` modify labels: +A-exhaustiveness-checking
2020-11-17Fix exhaustiveness in case a byte string literal is used at slice typeoli-2/+2
2020-11-16Add a test for foreign empty enumsNadrieril-48/+102
2020-11-12Handle empty matches cleanlyNadrieril-36/+43
2020-11-12Add testsNadrieril-42/+88
2020-11-01Fix #78549Nadrieril-0/+25
Before #78430, string literals worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. Since then, string literals are special cased and a bit hacky. I did not anticipate patterns for the `&str` type other than string literals, hence this bug. This makes string literals less hacky.
2020-10-20Accidentally fixed #78071Nadrieril-24/+36
2020-10-18The only remaining constant patterns are opaqueNadrieril-9/+2
2020-10-18Destructure byte array constants to array patterns instead of keeping them ↵Oliver Scherer-2/+2
opaque
2020-10-18Add some testsNadrieril-0/+267
2020-09-20Implement destructuring for all aggregates and for referencesOliver Scherer-41/+143
2020-09-02pretty: trim paths of unique symbolsDan Aloni-10/+10
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-07-27mv std libs to library/mark-3/+3