Skip to content

Commit c430d74

Browse files
committed
Add match test cases
1 parent dd870d7 commit c430d74

2 files changed

+76
-1
lines changed

src/test/ui/point-to-type-err-cause-on-impl-trait-return.rs

+29
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,33 @@ fn qux() -> impl std::fmt::Display {
3333
}
3434
}
3535

36+
fn bat() -> impl std::fmt::Display {
37+
match 13 {
38+
0 => return 0i32,
39+
_ => 1u32,
40+
//~^ ERROR mismatched types
41+
}
42+
}
43+
44+
fn can() -> impl std::fmt::Display {
45+
match 13 {
46+
//~^ ERROR mismatched types
47+
0 => return 0i32,
48+
1 => 1u32,
49+
_ => 2u32,
50+
}
51+
}
52+
53+
fn cat() -> impl std::fmt::Display {
54+
match 13 {
55+
0 => {
56+
return 0i32;
57+
}
58+
_ => {
59+
1u32
60+
//~^ ERROR mismatched types
61+
}
62+
}
63+
}
64+
3665
fn main() {}

src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr

+47-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,52 @@ LL | | }
5959
= note: expected type `i32`
6060
found type `u32`
6161

62-
error: aborting due to 4 previous errors
62+
error[E0308]: mismatched types
63+
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:39:14
64+
|
65+
LL | fn bat() -> impl std::fmt::Display {
66+
| ---------------------- expected because this return type...
67+
LL | match 13 {
68+
LL | 0 => return 0i32,
69+
| ---- ...is found to be `i32` here
70+
LL | _ => 1u32,
71+
| ^^^^ expected i32, found u32
72+
|
73+
= note: expected type `i32`
74+
found type `u32`
75+
76+
error[E0308]: mismatched types
77+
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:45:5
78+
|
79+
LL | fn can() -> impl std::fmt::Display {
80+
| ---------------------- expected because this return type...
81+
LL | / match 13 {
82+
LL | |
83+
LL | | 0 => return 0i32,
84+
| | ---- ...is found to be `i32` here
85+
LL | | 1 => 1u32,
86+
LL | | _ => 2u32,
87+
LL | | }
88+
| |_____^ expected i32, found u32
89+
|
90+
= note: expected type `i32`
91+
found type `u32`
92+
93+
error[E0308]: mismatched types
94+
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:59:13
95+
|
96+
LL | fn cat() -> impl std::fmt::Display {
97+
| ---------------------- expected because this return type...
98+
...
99+
LL | return 0i32;
100+
| ---- ...is found to be `i32` here
101+
...
102+
LL | 1u32
103+
| ^^^^ expected i32, found u32
104+
|
105+
= note: expected type `i32`
106+
found type `u32`
107+
108+
error: aborting due to 7 previous errors
63109

64110
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)