Skip to content

Commit f82adf5

Browse files
committed
Add test of incompatible match arm types with multiline arm
1 parent a9cd294 commit f82adf5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/test/ui/match/match-incompat-type-semi.rs

+10
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@ fn main() {
3939
None => { //~ ERROR incompatible types
4040
},
4141
};
42+
43+
let _ = match Some(42) {
44+
Some(x) => "rust-lang.org"
45+
.chars()
46+
.skip(1)
47+
.chain(Some(x as u8 as char))
48+
.take(10)
49+
.any(char::is_alphanumeric),
50+
None => {} //~ ERROR incompatible types
51+
};
4252
}

src/test/ui/match/match-incompat-type-semi.stderr

+19-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ LL | || },
6969
LL | | };
7070
| |_____- `match` arms have incompatible types
7171

72-
error: aborting due to 4 previous errors
72+
error[E0308]: `match` arms have incompatible types
73+
--> $DIR/match-incompat-type-semi.rs:50:17
74+
|
75+
LL | let _ = match Some(42) {
76+
| _____________-
77+
LL | | Some(x) => "rust-lang.org"
78+
| |____________________-
79+
LL | || .chars()
80+
LL | || .skip(1)
81+
LL | || .chain(Some(x as u8 as char))
82+
LL | || .take(10)
83+
LL | || .any(char::is_alphanumeric),
84+
| ||_______________________________________- this is found to be of type `bool`
85+
LL | | None => {}
86+
| | ^^ expected `bool`, found `()`
87+
LL | | };
88+
| |_____- `match` arms have incompatible types
89+
90+
error: aborting due to 5 previous errors
7391

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

0 commit comments

Comments
 (0)