Point at the match discriminant when arm pattern has a type mismatch
This commit is contained in:
parent
c2d381d39d
commit
a873337f21
27 changed files with 183 additions and 77 deletions
|
|
@ -12,6 +12,8 @@ LL | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13624.rs:22:9
|
||||
|
|
||||
LL | match enum_struct_variant {
|
||||
| ------------------- this match expression evaluates to `()`
|
||||
LL | a::Enum::EnumStructVariant { x, y, z } => {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/E0308-4.rs:4:9
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression evaluates to `u8`
|
||||
LL | 0u8..=3i8 => (), //~ ERROR E0308
|
||||
| ^^^^^^^^^ expected u8, found i8
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-11844.rs:6:9
|
||||
|
|
||||
LL | match a {
|
||||
| - this match expression evaluates to `std::option::Option<std::boxed::Box<{integer}>>`
|
||||
LL | Ok(a) => //~ ERROR: mismatched types
|
||||
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-12552.rs:6:5
|
||||
|
|
||||
LL | match t {
|
||||
| - this match expression evaluates to `std::result::Result<_, {integer}>`
|
||||
LL | Some(k) => match k { //~ ERROR mismatched types
|
||||
| ^^^^^^^ expected enum `std::result::Result`, found enum `std::option::Option`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13466.rs:8:9
|
||||
|
|
||||
LL | let _x: usize = match Some(1) {
|
||||
| ------- this match expression evaluates to `std::option::Option<{integer}>`
|
||||
LL | Ok(u) => u,
|
||||
| ^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
@ -10,6 +12,9 @@ LL | Ok(u) => u,
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13466.rs:14:9
|
||||
|
|
||||
LL | let _x: usize = match Some(1) {
|
||||
| ------- this match expression evaluates to `std::option::Option<{integer}>`
|
||||
...
|
||||
LL | Err(e) => panic!(e)
|
||||
| ^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-15896.rs:11:11
|
||||
|
|
||||
LL | let u = match e {
|
||||
| - this match expression evaluates to `main::R`
|
||||
LL | E::B(
|
||||
LL | Tau{t: x},
|
||||
| ^^^^^^^^^ expected enum `main::R`, found struct `main::Tau`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-16401.rs:8:9
|
||||
|
|
||||
LL | match () {
|
||||
| -- this match expression evaluates to `()`
|
||||
LL | Slice { data: data, len: len } => (),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found struct `Slice`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-3680.rs:3:9
|
||||
|
|
||||
LL | match None {
|
||||
| ---- this match expression evaluates to `std::option::Option<_>`
|
||||
LL | Err(_) => ()
|
||||
| ^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ LL | (true, false, false) => ()
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-5100.rs:33:9
|
||||
|
|
||||
LL | match (true, false) {
|
||||
| ------------- this match expression evaluates to `(bool, bool)`
|
||||
LL | box (true, false) => ()
|
||||
| ^^^^^^^^^^^^^^^^^ expected tuple, found struct `std::boxed::Box`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-5358-1.rs:6:9
|
||||
|
|
||||
LL | match S(Either::Left(5)) {
|
||||
| ------------------ this match expression evaluates to `S`
|
||||
LL | Either::Right(_) => {}
|
||||
| ^^^^^^^^^^^^^^^^ expected struct `S`, found enum `Either`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-7092.rs:6:9
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression evaluates to `Whatever`
|
||||
LL | Some(field) =>
|
||||
| ^^^^^^^^^^^ expected enum `Whatever`, found enum `std::option::Option`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ LL | 10 ..= "what" => ()
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/match-range-fail.rs:17:9
|
||||
|
|
||||
LL | match 5 {
|
||||
| - this match expression evaluates to `{integer}`
|
||||
LL | 'c' ..= 100 => { }
|
||||
| ^^^^^^^^^^^ expected integer, found char
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/match-struct.rs:6:9
|
||||
|
|
||||
LL | match (S { a: 1 }) {
|
||||
| ------------ this match expression evaluates to `S`
|
||||
LL | E::C(_) => (),
|
||||
| ^^^^^^^ expected struct `S`, found enum `E`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/match-tag-unary.rs:4:43
|
||||
|
|
||||
LL | fn main() { let x: A = A::A(0); match x { B::B(y) => { } } } //~ ERROR mismatched types
|
||||
| ^^^^^^^ expected enum `A`, found enum `B`
|
||||
| - ^^^^^^^ expected enum `A`, found enum `B`
|
||||
| |
|
||||
| this match expression evaluates to `A`
|
||||
|
|
||||
= note: expected type `A`
|
||||
found type `B`
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ LL | (0, ref y) | (y, 0) => {} //~ ERROR E0409
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/E0409.rs:5:23
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression evaluates to `_`
|
||||
LL | (0, ref y) | (y, 0) => {} //~ ERROR E0409
|
||||
| ^ expected &{integer}, found integer
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ error[E0308]: mismatched types
|
|||
--> $DIR/or-pattern-mismatch.rs:3:68
|
||||
|
|
||||
LL | fn main() { match Blah::A(1, 1, 2) { Blah::A(_, x, y) | Blah::B(x, y) => { } } }
|
||||
| ^ expected usize, found isize
|
||||
| ---------------- ^ expected usize, found isize
|
||||
| |
|
||||
| this match expression evaluates to `_`
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found type `isize`
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ LL | A::B(_, _, _) => (), //~ ERROR this pattern has 3 fields, but
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/pattern-error-continue.rs:22:9
|
||||
|
|
||||
LL | match 'c' {
|
||||
| --- this match expression evaluates to `char`
|
||||
LL | S { .. } => (),
|
||||
| ^^^^^^^^ expected char, found struct `S`
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/pattern-tyvar.rs:5:18
|
||||
|
|
||||
LL | match t {
|
||||
| - this match expression evaluates to `std::option::Option<std::vec::Vec<isize>>`
|
||||
LL | Bar::T1(_, Some::<isize>(x)) => { //~ ERROR mismatched types
|
||||
| ^^^^^^^^^^^^^^^^ expected struct `std::vec::Vec`, found isize
|
||||
|
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ LL | Opts::A(ref mut i) | Opts::B(ref i) => {}
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/resolve-inconsistent-binding-mode.rs:7:32
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression evaluates to `_`
|
||||
LL | Opts::A(ref i) | Opts::B(i) => {}
|
||||
| ^ expected &isize, found isize
|
||||
|
|
||||
|
|
@ -32,6 +34,8 @@ LL | Opts::A(ref i) | Opts::B(i) => {}
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/resolve-inconsistent-binding-mode.rs:16:32
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression evaluates to `_`
|
||||
LL | Opts::A(ref i) | Opts::B(i) => {}
|
||||
| ^ expected &isize, found isize
|
||||
|
|
||||
|
|
@ -41,6 +45,8 @@ LL | Opts::A(ref i) | Opts::B(i) => {}
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/resolve-inconsistent-binding-mode.rs:25:36
|
||||
|
|
||||
LL | match x {
|
||||
| - this match expression evaluates to `_`
|
||||
LL | Opts::A(ref mut i) | Opts::B(ref i) => {}
|
||||
| ^^^^^ types differ in mutability
|
||||
|
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ LL | PointF::<u32> { .. } => {} //~ ERROR wrong number of type arguments
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/structure-constructor-type-mismatch.rs:54:9
|
||||
|
|
||||
LL | match (Point { x: 1, y: 2 }) {
|
||||
| ---------------------- this match expression evaluates to `Point<{integer}>`
|
||||
LL | PointF::<u32> { .. } => {} //~ ERROR wrong number of type arguments
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected integer, found f32
|
||||
|
|
||||
|
|
@ -118,6 +120,8 @@ LL | PointF::<u32> { .. } => {} //~ ERROR wrong number of type arguments
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/structure-constructor-type-mismatch.rs:59:9
|
||||
|
|
||||
LL | match (Point { x: 1, y: 2 }) {
|
||||
| ---------------------- this match expression evaluates to `Point<{integer}>`
|
||||
LL | PointF { .. } => {} //~ ERROR mismatched types
|
||||
| ^^^^^^^^^^^^^ expected integer, found f32
|
||||
|
|
||||
|
|
@ -127,6 +131,8 @@ LL | PointF { .. } => {} //~ ERROR mismatched types
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/structure-constructor-type-mismatch.rs:67:9
|
||||
|
|
||||
LL | match (Pair { x: 1, y: 2 }) {
|
||||
| --------------------- this match expression evaluates to `Pair<{integer}, {integer}>`
|
||||
LL | PairF::<u32> { .. } => {} //~ ERROR mismatched types
|
||||
| ^^^^^^^^^^^^^^^^^^^ expected integer, found f32
|
||||
|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue