Skip to content

Commit b1de8f1

Browse files
committed
check_pat_tuple: use pattern_cause
1 parent e9f6bb7 commit b1de8f1

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

src/librustc_typeck/check/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
918918
});
919919
let element_tys = tcx.mk_substs(element_tys_iter);
920920
let pat_ty = tcx.mk_ty(ty::Tuple(element_tys));
921-
if let Some(mut err) = self.demand_eqtype_diag(span, expected, pat_ty) {
921+
if let Some(mut err) = self.demand_eqtype_pat_diag(span, expected, pat_ty, ti) {
922922
err.emit();
923923
// Walk subpatterns with an expected type of `err` in this case to silence
924924
// further errors being emitted when using the bindings. #50333

src/test/ui/elide-errors-on-mismatched-tuple.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
22
--> $DIR/elide-errors-on-mismatched-tuple.rs:14:9
33
|
44
LL | let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
5-
| ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
5+
| ^^^^^^^^^ -------------------- this expression has type `(A, A)`
6+
| |
7+
| expected a tuple with 2 elements, found one with 3 elements
68
|
79
= note: expected tuple `(A, A)`
810
found tuple `(_, _, _)`

src/test/ui/issues/issue-5100.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ LL | A::B => (),
1212
error[E0308]: mismatched types
1313
--> $DIR/issue-5100.rs:17:9
1414
|
15+
LL | match (true, false) {
16+
| ------------- this expression has type `(bool, bool)`
1517
LL | (true, false, false) => ()
1618
| ^^^^^^^^^^^^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
1719
|
@@ -21,6 +23,8 @@ LL | (true, false, false) => ()
2123
error[E0308]: mismatched types
2224
--> $DIR/issue-5100.rs:25:9
2325
|
26+
LL | match (true, false) {
27+
| ------------- this expression has type `(bool, bool)`
2428
LL | (true, false, false) => ()
2529
| ^^^^^^^^^^^^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
2630
|

src/test/ui/pattern/pat-tuple-bad-type.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ LL | (..) => {}
1212
error[E0308]: mismatched types
1313
--> $DIR/pat-tuple-bad-type.rs:10:9
1414
|
15+
LL | match 0u8 {
16+
| --- this expression has type `u8`
1517
LL | (..) => {}
1618
| ^^^^ expected `u8`, found `()`
1719

src/test/ui/pattern/pat-tuple-overfield.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
error[E0308]: mismatched types
22
--> $DIR/pat-tuple-overfield.rs:5:9
33
|
4+
LL | match (1, 2, 3) {
5+
| --------- this expression has type `({integer}, {integer}, {integer})`
46
LL | (1, 2, 3, 4) => {}
57
| ^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
68
|
@@ -10,6 +12,9 @@ LL | (1, 2, 3, 4) => {}
1012
error[E0308]: mismatched types
1113
--> $DIR/pat-tuple-overfield.rs:6:9
1214
|
15+
LL | match (1, 2, 3) {
16+
| --------- this expression has type `({integer}, {integer}, {integer})`
17+
LL | (1, 2, 3, 4) => {}
1318
LL | (1, 2, .., 3, 4) => {}
1419
| ^^^^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
1520
|

src/test/ui/suppressed-error.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
22
--> $DIR/suppressed-error.rs:2:9
33
|
44
LL | let (x, y) = ();
5-
| ^^^^^^ expected `()`, found tuple
5+
| ^^^^^^ -- this expression has type `()`
6+
| |
7+
| expected `()`, found tuple
68
|
79
= note: expected unit type `()`
810
found tuple `(_, _)`

0 commit comments

Comments
 (0)