diff options
| author | David Tolnay <dtolnay@gmail.com> | 2020-10-22 16:08:26 -0700 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2020-10-22 16:11:57 -0700 |
| commit | f82adf5bdba6e2a9fe4a42c9d260f20b60b33960 (patch) | |
| tree | d2e21c2f76ff57f988bd5e24464fe56c194be6b6 | |
| parent | a9cd294cf2775441e713c7ee2918b728733b99f5 (diff) | |
| download | rust-f82adf5bdba6e2a9fe4a42c9d260f20b60b33960.tar.gz rust-f82adf5bdba6e2a9fe4a42c9d260f20b60b33960.zip | |
Add test of incompatible match arm types with multiline arm
| -rw-r--r-- | src/test/ui/match/match-incompat-type-semi.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/match/match-incompat-type-semi.stderr | 20 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/test/ui/match/match-incompat-type-semi.rs b/src/test/ui/match/match-incompat-type-semi.rs index 9ab40fa3cce..37f6beabd33 100644 --- a/src/test/ui/match/match-incompat-type-semi.rs +++ b/src/test/ui/match/match-incompat-type-semi.rs @@ -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 + }; } diff --git a/src/test/ui/match/match-incompat-type-semi.stderr b/src/test/ui/match/match-incompat-type-semi.stderr index 701f15fdc4b..1a2dbbcc29f 100644 --- a/src/test/ui/match/match-incompat-type-semi.stderr +++ b/src/test/ui/match/match-incompat-type-semi.stderr @@ -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`. |
