Rollup merge of #69452 - Centril:typeck-pat, r=estebank
typeck: use `Pattern` obligation cause more for better diagnostics r? @estebank
This commit is contained in:
commit
a245221497
28 changed files with 284 additions and 102 deletions
|
|
@ -20,7 +20,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/destructure-trait-ref.rs:32:10
|
||||
|
|
||||
LL | let &&x = &1isize as &dyn T;
|
||||
| ^^
|
||||
| ^^ ----------------- this expression has type `&dyn T`
|
||||
| |
|
||||
| expected trait object `dyn T`, found reference
|
||||
| help: you can probably remove the explicit borrow: `x`
|
||||
|
|
@ -32,7 +32,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/destructure-trait-ref.rs:36:11
|
||||
|
|
||||
LL | let &&&x = &(&1isize as &dyn T);
|
||||
| ^^
|
||||
| ^^ -------------------- this expression has type `&&dyn T`
|
||||
| |
|
||||
| expected trait object `dyn T`, found reference
|
||||
| help: you can probably remove the explicit borrow: `x`
|
||||
|
|
|
|||
|
|
@ -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,9 @@ LL | Some(k) => match k {
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-12552.rs:9:5
|
||||
|
|
||||
LL | match t {
|
||||
| - this expression has type `std::result::Result<_, {integer}>`
|
||||
...
|
||||
LL | None => ()
|
||||
| ^^^^ expected enum `std::result::Result`, found enum `std::option::Option`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-37026.rs:6:9
|
||||
|
|
||||
LL | let empty_struct::XEmpty2 = ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `empty_struct::XEmpty2`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ -- this expression has type `()`
|
||||
| |
|
||||
| expected `()`, found struct `empty_struct::XEmpty2`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-37026.rs:7:9
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-5100.rs:8:9
|
||||
|
|
||||
LL | match (true, false) {
|
||||
| ------------- this expression has type `(bool, bool)`
|
||||
LL | A::B => (),
|
||||
| ^^^^ expected tuple, found enum `A`
|
||||
|
|
||||
|
|
@ -10,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
|
||||
|
|
||||
|
|
@ -19,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
|
||||
|
|
||||
|
|
@ -39,6 +45,8 @@ LL | box (true, false) => ()
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-5100.rs:40:9
|
||||
|
|
||||
LL | match (true, false) {
|
||||
| ------------- this expression has type `(bool, bool)`
|
||||
LL | &(true, false) => ()
|
||||
| ^^^^^^^^^^^^^^ expected tuple, found reference
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-7867.rs:7:9
|
||||
|
|
||||
LL | match (true, false) {
|
||||
| ------------- this expression has type `(bool, bool)`
|
||||
LL | A::B => (),
|
||||
| ^^^^ expected tuple, found enum `A`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/match-ill-type2.rs:4:9
|
||||
|
|
||||
LL | match 1i32 {
|
||||
| ---- this expression has type `i32`
|
||||
LL | 1i32 => 1,
|
||||
LL | 2u32 => 1,
|
||||
| ^^^^ expected `i32`, found `u32`
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/match-tag-nullary.rs:4:40
|
||||
|
|
||||
LL | fn main() { let x: A = A::A; match x { B::B => { } } }
|
||||
| ^^^^ expected enum `A`, found enum `B`
|
||||
| - ^^^^ expected enum `A`, found enum `B`
|
||||
| |
|
||||
| this expression has type `A`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,11 @@ error[E0308]: mismatched types
|
|||
LL | match x {
|
||||
| - this expression has type `({integer}, {integer})`
|
||||
LL | (0, ref y) | (y, 0) => {}
|
||||
| ^ expected `&{integer}`, found integer
|
||||
| ----- ^ expected `&{integer}`, found integer
|
||||
| |
|
||||
| first introduced with type `&{integer}` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ error[E0308]: mismatched types
|
|||
|
|
||||
LL | fn foo(&foo: Foo) {
|
||||
| ^^^^------
|
||||
| |
|
||||
| | |
|
||||
| | expected due to this
|
||||
| expected struct `Foo`, found reference
|
||||
| help: did you mean `foo`: `&Foo`
|
||||
|
|
||||
|
|
@ -14,7 +15,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-38371.rs:18:9
|
||||
|
|
||||
LL | fn agh(&&bar: &u32) {
|
||||
| ^^^^
|
||||
| ^^^^ ---- expected due to this
|
||||
| |
|
||||
| expected `u32`, found reference
|
||||
| help: you can probably remove the explicit borrow: `bar`
|
||||
|
|
@ -26,7 +27,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-38371.rs:21:8
|
||||
|
|
||||
LL | fn bgh(&&bar: u32) {
|
||||
| ^^^^^ expected `u32`, found reference
|
||||
| ^^^^^ --- expected due to this
|
||||
| |
|
||||
| expected `u32`, found reference
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found reference `&_`
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ error[E0308]: mismatched types
|
|||
|
|
||||
LL | let &_
|
||||
| ^^ types differ in mutability
|
||||
...
|
||||
LL | = foo;
|
||||
| --- this expression has type `&mut {integer}`
|
||||
|
|
||||
= note: expected mutable reference `&mut {integer}`
|
||||
found reference `&_`
|
||||
|
|
@ -12,6 +15,9 @@ error[E0308]: mismatched types
|
|||
|
|
||||
LL | let &mut _
|
||||
| ^^^^^^ types differ in mutability
|
||||
...
|
||||
LL | = bar;
|
||||
| --- this expression has type `&{integer}`
|
||||
|
|
||||
= note: expected reference `&{integer}`
|
||||
found mutable reference `&mut _`
|
||||
|
|
|
|||
|
|
@ -86,12 +86,14 @@ error[E0308]: mismatched types
|
|||
--> $DIR/already-bound-name.rs:32:31
|
||||
|
|
||||
LL | let B(A(a, _) | B(a)) | A(a, A(a, _) | B(a)) = B(B(1));
|
||||
| ^ ------- this expression has type `E<E<{integer}>>`
|
||||
| |
|
||||
| expected integer, found enum `E`
|
||||
| - ^ ------- this expression has type `E<E<{integer}>>`
|
||||
| | |
|
||||
| | expected integer, found enum `E`
|
||||
| first introduced with type `{integer}` here
|
||||
|
|
||||
= note: expected type `{integer}`
|
||||
found type `E<{integer}>`
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -52,23 +52,27 @@ error[E0308]: mismatched types
|
|||
--> $DIR/inconsistent-modes.rs:11:25
|
||||
|
|
||||
LL | let Ok(ref a) | Err(ref mut a): Result<&u8, &mut u8> = Ok(&0);
|
||||
| ^^^^^^^^^ -------------------- expected due to this
|
||||
| |
|
||||
| types differ in mutability
|
||||
| ----- ^^^^^^^^^ -------------------- expected due to this
|
||||
| | |
|
||||
| | types differ in mutability
|
||||
| first introduced with type `&&u8` here
|
||||
|
|
||||
= note: expected type `&&u8`
|
||||
found type `&mut &mut u8`
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/inconsistent-modes.rs:14:31
|
||||
|
|
||||
LL | let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0));
|
||||
| ^^^^^^^^^ ----------- this expression has type `std::result::Result<({integer}, &{integer}), (_, _)>`
|
||||
| |
|
||||
| types differ in mutability
|
||||
| ----- ^^^^^^^^^ ----------- this expression has type `std::result::Result<({integer}, &{integer}), (_, _)>`
|
||||
| | |
|
||||
| | types differ in mutability
|
||||
| first introduced with type `&{integer}` here
|
||||
|
|
||||
= note: expected type `&{integer}`
|
||||
found type `&mut _`
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,11 @@ error[E0308]: mismatched types
|
|||
LL | match Blah::A(1, 1, 2) {
|
||||
| ---------------- this expression has type `main::Blah`
|
||||
LL | Blah::A(_, x, y) | Blah::B(x, y) => {}
|
||||
| ^ expected `usize`, found `isize`
|
||||
| - ^ expected `usize`, found `isize`
|
||||
| |
|
||||
| first introduced with type `usize` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:17:44
|
||||
|
|
@ -12,7 +16,11 @@ error[E0308]: mismatched types
|
|||
LL | match Some(Blah::A(1, 1, 2)) {
|
||||
| ---------------------- this expression has type `std::option::Option<main::Blah>`
|
||||
LL | Some(Blah::A(_, x, y) | Blah::B(x, y)) => {}
|
||||
| ^ expected `usize`, found `isize`
|
||||
| - ^ expected `usize`, found `isize`
|
||||
| |
|
||||
| first introduced with type `usize` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:21:19
|
||||
|
|
@ -20,7 +28,11 @@ error[E0308]: mismatched types
|
|||
LL | match (0u8, 1u16) {
|
||||
| ----------- this expression has type `(u8, u16)`
|
||||
LL | (x, y) | (y, x) => {}
|
||||
| ^ expected `u16`, found `u8`
|
||||
| - ^ expected `u16`, found `u8`
|
||||
| |
|
||||
| first introduced with type `u16` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:21:22
|
||||
|
|
@ -28,7 +40,11 @@ error[E0308]: mismatched types
|
|||
LL | match (0u8, 1u16) {
|
||||
| ----------- this expression has type `(u8, u16)`
|
||||
LL | (x, y) | (y, x) => {}
|
||||
| ^ expected `u8`, found `u16`
|
||||
| - ^ expected `u8`, found `u16`
|
||||
| |
|
||||
| first introduced with type `u8` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:26:41
|
||||
|
|
@ -36,7 +52,11 @@ error[E0308]: mismatched types
|
|||
LL | match Some((0u8, Some((1u16, 2u32)))) {
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
|
||||
| ^ expected `u16`, found `u8`
|
||||
| - ^ expected `u16`, found `u8`
|
||||
| |
|
||||
| first introduced with type `u16` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:26:50
|
||||
|
|
@ -44,7 +64,11 @@ error[E0308]: mismatched types
|
|||
LL | match Some((0u8, Some((1u16, 2u32)))) {
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
|
||||
| ^ expected `u8`, found `u16`
|
||||
| - ^ expected `u8`, found `u16`
|
||||
| |
|
||||
| first introduced with type `u8` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:26:59
|
||||
|
|
@ -52,7 +76,11 @@ error[E0308]: mismatched types
|
|||
LL | match Some((0u8, Some((1u16, 2u32)))) {
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
|
||||
| ^ expected `u32`, found `u16`
|
||||
| - ^ expected `u32`, found `u16`
|
||||
| |
|
||||
| first introduced with type `u32` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:26:62
|
||||
|
|
@ -60,123 +88,169 @@ error[E0308]: mismatched types
|
|||
LL | match Some((0u8, Some((1u16, 2u32)))) {
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
LL | Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x)))) => {}
|
||||
| ^ expected `u8`, found `u32`
|
||||
| - first introduced with type `u8` here ^ expected `u8`, found `u32`
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:34:42
|
||||
|
|
||||
LL | if let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2) {
|
||||
| ^ ---------------- this expression has type `main::Blah`
|
||||
| |
|
||||
| expected `usize`, found `isize`
|
||||
| - ^ ---------------- this expression has type `main::Blah`
|
||||
| | |
|
||||
| | expected `usize`, found `isize`
|
||||
| first introduced with type `usize` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:38:47
|
||||
|
|
||||
LL | if let Some(Blah::A(_, x, y) | Blah::B(x, y)) = Some(Blah::A(1, 1, 2)) {
|
||||
| ^ ---------------------- this expression has type `std::option::Option<main::Blah>`
|
||||
| |
|
||||
| expected `usize`, found `isize`
|
||||
| - ^ ---------------------- this expression has type `std::option::Option<main::Blah>`
|
||||
| | |
|
||||
| | expected `usize`, found `isize`
|
||||
| first introduced with type `usize` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:42:22
|
||||
|
|
||||
LL | if let (x, y) | (y, x) = (0u8, 1u16) {
|
||||
| ^ ----------- this expression has type `(u8, u16)`
|
||||
| |
|
||||
| expected `u16`, found `u8`
|
||||
| - ^ ----------- this expression has type `(u8, u16)`
|
||||
| | |
|
||||
| | expected `u16`, found `u8`
|
||||
| first introduced with type `u16` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:42:25
|
||||
|
|
||||
LL | if let (x, y) | (y, x) = (0u8, 1u16) {
|
||||
| ^ ----------- this expression has type `(u8, u16)`
|
||||
| |
|
||||
| expected `u8`, found `u16`
|
||||
| - ^ ----------- this expression has type `(u8, u16)`
|
||||
| | |
|
||||
| | expected `u8`, found `u16`
|
||||
| first introduced with type `u8` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:47:44
|
||||
|
|
||||
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
|
||||
| ^ expected `u16`, found `u8`
|
||||
| - ^ expected `u16`, found `u8`
|
||||
| |
|
||||
| first introduced with type `u16` here
|
||||
...
|
||||
LL | = Some((0u8, Some((1u16, 2u32))))
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:47:53
|
||||
|
|
||||
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
|
||||
| ^ expected `u8`, found `u16`
|
||||
| - ^ expected `u8`, found `u16`
|
||||
| |
|
||||
| first introduced with type `u8` here
|
||||
...
|
||||
LL | = Some((0u8, Some((1u16, 2u32))))
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:47:62
|
||||
|
|
||||
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
|
||||
| ^ expected `u32`, found `u16`
|
||||
| - ^ expected `u32`, found `u16`
|
||||
| |
|
||||
| first introduced with type `u32` here
|
||||
...
|
||||
LL | = Some((0u8, Some((1u16, 2u32))))
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:47:65
|
||||
|
|
||||
LL | if let Some((x, Some((y, z)))) | Some((y, Some((x, z) | (z, x))))
|
||||
| ^ expected `u8`, found `u32`
|
||||
| - first introduced with type `u8` here ^ expected `u8`, found `u32`
|
||||
...
|
||||
LL | = Some((0u8, Some((1u16, 2u32))))
|
||||
| ------------------------------- this expression has type `std::option::Option<(u8, std::option::Option<(u16, u32)>)>`
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:55:39
|
||||
|
|
||||
LL | let Blah::A(_, x, y) | Blah::B(x, y) = Blah::A(1, 1, 2);
|
||||
| ^ ---------------- this expression has type `main::Blah`
|
||||
| |
|
||||
| expected `usize`, found `isize`
|
||||
| - ^ ---------------- this expression has type `main::Blah`
|
||||
| | |
|
||||
| | expected `usize`, found `isize`
|
||||
| first introduced with type `usize` here
|
||||
|
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:58:19
|
||||
|
|
||||
LL | let (x, y) | (y, x) = (0u8, 1u16);
|
||||
| ^ ----------- this expression has type `(u8, u16)`
|
||||
| |
|
||||
| expected `u16`, found `u8`
|
||||
| - ^ ----------- this expression has type `(u8, u16)`
|
||||
| | |
|
||||
| | expected `u16`, found `u8`
|
||||
| first introduced with type `u16` here
|
||||
|
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:58:22
|
||||
|
|
||||
LL | let (x, y) | (y, x) = (0u8, 1u16);
|
||||
| ^ ----------- this expression has type `(u8, u16)`
|
||||
| |
|
||||
| expected `u8`, found `u16`
|
||||
| - ^ ----------- this expression has type `(u8, u16)`
|
||||
| | |
|
||||
| | expected `u8`, found `u16`
|
||||
| first introduced with type `u8` here
|
||||
|
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:62:42
|
||||
|
|
||||
LL | fn f1((Blah::A(_, x, y) | Blah::B(x, y)): Blah) {}
|
||||
| ^ ---- expected due to this
|
||||
| |
|
||||
| expected `usize`, found `isize`
|
||||
| - ^ ---- expected due to this
|
||||
| | |
|
||||
| | expected `usize`, found `isize`
|
||||
| first introduced with type `usize` here
|
||||
|
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:65:22
|
||||
|
|
||||
LL | fn f2(((x, y) | (y, x)): (u8, u16)) {}
|
||||
| ^ --------- expected due to this
|
||||
| |
|
||||
| expected `u16`, found `u8`
|
||||
| - ^ --------- expected due to this
|
||||
| | |
|
||||
| | expected `u16`, found `u8`
|
||||
| first introduced with type `u16` here
|
||||
|
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/or-patterns-binding-type-mismatch.rs:65:25
|
||||
|
|
||||
LL | fn f2(((x, y) | (y, x)): (u8, u16)) {}
|
||||
| ^ --------- expected due to this
|
||||
| |
|
||||
| expected `u8`, found `u16`
|
||||
| - ^ --------- expected due to this
|
||||
| | |
|
||||
| | expected `u8`, found `u16`
|
||||
| first introduced with type `u8` here
|
||||
|
|
||||
= note: a binding must have the same type in all alternatives
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/pattern-ident-path-generics.rs:3:9
|
||||
|
|
||||
LL | match Some("foo") {
|
||||
| ----------- this expression has type `std::option::Option<&str>`
|
||||
LL | None::<isize> => {}
|
||||
| ^^^^^^^^^^^^^ expected `&str`, found `isize`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/name-clash-nullary.rs:2:7
|
||||
|
|
||||
LL | let None: isize = 42;
|
||||
| ^^^^ expected `isize`, found enum `std::option::Option`
|
||||
| ^^^^ ----- expected due to this
|
||||
| |
|
||||
| expected `isize`, found enum `std::option::Option`
|
||||
|
|
||||
= note: expected type `isize`
|
||||
found enum `std::option::Option<_>`
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@ error[E0308]: mismatched types
|
|||
LL | match x {
|
||||
| - this expression has type `Opts`
|
||||
LL | Opts::A(ref i) | Opts::B(i) => {}
|
||||
| ^ expected `&isize`, found `isize`
|
||||
| ----- ^ expected `&isize`, found `isize`
|
||||
| |
|
||||
| first introduced with type `&isize` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/resolve-inconsistent-binding-mode.rs:16:32
|
||||
|
|
@ -34,7 +38,11 @@ error[E0308]: mismatched types
|
|||
LL | match x {
|
||||
| - this expression has type `Opts`
|
||||
LL | Opts::A(ref i) | Opts::B(i) => {}
|
||||
| ^ expected `&isize`, found `isize`
|
||||
| ----- ^ expected `&isize`, found `isize`
|
||||
| |
|
||||
| first introduced with type `&isize` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/resolve-inconsistent-binding-mode.rs:25:36
|
||||
|
|
@ -42,10 +50,13 @@ error[E0308]: mismatched types
|
|||
LL | match x {
|
||||
| - this expression has type `Opts`
|
||||
LL | Opts::A(ref mut i) | Opts::B(ref i) => {}
|
||||
| ^^^^^ types differ in mutability
|
||||
| --------- ^^^^^ types differ in mutability
|
||||
| |
|
||||
| first introduced with type `&mut isize` here
|
||||
|
|
||||
= note: expected type `&mut isize`
|
||||
found type `&isize`
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,11 @@ error[E0308]: mismatched types
|
|||
LL | match x {
|
||||
| - this expression has type `(E, E)`
|
||||
LL | (A, B) | (ref B, c) | (c, A) => ()
|
||||
| ^^^^^ expected enum `E`, found `&E`
|
||||
| - ^^^^^ expected enum `E`, found `&E`
|
||||
| |
|
||||
| first introduced with type `E` here
|
||||
|
|
||||
= note: in the same arm, a binding must have the same type in all alternatives
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/const.rs:14:9
|
||||
|
|
||||
LL | match &f {
|
||||
| -- this expression has type `&Foo`
|
||||
LL | FOO => {},
|
||||
| ^^^ expected `&Foo`, found struct `Foo`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/lit.rs:7:13
|
||||
|
|
||||
LL | match &s {
|
||||
| -- this expression has type `&&str`
|
||||
LL | "abc" => true,
|
||||
| ^^^^^ expected `&str`, found `str`
|
||||
|
|
||||
|
|
@ -10,6 +12,8 @@ LL | "abc" => true,
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/lit.rs:16:9
|
||||
|
|
||||
LL | match &s {
|
||||
| -- this expression has type `&&[u8]`
|
||||
LL | b"abc" => true,
|
||||
| ^^^^^^ expected `&[u8]`, found array `[u8; 3]`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/slightly-nice-generic-literal-messages.rs:7:9
|
||||
|
|
||||
LL | match Foo(1.1, marker::PhantomData) {
|
||||
| ----------------------------- this expression has type `Foo<{float}, _>`
|
||||
LL | 1 => {}
|
||||
| ^ expected struct `Foo`, found integer
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/match-ergonomics.rs:4:10
|
||||
|
|
||||
LL | match &x[..] {
|
||||
| ------ this expression has type `&[i32]`
|
||||
LL | [&v] => {},
|
||||
| ^^
|
||||
| |
|
||||
|
|
@ -25,6 +27,8 @@ LL | [v] => {},
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/match-ergonomics.rs:29:9
|
||||
|
|
||||
LL | match y {
|
||||
| - this expression has type `i32`
|
||||
LL | &v => {},
|
||||
| ^^
|
||||
| |
|
||||
|
|
@ -38,7 +42,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/match-ergonomics.rs:40:13
|
||||
|
|
||||
LL | if let [&v] = &x[..] {}
|
||||
| ^^
|
||||
| ^^ ------ this expression has type `&[i32]`
|
||||
| |
|
||||
| expected `i32`, found reference
|
||||
| help: you can probably remove the explicit borrow: `v`
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue