about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-02-25 05:46:58 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-02-25 05:46:58 +0100
commitb1de8f16ca6a4715fcdc3720c76d8416e3d6315d (patch)
tree72049ed749d96f4ee5fded5a368b9b7ccb4ff7cd
parente9f6bb7f79ef68859cc5c7641dcc8a399e9e9c46 (diff)
check_pat_tuple: use pattern_cause
-rw-r--r--src/librustc_typeck/check/pat.rs2
-rw-r--r--src/test/ui/elide-errors-on-mismatched-tuple.stderr4
-rw-r--r--src/test/ui/issues/issue-5100.stderr4
-rw-r--r--src/test/ui/pattern/pat-tuple-bad-type.stderr2
-rw-r--r--src/test/ui/pattern/pat-tuple-overfield.stderr5
-rw-r--r--src/test/ui/suppressed-error.stderr4
6 files changed, 18 insertions, 3 deletions
diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs
index ef80803adde..da78667160e 100644
--- a/src/librustc_typeck/check/pat.rs
+++ b/src/librustc_typeck/check/pat.rs
@@ -918,7 +918,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         });
         let element_tys = tcx.mk_substs(element_tys_iter);
         let pat_ty = tcx.mk_ty(ty::Tuple(element_tys));
-        if let Some(mut err) = self.demand_eqtype_diag(span, expected, pat_ty) {
+        if let Some(mut err) = self.demand_eqtype_pat_diag(span, expected, pat_ty, ti) {
             err.emit();
             // Walk subpatterns with an expected type of `err` in this case to silence
             // further errors being emitted when using the bindings. #50333
diff --git a/src/test/ui/elide-errors-on-mismatched-tuple.stderr b/src/test/ui/elide-errors-on-mismatched-tuple.stderr
index 122c71bebc4..e0537ff6faa 100644
--- a/src/test/ui/elide-errors-on-mismatched-tuple.stderr
+++ b/src/test/ui/elide-errors-on-mismatched-tuple.stderr
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
   --> $DIR/elide-errors-on-mismatched-tuple.rs:14:9
    |
 LL |     let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
-   |         ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
+   |         ^^^^^^^^^   -------------------- this expression has type `(A, A)`
+   |         |
+   |         expected a tuple with 2 elements, found one with 3 elements
    |
    = note: expected tuple `(A, A)`
               found tuple `(_, _, _)`
diff --git a/src/test/ui/issues/issue-5100.stderr b/src/test/ui/issues/issue-5100.stderr
index 5fc0ff575d6..070c09d745b 100644
--- a/src/test/ui/issues/issue-5100.stderr
+++ b/src/test/ui/issues/issue-5100.stderr
@@ -12,6 +12,8 @@ LL |         A::B => (),
 error[E0308]: mismatched types
   --> $DIR/issue-5100.rs:17:9
    |
+LL |     match (true, false) {
+   |           ------------- this expression has type `(bool, bool)`
 LL |         (true, false, false) => ()
    |         ^^^^^^^^^^^^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
    |
@@ -21,6 +23,8 @@ LL |         (true, false, false) => ()
 error[E0308]: mismatched types
   --> $DIR/issue-5100.rs:25:9
    |
+LL |     match (true, false) {
+   |           ------------- this expression has type `(bool, bool)`
 LL |         (true, false, false) => ()
    |         ^^^^^^^^^^^^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
    |
diff --git a/src/test/ui/pattern/pat-tuple-bad-type.stderr b/src/test/ui/pattern/pat-tuple-bad-type.stderr
index 95cca38f7de..598b6a3794e 100644
--- a/src/test/ui/pattern/pat-tuple-bad-type.stderr
+++ b/src/test/ui/pattern/pat-tuple-bad-type.stderr
@@ -12,6 +12,8 @@ LL |         (..) => {}
 error[E0308]: mismatched types
   --> $DIR/pat-tuple-bad-type.rs:10:9
    |
+LL |     match 0u8 {
+   |           --- this expression has type `u8`
 LL |         (..) => {}
    |         ^^^^ expected `u8`, found `()`
 
diff --git a/src/test/ui/pattern/pat-tuple-overfield.stderr b/src/test/ui/pattern/pat-tuple-overfield.stderr
index 25d02b8627c..45b6fd1b4d4 100644
--- a/src/test/ui/pattern/pat-tuple-overfield.stderr
+++ b/src/test/ui/pattern/pat-tuple-overfield.stderr
@@ -1,6 +1,8 @@
 error[E0308]: mismatched types
   --> $DIR/pat-tuple-overfield.rs:5:9
    |
+LL |     match (1, 2, 3) {
+   |           --------- this expression has type `({integer}, {integer}, {integer})`
 LL |         (1, 2, 3, 4) => {}
    |         ^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
    |
@@ -10,6 +12,9 @@ LL |         (1, 2, 3, 4) => {}
 error[E0308]: mismatched types
   --> $DIR/pat-tuple-overfield.rs:6:9
    |
+LL |     match (1, 2, 3) {
+   |           --------- this expression has type `({integer}, {integer}, {integer})`
+LL |         (1, 2, 3, 4) => {}
 LL |         (1, 2, .., 3, 4) => {}
    |         ^^^^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 4 elements
    |
diff --git a/src/test/ui/suppressed-error.stderr b/src/test/ui/suppressed-error.stderr
index 846cd2adcd8..c2874ae9a14 100644
--- a/src/test/ui/suppressed-error.stderr
+++ b/src/test/ui/suppressed-error.stderr
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
   --> $DIR/suppressed-error.rs:2:9
    |
 LL |     let (x, y) = ();
-   |         ^^^^^^ expected `()`, found tuple
+   |         ^^^^^^   -- this expression has type `()`
+   |         |
+   |         expected `()`, found tuple
    |
    = note: expected unit type `()`
                   found tuple `(_, _)`