mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
check_pat_tuple: use pattern_cause
This commit is contained in:
parent
e9f6bb7f79
commit
b1de8f16ca
@ -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
|
||||
|
@ -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 `(_, _, _)`
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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 `()`
|
||||
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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 `(_, _)`
|
||||
|
Loading…
Reference in New Issue
Block a user