Add match test cases

This commit is contained in:
Esteban Küber 2019-09-02 17:37:50 -07:00
parent dd870d7422
commit c430d743e9
2 changed files with 76 additions and 1 deletions

View file

@ -33,4 +33,33 @@ fn qux() -> impl std::fmt::Display {
}
}
fn bat() -> impl std::fmt::Display {
match 13 {
0 => return 0i32,
_ => 1u32,
//~^ ERROR mismatched types
}
}
fn can() -> impl std::fmt::Display {
match 13 {
//~^ ERROR mismatched types
0 => return 0i32,
1 => 1u32,
_ => 2u32,
}
}
fn cat() -> impl std::fmt::Display {
match 13 {
0 => {
return 0i32;
}
_ => {
1u32
//~^ ERROR mismatched types
}
}
}
fn main() {}

View file

@ -59,6 +59,52 @@ LL | | }
= note: expected type `i32`
found type `u32`
error: aborting due to 4 previous errors
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:39:14
|
LL | fn bat() -> impl std::fmt::Display {
| ---------------------- expected because this return type...
LL | match 13 {
LL | 0 => return 0i32,
| ---- ...is found to be `i32` here
LL | _ => 1u32,
| ^^^^ expected i32, found u32
|
= note: expected type `i32`
found type `u32`
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:45:5
|
LL | fn can() -> impl std::fmt::Display {
| ---------------------- expected because this return type...
LL | / match 13 {
LL | |
LL | | 0 => return 0i32,
| | ---- ...is found to be `i32` here
LL | | 1 => 1u32,
LL | | _ => 2u32,
LL | | }
| |_____^ expected i32, found u32
|
= note: expected type `i32`
found type `u32`
error[E0308]: mismatched types
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:59:13
|
LL | fn cat() -> impl std::fmt::Display {
| ---------------------- expected because this return type...
...
LL | return 0i32;
| ---- ...is found to be `i32` here
...
LL | 1u32
| ^^^^ expected i32, found u32
|
= note: expected type `i32`
found type `u32`
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0308`.