Add test of incompatible match arm types with multiline arm

This commit is contained in:
David Tolnay 2020-10-22 16:08:26 -07:00
parent a9cd294cf2
commit f82adf5bdb
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 29 additions and 1 deletions

View File

@ -39,4 +39,14 @@ fn main() {
None => { //~ ERROR incompatible types
},
};
let _ = match Some(42) {
Some(x) => "rust-lang.org"
.chars()
.skip(1)
.chain(Some(x as u8 as char))
.take(10)
.any(char::is_alphanumeric),
None => {} //~ ERROR incompatible types
};
}

View File

@ -69,6 +69,24 @@ LL | || },
LL | | };
| |_____- `match` arms have incompatible types
error: aborting due to 4 previous errors
error[E0308]: `match` arms have incompatible types
--> $DIR/match-incompat-type-semi.rs:50:17
|
LL | let _ = match Some(42) {
| _____________-
LL | | Some(x) => "rust-lang.org"
| |____________________-
LL | || .chars()
LL | || .skip(1)
LL | || .chain(Some(x as u8 as char))
LL | || .take(10)
LL | || .any(char::is_alphanumeric),
| ||_______________________________________- this is found to be of type `bool`
LL | | None => {}
| | ^^ expected `bool`, found `()`
LL | | };
| |_____- `match` arms have incompatible types
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0308`.