-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Match is not smart enough to deduce the only possible catch-all type #51479
Comments
This is because That being said, for this case the idiomatic code would be
or
|
The match f2() {
Ok(value) => Ok(value as i64),
Err::<i32, String>(err) => Err::<i64, String>(err),
} Accepting fn f2<T>() -> Result<T, String> {
unimplemented!()
}
fn f1() -> Result<i64, String> {
match f2() {
Ok(value) => Ok(value as i64),
err => err,
}
} This compiles today but an implicit conversion from |
Cc #47560 |
Triage: no change Since the reason is known and is a non-bug, can we close this issue? |
@Spoonbender potentially, but I would like it if we had a structured suggestion for the presented cases, but I understand it might be too niche of a situation to make it worth it to handle it. The original request would probably be better served as a t-lang request (which I would likely expect would be considered a bad idea). Edit: let's close it, at least for now. I would like the suggestion to exist, but don't think this is necessarily the ticket for that. |
This example compiles successfully:
However, this example does not:
Obviously,
err
can only be ofErr(e)
kind so it's correct to return it fromf1()
.The text was updated successfully, but these errors were encountered: