-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Identity operation enforced by compiler? #56923
Comments
Parentheses work: fn type_code(switch: bool) -> u8 {
(if switch { 128 } else { 0 }) + base_type_code()
} I'm not sure how the parser determines when conditionals-as-expressions need parentheses; I agree that it's very counterintuitive for a leading |
Not yet good, but already much better ;-) |
Related: #54186 |
I‘m gonna close this as a duplicate of #54186 as that seems to be pretty much exactly the same thing, with a different operator. |
(Playground)
Output:
Shouldn't the above code also compile without the "0_u8 + "?
Note that clippy even complains about this identity operation.
The text was updated successfully, but these errors were encountered: