about summary refs log tree commit diff
path: root/tests/ui/match
AgeCommit message (Collapse)AuthorLines
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
2023-05-31Only rewrite valtree-constants to patterns and keep other constants opaqueOli Scherer-2/+2
2023-04-30Remove wrong assertion.Camille GILLOT-0/+10
2023-04-15Add some reasons why tests are ignored.Eric Huss-2/+2
2023-04-03Perform match checking on THIR.Camille GILLOT-27/+6
2023-02-22diagnostics: update test cases to refer to assoc fn with `self` as methodMichael Howell-2/+2
2023-01-30Modify primary span label for E0308Esteban Küber-7/+7
The previous output was unintuitive to users.
2023-01-17Account for method call and indexing when looking for inner-most path in ↵Esteban Küber-0/+1
expression
2023-01-11Move /src/test to /testsAlbert Larsan-0/+1848