about summary refs log tree commit diff
path: root/src/test/ui/pattern
AgeCommit message (Collapse)AuthorLines
2021-03-22Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakisbors-14/+10
Stabilize or_patterns (RFC 2535, 2530, 2175) closes #54883 This PR stabilizes the or_patterns feature in Rust 1.53. This is blocked on the following (in order): - [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021 - [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705) - It looks like we will need to pursue some sort of edition-based transition for `:pat`. - [x] Nomination and discussion by T-lang - [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100). - [ ] An FCP on stabilization EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-20Move some tests to more reasonable directories - 5Caio-0/+30
2021-03-19update testsmark-14/+10
2021-03-07Account for `if (let pat = expr) {}`Esteban Küber-2/+1
Partially address #82827.
2021-02-23Rollup merge of #82308 - estebank:issue-82290, r=lcnrDylan DPC-0/+27
Lower condition of `if` expression before it's "then" block Fix #82290, fix #82250.
2021-02-19Lower condition of `if` expression before it's "then" blockEsteban Küber-0/+27
Fix #82290, fix #82250.
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-13/+13
2021-02-03move test to be with the othersmark-44/+0
2021-01-26Account for existing `_` field pattern when suggesting `..`Esteban Küber-2/+2
Follow up to #80017.
2021-01-24Identify subpatterns by the path to them instead of spansNadrieril-21/+3
2021-01-24Add testsNadrieril-0/+45
2021-01-16Move some tests to more reasonable directories - 2Caio-0/+244
Address comments Update limits
2021-01-12Include `..` suggestion if fields are all wildcardsCamelid-6/+16
2021-01-12Always show suggestions in their own subwindowsCamelid-20/+30
2021-01-12Add a test case with lots of whitespaceCamelid-8/+34
2021-01-12Only suggest `..` if more than one field is missingCamelid-60/+26
2021-01-12Specialize `..` help message for all fields vs. the restCamelid-13/+13
2021-01-12Suggest `Variant(..)` if all of the mentioned fields are `_`Camelid-4/+4
2021-01-12Suggest `_` and `..` if a pattern has too few fieldsCamelid-0/+179
For example, this code: struct S(i32, f32); let S(x) = S(0, 1.0); will make the compiler suggest either: let S(x, _) = S(0, 1.0); or: let S(x, ..) = S(0, 1.0);
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-20Fix pretty printing an AST representing `&(mut ident)`Thomas Bahn-0/+19
`PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), ..)` is an AST representing `&(mut ident)`. It was errorneously printed as `&mut ident` which reparsed into a syntactically different AST. This affected help diagnostics in the parser.
2020-12-20Auto merge of #80100 - mark-i-m:pattORns-2, r=petrochenkovbors-0/+44
or_patterns: implement :pat edition-specific behavior cc #54883 `@joshtriplett` This PR implements the edition-specific behavior of `:pat` wrt or-patterns, as determined by the crater runs and T-lang consensus in https://github.com/rust-lang/rust/issues/54883#issuecomment-745509090. I believe this can unblock stabilization of or_patterns. r? `@petrochenkov`
2020-12-19Tweak diagnosticsNadrieril-8/+8
2020-12-19implement edition-specific :pat behavior for 2015/18mark-0/+44
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-655/+892
2020-11-19Regroup many usefulness-related test in the same folderNadrieril-0/+686
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-05Auto merge of #78638 - vn-ki:bindigs-after-at-issue-69971, r=oli-obkbors-595/+524
reverse binding order in matches to allow the subbinding of copyable fields in bindings after @ Fixes #69971 ### TODO - [x] Regression tests r? `@oli-obk`
2020-11-03review commentsVishnunarayan K I-1/+4