about summary refs log tree commit diff
path: root/tests/ui/match
AgeCommit message (Collapse)AuthorLines
2024-05-20hir pretty: fix block indentNilstrieb-7/+7
2024-05-15Gate implicit mutable by-reference bindings behind `mut ref`Jules Bertholet-2/+33
2024-05-15`&mut` no longer peels off `&`Jules Bertholet-62/+119
2024-05-15Remove `ref_pat_everywhere`Jules Bertholet-74/+0
2024-05-10Comments and fixesJules Bertholet-42/+108
2024-05-10Fix spans when macros are involvedJules Bertholet-4/+3
2024-05-10Various fixes:Jules Bertholet-24/+41
- Only show error when move-check would not be triggered - Add structured suggestion
2024-05-10Match ergonomics 2024: let `&` patterns eat `&mut`Jules Bertholet-69/+115
2024-05-02Stabilize exclusive_rangeRoss Smyth-17/+14
2024-04-29Change wordingest31-1/+1
2024-04-28Add a note to the ArbitraryExpressionInPattern errorest31-0/+2
2024-04-15Ensure inherited reference is never set to `&mut` behind an `&`Jules Bertholet-23/+59
2024-04-15Support `let &mut x = &&mut 0;`Jules Bertholet-3/+44
2024-04-15Properly downgrade inherited mutabilityJules Bertholet-2/+72
2024-04-15Match ergonomics 2024: Implement eat-one-layerJules Bertholet-0/+400
2024-04-05Rollup merge of #123311 - Jules-Bertholet:andpat-everywhere, r=NadrierilGuillaume Gomez-0/+78
Match ergonomics: implement "`&`pat everywhere" Implements the eat-two-layers (feature gate `and_pat_everywhere`, all editions) ~and the eat-one-layer (feature gate `and_eat_one_layer_2024`, edition 2024 only, takes priority on that edition when both feature gates are active)~ (EDIT: will be done in later PR) semantics. cc #123076 r? ``@Nadrieril`` ``@rustbot`` label A-patterns A-edition-2024
2024-04-02Fix suggestions for match non-exhaustivenessMichael Goulet-1/+1
2024-04-02Don't ICE for postfix match after asMichael Goulet-0/+35
2024-04-02Address review commentsJules Bertholet-68/+27
2024-03-30Implement "&<pat> everywhere"Jules Bertholet-0/+119
The original proposal allows reference patterns with "compatible" mutability, however it's not clear what that means so for now we require an exact match. I don't know the type system code well, so if something seems to not make sense it's probably because I made a mistake
2024-03-26Don't check match scrutinee of postfix match for unused parensMichael Goulet-0/+8
2024-03-22Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkovMatthias Krüger-0/+142
Experimental feature postfix match This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, #121618). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement. It is entirely implemented in the parser, so it should be relatively easy to remove if needed. This PR is split in to 5 commits to ease review. 1. The implementation of the feature & gating. 2. Add a MatchKind field, fix uses, fix pretty. 3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix. 4. Add new MatchSource to HIR for Clippy & other HIR consumers
2024-03-09Allow lint where we don't careNadrieril-0/+1
2024-03-05Add postfix-match experimental featureRoss Smyth-0/+142
Co-authored-by: Josh Stone <jistone@redhat.com>
2024-03-03Move testsCaio-0/+27
2024-02-25make non-PartialEq-typed consts as patterns a hard errorRalf Jung-21/+4
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-46/+46
2024-02-15Remove a suggestion that is redundantMichael Goulet-5/+1
2024-02-15Only point out non-diverging arms for match suggestionsMichael Goulet-1/+46
2024-02-05Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillotMatthias Krüger-165/+11
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing https://github.com/rust-lang/rfcs/pull/3535. Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint. https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-02-01`#![feature(inline_const_pat)]` is no longer incompleteMatthew Jasper-13/+11
2024-01-26add test checking behavior of matching on floats, and NaNs in constsRalf Jung-0/+11
2024-01-26remove illegal_floating_point_literal_pattern lintRalf Jung-165/+0
2023-11-27Account for `!` arm in tail `match` exprEsteban Küber-0/+37
On functions with a default return type that influences the coerced type of `match` arms, check if the failing arm is actually of type `!`. If so, suggest changing the return type so the coercion against the prior arms is successful. ``` error[E0308]: `match` arms have incompatible types --> $DIR/match-tail-expr-never-type-error.rs:9:13 | LL | fn bar(a: bool) { | - help: try adding a return type: `-> i32` LL | / match a { LL | | true => 1, | | - this is found to be of type `{integer}` LL | | false => { LL | | never() | | ^^^^^^^ | | | | | expected integer, found `()` | | this expression is of type `!`, but it get's coerced to `()` due to its surrounding expression LL | | } LL | | } | |_____- `match` arms have incompatible types ``` Fix #24157.
2023-11-24Show number in error message even for one errorNilstrieb-20/+20
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-17On resolve error of `[rest..]`, suggest `[rest @ ..]`Esteban Küber-0/+5
When writing a pattern to collect multiple entries of a slice in a single binding, it is easy to misremember or typo the appropriate syntax to do so, instead writing the experimental `X..` pattern syntax. When we encounter a resolve error because `X` isn't available, we suggest `X @ ..` as an alternative. ``` error[E0425]: cannot find value `rest` in this scope --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:13 | LL | [1, rest..] => println!("{rest:?}"), | ^^^^ not found in this scope | help: if you meant to collect the rest of the slice in `rest`, use the at operator | LL | [1, rest @ ..] => println!("{rest:?}"), | + ``` Fix #88404.
2023-11-03Tweak spans for "adt defined here" noteNadrieril-2/+2
2023-10-11Fix range overflow checkingNadrieril-28/+27
2023-10-11Add testsNadrieril-0/+144
2023-09-25rename lint; add tracking issueRalf Jung-4/+4
2023-09-24work towards rejecting consts in patterns that do not implement PartialEqRalf Jung-1/+25
2023-09-19Update to LLVM 17.0.0Nikita Popov-0/+32
This rebases our LLVM fork to 17.0.0. Fixes #115681.
2023-09-03Improve clarity of diagnostic message on non-exhaustive matchesSebastian Toh-1/+1
2023-08-28Add note when matching on nested non-exhaustive enumsSebastian Toh-1/+2
2023-08-16Auto merge of #114847 - nikic:update-llvm-12, r=cuviperbors-0/+39
Update LLVM submodule Merge the current release/17.x branch. Fixes #114691. Fixes #114312. The test for the latter is taken from #114726.
2023-08-15Add test for #114691Nikita Popov-0/+39
2023-08-14Point at return type when it influences non-first `match` armEsteban Küber-0/+33
When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-1/+1
2023-06-28remove FIXME and add testJames Dietz-0/+12
2023-06-15add testJames Dietz-0/+11