Skip to content

Commit

Permalink
Add test of incompatible match arm types with multiline arm
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 22, 2020
1 parent a9cd294 commit f82adf5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/test/ui/match/match-incompat-type-semi.rs
Expand Up @@ -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
};
}
20 changes: 19 additions & 1 deletion src/test/ui/match/match-incompat-type-semi.stderr
Expand Up @@ -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`.

0 comments on commit f82adf5

Please sign in to comment.