You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When returning the result of a match expression with incompatible arms, rust gives a rather obscure error message:
fnmain(){is_one(1)}fnis_one(a:u8){match a {1 => true,
_ => panic!("It's not one!"),}}
<anon>:6:5: 9:6 error: match arms have incompatible types:
expected `bool`,
found `()`
(expected bool,
found ()) [E0308]
<anon>:6 match a {
<anon>:7 1 => true,
<anon>:8 _ => panic!("It's not one!"),
<anon>:9 }
<anon>:8:14: 8:38 note: match arm with an incompatible type
<anon>:8 _ => panic!("It's not one!"),
^~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
playpen: application terminated with error code 101
Program ended.
This is likely to be because panic! takes on the return type of the function, which is (), and than complains that it doesn't match the first arm's return type. This error message makes sense, but left me quite puzzled figuring out what was wrong.
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue! This is essentially #24157 so I'm going to close it as such. The test case is sufficiently different, though, that I'll include it in the other issue too.
When returning the result of a match expression with incompatible arms, rust gives a rather obscure error message:
http://is.gd/J3qEpq
This is likely to be because panic! takes on the return type of the function, which is (), and than complains that it doesn't match the first arm's return type. This error message makes sense, but left me quite puzzled figuring out what was wrong.
The text was updated successfully, but these errors were encountered: